[jbosstools-commits] JBoss Tools SVN: r42270 - in trunk/seam: tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet and 1 other directory.

jbosstools-commits at lists.jboss.org jbosstools-commits at lists.jboss.org
Wed Jun 27 19:35:39 EDT 2012


Author: akazakov
Date: 2012-06-27 19:35:35 -0400 (Wed, 27 Jun 2012)
New Revision: 42270

Modified:
   trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
   trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/SeamRuntimeManagerTest.java
Log:
https://issues.jboss.org/browse/JBIDE-12268 org.jboss.tools.seam.core.test failure

Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java	2012-06-27 22:34:06 UTC (rev 42269)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java	2012-06-27 23:35:35 UTC (rev 42270)
@@ -183,7 +183,7 @@
 	 * @param defaultRt
 	 * 	boolean - default flag
 	 */
-	public void addRuntime(String name, String path, SeamVersion version,
+	public SeamRuntime addRuntime(String name, String path, SeamVersion version,
 			boolean defaultRt) {
 		SeamRuntime seamRt = new SeamRuntime();
 		seamRt.setVersion(version);
@@ -191,6 +191,7 @@
 		seamRt.setName(name);
 		seamRt.setDefault(defaultRt);
 		addRuntime(seamRt);
+		return seamRt;
 	}
 
 	/**

Modified: trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/SeamRuntimeManagerTest.java
===================================================================
--- trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/SeamRuntimeManagerTest.java	2012-06-27 22:34:06 UTC (rev 42269)
+++ trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/project/facet/SeamRuntimeManagerTest.java	2012-06-27 23:35:35 UTC (rev 42270)
@@ -35,13 +35,8 @@
 	@Override
 	protected void setUp() throws Exception {
 		super.setUp();
-		Bundle seamCoreTest = Platform.getBundle("org.jboss.tools.seam.core.test");
-		URL seamUrl = FileLocator.resolve(seamCoreTest.getEntry("/seam/seam-1.2.0"));
-		File folder = new File(seamUrl.getPath());
 		manager = SeamRuntimeManager.getInstance();
 		assertNotNull("Cannot obtainSeamRuntimeManager instance", manager);
-		if(manager.findRuntimeByName("Seam 1.2.0")!=null) return;
-		manager.addRuntime("Seam 1.2.0", folder.getAbsolutePath(), SeamVersion.SEAM_1_2, true);
 	}
 
 	/**
@@ -49,18 +44,38 @@
 	 * @throws IOException 
 	 */
 	public void testGetRuntimes() throws IOException {
-		SeamRuntime[] rtms = manager.getRuntimes();
-		assertTrue("Seam runtime 'Seam 1.2.0' is not created", rtms.length==1);
-		assertTrue("Seam runtime 'Seam 1.2.0' is not created", rtms[0].getName().equals("Seam 1.2.0"));
+		Bundle seamCoreTest = Platform.getBundle("org.jboss.tools.seam.core.test");
+		URL seamUrl = FileLocator.resolve(seamCoreTest.getEntry("/seam/seam-1.2.0"));
+		File folder = new File(seamUrl.getPath());
+		SeamRuntime runtime = null;
+		try {
+			runtime = manager.addRuntime("Seam 1.2.0", folder.getAbsolutePath(), SeamVersion.SEAM_1_2, true);
+			SeamRuntime[] rts = manager.getRuntimes();
+			assertTrue("Seam runtime 'Seam 1.2.0' is not created", rts.length>0);
+		} finally {
+			if(runtime!=null) {
+				manager.removeRuntime(runtime);
+			}
+		}
 	}
 
 	/**
 	 * Test method for {@link org.jboss.tools.seam.core.project.facet.SeamRuntimeManager#getRuntimes(org.jboss.tools.seam.core.project.facet.SeamVersion)}.
 	 */
-	public void testGetRuntimesSeamVersion() {
-		SeamRuntimeManager manager = SeamRuntimeManager.getInstance();
-		SeamRuntime[] rtms = manager.getRuntimes(SeamVersion.SEAM_1_2);
-		assertTrue("Error in obtaining seam runtimes list for Seam 1.2", rtms.length==1);
+	public void testGetRuntimesSeamVersion() throws IOException {
+		Bundle seamCoreTest = Platform.getBundle("org.jboss.tools.seam.core.test");
+		URL seamUrl = FileLocator.resolve(seamCoreTest.getEntry("/seam/seam-1.2.0"));
+		File folder = new File(seamUrl.getPath());
+		SeamRuntime runtime = null;
+		try {
+			runtime = manager.addRuntime("Seam 1.2.0", folder.getAbsolutePath(), SeamVersion.SEAM_1_2, true);
+			SeamRuntime[] rtms = manager.getRuntimes(SeamVersion.SEAM_1_2);
+			assertEquals("Error in obtaining seam runtimes list for Seam 1.2", 1, rtms.length);
+		} finally {
+			if(runtime!=null) {
+				manager.removeRuntime(runtime);
+			}
+		}
 	}
 
 	/**
@@ -71,17 +86,46 @@
 		Bundle seamCoreTest = Platform.getBundle("org.jboss.tools.seam.core.test");
 		URL seamUrl = FileLocator.resolve(seamCoreTest.getEntry("/seam/seam-1.2.1"));
 		File folder = new File(seamUrl.getPath());
-		manager.addRuntime("Seam 1.2.1", folder.getAbsolutePath(), SeamVersion.SEAM_1_2, true);
+		SeamRuntime runtime = null;
+		try {
+			runtime = manager.addRuntime("Seam 1.2.1", folder.getAbsolutePath(), SeamVersion.SEAM_1_2, true);
+			assertNotNull(runtime);
+		} finally {
+			if(runtime!=null) {
+				manager.removeRuntime(runtime);
+			}
+		}
 	}
 
 	/**
 	 * Test method for {@link org.jboss.tools.seam.core.project.facet.SeamRuntimeManager#findRuntimeByName(java.lang.String)}.
 	 */
-	public void testFindRuntimeByName() {
-		SeamRuntime srt = manager.findRuntimeByName("Seam 1.2.1");
-		assertNotNull("Cannot find runtime 'Seam 1.2.1'",srt);
-		srt = manager.findRuntimeByName("Seam 1.2.0");
-		assertNotNull("Cannot find runtime 'Seam 1.2.0'",srt);
+	public void testFindRuntimeByName() throws IOException {
+		Bundle seamCoreTest = Platform.getBundle("org.jboss.tools.seam.core.test");
+		URL seamUrl = FileLocator.resolve(seamCoreTest.getEntry("/seam/seam-1.2.0"));
+		File folder = new File(seamUrl.getPath());
+		SeamRuntime runtime = null;
+		try {
+			manager.addRuntime("Seam 1.2.0", folder.getAbsolutePath(), SeamVersion.SEAM_1_2, true);
+			runtime = manager.findRuntimeByName("Seam 1.2.0");
+			assertNotNull("Can't find runtime 'Seam 1.2.0' is not created", runtime);
+		} finally {
+			if(runtime!=null) {
+				manager.removeRuntime(runtime);
+			}
+		}
+		seamUrl = FileLocator.resolve(seamCoreTest.getEntry("/seam/seam-1.2.1"));
+		folder = new File(seamUrl.getPath());
+		runtime = null;
+		try {
+			manager.addRuntime("Seam 1.2.1", folder.getAbsolutePath(), SeamVersion.SEAM_1_2, true);
+			runtime = manager.findRuntimeByName("Seam 1.2.1");
+			assertNotNull("Can't find runtime 'Seam 1.2.1' is not created", runtime);
+		} finally {
+			if(runtime!=null) {
+				manager.removeRuntime(runtime);
+			}
+		}
 	}
 
 	public void testMatchedRuntimes() {
@@ -98,8 +142,18 @@
 	/**
 	 * Test method for {@link org.jboss.tools.seam.core.project.facet.SeamRuntimeManager#getDefaultRuntime()}.
 	 */
-	public void testGetDefaultRuntime() {
-		assertNotNull("Cannot obtain default runtime 'Seam 1.2.0'",manager.getDefaultRuntime(SeamVersion.SEAM_1_2));
-		assertNotNull("Cannot obtain default runtime 'Seam 1.2.0'",manager.getDefaultRuntime(SeamVersion.SEAM_1_2).getName().equals("Seam 1.2.0"));
+	public void testGetDefaultRuntime() throws IOException {
+		Bundle seamCoreTest = Platform.getBundle("org.jboss.tools.seam.core.test");
+		URL seamUrl = FileLocator.resolve(seamCoreTest.getEntry("/seam/seam-1.2.0"));
+		File folder = new File(seamUrl.getPath());
+		SeamRuntime runtime = null;
+		try {
+			runtime = manager.addRuntime("Seam 1.2.0", folder.getAbsolutePath(), SeamVersion.SEAM_1_2, true);
+			assertNotNull("Cannot obtain default runtime 'Seam 1.2.0'", manager.getDefaultRuntime(SeamVersion.SEAM_1_2));
+		} finally {
+			if(runtime!=null) {
+				manager.removeRuntime(runtime);
+			}
+		}
 	}
 }
\ No newline at end of file



More information about the jbosstools-commits mailing list