Author: koen.aers(a)jboss.com
Date: 2011-06-24 08:33:28 -0400 (Fri, 24 Jun 2011)
New Revision: 32349
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeLaunchHelperTest.java
Log:
ForgeLaunchHelper and ForgeLaunchHelperTest are ready and running
Modified:
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java
===================================================================
---
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java 2011-06-24
10:51:17 UTC (rev 32348)
+++
trunk/forge/plugins/org.jboss.tools.forge.core/src/org/jboss/tools/forge/core/process/ForgeLaunchHelper.java 2011-06-24
12:33:28 UTC (rev 32349)
@@ -144,10 +144,10 @@
return result;
}
- public static IProcess launch(String name, String location) {
+ public static IProcess launch(ForgeRuntime runtime) {
IProcess result = null;
- String launchConfigurationName = name + System.currentTimeMillis();
- List<String> classPath = createClassPath(location);
+ String launchConfigurationName = runtime.getName() + System.currentTimeMillis();
+ List<String> classPath = createClassPath(runtime.getLocation());
if (classPath != null) {
ILaunch launch = launch(launchConfigurationName, classPath);
removeLaunchConfiguration(launchConfigurationName);
Modified:
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeLaunchHelperTest.java
===================================================================
---
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeLaunchHelperTest.java 2011-06-24
10:51:17 UTC (rev 32348)
+++
trunk/forge/tests/org.jboss.tools.forge.core.test/src/org/jboss/tools/forge/core/process/ForgeLaunchHelperTest.java 2011-06-24
12:33:28 UTC (rev 32349)
@@ -1,41 +1,72 @@
package org.jboss.tools.forge.core.process;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertFalse;
+
+import java.io.IOException;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.ui.progress.UIJob;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import junit.framework.TestCase;
+public class ForgeLaunchHelperTest {
-public class ForgeLaunchHelperTest extends TestCase {
-
- private static final String PREFIX = "reference:file:";
private IProcess forgeProcess = null;
-
- protected void setUp() {
+ private ForgeRuntime forgeRuntime = null;
+
+ @Before
+ public void setUp() throws Exception {
+ forgeRuntime = new TestRuntime();
forgeProcess = null;
}
-
- public void testLaunch() {
- try {
- String location =
Platform.getBundle("org.jboss.tools.forge.runtime").getLocation();
- assertTrue(location.startsWith(PREFIX));
- location = location.substring(PREFIX.length());
- forgeProcess = ForgeLaunchHelper.launch("test", location);
- assertNotNull(forgeProcess);
- assertFalse(forgeProcess.isTerminated());
- } catch (Throwable t) {
- t.printStackTrace();
- fail();
- }
- }
-
- protected void tearDown() {
+
+ @After
+ public void tearDown() throws Exception {
if (forgeProcess != null) {
try {
forgeProcess.terminate();
} catch (DebugException e) {}
}
forgeProcess = null;
+ forgeRuntime = null;
}
+ @Test
+ public void test() {
+ new UIJob("testLaunch") {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ try {
+ forgeProcess = ForgeLaunchHelper.launch(forgeRuntime);
+ assertNotNull(forgeProcess);
+ assertFalse(forgeProcess.isTerminated());
+ } catch (RuntimeException e) {
+ fail();
+ }
+ return null;
+ }
+
+ }.schedule();
+ }
+
+ private class TestRuntime extends ForgeRuntime {
+ public String getName() {
+ return "test";
+ }
+ public String getLocation() {
+ try {
+ return
FileLocator.getBundleFile(Platform.getBundle("org.jboss.tools.forge.runtime")).getAbsolutePath();
+ } catch (IOException e) {
+ return null;
+ }
+ }
+ }
+
}
Show replies by date