Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add support for FakeApplication path param

  • Loading branch information...
commit c12e6c51f0c16be8dcbcc0247a96ce426da7ad59 1 parent dbec27d
jto authored
View
16 helpers/src/main/java/com/linkedin/plugin/NGTests.java
@@ -16,6 +16,7 @@
import java.lang.annotation.*;
import java.lang.reflect.*;
import java.util.*;
+import java.io.File;
import org.testng.*;
import play.test.*;
@@ -31,20 +32,23 @@ private Class testClass(ITestResult testResult){
return testResult.getTestClass().getRealClass();
}
- private Boolean hasFakeApp(ITestResult testResult){
+ private WithFakeApplication getFakeApp(ITestResult testResult){
Class clazz = testClass(testResult);
Method m = testMethod(testResult);
WithFakeApplication classFakeApp = (WithFakeApplication)clazz.getAnnotation(WithFakeApplication.class);
WithFakeApplication a = m.getAnnotation(WithFakeApplication.class);
- return classFakeApp != null || a != null;
+ if(a != null)
+ return a;
+ else
+ return classFakeApp;
}
private Map<String, String> getConf(ITestResult testResult){
Map<String, String> conf = new HashMap<String, String>();
- if(!hasFakeApp(testResult))
+ if(getFakeApp(testResult) == null)
return conf;
Class clazz = testClass(testResult);
@@ -91,8 +95,10 @@ private Boolean hasFakeApp(ITestResult testResult){
}
public void run(final IHookCallBack icb, ITestResult testResult) {
- if(hasFakeApp(testResult)){
- FakeApplication app = fakeApplication(getConf(testResult), getPlugins(testResult));
+ WithFakeApplication fa = getFakeApp(testResult);
+ if(fa != null){
+ String path = fa.path();
+ FakeApplication app = new FakeApplication(new File(path), Helpers.class.getClassLoader(), getConf(testResult), getPlugins(testResult));
start(app);
icb.runTestMethod(testResult);
stop(app);
View
1  helpers/src/main/java/com/linkedin/plugin/WithFakeApplication.java
@@ -22,4 +22,5 @@
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface WithFakeApplication {
+ String path() default ".";
}
View
2  project/Build.scala
@@ -47,7 +47,7 @@ object NGPluginBuild extends Build {
lazy val commonSettings: Seq[Setting[_]] = Project.defaultSettings ++ publishSettings ++ Seq(
organization := "com.linkedin",
scalaVersion := "2.9.2",
- version := "2012.08.15.c4c3576.v4",
+ version := "2012.08.15.c4c3576.v5",
resolvers ++= Seq(Repos.sandbox, Repos.typeSafeReleases))
lazy val publishSettings: Seq[Setting[_]] = Seq(
View
4 sample/project/Build.scala
@@ -11,13 +11,13 @@ object ApplicationBuild extends Build {
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
- "com.linkedin" %% "play-testng-helpers" % "2012.08.15.c4c3576"
+ "com.linkedin" %% "play-testng-helpers" % "2012.08.15.c4c3576.v5"
)
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
// Add your own project settings here
)
//.configs(NGTest)
- //.settings(NGPlugin.ngSettings: _*)
+ .settings(NGPlugin.ngSettings: _*)
}
View
2  sample/project/plugins.sbt
@@ -7,4 +7,4 @@ resolvers += "Typesafe repository" at "http://repo.typesafe.com/typesafe/release
// Use the Play sbt plugin for Play projects
addSbtPlugin("play" % "sbt-plugin" % "2012.08.15.c4c3576")
-addSbtPlugin("com.linkedin" % "play-plugins-testng" % "2012.08.15.c4c3576")
+addSbtPlugin("com.linkedin" % "play-plugins-testng" % "2012.08.15.c4c3576.v5")
View
2  sample/test/AllWithFakeApp.java
@@ -8,7 +8,7 @@
import com.linkedin.plugin.*;
-@WithFakeApplication
+@WithFakeApplication(path=".")
@Confs({
@Conf(key="test.fakeconf", value="fake")
})
Please sign in to comment.
Something went wrong with that request. Please try again.