diff options
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse')
7 files changed, 484 insertions, 484 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/concurrent/ConcurrentTestCase.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/concurrent/ConcurrentTestCase.java index 71eae0eff..c9dd495ab 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/concurrent/ConcurrentTestCase.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/concurrent/ConcurrentTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTests.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTests.java index 13ac6b91d..81572a4b2 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTests.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/StepperTests.java @@ -1,296 +1,296 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tests.stepper;
-
-import java.util.Map;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.properties.PropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.StepperManager;
-import org.eclipse.tcf.te.runtime.stepper.context.AbstractStepContext;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStep;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroupable;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper;
-import org.eclipse.tcf.te.runtime.stepper.stepper.Stepper;
-import org.eclipse.tcf.te.tests.CoreTestCase;
-import org.eclipse.tcf.te.tests.stepper.steps.ParameterizedTestStep;
-import org.eclipse.tcf.te.tests.stepper.steps.TestStep;
-
-/**
- * Stepper engine test cases.
- */
-public class StepperTests extends CoreTestCase {
-
- protected static class TestStepContext extends AbstractStepContext {
-
- /**
- * Constructor.
- */
- public TestStepContext(Object contextObject) {
- super(contextObject);
- }
-
- @Override
- public String getId() {
- return "org.eclipse.tcf.te.tests.stepper.TestStepContext"; //$NON-NLS-1$
- }
-
- @Override
- public String getName() {
- return "TestStepContext"; //$NON-NLS-1$
- }
- }
-
- /**
- * Provides a test suite to the caller which combines all single
- * test bundled within this category.
- *
- * @return Test suite containing all test for this test category.
- */
- public static Test getTestSuite() {
- TestSuite testSuite = new TestSuite("Test stepper engine"); //$NON-NLS-1$
-
- // add ourself to the test suite
- testSuite.addTestSuite(StepperTests.class);
-
- return testSuite;
- }
-
- /**
- * Test the stepper extension point mechanism.
- */
- public void testStepperContributions() {
- assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance()); //$NON-NLS-1$
- }
-
- /**
- * Test the steps extension point mechanism.
- */
- public void testStepContributions() {
- assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance()); //$NON-NLS-1$
- assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance().getStepExtManager()); //$NON-NLS-1$
-
- IStep[] steps = StepperManager.getInstance().getStepExtManager().getSteps(false);
- int testStepCount = 0;
-
- for (IStep step : steps) {
- if (step.getId().startsWith("org.eclipse.tcf.te.tests.stepper.step")) { //$NON-NLS-1$
- testStepCount++;
- } else {
- continue;
- }
-
- if (step.getId().endsWith(".step1")) { //$NON-NLS-1$
- assertEquals("Unexpected step label found.", "Test Step 1", step.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step description found.", "", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Unexpected step class type found.", step instanceof TestStep); //$NON-NLS-1$
- assertEquals("Unexpected number of dependencies found.", 0, step.getDependencies().length); //$NON-NLS-1$
- }
-
- if (step.getId().endsWith(".step2")) { //$NON-NLS-1$
- assertEquals("Unexpected step label found.", "Test Step 2", step.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step description found.", "", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Unexpected step class type found.", step instanceof ParameterizedTestStep); //$NON-NLS-1$
-
- Map<?,?> params = ((ParameterizedTestStep)step).params;
- assertNotNull("Unexpected value 'null'.", params); //$NON-NLS-1$
- assertEquals("Unexpected number of parameter found.", 1, params.keySet().size()); //$NON-NLS-1$
- assertTrue("Missing expected key 'param1'.", params.containsKey("param1")); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Missing expected value 'value1'.", params.containsValue("value1")); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertEquals("Unexpected number of dependencies found.", 0, step.getDependencies().length); //$NON-NLS-1$
- }
-
- if (step.getId().endsWith(".step3")) { //$NON-NLS-1$
- assertEquals("Unexpected step label found.", "Test Step 3", step.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step description found.", "Just another test step", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Unexpected step class type found.", step instanceof TestStep); //$NON-NLS-1$
- assertEquals("Unexpected number of dependencies found.", 0, step.getDependencies().length); //$NON-NLS-1$
- }
-
- if (step.getId().endsWith(".step4")) { //$NON-NLS-1$
- assertEquals("Unexpected step label found.", "Test Step 4", step.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step description found.", "", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Unexpected step class type found.", step instanceof TestStep); //$NON-NLS-1$
- assertEquals("Unexpected number of dependencies found.", 1, step.getDependencies().length); //$NON-NLS-1$
- }
-
- if (step.getId().endsWith(".step5")) { //$NON-NLS-1$
- assertEquals("Unexpected step label found.", "Test Step 5", step.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step description found.", "", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Unexpected step class type found.", step instanceof TestStep); //$NON-NLS-1$
- assertEquals("Unexpected number of dependencies found.", 0, step.getDependencies().length); //$NON-NLS-1$
- }
- }
-
- assertEquals("Unexpected number of test steps found.", 5, testStepCount); //$NON-NLS-1$
- }
-
- /**
- * Test the step group extension point mechanism.
- */
- public void testStepGroupContributions() {
- assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance()); //$NON-NLS-1$
- assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance().getStepGroupExtManager()); //$NON-NLS-1$
-
- IStepGroup[] stepGroups = StepperManager.getInstance().getStepGroupExtManager().getStepGroups(false);
- int testStepGroupCount = 0;
-
- for (IStepGroup stepGroup : stepGroups) {
- if (stepGroup.getId().startsWith("org.eclipse.tcf.te.tests.stepper.stepGroup")) { //$NON-NLS-1$
- testStepGroupCount++;
- } else {
- continue;
- }
-
- Throwable error = null;
- String message = null;
- IStepGroupable[] steps = null;
-
- if (stepGroup.getId().endsWith(".stepGroup1")) { //$NON-NLS-1$
- assertEquals("Unexpected step group label found.", "Test Step Group 1", stepGroup.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step description found.", "", stepGroup.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("Step group is locked but should not.", stepGroup.isLocked()); //$NON-NLS-1$
- assertNull("Unexpected non-null value.", stepGroup.getStepGroupIterator()); //$NON-NLS-1$
-
- try {
- steps = stepGroup.getSteps(new TestStepContext(this));
- } catch (CoreException e) {
- error = e;
- message = e.getLocalizedMessage();
- }
- assertNull("Failed to determine steps from step group. Possible cause: " + message, error); //$NON-NLS-1$
- assertNotNull("Unexpected return value 'null'.", steps); //$NON-NLS-1$
- assertEquals("Unexpected number of steps returned.", 0, steps.length); //$NON-NLS-1$
- }
-
- if (stepGroup.getId().endsWith(".stepGroup2")) { //$NON-NLS-1$
- assertEquals("Unexpected step group label found.", "Test Step Group 2", stepGroup.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step description found.", "Just a step group description", stepGroup.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
- assertTrue("Step group is not locked but should.", stepGroup.isLocked()); //$NON-NLS-1$
- assertNull("Unexpected non-null value.", stepGroup.getStepGroupIterator()); //$NON-NLS-1$
-
- error = null; message = null; steps = null;
- try {
- steps = stepGroup.getSteps(new TestStepContext(this));
- } catch (CoreException e) {
- error = e;
- message = e.getLocalizedMessage();
- }
- assertNull("Failed to determine steps from step group. Possible cause: " + message, error); //$NON-NLS-1$
- assertNotNull("Unexpected return value 'null'.", steps); //$NON-NLS-1$
- assertEquals("Unexpected number of steps returned.", 0, steps.length); //$NON-NLS-1$
- }
-
- if (stepGroup.getId().endsWith(".stepGroup3")) { //$NON-NLS-1$
- assertEquals("Unexpected step group label found.", "Test Step Group 3", stepGroup.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step description found.", "", stepGroup.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("Step group is locked but should not.", stepGroup.isLocked()); //$NON-NLS-1$
- assertNull("Unexpected non-null value.", stepGroup.getStepGroupIterator()); //$NON-NLS-1$
-
- error = null; message = null; steps = null;
- try {
- steps = stepGroup.getSteps(new TestStepContext(this));
- } catch (CoreException e) {
- error = e;
- message = e.getLocalizedMessage();
- }
- assertNull("Failed to determine steps from step group. Possible cause: " + message, error); //$NON-NLS-1$
- assertNotNull("Unexpected return value 'null'.", steps); //$NON-NLS-1$
- assertEquals("Unexpected number of steps returned.", 4, steps.length); //$NON-NLS-1$
-
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step1", steps[0].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step2", steps[1].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step3", steps[2].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step4", steps[3].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
- if (stepGroup.getId().endsWith(".stepGroup4")) { //$NON-NLS-1$
- assertEquals("Unexpected step group label found.", "Test Step Group 4", stepGroup.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step description found.", "", stepGroup.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$
- assertFalse("Step group is locked but should not.", stepGroup.isLocked()); //$NON-NLS-1$
- assertNull("Unexpected non-null value.", stepGroup.getStepGroupIterator()); //$NON-NLS-1$
-
- error = null; message = null; steps = null;
- try {
- steps = stepGroup.getSteps(new TestStepContext(this));
- } catch (CoreException e) {
- error = e;
- message = e.getLocalizedMessage();
- }
- assertNull("Failed to determine steps from step group. Possible cause: " + message, error); //$NON-NLS-1$
- assertNotNull("Unexpected return value 'null'.", steps); //$NON-NLS-1$
- assertEquals("Unexpected number of steps returned.", 5, steps.length); //$NON-NLS-1$
-
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step1", steps[0].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step2", steps[1].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step3", steps[2].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step4", steps[3].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
-
- error = null; message = null; steps = null;
- try {
- steps = stepGroup.getSteps(new TestStepContext(this));
- } catch (CoreException e) {
- error = e;
- message = e.getLocalizedMessage();
- }
- assertNull("Failed to determine steps from step group. Possible cause: " + message, error); //$NON-NLS-1$
- assertNotNull("Unexpected return value 'null'.", steps); //$NON-NLS-1$
- assertEquals("Unexpected number of steps returned.", 5, steps.length); //$NON-NLS-1$
-
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step1", steps[0].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step2", steps[1].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step3", steps[2].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step4", steps[3].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step5", steps[4].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- assertEquals("Unexpected number of test step groups found.", 4, testStepGroupCount); //$NON-NLS-1$
- }
-
- public void testExecuteStepGroup() {
- final IStepper stepper = new Stepper("testExecuteStepGroup"); //$NON-NLS-1$
-
- IPropertiesContainer properties = new PropertiesContainer();
-
- // Initialize the stepper
- stepper.initialize(new TestStepContext(this), "org.eclipse.tcf.te.tests.stepper.stepGroup4", properties, null); //$NON-NLS-1$
-
- ExecutorsUtil.execute(new Runnable() {
- @Override
- public void run() {
- // Execute
- try {
- stepper.execute();
- }
- catch (Exception e) {
- assertNull("Unexpected exception when executing step group", e); //$NON-NLS-1$
- }
- }
- });
-
- // Wait for the stepper to be finished
- assertFalse("Timeout executing step group", ExecutorsUtil.waitAndExecute(10000, new IStepper.ExecutionFinishedConditionTester(stepper))); //$NON-NLS-1$
-
- assertNotNull("Missing executed step 1", properties.getProperty("org.eclipse.tcf.te.tests.stepper.step1")); //$NON-NLS-1$ //$NON-NLS-2$
- assertNotNull("Missing executed step 2", properties.getProperty("org.eclipse.tcf.te.tests.stepper.step2")); //$NON-NLS-1$ //$NON-NLS-2$
- assertNotNull("Missing executed step 3", properties.getProperty("org.eclipse.tcf.te.tests.stepper.step3")); //$NON-NLS-1$ //$NON-NLS-2$
- assertNotNull("Missing executed step 4", properties.getProperty("org.eclipse.tcf.te.tests.stepper.step4")); //$NON-NLS-1$ //$NON-NLS-2$
- assertNotNull("Missing executed step 5", properties.getProperty("org.eclipse.tcf.te.tests.stepper.step5")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
+/******************************************************************************* + * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tests.stepper; + +import java.util.Map; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.tcf.te.runtime.concurrent.util.ExecutorsUtil; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.properties.PropertiesContainer; +import org.eclipse.tcf.te.runtime.stepper.StepperManager; +import org.eclipse.tcf.te.runtime.stepper.context.AbstractStepContext; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStep; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroup; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepGroupable; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepper; +import org.eclipse.tcf.te.runtime.stepper.stepper.Stepper; +import org.eclipse.tcf.te.tests.CoreTestCase; +import org.eclipse.tcf.te.tests.stepper.steps.ParameterizedTestStep; +import org.eclipse.tcf.te.tests.stepper.steps.TestStep; + +/** + * Stepper engine test cases. + */ +public class StepperTests extends CoreTestCase { + + protected static class TestStepContext extends AbstractStepContext { + + /** + * Constructor. + */ + public TestStepContext(Object contextObject) { + super(contextObject); + } + + @Override + public String getId() { + return "org.eclipse.tcf.te.tests.stepper.TestStepContext"; //$NON-NLS-1$ + } + + @Override + public String getName() { + return "TestStepContext"; //$NON-NLS-1$ + } + } + + /** + * Provides a test suite to the caller which combines all single + * test bundled within this category. + * + * @return Test suite containing all test for this test category. + */ + public static Test getTestSuite() { + TestSuite testSuite = new TestSuite("Test stepper engine"); //$NON-NLS-1$ + + // add ourself to the test suite + testSuite.addTestSuite(StepperTests.class); + + return testSuite; + } + + /** + * Test the stepper extension point mechanism. + */ + public void testStepperContributions() { + assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance()); //$NON-NLS-1$ + } + + /** + * Test the steps extension point mechanism. + */ + public void testStepContributions() { + assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance()); //$NON-NLS-1$ + assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance().getStepExtManager()); //$NON-NLS-1$ + + IStep[] steps = StepperManager.getInstance().getStepExtManager().getSteps(false); + int testStepCount = 0; + + for (IStep step : steps) { + if (step.getId().startsWith("org.eclipse.tcf.te.tests.stepper.step")) { //$NON-NLS-1$ + testStepCount++; + } else { + continue; + } + + if (step.getId().endsWith(".step1")) { //$NON-NLS-1$ + assertEquals("Unexpected step label found.", "Test Step 1", step.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step description found.", "", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ + assertTrue("Unexpected step class type found.", step instanceof TestStep); //$NON-NLS-1$ + assertEquals("Unexpected number of dependencies found.", 0, step.getDependencies().length); //$NON-NLS-1$ + } + + if (step.getId().endsWith(".step2")) { //$NON-NLS-1$ + assertEquals("Unexpected step label found.", "Test Step 2", step.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step description found.", "", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ + assertTrue("Unexpected step class type found.", step instanceof ParameterizedTestStep); //$NON-NLS-1$ + + Map<?,?> params = ((ParameterizedTestStep)step).params; + assertNotNull("Unexpected value 'null'.", params); //$NON-NLS-1$ + assertEquals("Unexpected number of parameter found.", 1, params.keySet().size()); //$NON-NLS-1$ + assertTrue("Missing expected key 'param1'.", params.containsKey("param1")); //$NON-NLS-1$ //$NON-NLS-2$ + assertTrue("Missing expected value 'value1'.", params.containsValue("value1")); //$NON-NLS-1$ //$NON-NLS-2$ + + assertEquals("Unexpected number of dependencies found.", 0, step.getDependencies().length); //$NON-NLS-1$ + } + + if (step.getId().endsWith(".step3")) { //$NON-NLS-1$ + assertEquals("Unexpected step label found.", "Test Step 3", step.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step description found.", "Just another test step", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ + assertTrue("Unexpected step class type found.", step instanceof TestStep); //$NON-NLS-1$ + assertEquals("Unexpected number of dependencies found.", 0, step.getDependencies().length); //$NON-NLS-1$ + } + + if (step.getId().endsWith(".step4")) { //$NON-NLS-1$ + assertEquals("Unexpected step label found.", "Test Step 4", step.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step description found.", "", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ + assertTrue("Unexpected step class type found.", step instanceof TestStep); //$NON-NLS-1$ + assertEquals("Unexpected number of dependencies found.", 1, step.getDependencies().length); //$NON-NLS-1$ + } + + if (step.getId().endsWith(".step5")) { //$NON-NLS-1$ + assertEquals("Unexpected step label found.", "Test Step 5", step.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step description found.", "", step.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ + assertTrue("Unexpected step class type found.", step instanceof TestStep); //$NON-NLS-1$ + assertEquals("Unexpected number of dependencies found.", 0, step.getDependencies().length); //$NON-NLS-1$ + } + } + + assertEquals("Unexpected number of test steps found.", 5, testStepCount); //$NON-NLS-1$ + } + + /** + * Test the step group extension point mechanism. + */ + public void testStepGroupContributions() { + assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance()); //$NON-NLS-1$ + assertNotNull("Unexpected return value 'null'.", StepperManager.getInstance().getStepGroupExtManager()); //$NON-NLS-1$ + + IStepGroup[] stepGroups = StepperManager.getInstance().getStepGroupExtManager().getStepGroups(false); + int testStepGroupCount = 0; + + for (IStepGroup stepGroup : stepGroups) { + if (stepGroup.getId().startsWith("org.eclipse.tcf.te.tests.stepper.stepGroup")) { //$NON-NLS-1$ + testStepGroupCount++; + } else { + continue; + } + + Throwable error = null; + String message = null; + IStepGroupable[] steps = null; + + if (stepGroup.getId().endsWith(".stepGroup1")) { //$NON-NLS-1$ + assertEquals("Unexpected step group label found.", "Test Step Group 1", stepGroup.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step description found.", "", stepGroup.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ + assertFalse("Step group is locked but should not.", stepGroup.isLocked()); //$NON-NLS-1$ + assertNull("Unexpected non-null value.", stepGroup.getStepGroupIterator()); //$NON-NLS-1$ + + try { + steps = stepGroup.getSteps(new TestStepContext(this)); + } catch (CoreException e) { + error = e; + message = e.getLocalizedMessage(); + } + assertNull("Failed to determine steps from step group. Possible cause: " + message, error); //$NON-NLS-1$ + assertNotNull("Unexpected return value 'null'.", steps); //$NON-NLS-1$ + assertEquals("Unexpected number of steps returned.", 0, steps.length); //$NON-NLS-1$ + } + + if (stepGroup.getId().endsWith(".stepGroup2")) { //$NON-NLS-1$ + assertEquals("Unexpected step group label found.", "Test Step Group 2", stepGroup.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step description found.", "Just a step group description", stepGroup.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ + assertTrue("Step group is not locked but should.", stepGroup.isLocked()); //$NON-NLS-1$ + assertNull("Unexpected non-null value.", stepGroup.getStepGroupIterator()); //$NON-NLS-1$ + + error = null; message = null; steps = null; + try { + steps = stepGroup.getSteps(new TestStepContext(this)); + } catch (CoreException e) { + error = e; + message = e.getLocalizedMessage(); + } + assertNull("Failed to determine steps from step group. Possible cause: " + message, error); //$NON-NLS-1$ + assertNotNull("Unexpected return value 'null'.", steps); //$NON-NLS-1$ + assertEquals("Unexpected number of steps returned.", 0, steps.length); //$NON-NLS-1$ + } + + if (stepGroup.getId().endsWith(".stepGroup3")) { //$NON-NLS-1$ + assertEquals("Unexpected step group label found.", "Test Step Group 3", stepGroup.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step description found.", "", stepGroup.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ + assertFalse("Step group is locked but should not.", stepGroup.isLocked()); //$NON-NLS-1$ + assertNull("Unexpected non-null value.", stepGroup.getStepGroupIterator()); //$NON-NLS-1$ + + error = null; message = null; steps = null; + try { + steps = stepGroup.getSteps(new TestStepContext(this)); + } catch (CoreException e) { + error = e; + message = e.getLocalizedMessage(); + } + assertNull("Failed to determine steps from step group. Possible cause: " + message, error); //$NON-NLS-1$ + assertNotNull("Unexpected return value 'null'.", steps); //$NON-NLS-1$ + assertEquals("Unexpected number of steps returned.", 4, steps.length); //$NON-NLS-1$ + + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step1", steps[0].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step2", steps[1].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step3", steps[2].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step4", steps[3].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + } + + + if (stepGroup.getId().endsWith(".stepGroup4")) { //$NON-NLS-1$ + assertEquals("Unexpected step group label found.", "Test Step Group 4", stepGroup.getLabel()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step description found.", "", stepGroup.getDescription()); //$NON-NLS-1$ //$NON-NLS-2$ + assertFalse("Step group is locked but should not.", stepGroup.isLocked()); //$NON-NLS-1$ + assertNull("Unexpected non-null value.", stepGroup.getStepGroupIterator()); //$NON-NLS-1$ + + error = null; message = null; steps = null; + try { + steps = stepGroup.getSteps(new TestStepContext(this)); + } catch (CoreException e) { + error = e; + message = e.getLocalizedMessage(); + } + assertNull("Failed to determine steps from step group. Possible cause: " + message, error); //$NON-NLS-1$ + assertNotNull("Unexpected return value 'null'.", steps); //$NON-NLS-1$ + assertEquals("Unexpected number of steps returned.", 5, steps.length); //$NON-NLS-1$ + + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step1", steps[0].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step2", steps[1].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step3", steps[2].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step4", steps[3].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + + error = null; message = null; steps = null; + try { + steps = stepGroup.getSteps(new TestStepContext(this)); + } catch (CoreException e) { + error = e; + message = e.getLocalizedMessage(); + } + assertNull("Failed to determine steps from step group. Possible cause: " + message, error); //$NON-NLS-1$ + assertNotNull("Unexpected return value 'null'.", steps); //$NON-NLS-1$ + assertEquals("Unexpected number of steps returned.", 5, steps.length); //$NON-NLS-1$ + + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step1", steps[0].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step2", steps[1].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step3", steps[2].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step4", steps[3].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + assertEquals("Unexpected step order.", "org.eclipse.tcf.te.tests.stepper.step5", steps[4].getExtension().getId()); //$NON-NLS-1$ //$NON-NLS-2$ + } + } + + assertEquals("Unexpected number of test step groups found.", 4, testStepGroupCount); //$NON-NLS-1$ + } + + public void testExecuteStepGroup() { + final IStepper stepper = new Stepper("testExecuteStepGroup"); //$NON-NLS-1$ + + IPropertiesContainer properties = new PropertiesContainer(); + + // Initialize the stepper + stepper.initialize(new TestStepContext(this), "org.eclipse.tcf.te.tests.stepper.stepGroup4", properties, null); //$NON-NLS-1$ + + ExecutorsUtil.execute(new Runnable() { + @Override + public void run() { + // Execute + try { + stepper.execute(); + } + catch (Exception e) { + assertNull("Unexpected exception when executing step group", e); //$NON-NLS-1$ + } + } + }); + + // Wait for the stepper to be finished + assertFalse("Timeout executing step group", ExecutorsUtil.waitAndExecute(10000, new IStepper.ExecutionFinishedConditionTester(stepper))); //$NON-NLS-1$ + + assertNotNull("Missing executed step 1", properties.getProperty("org.eclipse.tcf.te.tests.stepper.step1")); //$NON-NLS-1$ //$NON-NLS-2$ + assertNotNull("Missing executed step 2", properties.getProperty("org.eclipse.tcf.te.tests.stepper.step2")); //$NON-NLS-1$ //$NON-NLS-2$ + assertNotNull("Missing executed step 3", properties.getProperty("org.eclipse.tcf.te.tests.stepper.step3")); //$NON-NLS-1$ //$NON-NLS-2$ + assertNotNull("Missing executed step 4", properties.getProperty("org.eclipse.tcf.te.tests.stepper.step4")); //$NON-NLS-1$ //$NON-NLS-2$ + assertNotNull("Missing executed step 5", properties.getProperty("org.eclipse.tcf.te.tests.stepper.step5")); //$NON-NLS-1$ //$NON-NLS-2$ + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/steps/ParameterizedTestStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/steps/ParameterizedTestStep.java index 050b78a72..5558db5d5 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/steps/ParameterizedTestStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/steps/ParameterizedTestStep.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/steps/TestStep.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/steps/TestStep.java index 9deeedb14..cb0832612 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/steps/TestStep.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/stepper/steps/TestStep.java @@ -1,41 +1,41 @@ -/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tests.stepper.steps;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback;
-import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId;
-import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext;
-import org.eclipse.tcf.te.runtime.stepper.steps.AbstractStep;
-
-/**
- * Empty test step contribution.
- */
-public class TestStep extends AbstractStep {
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor)
- */
- @Override
- public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback)
- */
- @Override
- public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) {
- data.setProperty(getId(), fullQualifiedId.toString());
- callback.done(this, Status.OK_STATUS);
- }
-}
+/******************************************************************************* + * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tests.stepper.steps; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Status; +import org.eclipse.tcf.te.runtime.interfaces.callback.ICallback; +import org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId; +import org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext; +import org.eclipse.tcf.te.runtime.stepper.steps.AbstractStep; + +/** + * Empty test step contribution. + */ +public class TestStep extends AbstractStep { + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IExtendedStep#validateExecute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public void validateExecute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor) throws CoreException { + } + + /* (non-Javadoc) + * @see org.eclipse.tcf.te.runtime.stepper.interfaces.IStep#execute(org.eclipse.tcf.te.runtime.stepper.interfaces.IStepContext, org.eclipse.tcf.te.runtime.interfaces.properties.IPropertiesContainer, org.eclipse.tcf.te.runtime.stepper.interfaces.IFullQualifiedId, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.tcf.te.runtime.interfaces.callback.ICallback) + */ + @Override + public void execute(IStepContext context, IPropertiesContainer data, IFullQualifiedId fullQualifiedId, IProgressMonitor monitor, ICallback callback) { + data.setProperty(getId(), fullQualifiedId.toString()); + callback.done(this, Status.OK_STATUS); + } +} diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/suites/AllTests.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/suites/AllTests.java index 6fb7bf70b..ebaea1608 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/suites/AllTests.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/suites/AllTests.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2011, 2013 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/TcfTestCase.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/TcfTestCase.java index 0b6bb7434..ba8b90af6 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/TcfTestCase.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/TcfTestCase.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved. + * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others. All rights reserved. * This program and the accompanying materials are made available under the terms * of the Eclipse Public License v1.0 which accompanies this distribution, and is * available at http://www.eclipse.org/legal/epl-v10.html diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/launch/TcfLaunchTests.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/launch/TcfLaunchTests.java index 24e4067ba..a08e9c631 100644 --- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/launch/TcfLaunchTests.java +++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/tcf/launch/TcfLaunchTests.java @@ -1,143 +1,143 @@ -/*******************************************************************************
- * Copyright (c) 2012 Wind River Systems, Inc. and others. All rights reserved.
- * This program and the accompanying materials are made available under the terms
- * of the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tests.tcf.launch;
-
-import junit.framework.Test;
-import junit.framework.TestSuite;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.tcf.te.launch.core.lm.LaunchManager;
-import org.eclipse.tcf.te.launch.core.lm.LaunchSpecification;
-import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification;
-import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransfersPersistenceDelegate;
-import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate;
-import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
-import org.eclipse.tcf.te.runtime.services.filetransfer.FileTransferItem;
-import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem;
-import org.eclipse.tcf.te.runtime.utils.Host;
-import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILaunchTypes;
-import org.eclipse.tcf.te.tcf.processes.core.interfaces.steps.IProcessesStepAttributes;
-import org.eclipse.tcf.te.tests.tcf.TcfTestCase;
-
-/**
- * TCF Launch tests.
- */
-public class TcfLaunchTests extends TcfTestCase {
-
- /**
- * Provides a test suite to the caller which combines all single
- * test bundled within this category.
- *
- * @return Test suite containing all test for this test category.
- */
- public static Test getTestSuite() {
- TestSuite testSuite = new TestSuite("TCF Launch tests"); //$NON-NLS-1$
-
- // add ourself to the test suite
- testSuite.addTestSuite(TcfLaunchTests.class);
-
- return testSuite;
- }
-
-
- public void testRemoteAppLaunch() {
- final ILaunchSpecification spec = new LaunchSpecification(ILaunchTypes.REMOTE_APPLICATION, ILaunchManager.RUN_MODE);
- LaunchContextsPersistenceDelegate.setLaunchContexts(spec, new IModelNode[]{peerModel});
-
- IPath helloWorldLocation = getHelloWorldLocation();
- assertTrue("Missing hello world example for current OS and Arch:" + Platform.getOS() + "/" + Platform.getOSArch(), //$NON-NLS-1$ //$NON-NLS-2$
- helloWorldLocation != null &&
- helloWorldLocation.toFile().exists() &&
- helloWorldLocation.toFile().canRead());
-
- String temp = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$
- IPath tempDir = temp != null ? new Path(temp) : null;
- assertNotNull("Missing java temp directory", tempDir); //$NON-NLS-1$
-
- // If the temporary directory is not writable for whatever reason to us,
- // fallback to the users home directory
- if (!tempDir.toFile().canWrite()) {
- temp = System.getProperty("user.home"); //$NON-NLS-1$
- tempDir = temp != null ? new Path(temp) : null;
- assertNotNull("Missing user home directory", tempDir); //$NON-NLS-1$
- }
-
- tempDir = tempDir.append(TcfLaunchTests.class.getSimpleName());
- assertNotNull("Cannot append test case specific temp directory", tempDir); //$NON-NLS-1$
- if (!tempDir.toFile().exists()) {
- assertTrue("Failed to create path " + tempDir.toString(), tempDir.toFile().mkdirs()); //$NON-NLS-1$
- }
- assertTrue("Temporary file location is not writable (" + tempDir.toOSString() + ")", tempDir.toFile().canWrite()); //$NON-NLS-1$ //$NON-NLS-2$
-
- IPath tempHelloWorld = tempDir.append(helloWorldLocation.lastSegment());
- if (tempHelloWorld.toFile().exists()) {
- tempHelloWorld.toFile().setWritable(true, false);
- tempHelloWorld.toFile().delete();
- }
- assertFalse("Cannot delete process image " + tempHelloWorld.toOSString(), tempHelloWorld.toFile().exists()); //$NON-NLS-1$
-
- IPath outFile = tempDir.append("/HelloWorld.out"); //$NON-NLS-1$
- if (outFile.toFile().exists()) {
- outFile.toFile().delete();
- }
- assertFalse("Cannot delete console output file " + outFile.toOSString(), outFile.toFile().exists()); //$NON-NLS-1$
-
- FileTransfersPersistenceDelegate.setFileTransfers(spec, new IFileTransferItem[]{new FileTransferItem(helloWorldLocation, tempDir)});
- spec.addAttribute(IProcessesStepAttributes.ATTR_PROCESS_IMAGE, tempHelloWorld.toOSString());
-
- ILaunchConfiguration config = null;
- try {
- config = LaunchManager.getInstance().getLaunchConfiguration(spec, true);
- ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
- wc.setAttribute("org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON", false); //$NON-NLS-1$
- wc.setAttribute("org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE", outFile.toOSString()); //$NON-NLS-1$
- config = wc.doSave();
- }
- catch (Exception e) {
- assertNull("Unexpected exception when creating launch: " + e, e); //$NON-NLS-1$
- }
-
- try {
- LaunchManager.getInstance().launch(config, ILaunchManager.RUN_MODE, false, new NullProgressMonitor());
- }
- catch (Exception e) {
- assertNull("Unexpected exception when launching hello world: " + e, e); //$NON-NLS-1$
- }
-
- int counter = 20;
- boolean exist = outFile.toFile().exists() && outFile.toFile().length() > 0;
- while (!exist && counter > 0) {
- try {
- Thread.sleep(200);
- } catch (InterruptedException e) { /* ignored on purpose */ }
- exist = outFile.toFile().exists() && outFile.toFile().length() > 0;
- counter--;
- }
- assertTrue("Missing console output file (" + outFile.toOSString() + ")", exist); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private IPath getHelloWorldLocation() {
- IPath path = getDataLocation("helloWorld", true, true); //$NON-NLS-1$
- if (path != null) {
- path = path.append("HelloWorld"); //$NON-NLS-1$
- if (Host.isWindowsHost()) {
- path = path.addFileExtension("exe"); //$NON-NLS-1$
- }
- }
-
- return path;
- }
-}
+/******************************************************************************* + * Copyright (c) 2012, 2013 Wind River Systems, Inc. and others. All rights reserved. + * This program and the accompanying materials are made available under the terms + * of the Eclipse Public License v1.0 which accompanies this distribution, and is + * available at http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.tcf.te.tests.tcf.launch; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.core.runtime.Platform; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.tcf.te.launch.core.lm.LaunchManager; +import org.eclipse.tcf.te.launch.core.lm.LaunchSpecification; +import org.eclipse.tcf.te.launch.core.lm.interfaces.ILaunchSpecification; +import org.eclipse.tcf.te.launch.core.persistence.filetransfer.FileTransfersPersistenceDelegate; +import org.eclipse.tcf.te.launch.core.persistence.launchcontext.LaunchContextsPersistenceDelegate; +import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode; +import org.eclipse.tcf.te.runtime.services.filetransfer.FileTransferItem; +import org.eclipse.tcf.te.runtime.services.interfaces.filetransfer.IFileTransferItem; +import org.eclipse.tcf.te.runtime.utils.Host; +import org.eclipse.tcf.te.tcf.launch.core.interfaces.ILaunchTypes; +import org.eclipse.tcf.te.tcf.processes.core.interfaces.steps.IProcessesStepAttributes; +import org.eclipse.tcf.te.tests.tcf.TcfTestCase; + +/** + * TCF Launch tests. + */ +public class TcfLaunchTests extends TcfTestCase { + + /** + * Provides a test suite to the caller which combines all single + * test bundled within this category. + * + * @return Test suite containing all test for this test category. + */ + public static Test getTestSuite() { + TestSuite testSuite = new TestSuite("TCF Launch tests"); //$NON-NLS-1$ + + // add ourself to the test suite + testSuite.addTestSuite(TcfLaunchTests.class); + + return testSuite; + } + + + public void testRemoteAppLaunch() { + final ILaunchSpecification spec = new LaunchSpecification(ILaunchTypes.REMOTE_APPLICATION, ILaunchManager.RUN_MODE); + LaunchContextsPersistenceDelegate.setLaunchContexts(spec, new IModelNode[]{peerModel}); + + IPath helloWorldLocation = getHelloWorldLocation(); + assertTrue("Missing hello world example for current OS and Arch:" + Platform.getOS() + "/" + Platform.getOSArch(), //$NON-NLS-1$ //$NON-NLS-2$ + helloWorldLocation != null && + helloWorldLocation.toFile().exists() && + helloWorldLocation.toFile().canRead()); + + String temp = System.getProperty("java.io.tmpdir"); //$NON-NLS-1$ + IPath tempDir = temp != null ? new Path(temp) : null; + assertNotNull("Missing java temp directory", tempDir); //$NON-NLS-1$ + + // If the temporary directory is not writable for whatever reason to us, + // fallback to the users home directory + if (!tempDir.toFile().canWrite()) { + temp = System.getProperty("user.home"); //$NON-NLS-1$ + tempDir = temp != null ? new Path(temp) : null; + assertNotNull("Missing user home directory", tempDir); //$NON-NLS-1$ + } + + tempDir = tempDir.append(TcfLaunchTests.class.getSimpleName()); + assertNotNull("Cannot append test case specific temp directory", tempDir); //$NON-NLS-1$ + if (!tempDir.toFile().exists()) { + assertTrue("Failed to create path " + tempDir.toString(), tempDir.toFile().mkdirs()); //$NON-NLS-1$ + } + assertTrue("Temporary file location is not writable (" + tempDir.toOSString() + ")", tempDir.toFile().canWrite()); //$NON-NLS-1$ //$NON-NLS-2$ + + IPath tempHelloWorld = tempDir.append(helloWorldLocation.lastSegment()); + if (tempHelloWorld.toFile().exists()) { + tempHelloWorld.toFile().setWritable(true, false); + tempHelloWorld.toFile().delete(); + } + assertFalse("Cannot delete process image " + tempHelloWorld.toOSString(), tempHelloWorld.toFile().exists()); //$NON-NLS-1$ + + IPath outFile = tempDir.append("/HelloWorld.out"); //$NON-NLS-1$ + if (outFile.toFile().exists()) { + outFile.toFile().delete(); + } + assertFalse("Cannot delete console output file " + outFile.toOSString(), outFile.toFile().exists()); //$NON-NLS-1$ + + FileTransfersPersistenceDelegate.setFileTransfers(spec, new IFileTransferItem[]{new FileTransferItem(helloWorldLocation, tempDir)}); + spec.addAttribute(IProcessesStepAttributes.ATTR_PROCESS_IMAGE, tempHelloWorld.toOSString()); + + ILaunchConfiguration config = null; + try { + config = LaunchManager.getInstance().getLaunchConfiguration(spec, true); + ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy(); + wc.setAttribute("org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON", false); //$NON-NLS-1$ + wc.setAttribute("org.eclipse.debug.ui.ATTR_CAPTURE_IN_FILE", outFile.toOSString()); //$NON-NLS-1$ + config = wc.doSave(); + } + catch (Exception e) { + assertNull("Unexpected exception when creating launch: " + e, e); //$NON-NLS-1$ + } + + try { + LaunchManager.getInstance().launch(config, ILaunchManager.RUN_MODE, false, new NullProgressMonitor()); + } + catch (Exception e) { + assertNull("Unexpected exception when launching hello world: " + e, e); //$NON-NLS-1$ + } + + int counter = 20; + boolean exist = outFile.toFile().exists() && outFile.toFile().length() > 0; + while (!exist && counter > 0) { + try { + Thread.sleep(200); + } catch (InterruptedException e) { /* ignored on purpose */ } + exist = outFile.toFile().exists() && outFile.toFile().length() > 0; + counter--; + } + assertTrue("Missing console output file (" + outFile.toOSString() + ")", exist); //$NON-NLS-1$ //$NON-NLS-2$ + } + + private IPath getHelloWorldLocation() { + IPath path = getDataLocation("helloWorld", true, true); //$NON-NLS-1$ + if (path != null) { + path = path.append("HelloWorld"); //$NON-NLS-1$ + if (Host.isWindowsHost()) { + path = path.addFileExtension("exe"); //$NON-NLS-1$ + } + } + + return path; + } +} |