Skip to content

Commit f88b291

Browse files
committed
Merge pull request #931 from xael-fry/1993_fixImagesTest
* [#1993] test(images): fix path to run test with ant task
2 parents a4d8984 + 0abc6f3 commit f88b291

File tree

2 files changed

+28
-23
lines changed

2 files changed

+28
-23
lines changed

framework/test-src/play/PlayBuilder.java

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
package play;
22

3+
import java.io.ByteArrayInputStream;
4+
import java.io.ByteArrayOutputStream;
5+
import java.io.File;
6+
import java.util.ArrayList;
7+
import java.util.Collections;
8+
import java.util.Properties;
39

410
import play.classloading.ApplicationClasses;
511
import play.classloading.ApplicationClassloader;
@@ -8,47 +14,39 @@
814
import play.mvc.Scope.RenderArgs;
915
import play.vfs.VirtualFile;
1016

11-
import java.io.ByteArrayInputStream;
12-
import java.io.ByteArrayOutputStream;
13-
import java.io.File;
14-
import java.util.ArrayList;
15-
import java.util.Collections;
16-
import java.util.Properties;
17-
1817
/**
1918
* Builder-pattern-builder for Play-class..
2019
*
21-
* It's kind of odd since Play only uses statics,
22-
* But it basically inits the needed properties for Play-object to work in unittests
20+
* It's kind of odd since Play only uses statics, But it basically inits the
21+
* needed properties for Play-object to work in unittests
2322
*/
2423
public class PlayBuilder {
2524

2625
public Properties configuration = new Properties();
2726

28-
public PlayBuilder withConfiguration(Properties config){
27+
public PlayBuilder withConfiguration(Properties config) {
2928
this.configuration = config;
3029
return this;
3130
}
3231

32+
@SuppressWarnings({ "deprecation" })
33+
public void build() {
3334

34-
@SuppressWarnings({"deprecation"})
35-
public void build(){
36-
3735
Play.version = "localbuild";
3836
Play.configuration = configuration;
3937
Play.classes = new ApplicationClasses();
4038
Play.javaPath = new ArrayList<VirtualFile>();
4139
Play.applicationPath = new File(".");
4240
Play.classloader = new ApplicationClassloader();
43-
Play.plugins = Collections.unmodifiableList( new ArrayList<PlayPlugin>());
41+
Play.plugins = Collections.unmodifiableList(new ArrayList<PlayPlugin>());
42+
Play.guessFrameworkPath();
4443

4544
}
46-
47-
public void initMvcObject(){
45+
46+
public void initMvcObject() {
4847
if (Request.current() == null) {
49-
Request request = Request
50-
.createRequest(null, "GET", "/", "", null, null, null,
51-
null, false, 80, "localhost", false, null, null);
48+
Request request = Request.createRequest(null, "GET", "/", "", null, null, null, null, false, 80, "localhost", false, null,
49+
null);
5250
request.body = new ByteArrayInputStream(new byte[0]);
5351
Request.current.set(request);
5452
}

framework/test-src/play/libs/ImagesTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,18 @@
1111

1212
import org.junit.Test;
1313

14+
import play.Play;
15+
import play.PlayBuilder;
16+
1417
/**
1518
* @author Alexandre Chatiron
1619
*/
1720
public class ImagesTest {
1821

1922
@Test
2023
public void testImagesResizeGif() {
21-
File folder = new File("framework/test-src/play/libs");
24+
new PlayBuilder().build();
25+
File folder = new File(Play.frameworkPath, "/framework/test-src/play/libs");
2226

2327
File source = new File(folder, "angel.gif");
2428
File result = new File(folder, "angel_testResult.gif");
@@ -41,7 +45,8 @@ public void testImagesResizeGif() {
4145

4246
@Test
4347
public void testImagesResizePng() {
44-
File folder = new File("framework/test-src/play/libs");
48+
new PlayBuilder().build();
49+
File folder = new File(Play.frameworkPath, "/framework/test-src/play/libs");
4550

4651
File source = new File(folder, "fond1.png");
4752
File result = new File(source.getParent(), "fond1_testResult.png");
@@ -64,7 +69,8 @@ public void testImagesResizePng() {
6469

6570
@Test
6671
public void testImagesResizePngTransparent() {
67-
File folder = new File("framework/test-src/play/libs");
72+
new PlayBuilder().build();
73+
File folder = new File(Play.frameworkPath, "/framework/test-src/play/libs");
6874

6975
File source = new File(folder, "fond2.png");
7076
File result = new File(source.getParent(), "fond2_testResult.png");
@@ -87,7 +93,8 @@ public void testImagesResizePngTransparent() {
8793

8894
@Test
8995
public void testImagesResizeJpg() {
90-
File folder = new File("framework/test-src/play/libs");
96+
new PlayBuilder().build();
97+
File folder = new File(Play.frameworkPath, "/framework/test-src/play/libs");
9198

9299
File source = new File(folder, "winie.jpg");
93100
File result = new File(source.getParent(), "winie_testResult.jpg");

0 commit comments

Comments
 (0)