Permalink
Browse files

add maven invoker api for testing the compilation of projects using m…

…aven
  • Loading branch information...
1 parent b03d147 commit 5bccd3fc4389b801a80444a7b27e0206eb55cb83 @a-thomas a-thomas committed Oct 25, 2012
@@ -46,6 +46,10 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-invoker</artifactId>
+ </dependency>
</dependencies>
</project>
@@ -5,14 +5,19 @@
import junit.framework.Assert;
+import org.apache.maven.shared.invoker.DefaultInvocationRequest;
+import org.apache.maven.shared.invoker.DefaultInvoker;
+import org.apache.maven.shared.invoker.InvocationRequest;
+import org.apache.maven.shared.invoker.InvocationResult;
+import org.apache.maven.shared.invoker.MavenInvocationException;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.athomas.androidkickstartr.model.Application;
import com.athomas.androidkickstartr.model.State;
-public class KickstartrTest {
+public class KickstartrMavenTest {
private static Application application;
@@ -25,7 +30,7 @@ public void tearUp() {
packageName("com.androidkickstartr.app").//
name("MyApp").//
activity("MainActivity").//
- activityLayout("main_activity").//
+ activityLayout("activity_main").//
minSdk(8).//
targetSdk(16).//
permissions(new ArrayList<String>()).//
@@ -34,184 +39,95 @@ public void tearUp() {
@After
public void cleanProject() {
+ buildWithMaven();
kickstartr.clean();
}
- /*
- * MAVEN
- */
-
- @Test
- public void generateProject_maven_abs() {
- state = new State.Builder().//
- maven(true). //
- actionBarSherlock(true).//
- build();
-
- File file = launchKickstartr();
- Assert.assertNotNull(file);
+ private void buildWithMaven() {
+ InvocationRequest request = new DefaultInvocationRequest();
+
+ File pom = new File("generated/MyApp-AndroidKickstartr/MyApp/pom.xml");
+ Assert.assertNotNull(pom);
+ Assert.assertTrue(pom.exists());
+ request.setPomFile(pom);
+
+ File baseDir = new File("generated/MyApp-AndroidKickstartr/MyApp");
+ Assert.assertNotNull(baseDir);
+ Assert.assertTrue(baseDir.exists());
+ request.setBaseDirectory(baseDir);
+
+ ArrayList<String> goals = new ArrayList<String>();
+ goals.add("clean");
+ goals.add("install");
+ goals.add("android:deploy");
+ request.setGoals(goals);
+ request.setShowErrors(true);
+ request.setDebug(false);
+
+ DefaultInvoker invoker = new DefaultInvoker();
+ String mavenHome = System.getenv("MAVEN_HOME");
+
+ invoker.setMavenHome(new File(mavenHome));
+ InvocationResult result;
+ try {
+ result = invoker.execute(request);
+
+ Assert.assertTrue(result.getExitCode() == 0);
+ Assert.assertTrue(result.getExecutionException() == null);
+ } catch (MavenInvocationException e) {
+ e.printStackTrace();
+ }
}
@Test
- public void generateProject_maven_abs_tab() {
+ public void generateProject_maven() {
state = new State.Builder().//
maven(true). //
- actionBarSherlock(true).//
- tabNavigation(true). //
build();
File file = launchKickstartr();
Assert.assertNotNull(file);
}
@Test
- public void generateProject_maven_abs_tab_view_pager() {
+ public void generateProject_maven_viewpager() {
state = new State.Builder().//
maven(true). //
- actionBarSherlock(true).//
viewPager(true). //
- tabNavigation(true). //
+ supportV4(true). //
build();
File file = launchKickstartr();
Assert.assertNotNull(file);
}
-
+
@Test
- public void generateProject_maven_abs_list() {
+ public void generateProject_maven_abs() {
state = new State.Builder().//
maven(true). //
actionBarSherlock(true).//
- listNavigation(true). //
build();
File file = launchKickstartr();
Assert.assertNotNull(file);
}
-
+
@Test
- public void generateProject_maven_abs_list_view_pager() {
+ public void generateProject_maven_abs_viewpager() {
state = new State.Builder().//
maven(true). //
actionBarSherlock(true).//
viewPager(true). //
- listNavigation(true). //
- build();
-
- File file = launchKickstartr();
- Assert.assertNotNull(file);
- }
-
- @Test
- public void generateProject_maven_aa() {
- state = new State.Builder().//
- maven(true). //
- androidAnnotations(true).//
- build();
-
- File file = launchKickstartr();
- Assert.assertNotNull(file);
- }
-
- @Test
- public void generateProject_maven_abs_aa() {
- state = new State.Builder().//
- maven(true). //
- androidAnnotations(true).//
- actionBarSherlock(true).//
- build();
-
- File file = launchKickstartr();
- Assert.assertNotNull(file);
- }
-
- @Test
- public void generateProject_maven_aa_rest() {
- state = new State.Builder().//
- maven(true). //
- androidAnnotations(true).//
- restTemplate(true).//
- build();
-
- File file = launchKickstartr();
- Assert.assertNotNull(file);
- }
-
- @Test
- public void generateProject_maven_aa_rest_acra() {
- state = new State.Builder().//
- maven(true). //
- androidAnnotations(true).//
- restTemplate(true).//
- acra(true). //
- build();
-
- File file = launchKickstartr();
- Assert.assertNotNull(file);
- }
-
- @Test
- public void generateProject_maven_abs_aa_rest_acra() {
- state = new State.Builder().//
- maven(true). //
- actionBarSherlock(true). //
- androidAnnotations(true). //
- restTemplate(true).//
- acra(true). //
build();
File file = launchKickstartr();
Assert.assertNotNull(file);
}
@Test
- public void generateProject_maven_abs_aa_rest_acra_nine() {
- state = new State.Builder().//
- maven(true). //
- actionBarSherlock(true). //
- androidAnnotations(true). //
- restTemplate(true).//
- acra(true). //
- nineOldAndroids(true). //
- build();
-
- File file = launchKickstartr();
- Assert.assertNotNull(file);
- }
-
- @Test
- public void generateProject_maven_abs_aa_rest_acra_nine_viewpager() {
+ public void generateProject_maven_abs_tab() {
state = new State.Builder().//
maven(true). //
- actionBarSherlock(true). //
- androidAnnotations(true). //
- restTemplate(true).//
- acra(true). //
- nineOldAndroids(true). //
- viewPager(true). //
- build();
-
- File file = launchKickstartr();
- Assert.assertNotNull(file);
- }
-
- /*
- * NON-MAVEN
- */
-
- @Test
- public void generateProject_abs() {
- state = new State.Builder().//
- actionBarSherlock(true).//
- build();
-
- File file = launchKickstartr();
- Assert.assertNotNull(file);
- }
-
- @Test
- public void generateProject_abs_tab() {
- state = new State.Builder().//
actionBarSherlock(true).//
tabNavigation(true). //
build();
@@ -221,20 +137,22 @@ public void generateProject_abs_tab() {
}
@Test
- public void generateProject_abs_tab_view_pager() {
+ public void generateProject_maven_abs_tab_viewpager() {
state = new State.Builder().//
+ maven(true). //
actionBarSherlock(true).//
- tabNavigation(true). //
viewPager(true). //
+ tabNavigation(true). //
build();
File file = launchKickstartr();
Assert.assertNotNull(file);
}
@Test
- public void generateProject_abs_list() {
+ public void generateProject_maven_abs_list() {
state = new State.Builder().//
+ maven(true). //
actionBarSherlock(true).//
listNavigation(true). //
build();
@@ -244,20 +162,22 @@ public void generateProject_abs_list() {
}
@Test
- public void generateProject_abs_list_viewpager() {
+ public void generateProject_maven_abs_list_viewpager() {
state = new State.Builder().//
+ maven(true). //
actionBarSherlock(true).//
- listNavigation(true). //
viewPager(true). //
+ listNavigation(true). //
build();
File file = launchKickstartr();
Assert.assertNotNull(file);
}
@Test
- public void generateProject_aa() {
+ public void generateProject_maven_aa() {
state = new State.Builder().//
+ maven(true). //
androidAnnotations(true).//
build();
@@ -266,8 +186,9 @@ public void generateProject_aa() {
}
@Test
- public void generateProject_abs_aa() {
+ public void generateProject_maven_abs_aa() {
state = new State.Builder().//
+ maven(true). //
androidAnnotations(true).//
actionBarSherlock(true).//
build();
@@ -277,8 +198,9 @@ public void generateProject_abs_aa() {
}
@Test
- public void generateProject_aa_rest() {
+ public void generateProject_maven_aa_rest() {
state = new State.Builder().//
+ maven(true). //
androidAnnotations(true).//
restTemplate(true).//
build();
@@ -288,8 +210,9 @@ public void generateProject_aa_rest() {
}
@Test
- public void generateProject_aa_rest_acra() {
+ public void generateProject_maven_aa_rest_acra() {
state = new State.Builder().//
+ maven(true). //
androidAnnotations(true).//
restTemplate(true).//
acra(true). //
@@ -300,8 +223,9 @@ public void generateProject_aa_rest_acra() {
}
@Test
- public void generateProject_abs_aa_rest_acra() {
+ public void generateProject_maven_abs_aa_rest_acra() {
state = new State.Builder().//
+ maven(true). //
actionBarSherlock(true). //
androidAnnotations(true). //
restTemplate(true).//
@@ -313,8 +237,9 @@ public void generateProject_abs_aa_rest_acra() {
}
@Test
- public void generateProject_abs_aa_rest_acra_nine() {
+ public void generateProject_maven_abs_aa_rest_acra_nine() {
state = new State.Builder().//
+ maven(true). //
actionBarSherlock(true). //
androidAnnotations(true). //
restTemplate(true).//
@@ -327,8 +252,9 @@ public void generateProject_abs_aa_rest_acra_nine() {
}
@Test
- public void generateProject_abs_aa_rest_acra_nine_viewpager() {
+ public void generateProject_maven_abs_aa_rest_acra_nine_viewpager() {
state = new State.Builder().//
+ maven(true). //
actionBarSherlock(true). //
androidAnnotations(true). //
restTemplate(true).//
Oops, something went wrong.

0 comments on commit 5bccd3f

Please sign in to comment.