diff options
author | Mike Rennie | 2014-08-13 12:51:53 +0000 |
---|---|---|
committer | Mike Rennie | 2014-08-13 12:52:34 +0000 |
commit | bbfb01305dca3332c80e5cdc4a50b5b7ddcbdf31 (patch) | |
tree | 7a9a96383569e0ee6cef97d71db669cdd9498beb /org.eclipse.debug.tests | |
parent | 5d4ea367b42aa3d2a875fcc86f4ccf6ef74a62fe (diff) | |
download | eclipse.platform.debug-bbfb01305dca3332c80e5cdc4a50b5b7ddcbdf31.tar.gz eclipse.platform.debug-bbfb01305dca3332c80e5cdc4a50b5b7ddcbdf31.tar.xz eclipse.platform.debug-bbfb01305dca3332c80e5cdc4a50b5b7ddcbdf31.zip |
Bug 437193 - JSR-45 Support broken
Diffstat (limited to 'org.eclipse.debug.tests')
7 files changed, 542 insertions, 0 deletions
diff --git a/org.eclipse.debug.tests/META-INF/MANIFEST.MF b/org.eclipse.debug.tests/META-INF/MANIFEST.MF index ee106f378..a7168199b 100644 --- a/org.eclipse.debug.tests/META-INF/MANIFEST.MF +++ b/org.eclipse.debug.tests/META-INF/MANIFEST.MF @@ -20,6 +20,7 @@ Export-Package: org.eclipse.debug.tests, org.eclipse.debug.tests.breakpoint, org.eclipse.debug.tests.expressions, org.eclipse.debug.tests.launching, + org.eclipse.debug.tests.sourcelookup, org.eclipse.debug.tests.statushandlers, org.eclipse.debug.tests.stepfilters, org.eclipse.debug.tests.view.memory, diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java index b268324ac..7af33159d 100644 --- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java @@ -23,6 +23,7 @@ import org.eclipse.debug.tests.launching.LaunchFavoriteTests; import org.eclipse.debug.tests.launching.LaunchHistoryTests; import org.eclipse.debug.tests.launching.LaunchManagerTests; import org.eclipse.debug.tests.launching.RefreshTabTests; +import org.eclipse.debug.tests.sourcelookup.SourceLookupFacilityTests; import org.eclipse.debug.tests.statushandlers.StatusHandlerTests; import org.eclipse.debug.tests.stepfilters.StepFiltersTests; import org.eclipse.debug.tests.view.memory.MemoryRenderingTests; @@ -57,6 +58,9 @@ public class AutomatedSuite extends TestSuite { * Constructs the automated test suite. Adds all tests. */ public AutomatedSuite() { + // Source lookup tests + addTest(new TestSuite(SourceLookupFacilityTests.class)); + // BP tests addTest(new TestSuite(BreakpointOrderingTests.class)); // Note: jface viewer tests were moved out of nightly tests // due to frequent problems on nightly build machines. diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/SourceLookupFacilityTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/SourceLookupFacilityTests.java new file mode 100644 index 000000000..9e474edd1 --- /dev/null +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/SourceLookupFacilityTests.java @@ -0,0 +1,292 @@ +/******************************************************************************* + * Copyright (c) Jul 30, 2014 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.tests.sourcelookup; + +import junit.framework.TestCase; + +import org.eclipse.debug.core.model.IStackFrame; +import org.eclipse.debug.internal.ui.sourcelookup.SourceLookupFacility; +import org.eclipse.debug.ui.sourcelookup.ISourceLookupResult; + +/** + * Tests {@link SourceLookupFacility} + * + * @since 3.9.200 + */ +public class SourceLookupFacilityTests extends TestCase { + + /** + * {@link IStackFrame} to be reused + */ + TestStackFrame fReusableFrame = new TestStackFrame(new TestLaunch()); + /** + * Testing source director + */ + TestSourceDirector fTestDirector = new TestSourceDirector(); + /** + * Test source locator + */ + TestSourceLocator fTestLocator = new TestSourceLocator(); + + /** + * @param name + */ + public SourceLookupFacilityTests(String name) { + super(name); + } + + /** + * Tests calling + * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} + * with simple type, no locator and no forcing + * + * @throws Exception + */ + public void testLookupStringNoLocatorNoForce() throws Exception { + try { + String artifact = "Empty"; //$NON-NLS-1$ + ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(artifact, null, false); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertNull("Source element should be null", result.getSourceElement()); //$NON-NLS-1$ + } finally { + SourceLookupFacility.shutdown(); + } + } + + /** + * Tests calling + * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} + * with simple type and no forcing + * + * @throws Exception + */ + public void testLookupStringNoForce() throws Exception { + try { + String artifact = "One"; //$NON-NLS-1$ + ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(artifact, fTestDirector, false); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result artifact should be a String", result.getArtifact() instanceof String); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + String value = (String) result.getSourceElement(); + result = SourceLookupFacility.getDefault().lookup(artifact, fTestDirector, false); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result artifact should be a String", result.getArtifact() instanceof String); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + assertEquals("The results should be equal", value, result.getSourceElement()); //$NON-NLS-1$ + } finally { + SourceLookupFacility.shutdown(); + } + } + + /** + * Tests calling + * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} + * with simple type and forcing + * + * @throws Exception + */ + public void testLookupStringForce() throws Exception { + try { + String artifact = "Two"; //$NON-NLS-1$ + ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(artifact, fTestDirector, true); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result artifact should be a String", result.getArtifact() instanceof String); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + String value = (String) result.getSourceElement(); + result = SourceLookupFacility.getDefault().lookup(artifact, fTestDirector, true); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result artifact should be a String", result.getArtifact() instanceof String); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + assertNotSame("The results should not be equal", value, result.getSourceElement()); //$NON-NLS-1$ + } finally { + SourceLookupFacility.shutdown(); + } + } + + /** + * Tests calling + * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} + * with simple type and no forcing + * + * @throws Exception + */ + public void testLookupStringLocatorNoForce() throws Exception { + try { + String artifact = "Three"; //$NON-NLS-1$ + ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(artifact, fTestLocator, false); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertNull("The source element should be null", result.getSourceElement()); //$NON-NLS-1$ + } finally { + SourceLookupFacility.shutdown(); + } + } + + /** + * Tests calling + * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} + * with an {@link IStackFrame} impl and no forcing + * + * @throws Exception + */ + public void testLookupStackframeNoForce() throws Exception { + try { + ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestDirector, false); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + String value = (String) result.getSourceElement(); + result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestDirector, false); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result artifact should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + assertEquals("The results should not be equal", value, result.getSourceElement()); //$NON-NLS-1$ + } finally { + SourceLookupFacility.shutdown(); + } + } + + /** + * Tests calling + * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} + * with an {@link IStackFrame} impl and forcing + * + * @throws Exception + */ + public void testLookupStackframeForce() throws Exception { + try { + ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestDirector, true); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + String value = (String) result.getSourceElement(); + result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestDirector, true); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result artifact should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + assertNotSame("The results should not be equal", value, result.getSourceElement()); //$NON-NLS-1$ + } finally { + SourceLookupFacility.shutdown(); + } + } + + /** + * Tests calling + * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} + * with an {@link IStackFrame} impl, no forcing, no locator, no launch + * + * @throws Exception + */ + public void testLookupStackframeWithDebugElement1() throws Exception { + try { + ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(new TestStackFrame(null), null, false); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertNull("Source element should be null", result.getSourceElement()); //$NON-NLS-1$ + } finally { + SourceLookupFacility.shutdown(); + } + } + + /** + * Tests calling + * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} + * with an {@link IStackFrame} impl, no forcing, no locator + * + * @throws Exception + */ + public void testLookupStackframeWithDebugElement2() throws Exception { + try { + ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, null, false); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + String value = (String) result.getSourceElement(); + result = SourceLookupFacility.getDefault().lookup(fReusableFrame, null, false); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result artifact should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + assertEquals("The results should be equal", value, result.getSourceElement()); //$NON-NLS-1$ + } finally { + SourceLookupFacility.shutdown(); + } + } + + /** + * Tests calling + * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} + * with an {@link IStackFrame} impl, forcing, no locator + * + * @throws Exception + */ + public void testLookupStackframeWithDebugElement3() throws Exception { + try { + ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, null, true); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + String value = (String) result.getSourceElement(); + result = SourceLookupFacility.getDefault().lookup(fReusableFrame, null, true); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result artifact should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + assertNotSame("The results should not be equal", value, result.getSourceElement()); //$NON-NLS-1$ + } finally { + SourceLookupFacility.shutdown(); + } + } + + /** + * Tests calling + * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} + * with an {@link IStackFrame} impl, no forcing, ISourceLocator impl + * + * @throws Exception + */ + public void testLookupStackframeWithDebugElement4() throws Exception { + try { + ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestLocator, false); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + String value = (String) result.getSourceElement(); + result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestLocator, false); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result artifact should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + assertEquals("The results should not be equal", value, result.getSourceElement()); //$NON-NLS-1$ + } finally { + SourceLookupFacility.shutdown(); + } + } + + /** + * Tests calling + * {@link SourceLookupFacility#lookup(Object, org.eclipse.debug.core.model.ISourceLocator, boolean)} + * with an {@link IStackFrame} impl, forcing, ISourceLocator impl + * + * @throws Exception + */ + public void testLookupStackframeWithDebugElement5() throws Exception { + try { + ISourceLookupResult result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestLocator, true); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + String value = (String) result.getSourceElement(); + result = SourceLookupFacility.getDefault().lookup(fReusableFrame, fTestLocator, true); + assertNotNull("There should be a result", result); //$NON-NLS-1$ + assertTrue("The result artifact should be a String", result.getArtifact() instanceof IStackFrame); //$NON-NLS-1$ + assertTrue("The result source element should be a String", result.getSourceElement() instanceof String); //$NON-NLS-1$ + assertNotSame("The results should not be equal", value, result.getSourceElement()); //$NON-NLS-1$ + } finally { + SourceLookupFacility.shutdown(); + } + } +} diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestLaunch.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestLaunch.java new file mode 100644 index 000000000..2c94c0e56 --- /dev/null +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestLaunch.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2014 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.tests.sourcelookup; + +import org.eclipse.debug.core.Launch; + +public class TestLaunch extends Launch { + + public TestLaunch() { + super(null, "debug", new TestSourceDirector()); //$NON-NLS-1$ + } + +} diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestSourceDirector.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestSourceDirector.java new file mode 100644 index 000000000..6ec38faaa --- /dev/null +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestSourceDirector.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * Copyright (c) 2014 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.tests.sourcelookup; + +import org.eclipse.debug.core.model.IStackFrame; +import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector; + +public class TestSourceDirector extends AbstractSourceLookupDirector { + + + @Override + public Object getSourceElement(Object element) { + if (element instanceof String) { + return element.toString() + System.currentTimeMillis(); + } else if (element instanceof IStackFrame) { + IStackFrame frame = (IStackFrame) element; + return frame.getModelIdentifier() + System.currentTimeMillis(); + } + return super.getSourceElement(element); + } + + @Override + public void initializeParticipants() { + } +} diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestSourceLocator.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestSourceLocator.java new file mode 100644 index 000000000..bff349358 --- /dev/null +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestSourceLocator.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) Jul 30, 2014 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.tests.sourcelookup; + +import org.eclipse.debug.core.model.ISourceLocator; +import org.eclipse.debug.core.model.IStackFrame; + +/** + * Test source locator + */ +public class TestSourceLocator implements ISourceLocator { + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.ISourceLocator#getSourceElement(org.eclipse.debug.core.model.IStackFrame) + */ + @Override + public Object getSourceElement(IStackFrame stackFrame) { + return stackFrame.getModelIdentifier() + System.currentTimeMillis(); + } + +} diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestStackFrame.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestStackFrame.java new file mode 100644 index 000000000..2e6da1a2c --- /dev/null +++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/sourcelookup/TestStackFrame.java @@ -0,0 +1,162 @@ +/******************************************************************************* + * Copyright (c) 2014 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.debug.tests.sourcelookup; + +import org.eclipse.debug.core.DebugException; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.model.IDebugTarget; +import org.eclipse.debug.core.model.IRegisterGroup; +import org.eclipse.debug.core.model.IStackFrame; +import org.eclipse.debug.core.model.IThread; +import org.eclipse.debug.core.model.IVariable; + +public class TestStackFrame implements IStackFrame { + + TestLaunch fLaunch = null; + + public TestStackFrame(TestLaunch launch) { + fLaunch = launch; + } + + @Override + public String getModelIdentifier() { + return "test.debug.model"; //$NON-NLS-1$ + } + + @Override + public IDebugTarget getDebugTarget() { + return null; + } + + @Override + public ILaunch getLaunch() { + return fLaunch; + } + + @Override + public Object getAdapter(Class adapter) { + return null; + } + + @Override + public boolean canStepInto() { + return false; + } + + @Override + public boolean canStepOver() { + return false; + } + + @Override + public boolean canStepReturn() { + return false; + } + + @Override + public boolean isStepping() { + return false; + } + + @Override + public void stepInto() throws DebugException { + } + + @Override + public void stepOver() throws DebugException { + } + + @Override + public void stepReturn() throws DebugException { + } + + @Override + public boolean canResume() { + return false; + } + + @Override + public boolean canSuspend() { + return false; + } + + @Override + public boolean isSuspended() { + return false; + } + + @Override + public void resume() throws DebugException { + } + + @Override + public void suspend() throws DebugException { + } + + @Override + public boolean canTerminate() { + return false; + } + + @Override + public boolean isTerminated() { + return false; + } + + @Override + public void terminate() throws DebugException { + } + + @Override + public IThread getThread() { + return null; + } + + @Override + public IVariable[] getVariables() throws DebugException { + return new IVariable[0]; + } + + @Override + public boolean hasVariables() throws DebugException { + return false; + } + + @Override + public int getLineNumber() throws DebugException { + return 0; + } + + @Override + public int getCharStart() throws DebugException { + return 0; + } + + @Override + public int getCharEnd() throws DebugException { + return 0; + } + + @Override + public String getName() throws DebugException { + return "Test Debug Source Lookup Frame"; //$NON-NLS-1$ + } + + @Override + public IRegisterGroup[] getRegisterGroups() throws DebugException { + return new IRegisterGroup[0]; + } + + @Override + public boolean hasRegisterGroups() throws DebugException { + return false; + } +} |