Skip to content

Commit

Permalink
* [#1993] test(images): fix path to run test with ant task
Browse files Browse the repository at this point in the history
  • Loading branch information
xael-fry committed Nov 30, 2015
1 parent e2f8f39 commit 41b37ee
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
36 changes: 17 additions & 19 deletions framework/test-src/play/PlayBuilder.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
package play;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Properties;

import play.classloading.ApplicationClasses;
import play.classloading.ApplicationClassloader;
Expand All @@ -8,47 +14,39 @@
import play.mvc.Scope.RenderArgs;
import play.vfs.VirtualFile;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Properties;

/**
* Builder-pattern-builder for Play-class..
*
* It's kind of odd since Play only uses statics,
* But it basically inits the needed properties for Play-object to work in unittests
* It's kind of odd since Play only uses statics, But it basically inits the
* needed properties for Play-object to work in unittests
*/
public class PlayBuilder {

public Properties configuration = new Properties();

public PlayBuilder withConfiguration(Properties config){
public PlayBuilder withConfiguration(Properties config) {
this.configuration = config;
return this;
}

@SuppressWarnings({ "deprecation" })
public void build() {

@SuppressWarnings({"deprecation"})
public void build(){

Play.version = "localbuild";
Play.configuration = configuration;
Play.classes = new ApplicationClasses();
Play.javaPath = new ArrayList<VirtualFile>();
Play.applicationPath = new File(".");
Play.classloader = new ApplicationClassloader();
Play.plugins = Collections.unmodifiableList( new ArrayList<PlayPlugin>());
Play.plugins = Collections.unmodifiableList(new ArrayList<PlayPlugin>());
Play.guessFrameworkPath();

}
public void initMvcObject(){

public void initMvcObject() {
if (Request.current() == null) {
Request request = Request
.createRequest(null, "GET", "/", "", null, null, null,
null, false, 80, "localhost", false, null, null);
Request request = Request.createRequest(null, "GET", "/", "", null, null, null, null, false, 80, "localhost", false, null,
null);
request.body = new ByteArrayInputStream(new byte[0]);
Request.current.set(request);
}
Expand Down
15 changes: 11 additions & 4 deletions framework/test-src/play/libs/ImagesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,18 @@

import org.junit.Test;

import play.Play;
import play.PlayBuilder;

/**
* @author Alexandre Chatiron
*/
public class ImagesTest {

@Test
public void testImagesResizeGif() {
File folder = new File("framework/test-src/play/libs");
new PlayBuilder().build();
File folder = new File(Play.frameworkPath, "/framework/test-src/play/libs");

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

@Test
public void testImagesResizePng() {
File folder = new File("framework/test-src/play/libs");
new PlayBuilder().build();
File folder = new File(Play.frameworkPath, "/framework/test-src/play/libs");

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

@Test
public void testImagesResizePngTransparent() {
File folder = new File("framework/test-src/play/libs");
new PlayBuilder().build();
File folder = new File(Play.frameworkPath, "/framework/test-src/play/libs");

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

@Test
public void testImagesResizeJpg() {
File folder = new File("framework/test-src/play/libs");
new PlayBuilder().build();
File folder = new File(Play.frameworkPath, "/framework/test-src/play/libs");

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

0 comments on commit 41b37ee

Please sign in to comment.