1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Don't use deprecated junit.framework.Assert.

The replacment is org.junit.Assert.

Change-Id: I44bd6da6e19f9d69f91eb1ad251bd6e259ff67a9
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Reviewed-on: https://git.eclipse.org/r/30629
Tested-by: Hudson CI
Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com>
This commit is contained in:
Alexander Kurtakov 2014-07-28 23:20:19 +03:00 committed by Marc Khouzam
parent e26e8a60c0
commit 6534051b1b
13 changed files with 230 additions and 221 deletions

View file

@ -10,6 +10,8 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf; package org.eclipse.cdt.tests.dsf;
import static org.junit.Assert.fail;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -17,8 +19,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.TreeSet; import java.util.TreeSet;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.IPropertiesUpdate; import org.eclipse.cdt.dsf.ui.viewmodel.properties.IPropertiesUpdate;
import org.eclipse.cdt.dsf.ui.viewmodel.properties.IPropertiesUpdateListener; import org.eclipse.cdt.dsf.ui.viewmodel.properties.IPropertiesUpdateListener;
import org.eclipse.debug.internal.ui.viewers.model.ILabelUpdateListener; import org.eclipse.debug.internal.ui.viewers.model.ILabelUpdateListener;
@ -245,13 +245,13 @@ public class ViewerUpdatesListener
} }
if (fFailOnRedundantUpdates && !fRedundantUpdates.isEmpty()) { if (fFailOnRedundantUpdates && !fRedundantUpdates.isEmpty()) {
Assert.fail("Redundant Updates: " + fRedundantUpdates.toString()); fail("Redundant Updates: " + fRedundantUpdates.toString());
} }
if (fFailOnMultipleLabelUpdateSequences && !fMultipleLabelUpdateSequencesObserved) { if (fFailOnMultipleLabelUpdateSequences && !fMultipleLabelUpdateSequencesObserved) {
Assert.fail("Multiple label update sequences detected"); fail("Multiple label update sequences detected");
} }
if (fFailOnMultipleModelUpdateSequences && fMultipleModelUpdateSequencesObserved) { if (fFailOnMultipleModelUpdateSequences && fMultipleModelUpdateSequencesObserved) {
Assert.fail("Multiple viewer update sequences detected"); fail("Multiple viewer update sequences detected");
} }
if ( (flags & LABEL_SEQUENCE_COMPLETE) != 0) { if ( (flags & LABEL_SEQUENCE_COMPLETE) != 0) {

View file

@ -10,14 +10,17 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.concurrent; package org.eclipse.cdt.tests.dsf.concurrent;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor; import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
@ -119,54 +122,54 @@ public class CacheTests {
} }
private void assertCacheValidWithData(Object data) { private void assertCacheValidWithData(Object data) {
Assert.assertTrue(fTestCache.isValid()); assertTrue(fTestCache.isValid());
Assert.assertEquals(data, fTestCache.getData()); assertEquals(data, fTestCache.getData());
Assert.assertTrue(fTestCache.getStatus().isOK()); assertTrue(fTestCache.getStatus().isOK());
} }
private void assertCacheResetWithoutData() { private void assertCacheResetWithoutData() {
Assert.assertFalse(fTestCache.isValid()); assertFalse(fTestCache.isValid());
try { try {
fTestCache.getData(); fTestCache.getData();
Assert.fail("Expected an IllegalStateException"); fail("Expected an IllegalStateException");
} catch (IllegalStateException e) {} } catch (IllegalStateException e) {}
try { try {
fTestCache.getStatus(); fTestCache.getStatus();
Assert.fail("Expected an IllegalStateException"); fail("Expected an IllegalStateException");
} catch (IllegalStateException e) {} } catch (IllegalStateException e) {}
} }
private void assertCacheValidWithoutData() { private void assertCacheValidWithoutData() {
Assert.assertTrue(fTestCache.isValid()); assertTrue(fTestCache.isValid());
Assert.assertEquals(null, fTestCache.getData()); assertEquals(null, fTestCache.getData());
Assert.assertFalse(fTestCache.getStatus().isOK()); assertFalse(fTestCache.getStatus().isOK());
Assert.assertEquals(fTestCache.getStatus().getCode(), ERRCODE_TARGET_RUNNING); assertEquals(fTestCache.getStatus().getCode(), ERRCODE_TARGET_RUNNING);
} }
private void assertCacheWaiting() { private void assertCacheWaiting() {
Assert.assertFalse(fTestCache.isValid()); assertFalse(fTestCache.isValid());
try { try {
fTestCache.getData(); fTestCache.getData();
Assert.fail("Expected an IllegalStateException"); fail("Expected an IllegalStateException");
} catch (IllegalStateException e) {} } catch (IllegalStateException e) {}
try { try {
fTestCache.getStatus(); fTestCache.getStatus();
Assert.fail("Expected an IllegalStateException"); fail("Expected an IllegalStateException");
} catch (IllegalStateException e) {} } catch (IllegalStateException e) {}
Assert.assertFalse(fRetrieveRm.isCanceled()); assertFalse(fRetrieveRm.isCanceled());
} }
private void assertCacheInvalidAndWithCanceledRM() { private void assertCacheInvalidAndWithCanceledRM() {
Assert.assertFalse(fTestCache.isValid()); assertFalse(fTestCache.isValid());
try { try {
fTestCache.getData(); fTestCache.getData();
Assert.fail("Expected an IllegalStateException"); fail("Expected an IllegalStateException");
} catch (IllegalStateException e) {} } catch (IllegalStateException e) {}
try { try {
fTestCache.getStatus(); fTestCache.getStatus();
Assert.fail("Expected an IllegalStateException"); fail("Expected an IllegalStateException");
} catch (IllegalStateException e) {} } catch (IllegalStateException e) {}
Assert.assertTrue(fRetrieveRm.isCanceled()); assertTrue(fRetrieveRm.isCanceled());
} }
@Test @Test
@ -175,7 +178,7 @@ public class CacheTests {
Query<Integer> q = new TestQuery(); Query<Integer> q = new TestQuery();
// Check initial state // Check initial state
Assert.assertFalse(fTestCache.isValid()); assertFalse(fTestCache.isValid());
fExecutor.execute(q); fExecutor.execute(q);
@ -183,7 +186,7 @@ public class CacheTests {
waitForRetrieveRm(); waitForRetrieveRm();
// Check state while waiting for data // Check state while waiting for data
Assert.assertFalse(fTestCache.isValid()); assertFalse(fTestCache.isValid());
// Complete the cache's retrieve data request. // Complete the cache's retrieve data request.
fExecutor.submit(new Callable<Object>() { public Object call() { fExecutor.submit(new Callable<Object>() { public Object call() {
@ -192,13 +195,13 @@ public class CacheTests {
// Check that the data is available in the cache immediately // Check that the data is available in the cache immediately
// (in the same dispatch cycle). // (in the same dispatch cycle).
Assert.assertEquals(1, (int)fTestCache.getData()); assertEquals(1, (int)fTestCache.getData());
Assert.assertTrue(fTestCache.isValid()); assertTrue(fTestCache.isValid());
return null; return null;
}}).get(); }}).get();
Assert.assertEquals(1, (int)q.get()); assertEquals(1, (int)q.get());
// Re-check final state // Re-check final state
assertCacheValidWithData(1); assertCacheValidWithData(1);
@ -207,7 +210,7 @@ public class CacheTests {
@Test @Test
public void getTest() throws InterruptedException, ExecutionException { public void getTest() throws InterruptedException, ExecutionException {
// Check initial state // Check initial state
Assert.assertFalse(fTestCache.isValid()); assertFalse(fTestCache.isValid());
// Request data from cache // Request data from cache
Query<Integer> q = new TestQuery(); Query<Integer> q = new TestQuery();
@ -217,13 +220,13 @@ public class CacheTests {
waitForRetrieveRm(); waitForRetrieveRm();
// Check state while waiting for data // Check state while waiting for data
Assert.assertFalse(fTestCache.isValid()); assertFalse(fTestCache.isValid());
// Set the data without using an executor. // Set the data without using an executor.
fRetrieveRm.setData(1); fRetrieveRm.setData(1);
fRetrieveRm.done(); fRetrieveRm.done();
Assert.assertEquals(1, (int)q.get()); assertEquals(1, (int)q.get());
// Check final state // Check final state
assertCacheValidWithData(1); assertCacheValidWithData(1);
@ -232,7 +235,7 @@ public class CacheTests {
@Test @Test
public void getTestWithTwoClients() throws InterruptedException, ExecutionException { public void getTestWithTwoClients() throws InterruptedException, ExecutionException {
// Check initial state // Check initial state
Assert.assertFalse(fTestCache.isValid()); assertFalse(fTestCache.isValid());
// Request data from cache // Request data from cache
Query<Integer> q1 = new TestQuery(); Query<Integer> q1 = new TestQuery();
@ -246,14 +249,14 @@ public class CacheTests {
waitForRetrieveRm(); waitForRetrieveRm();
// Check state while waiting for data // Check state while waiting for data
Assert.assertFalse(fTestCache.isValid()); assertFalse(fTestCache.isValid());
// Set the data without using an executor. // Set the data without using an executor.
fRetrieveRm.setData(1); fRetrieveRm.setData(1);
fRetrieveRm.done(); fRetrieveRm.done();
Assert.assertEquals(1, (int)q1.get()); assertEquals(1, (int)q1.get());
Assert.assertEquals(1, (int)q2.get()); assertEquals(1, (int)q2.get());
// Check final state // Check final state
assertCacheValidWithData(1); assertCacheValidWithData(1);
@ -262,7 +265,7 @@ public class CacheTests {
@Test @Test
public void getTestWithManyClients() throws InterruptedException, ExecutionException { public void getTestWithManyClients() throws InterruptedException, ExecutionException {
// Check initial state // Check initial state
Assert.assertFalse(fTestCache.isValid()); assertFalse(fTestCache.isValid());
// Request data from cache // Request data from cache
List<Query<Integer>> qList = new ArrayList<Query<Integer>>(); List<Query<Integer>> qList = new ArrayList<Query<Integer>>();
@ -275,14 +278,14 @@ public class CacheTests {
waitForRetrieveRm(); waitForRetrieveRm();
// Check state while waiting for data // Check state while waiting for data
Assert.assertFalse(fTestCache.isValid()); assertFalse(fTestCache.isValid());
// Set the data without using an executor. // Set the data without using an executor.
fRetrieveRm.setData(1); fRetrieveRm.setData(1);
fRetrieveRm.done(); fRetrieveRm.done();
for (Query<Integer> q : qList) { for (Query<Integer> q : qList) {
Assert.assertEquals(1, (int)q.get()); assertEquals(1, (int)q.get());
} }
// Check final state // Check final state
@ -329,12 +332,12 @@ public class CacheTests {
Thread.sleep(100); Thread.sleep(100);
// Retrieval should never have been made. // Retrieval should never have been made.
Assert.assertEquals(null, fRetrieveRm); assertEquals(null, fRetrieveRm);
// The cache has no data so the query should have failed // The cache has no data so the query should have failed
try { try {
q.get(); q.get();
Assert.fail("expected an exeption"); fail("expected an exeption");
} catch (ExecutionException e) { } catch (ExecutionException e) {
// expected the exception // expected the exception
} }
@ -392,7 +395,7 @@ public class CacheTests {
fRetrieveRm.setData(1); fRetrieveRm.setData(1);
fRetrieveRm.done(); fRetrieveRm.done();
Assert.assertEquals(Integer.valueOf(1), q.get()); assertEquals(Integer.valueOf(1), q.get());
// Disable the cache // Disable the cache
fExecutor.submit(new DsfRunnable() { fExecutor.submit(new DsfRunnable() {
@ -432,7 +435,7 @@ public class CacheTests {
q.cancel(true); q.cancel(true);
try { try {
q.get(); q.get();
Assert.fail("Expected a cancellation exception"); fail("Expected a cancellation exception");
} catch (CancellationException e) {} // Expected exception; } catch (CancellationException e) {} // Expected exception;
assertCacheInvalidAndWithCanceledRM(); assertCacheInvalidAndWithCanceledRM();
@ -464,7 +467,7 @@ public class CacheTests {
q.cancel(true); q.cancel(true);
try { try {
q.get(); q.get();
Assert.fail("Expected a cancellation exception"); fail("Expected a cancellation exception");
} catch (CancellationException e) {} // Expected exception; } catch (CancellationException e) {} // Expected exception;
assertCacheInvalidAndWithCanceledRM(); assertCacheInvalidAndWithCanceledRM();
@ -499,7 +502,7 @@ public class CacheTests {
q.cancel(true); q.cancel(true);
try { try {
q.get(); q.get();
Assert.fail("Expected a cancellation exception"); fail("Expected a cancellation exception");
} catch (CancellationException e) {} // Expected exception; } catch (CancellationException e) {} // Expected exception;
assertCacheInvalidAndWithCanceledRM(); assertCacheInvalidAndWithCanceledRM();
@ -565,11 +568,11 @@ public class CacheTests {
// after is canceled is called. // after is canceled is called.
fRetrieveRm.isCanceled(); fRetrieveRm.isCanceled();
fExecutor.submit(new Runnable() { public void run() {} }).get(); fExecutor.submit(new Runnable() { public void run() {} }).get();
Assert.assertTrue(canceledCalled[0]); assertTrue(canceledCalled[0]);
try { try {
q.get(); q.get();
Assert.fail("Expected a cancellation exception"); fail("Expected a cancellation exception");
} catch (CancellationException e) {} // Expected exception; } catch (CancellationException e) {} // Expected exception;
@ -657,7 +660,7 @@ public class CacheTests {
qBadCanceled[0] = true; qBadCanceled[0] = true;
rmBad[0].cancel(); rmBad[0].cancel();
Assert.assertFalse(fRetrieveRm.isCanceled()); assertFalse(fRetrieveRm.isCanceled());
// Completed the retrieve RM // Completed the retrieve RM
fExecutor.submit(new DsfRunnable() { fExecutor.submit(new DsfRunnable() {
@ -692,7 +695,7 @@ public class CacheTests {
q1.cancel(true); q1.cancel(true);
try { try {
q1.get(); q1.get();
Assert.fail("Expected a cancellation exception"); fail("Expected a cancellation exception");
} catch (CancellationException e) {} // Expected exception; } catch (CancellationException e) {} // Expected exception;
assertCacheWaiting(); assertCacheWaiting();
@ -700,7 +703,7 @@ public class CacheTests {
q2.cancel(true); q2.cancel(true);
try { try {
q2.get(); q2.get();
Assert.fail("Expected a cancellation exception"); fail("Expected a cancellation exception");
} catch (CancellationException e) {} // Expected exception; } catch (CancellationException e) {} // Expected exception;
assertCacheInvalidAndWithCanceledRM(); assertCacheInvalidAndWithCanceledRM();
@ -739,7 +742,7 @@ public class CacheTests {
q.cancel(true); q.cancel(true);
try { try {
q.get(); q.get();
Assert.fail("Expected a cancellation exception"); fail("Expected a cancellation exception");
} catch (CancellationException e) {} // Expected exception; } catch (CancellationException e) {} // Expected exception;
qList.set(toCancel[i], null); qList.set(toCancel[i], null);

View file

@ -10,13 +10,13 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.concurrent; package org.eclipse.cdt.tests.dsf.concurrent;
import static org.junit.Assert.*;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants; import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
@ -64,15 +64,15 @@ public class DsfQueryTests {
} }
}; };
// Check initial state // Check initial state
Assert.assertTrue(!q.isDone()); assertTrue(!q.isDone());
Assert.assertTrue(!q.isCancelled()); assertTrue(!q.isCancelled());
fExecutor.execute(q); fExecutor.execute(q);
Assert.assertEquals(1, (int)q.get()); assertEquals(1, (int)q.get());
// Check final state // Check final state
Assert.assertTrue(q.isDone()); assertTrue(q.isDone());
Assert.assertTrue(!q.isCancelled()); assertTrue(!q.isCancelled());
} }
@ -89,21 +89,21 @@ public class DsfQueryTests {
}; };
// Check initial state // Check initial state
Assert.assertTrue(!q.isDone()); assertTrue(!q.isDone());
Assert.assertTrue(!q.isCancelled()); assertTrue(!q.isCancelled());
fExecutor.execute(q); fExecutor.execute(q);
try { try {
q.get(); q.get();
Assert.fail("Expected exception"); fail("Expected exception");
} catch (ExecutionException e) { } catch (ExecutionException e) {
Assert.assertEquals(e.getCause().getMessage(), error_message); assertEquals(e.getCause().getMessage(), error_message);
} }
// Check final state // Check final state
Assert.assertTrue(q.isDone()); assertTrue(q.isDone());
Assert.assertTrue(!q.isCancelled()); assertTrue(!q.isCancelled());
} }
@ -118,20 +118,20 @@ public class DsfQueryTests {
}; };
// Check initial state // Check initial state
Assert.assertTrue(!q.isDone()); assertTrue(!q.isDone());
Assert.assertTrue(!q.isCancelled()); assertTrue(!q.isCancelled());
fExecutor.execute(q); fExecutor.execute(q);
try { try {
q.get(); q.get();
Assert.fail("Expected exception"); fail("Expected exception");
} catch (ExecutionException e) { } catch (ExecutionException e) {
} }
// Check final state // Check final state
Assert.assertTrue(q.isDone()); assertTrue(q.isDone());
Assert.assertTrue(!q.isCancelled()); assertTrue(!q.isCancelled());
} }
@ -154,7 +154,7 @@ public class DsfQueryTests {
public String toString() { return super.toString() + "\n getWithMultipleDispatchesTest() first runnable (query)"; } //$NON-NLS-1$ public String toString() { return super.toString() + "\n getWithMultipleDispatchesTest() first runnable (query)"; } //$NON-NLS-1$
}; };
fExecutor.execute(q); fExecutor.execute(q);
Assert.assertEquals(1, (int)q.get()); assertEquals(1, (int)q.get());
} }
@Test (expected = ExecutionException.class) @Test (expected = ExecutionException.class)
@ -172,8 +172,8 @@ public class DsfQueryTests {
try { try {
q.get(); q.get();
} finally { } finally {
Assert.assertTrue(q.isDone()); assertTrue(q.isDone());
Assert.assertTrue(!q.isCancelled()); assertTrue(!q.isCancelled());
} }
} }
@ -181,7 +181,7 @@ public class DsfQueryTests {
public void cancelBeforeWaitingTest() throws InterruptedException, ExecutionException { public void cancelBeforeWaitingTest() throws InterruptedException, ExecutionException {
final Query<Integer> q = new Query<Integer>() { final Query<Integer> q = new Query<Integer>() {
@Override protected void execute(final DataRequestMonitor<Integer> rm) { @Override protected void execute(final DataRequestMonitor<Integer> rm) {
Assert.fail("Query was cancelled, it should not be called."); //$NON-NLS-1$ fail("Query was cancelled, it should not be called."); //$NON-NLS-1$
rm.done(); rm.done();
} }
}; };
@ -189,8 +189,8 @@ public class DsfQueryTests {
// Cancel before invoking the query. // Cancel before invoking the query.
q.cancel(false); q.cancel(false);
Assert.assertTrue(q.isDone()); assertTrue(q.isDone());
Assert.assertTrue(q.isCancelled()); assertTrue(q.isCancelled());
// Start the query. // Start the query.
fExecutor.execute(q); fExecutor.execute(q);
@ -203,10 +203,10 @@ public class DsfQueryTests {
} catch (CancellationException e) { } catch (CancellationException e) {
return; // Success return; // Success
} finally { } finally {
Assert.assertTrue(q.isDone()); assertTrue(q.isDone());
Assert.assertTrue(q.isCancelled()); assertTrue(q.isCancelled());
} }
Assert.assertTrue("CancellationException should have been thrown", false); //$NON-NLS-1$ assertTrue("CancellationException should have been thrown", false); //$NON-NLS-1$
} }
@Test @Test
@ -244,10 +244,10 @@ public class DsfQueryTests {
// Cancel running request. // Cancel running request.
q.cancel(false); q.cancel(false);
Assert.assertTrue(cancelCalled[0]); assertTrue(cancelCalled[0]);
Assert.assertTrue(rmHolder[0].isCanceled()); assertTrue(rmHolder[0].isCanceled());
Assert.assertTrue(q.isCancelled()); assertTrue(q.isCancelled());
Assert.assertTrue(q.isDone()); assertTrue(q.isDone());
// Retrieve data // Retrieve data
try { try {
@ -255,8 +255,8 @@ public class DsfQueryTests {
} catch (CancellationException e) { } catch (CancellationException e) {
return; // Success return; // Success
} finally { } finally {
Assert.assertTrue(q.isDone()); assertTrue(q.isDone());
Assert.assertTrue(q.isCancelled()); assertTrue(q.isCancelled());
} }
// Complete rm and query. // Complete rm and query.
@ -272,12 +272,12 @@ public class DsfQueryTests {
} catch (CancellationException e) { } catch (CancellationException e) {
return; // Success return; // Success
} finally { } finally {
Assert.assertTrue(q.isDone()); assertTrue(q.isDone());
Assert.assertTrue(q.isCancelled()); assertTrue(q.isCancelled());
} }
Assert.assertTrue("CancellationException should have been thrown", false); //$NON-NLS-1$ assertTrue("CancellationException should have been thrown", false); //$NON-NLS-1$
} }
@ -305,9 +305,9 @@ public class DsfQueryTests {
} catch (TimeoutException e) { } catch (TimeoutException e) {
return; // Success return; // Success
} finally { } finally {
Assert.assertFalse("Query should not be done yet, it should have timed out first.", q.isDone()); //$NON-NLS-1$ assertFalse("Query should not be done yet, it should have timed out first.", q.isDone()); //$NON-NLS-1$
} }
Assert.assertTrue("TimeoutException should have been thrown", false); //$NON-NLS-1$ assertTrue("TimeoutException should have been thrown", false); //$NON-NLS-1$
} }
} }

View file

@ -10,12 +10,13 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.concurrent; package org.eclipse.cdt.tests.dsf.concurrent;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import junit.framework.Assert;
import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
@ -191,20 +192,20 @@ public class DsfSequenceProgressTests {
System.out.println("RollBackCounter: " + rollBackCounter.fInteger); System.out.println("RollBackCounter: " + rollBackCounter.fInteger);
if (sequence.isCancelled()) if (sequence.isCancelled())
Assert.assertTrue( assertTrue(
"Wrong number of steps were rolled back after cancellation.", "Wrong number of steps were rolled back after cancellation.",
stepCounter.fInteger == rollBackCounter.fInteger); stepCounter.fInteger == rollBackCounter.fInteger);
else { else {
Assert.assertTrue( assertTrue(
"Wrong number of steps executed.", "Wrong number of steps executed.",
stepCounter.fInteger == steps.length); stepCounter.fInteger == steps.length);
Assert.assertTrue( assertTrue(
"Some steps are mistakenly rolled back", "Some steps are mistakenly rolled back",
rollBackCounter.fInteger == 0); rollBackCounter.fInteger == 0);
} }
// Check state from Future interface // Check state from Future interface
Assert.assertTrue(sequence.isDone()); assertTrue(sequence.isDone());
} catch (AssertionFailedError e) { } catch (AssertionFailedError e) {
fExceptions.add(e); fExceptions.add(e);
} }

View file

@ -10,12 +10,12 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.concurrent; package org.eclipse.cdt.tests.dsf.concurrent;
import static org.junit.Assert.*;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.ReflectionSequence; import org.eclipse.cdt.dsf.concurrent.ReflectionSequence;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
@ -85,18 +85,18 @@ public class DsfSequenceTests {
Sequence sequence = new Sequence(fExecutor) { Sequence sequence = new Sequence(fExecutor) {
@Override public Step[] getSteps() { return steps; } @Override public Step[] getSteps() { return steps; }
}; };
Assert.assertFalse(sequence.isDone()); assertFalse(sequence.isDone());
Assert.assertFalse(sequence.isCancelled()); assertFalse(sequence.isCancelled());
fExecutor.execute(sequence); fExecutor.execute(sequence);
sequence.get(); sequence.get();
// Check the count // Check the count
Assert.assertTrue(stepCounter.fInteger == 2); assertTrue(stepCounter.fInteger == 2);
// Check post conditions // Check post conditions
Assert.assertTrue(sequence.isDone()); assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled()); assertFalse(sequence.isCancelled());
} }
@ -133,18 +133,18 @@ public class DsfSequenceTests {
SimpleReflectionSequence sequence = new SimpleReflectionSequence(); SimpleReflectionSequence sequence = new SimpleReflectionSequence();
//Sequence sequence = new SimpleReflectionSequence(); //Sequence sequence = new SimpleReflectionSequence();
Assert.assertFalse(sequence.isDone()); assertFalse(sequence.isDone());
Assert.assertFalse(sequence.isCancelled()); assertFalse(sequence.isCancelled());
fExecutor.execute(sequence); fExecutor.execute(sequence);
sequence.get(); sequence.get();
// Check the count // Check the count
Assert.assertTrue(sequence.fStepCounter == 2); assertTrue(sequence.fStepCounter == 2);
// Check post conditions // Check post conditions
Assert.assertTrue(sequence.isDone()); assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled()); assertFalse(sequence.isCancelled());
} }
@ -192,15 +192,15 @@ public class DsfSequenceTests {
sequence.get(); sequence.get();
} finally { } finally {
// Both steps should be performed // Both steps should be performed
Assert.assertTrue(stepCounter.fInteger == 2); assertTrue(stepCounter.fInteger == 2);
// Only one step is rolled back, the first one. // Only one step is rolled back, the first one.
Assert.assertTrue(rollBackCounter.fInteger == 1); assertTrue(rollBackCounter.fInteger == 1);
// Check state from Future interface // Check state from Future interface
Assert.assertTrue(sequence.isDone()); assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled()); assertFalse(sequence.isCancelled());
} }
Assert.assertTrue("Exception should have been thrown", false); //$NON-NLS-1$ assertTrue("Exception should have been thrown", false); //$NON-NLS-1$
} }
@Test (expected = ExecutionException.class) @Test (expected = ExecutionException.class)
@ -248,15 +248,15 @@ public class DsfSequenceTests {
sequence.get(); sequence.get();
} finally { } finally {
// Both steps should be performed // Both steps should be performed
Assert.assertTrue(stepCounter.fInteger == 2); assertTrue(stepCounter.fInteger == 2);
// No steps should be rolled back. // No steps should be rolled back.
Assert.assertTrue(rollBackCounter.fInteger == 0); assertTrue(rollBackCounter.fInteger == 0);
// Check state from Future interface // Check state from Future interface
Assert.assertTrue(sequence.isDone()); assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled()); assertFalse(sequence.isCancelled());
} }
Assert.assertTrue("Exception should have been thrown", false); //$NON-NLS-1$ assertTrue("Exception should have been thrown", false); //$NON-NLS-1$
} }
@ -311,15 +311,15 @@ public class DsfSequenceTests {
sequence.get(); sequence.get();
} finally { } finally {
// Both steps should be performed // Both steps should be performed
Assert.assertEquals(2, sequence.fStepCounter); assertEquals(2, sequence.fStepCounter);
// Only one step is rolled back, the first one. // Only one step is rolled back, the first one.
Assert.assertEquals(1, sequence.fRollBackCounter); assertEquals(1, sequence.fRollBackCounter);
// Check state from Future interface // Check state from Future interface
Assert.assertTrue(sequence.isDone()); assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled()); assertFalse(sequence.isCancelled());
} }
Assert.assertTrue("Exception should have been thrown", false); //$NON-NLS-1$ assertTrue("Exception should have been thrown", false); //$NON-NLS-1$
} }
public class RollBackReflectionSequence2 extends ReflectionSequence { public class RollBackReflectionSequence2 extends ReflectionSequence {
@ -373,16 +373,16 @@ public class DsfSequenceTests {
sequence.get(); sequence.get();
} finally { } finally {
// All three steps should be performed // All three steps should be performed
Assert.assertEquals(3, sequence.fStepCounter); assertEquals(3, sequence.fStepCounter);
// Two steps are rolled back, but only the first one has // Two steps are rolled back, but only the first one has
// a rollback method. // a rollback method.
Assert.assertEquals(1, sequence.fRollBackCounter); assertEquals(1, sequence.fRollBackCounter);
// Check state from Future interface // Check state from Future interface
Assert.assertTrue(sequence.isDone()); assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled()); assertFalse(sequence.isCancelled());
} }
Assert.assertTrue("Exception should have been thrown", false); //$NON-NLS-1$ assertTrue("Exception should have been thrown", false); //$NON-NLS-1$
} }
@ -411,10 +411,10 @@ public class DsfSequenceTests {
sequence.get(); sequence.get();
} finally { } finally {
// Check state from Future interface // Check state from Future interface
Assert.assertTrue(sequence.isDone()); assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled()); assertFalse(sequence.isCancelled());
} }
Assert.assertTrue("Exception should have been thrown", false); //$NON-NLS-1$ assertTrue("Exception should have been thrown", false); //$NON-NLS-1$
} }
@ -424,7 +424,7 @@ public class DsfSequenceTests {
final Sequence.Step[] steps = new Sequence.Step[] { final Sequence.Step[] steps = new Sequence.Step[] {
new Sequence.Step() { new Sequence.Step() {
@Override public void execute(RequestMonitor requestMonitor) { @Override public void execute(RequestMonitor requestMonitor) {
Assert.assertTrue("Sequence was cancelled, it should not be called.", false); //$NON-NLS-1$ assertTrue("Sequence was cancelled, it should not be called.", false); //$NON-NLS-1$
} }
} }
}; };
@ -435,8 +435,8 @@ public class DsfSequenceTests {
// Cancel before invoking the sequence. // Cancel before invoking the sequence.
sequence.cancel(false); sequence.cancel(false);
Assert.assertFalse(sequence.isDone()); assertFalse(sequence.isDone());
Assert.assertTrue(sequence.isCancelled()); assertTrue(sequence.isCancelled());
// Start the sequence // Start the sequence
fExecutor.execute(sequence); fExecutor.execute(sequence);
@ -445,10 +445,10 @@ public class DsfSequenceTests {
try { try {
sequence.get(); sequence.get();
} finally { } finally {
Assert.assertTrue(sequence.isDone()); assertTrue(sequence.isDone());
Assert.assertTrue(sequence.isCancelled()); assertTrue(sequence.isCancelled());
} }
Assert.assertTrue("CancellationException should have been thrown", false); //$NON-NLS-1$ assertTrue("CancellationException should have been thrown", false); //$NON-NLS-1$
} }
@ -500,15 +500,15 @@ public class DsfSequenceTests {
sequence.get(); sequence.get();
} finally { } finally {
// Both steps should be performed // Both steps should be performed
Assert.assertTrue(stepCounter.fInteger == 2); assertTrue(stepCounter.fInteger == 2);
// Both roll-backs should be performed since cancel does not take effect until // Both roll-backs should be performed since cancel does not take effect until
// after the step is completed. // after the step is completed.
Assert.assertTrue(rollBackCounter.fInteger == 2); assertTrue(rollBackCounter.fInteger == 2);
Assert.assertTrue(sequence.isDone()); assertTrue(sequence.isDone());
Assert.assertTrue(sequence.isCancelled()); assertTrue(sequence.isCancelled());
} }
Assert.assertTrue("CancellationException should have been thrown", false); //$NON-NLS-1$ assertTrue("CancellationException should have been thrown", false); //$NON-NLS-1$
} }
@Test (expected = CancellationException.class) @Test (expected = CancellationException.class)
@ -517,7 +517,7 @@ public class DsfSequenceTests {
final Sequence.Step[] steps = new Sequence.Step[] { final Sequence.Step[] steps = new Sequence.Step[] {
new Sequence.Step() { new Sequence.Step() {
@Override public void execute(RequestMonitor requestMonitor) { @Override public void execute(RequestMonitor requestMonitor) {
Assert.assertTrue("Sequence was cancelled, it should not be called.", false); //$NON-NLS-1$ assertTrue("Sequence was cancelled, it should not be called.", false); //$NON-NLS-1$
} }
} }
}; };
@ -543,8 +543,8 @@ public class DsfSequenceTests {
try { try {
sequence.get(); sequence.get();
} finally { } finally {
Assert.assertTrue(sequence.isDone()); assertTrue(sequence.isDone());
Assert.assertTrue(sequence.isCancelled()); assertTrue(sequence.isCancelled());
} }
} }

View file

@ -10,6 +10,11 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.concurrent; package org.eclipse.cdt.tests.dsf.concurrent;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.SortedSet; import java.util.SortedSet;
@ -17,8 +22,6 @@ import java.util.TreeSet;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.ICache; import org.eclipse.cdt.dsf.concurrent.ICache;
@ -157,31 +160,31 @@ public class RangeCacheTests {
} }
private void assertCacheValidWithData(ICache<List<Integer>> cache, long offset, int count) { private void assertCacheValidWithData(ICache<List<Integer>> cache, long offset, int count) {
Assert.assertTrue(cache.isValid()); assertTrue(cache.isValid());
Assert.assertEquals(makeList(offset, count), cache.getData()); assertEquals(makeList(offset, count), cache.getData());
Assert.assertTrue(cache.getStatus().isOK()); assertTrue(cache.getStatus().isOK());
} }
private void assertCacheValidWithError(ICache<List<Integer>> cache) { private void assertCacheValidWithError(ICache<List<Integer>> cache) {
Assert.assertTrue(cache.isValid()); assertTrue(cache.isValid());
Assert.assertFalse(cache.getStatus().isOK()); assertFalse(cache.getStatus().isOK());
} }
private void assertCacheWaiting(ICache<List<Integer>> cache) { private void assertCacheWaiting(ICache<List<Integer>> cache) {
Assert.assertFalse(cache.isValid()); assertFalse(cache.isValid());
try { try {
cache.getData(); cache.getData();
Assert.fail("Expected an IllegalStateException"); fail("Expected an IllegalStateException");
} catch (IllegalStateException e) {} } catch (IllegalStateException e) {}
try { try {
cache.getStatus(); cache.getStatus();
Assert.fail("Expected an IllegalStateException"); fail("Expected an IllegalStateException");
} catch (IllegalStateException e) {} } catch (IllegalStateException e) {}
} }
private void completeInfo(RetrieveInfo info, long offset, int count) { private void completeInfo(RetrieveInfo info, long offset, int count) {
Assert.assertEquals(offset, info.fOffset); assertEquals(offset, info.fOffset);
Assert.assertEquals(count, info.fCount); assertEquals(count, info.fCount);
info.fRm.setData(makeList(offset, count)); info.fRm.setData(makeList(offset, count));
info.fRm.done(); info.fRm.done();
} }
@ -205,7 +208,7 @@ public class RangeCacheTests {
assertCacheWaiting(fRangeCache); assertCacheWaiting(fRangeCache);
// Set the data without using an executor. // Set the data without using an executor.
Assert.assertEquals(retrieveCount, fRetrieveInfos.size()); assertEquals(retrieveCount, fRetrieveInfos.size());
int i = 0; int i = 0;
for (RetrieveInfo info : fRetrieveInfos) { for (RetrieveInfo info : fRetrieveInfos) {
completeInfo(info, retrieveOffsets[i], retrieveCounts[i]); completeInfo(info, retrieveOffsets[i], retrieveCounts[i]);
@ -214,7 +217,7 @@ public class RangeCacheTests {
} }
// Wait for data. // Wait for data.
Assert.assertEquals(makeList(queryOffset, queryCount), q.get()); assertEquals(makeList(queryOffset, queryCount), q.get());
// Check state while waiting for data // Check state while waiting for data
assertCacheValidWithData(fRangeCache, queryOffset, queryCount); assertCacheValidWithData(fRangeCache, queryOffset, queryCount);
@ -261,23 +264,23 @@ public class RangeCacheTests {
assertCacheWaiting(fRangeCache); assertCacheWaiting(fRangeCache);
// Set the data without using an executor. // Set the data without using an executor.
Assert.assertEquals(retrieveCount, fRetrieveInfos.size()); assertEquals(retrieveCount, fRetrieveInfos.size());
int i = 0; int i = 0;
for (RetrieveInfo info : fRetrieveInfos) { for (RetrieveInfo info : fRetrieveInfos) {
Assert.assertEquals(retrieveOffsets[i], info.fOffset); assertEquals(retrieveOffsets[i], info.fOffset);
Assert.assertEquals(retrieveCounts[i], info.fCount); assertEquals(retrieveCounts[i], info.fCount);
Assert.assertFalse(info.fRm.isCanceled()); assertFalse(info.fRm.isCanceled());
i++; i++;
} }
q.cancel(true); q.cancel(true);
try { try {
q.get(); q.get();
Assert.fail("Expected a cancellation exception"); fail("Expected a cancellation exception");
} catch (CancellationException e) {} // Expected exception; } catch (CancellationException e) {} // Expected exception;
for (RetrieveInfo info : fRetrieveInfos) { for (RetrieveInfo info : fRetrieveInfos) {
Assert.assertTrue(info.fRm.isCanceled()); assertTrue(info.fRm.isCanceled());
} }
} }
@ -382,11 +385,11 @@ public class RangeCacheTests {
}).get(); }).get();
// Set the data without using an executor. // Set the data without using an executor.
Assert.assertEquals(1, fRetrieveInfos.size()); assertEquals(1, fRetrieveInfos.size());
completeInfo(fRetrieveInfos.first(), 10, 100); completeInfo(fRetrieveInfos.first(), 10, 100);
// Wait for data. // Wait for data.
Assert.assertEquals(makeList(10, 100), q.get()); assertEquals(makeList(10, 100), q.get());
// Check state while waiting for data // Check state while waiting for data
assertCacheValidWithData(fRangeCache, 10, 100); assertCacheValidWithData(fRangeCache, 10, 100);
@ -425,7 +428,7 @@ public class RangeCacheTests {
try { try {
q.get(); q.get();
Assert.fail("Expected an ExecutionException"); fail("Expected an ExecutionException");
} catch (ExecutionException e) {} } catch (ExecutionException e) {}
} }
@ -445,7 +448,7 @@ public class RangeCacheTests {
assertCacheWaiting(fRangeCache); assertCacheWaiting(fRangeCache);
// Set the data without using an executor. // Set the data without using an executor.
Assert.assertEquals(1, fRetrieveInfos.size()); assertEquals(1, fRetrieveInfos.size());
RetrieveInfo info = fRetrieveInfos.iterator().next(); RetrieveInfo info = fRetrieveInfos.iterator().next();
completeInfo(info, 0, 100); completeInfo(info, 0, 100);

View file

@ -10,11 +10,11 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.concurrent; package org.eclipse.cdt.tests.dsf.concurrent;
import static org.junit.Assert.*;
import java.util.Arrays; import java.util.Arrays;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.RequestCache; import org.eclipse.cdt.dsf.concurrent.RequestCache;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
@ -146,7 +146,7 @@ public class TransactionTests {
((DataRequestMonitor<Integer>)fRetrieveRms[0]).setData(1); ((DataRequestMonitor<Integer>)fRetrieveRms[0]).setData(1);
fRetrieveRms[0].done(); fRetrieveRms[0].done();
Assert.assertEquals(1, (int)q.get()); assertEquals(1, (int)q.get());
} }
@Test @Test
@ -172,7 +172,7 @@ public class TransactionTests {
} }
fExecutor.execute(q); fExecutor.execute(q);
Assert.assertEquals(NUM_CACHES, (int)q.get()); assertEquals(NUM_CACHES, (int)q.get());
} }
} }

View file

@ -10,13 +10,14 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.pda.service.command; package org.eclipse.cdt.tests.dsf.pda.service.command;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.io.File; import java.io.File;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable; import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.Query; import org.eclipse.cdt.dsf.concurrent.Query;
@ -97,14 +98,14 @@ public class BasicTests extends CommandControlTestsBase {
}; };
fExecutor.execute(sendCommandQuery); fExecutor.execute(sendCommandQuery);
PDACommandResult result = sendCommandQuery.get(); PDACommandResult result = sendCommandQuery.get();
Assert.assertEquals(1, listener.fQueuedCommands.size()); assertEquals(1, listener.fQueuedCommands.size());
Assert.assertEquals(testCommand, listener.fQueuedCommands.get(0).fCommand); assertEquals(testCommand, listener.fQueuedCommands.get(0).fCommand);
Assert.assertEquals(0, listener.fRemovedCommands.size()); assertEquals(0, listener.fRemovedCommands.size());
Assert.assertEquals(1, listener.fSentCommands.size()); assertEquals(1, listener.fSentCommands.size());
Assert.assertEquals(testCommand, listener.fSentCommands.get(0).fCommand); assertEquals(testCommand, listener.fSentCommands.get(0).fCommand);
Assert.assertEquals(1, listener.fDoneCommands.size()); assertEquals(1, listener.fDoneCommands.size());
Assert.assertEquals(testCommand, listener.fDoneCommands.get(0).fCommand); assertEquals(testCommand, listener.fDoneCommands.get(0).fCommand);
Assert.assertEquals(result, listener.fDoneCommands.get(0).fResult); assertEquals(result, listener.fDoneCommands.get(0).fResult);
// Test queuing then removing command // Test queuing then removing command
listener.reset(); listener.reset();
@ -116,7 +117,7 @@ public class BasicTests extends CommandControlTestsBase {
new DataRequestMonitor<PDACommandResult>(fExecutor, null) { new DataRequestMonitor<PDACommandResult>(fExecutor, null) {
@Override @Override
protected void handleCompleted() { protected void handleCompleted() {
Assert.fail("This command should never have been executed."); fail("This command should never have been executed.");
} }
}); });
fCommandControl.removeCommand(token); fCommandControl.removeCommand(token);
@ -127,12 +128,12 @@ public class BasicTests extends CommandControlTestsBase {
}; };
fExecutor.execute(queueRemoveCommandQuery); fExecutor.execute(queueRemoveCommandQuery);
queueRemoveCommandQuery.get(); queueRemoveCommandQuery.get();
Assert.assertEquals(1, listener.fQueuedCommands.size()); assertEquals(1, listener.fQueuedCommands.size());
Assert.assertEquals(testCommand, listener.fQueuedCommands.get(0).fCommand); assertEquals(testCommand, listener.fQueuedCommands.get(0).fCommand);
Assert.assertEquals(1, listener.fRemovedCommands.size()); assertEquals(1, listener.fRemovedCommands.size());
Assert.assertEquals(testCommand, listener.fRemovedCommands.get(0).fCommand); assertEquals(testCommand, listener.fRemovedCommands.get(0).fCommand);
Assert.assertEquals(0, listener.fSentCommands.size()); assertEquals(0, listener.fSentCommands.size());
Assert.assertEquals(0, listener.fDoneCommands.size()); assertEquals(0, listener.fDoneCommands.size());
} }
} }

View file

@ -10,6 +10,10 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.tests.dsf.pda.service.command; package org.eclipse.cdt.tests.dsf.pda.service.command;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.IOException; import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -17,8 +21,6 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingQueue; import java.util.concurrent.LinkedBlockingQueue;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor; import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DsfExecutor; import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
@ -62,14 +64,14 @@ public class CommandControlTestsBase {
fSession = DsfSession.startSession(fExecutor, "PDA Test"); fSession = DsfSession.startSession(fExecutor, "PDA Test");
Process proc = Launching.launchPDA(fSession, null, fProgram); Process proc = Launching.launchPDA(fSession, null, fProgram);
Assert.assertNotNull(proc); assertNotNull(proc);
// Remember the backend service of this session. // Remember the backend service of this session.
// Note this must be called after the above LaunchPDA(). // Note this must be called after the above LaunchPDA().
fPDABackend = Launching.getBackendService(); fPDABackend = Launching.getBackendService();
fOutputReader = new BufferedReader(new InputStreamReader(proc.getInputStream())); fOutputReader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
Assert.assertTrue(fOutputReader.readLine().contains("-debug")); assertTrue(fOutputReader.readLine().contains("-debug"));
fCommandControl = new PDACommandControl(fSession); fCommandControl = new PDACommandControl(fSession);
@ -82,7 +84,7 @@ public class CommandControlTestsBase {
InitializeCommandServiceQuery initQuery = new InitializeCommandServiceQuery(); InitializeCommandServiceQuery initQuery = new InitializeCommandServiceQuery();
fExecutor.execute(initQuery); fExecutor.execute(initQuery);
initQuery.get(); initQuery.get();
Assert.assertEquals("debug connection accepted", fOutputReader.readLine()); assertEquals("debug connection accepted", fOutputReader.readLine());
} }
@After @After
@ -146,7 +148,7 @@ public class CommandControlTestsBase {
throw e.getCause(); throw e.getCause();
} }
} }
Assert.assertEquals("Command returned an unexpected result", expectedResult, responseText); assertEquals("Command returned an unexpected result", expectedResult, responseText);
} }
@ -155,11 +157,11 @@ public class CommandControlTestsBase {
} }
protected void expectEvent(String expectedEvent) throws InterruptedException { protected void expectEvent(String expectedEvent) throws InterruptedException {
Assert.assertEquals("Unexpected event received", expectedEvent, fEventsQueue.take()); assertEquals("Unexpected event received", expectedEvent, fEventsQueue.take());
} }
protected void expectOutput(String expectedOutput) throws IOException { protected void expectOutput(String expectedOutput) throws IOException {
Assert.assertEquals("Unexpected output received", expectedOutput, fOutputReader.readLine()); assertEquals("Unexpected output received", expectedOutput, fOutputReader.readLine());
} }
} }

View file

@ -15,7 +15,6 @@ import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.concurrent.ExecutionException; import java.util.concurrent.ExecutionException;
import junit.framework.Assert;
import junit.framework.AssertionFailedError; import junit.framework.AssertionFailedError;
import junit.framework.TestCase; import junit.framework.TestCase;
@ -280,7 +279,7 @@ abstract public class FormattedValueTests extends TestCase implements IViewerUpd
fVMProvider.postEvent(new TestEvent(fModel.getRootElement(), IModelDelta.CONTENT)); fVMProvider.postEvent(new TestEvent(fModel.getRootElement(), IModelDelta.CONTENT));
while (!fViewerListener.isFinished(ALL_UPDATES_COMPLETE | PROPERTY_UPDATES)) while (!fViewerListener.isFinished(ALL_UPDATES_COMPLETE | PROPERTY_UPDATES))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep (); if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
Assert.assertTrue(fFormattedValuesListener.getFormattedValuesCompleted().isEmpty()); assertTrue(fFormattedValuesListener.getFormattedValuesCompleted().isEmpty());
} }
public void testInvalidFormat() { public void testInvalidFormat() {
@ -708,7 +707,7 @@ abstract public class FormattedValueTests extends TestCase implements IViewerUpd
while (!fViewerListener.isFinished(ALL_UPDATES_COMPLETE | PROPERTY_UPDATES) || !fVMListener.isFinished(CONTENT_COMPLETE | PROPERTY_UPDATES)) while (!fViewerListener.isFinished(ALL_UPDATES_COMPLETE | PROPERTY_UPDATES) || !fVMListener.isFinished(CONTENT_COMPLETE | PROPERTY_UPDATES))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep (); if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
Assert.assertTrue(fFormattedValuesListener.isFinished()); assertTrue(fFormattedValuesListener.isFinished());
} }
private void setUpdatePolicy(String policyId) { private void setUpdatePolicy(String policyId) {
@ -796,8 +795,8 @@ abstract public class FormattedValueTests extends TestCase implements IViewerUpd
if (expectCacheMissError) { if (expectCacheMissError) {
String formatProperty = FormattedValueVMUtil.getPropertyForFormatId(formatId); String formatProperty = FormattedValueVMUtil.getPropertyForFormatId(formatId);
Assert.assertTrue(fFormattedValuesListener.getFormattedValuesCompleted().isEmpty()); assertTrue(fFormattedValuesListener.getFormattedValuesCompleted().isEmpty());
Assert.assertFalse(fFormattedValuesListener.getPropertiesUpdates().isEmpty()); assertFalse(fFormattedValuesListener.getPropertiesUpdates().isEmpty());
for (IPropertiesUpdate update : fFormattedValuesListener.getPropertiesUpdates()) { for (IPropertiesUpdate update : fFormattedValuesListener.getPropertiesUpdates()) {
PropertiesUpdateStatus status = (PropertiesUpdateStatus)update.getStatus(); PropertiesUpdateStatus status = (PropertiesUpdateStatus)update.getStatus();
assertEquals(IDsfStatusConstants.INVALID_STATE, status.getCode()); assertEquals(IDsfStatusConstants.INVALID_STATE, status.getCode());
@ -825,7 +824,7 @@ abstract public class FormattedValueTests extends TestCase implements IViewerUpd
} }
} else { } else {
Assert.assertTrue(fFormattedValuesListener.isFinished()); assertTrue(fFormattedValuesListener.isFinished());
} }
} }

View file

@ -13,8 +13,6 @@ package org.eclipse.cdt.tests.dsf.vm;
import java.util.Arrays; import java.util.Arrays;
import java.util.Hashtable; import java.util.Hashtable;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor; import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor; import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
import org.eclipse.cdt.dsf.datamodel.AbstractDMContext; import org.eclipse.cdt.dsf.datamodel.AbstractDMContext;
@ -33,6 +31,7 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationCont
import org.eclipse.debug.internal.ui.viewers.model.provisional.ITreeModelViewer; import org.eclipse.debug.internal.ui.viewers.model.provisional.ITreeModelViewer;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta; import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.viewers.TreePath;
import static org.junit.Assert.*;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;
/** /**
@ -279,7 +278,7 @@ public class TestModel extends AbstractDsfService implements IFormattedValues {
public void elementChecked(IPresentationContext context, Object viewerInput, TreePath path, boolean checked) { public void elementChecked(IPresentationContext context, Object viewerInput, TreePath path, boolean checked) {
TestElement element = getElement(path); TestElement element = getElement(path);
Assert.assertFalse(element.getGrayed()); assertFalse(element.getGrayed());
element.setChecked(checked, false); element.setChecked(checked, false);
} }
@ -341,20 +340,20 @@ public class TestModel extends AbstractDsfService implements IFormattedValues {
IInternalTreeModelViewer viewer = (IInternalTreeModelViewer)_viewer; IInternalTreeModelViewer viewer = (IInternalTreeModelViewer)_viewer;
TestElement element = getElement(path); TestElement element = getElement(path);
if ( Boolean.TRUE.equals(_viewer.getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)) ) { if ( Boolean.TRUE.equals(_viewer.getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)) ) {
Assert.assertEquals(element.getChecked(), viewer.getElementChecked(path)); assertEquals(element.getChecked(), viewer.getElementChecked(path));
Assert.assertEquals(element.getGrayed(), viewer.getElementGrayed(path)); assertEquals(element.getGrayed(), viewer.getElementGrayed(path));
} }
if (!expandedElementsOnly || path.getSegmentCount() == 0 || viewer.getExpandedState(path) ) { if (!expandedElementsOnly || path.getSegmentCount() == 0 || viewer.getExpandedState(path) ) {
TestElement[] children = element.getChildren(); TestElement[] children = element.getChildren();
Assert.assertEquals(children.length, viewer.getChildCount(path)); assertEquals(children.length, viewer.getChildCount(path));
for (int i = 0; i < children.length; i++) { for (int i = 0; i < children.length; i++) {
Object viewerObject = viewer.getChildElement(path, i); Object viewerObject = viewer.getChildElement(path, i);
if (viewerObject instanceof TestElementVMContext) { if (viewerObject instanceof TestElementVMContext) {
TreePath childPath = path.createChildPath(viewerObject); TreePath childPath = path.createChildPath(viewerObject);
TestElement viewerElement = ((TestElementVMContext)viewerObject).getElement(); TestElement viewerElement = ((TestElementVMContext)viewerObject).getElement();
Assert.assertEquals(children[i], viewerElement); assertEquals(children[i], viewerElement);
if (validator != null) { if (validator != null) {
validator.validate(children[i], viewerElement, childPath); validator.validate(children[i], viewerElement, childPath);
} }
@ -364,7 +363,7 @@ public class TestModel extends AbstractDsfService implements IFormattedValues {
} }
} else if (!viewer.getExpandedState(path)) { } else if (!viewer.getExpandedState(path)) {
// If element not expanded, verify the plus sign. // If element not expanded, verify the plus sign.
Assert.assertEquals(viewer.getHasChildren(path), element.getChildren().length > 0); assertEquals(viewer.getHasChildren(path), element.getChildren().length > 0);
} }
} }
@ -415,7 +414,7 @@ public class TestModel extends AbstractDsfService implements IFormattedValues {
} }
public ModelDelta appendElementLabel(TreePath path, String labelAppendix) { public ModelDelta appendElementLabel(TreePath path, String labelAppendix) {
Assert.assertTrue(path.startsWith(fRootPath, null)); assertTrue(path.startsWith(fRootPath, null));
ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE); ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
ModelDelta baseDelta = getBaseDelta(rootDelta); ModelDelta baseDelta = getBaseDelta(rootDelta);
TreePath relativePath = getRelativePath(path); TreePath relativePath = getRelativePath(path);
@ -428,7 +427,7 @@ public class TestModel extends AbstractDsfService implements IFormattedValues {
} }
public ModelDelta setElementChecked(TreePath path, boolean checked, boolean grayed) { public ModelDelta setElementChecked(TreePath path, boolean checked, boolean grayed) {
Assert.assertTrue(path.startsWith(fRootPath, null)); assertTrue(path.startsWith(fRootPath, null));
ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE); ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
ModelDelta baseDelta = getBaseDelta(rootDelta); ModelDelta baseDelta = getBaseDelta(rootDelta);
TreePath relativePath = getRelativePath(path); TreePath relativePath = getRelativePath(path);
@ -441,7 +440,7 @@ public class TestModel extends AbstractDsfService implements IFormattedValues {
} }
public ModelDelta setElementChildren(TreePath path, TestElement[] children) { public ModelDelta setElementChildren(TreePath path, TestElement[] children) {
Assert.assertTrue(path.startsWith(fRootPath, null)); assertTrue(path.startsWith(fRootPath, null));
ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE); ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
ModelDelta baseDelta = getBaseDelta(rootDelta); ModelDelta baseDelta = getBaseDelta(rootDelta);
TreePath relativePath = getRelativePath(path); TreePath relativePath = getRelativePath(path);

View file

@ -11,11 +11,11 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.parser.util; package org.eclipse.cdt.internal.core.parser.util;
import static org.junit.Assert.fail;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import junit.framework.Assert;
import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.IName; import org.eclipse.cdt.core.dom.IName;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@ -135,7 +135,7 @@ public class DOMSearchUtil {
IBinding binding = searchName.resolveBinding(); IBinding binding = searchName.resolveBinding();
if (binding instanceof IIndexBinding) { if (binding instanceof IIndexBinding) {
Assert.fail("Not implemented"); fail("Not implemented");
// try { // try {
// ArrayList pdomNames = new ArrayList(); // ArrayList pdomNames = new ArrayList();
// IPDOMResolver pdom= ((PDOMBinding) binding).getPDOM(); // IPDOMResolver pdom= ((PDOMBinding) binding).getPDOM();

View file

@ -12,11 +12,12 @@
package org.eclipse.cdt.errorparsers.xlc.tests; package org.eclipse.cdt.errorparsers.xlc.tests;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import junit.framework.Assert;
import org.eclipse.cdt.core.ErrorParserManager; import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.IErrorParserNamed; import org.eclipse.cdt.core.IErrorParserNamed;
import org.eclipse.cdt.core.IMarkerGenerator; import org.eclipse.cdt.core.IMarkerGenerator;
@ -43,7 +44,7 @@ public class XlcErrorParserTester {
fTempProject.create(null); fTempProject.create(null);
} catch (CoreException e) { } catch (CoreException e) {
e.printStackTrace(); e.printStackTrace();
Assert.fail("Exception creating temporary project "+fTempProject.getName()+": "+e); fail("Exception creating temporary project "+fTempProject.getName()+": "+e);
} }
} }
@ -125,7 +126,7 @@ public class XlcErrorParserTester {
*/ */
boolean parseLine(String line) { boolean parseLine(String line) {
IErrorParserNamed errorParser = ErrorParserManager.getErrorParserCopy(XLC_ERROR_PARSER_ID); IErrorParserNamed errorParser = ErrorParserManager.getErrorParserCopy(XLC_ERROR_PARSER_ID);
Assert.assertNotNull(errorParser); assertNotNull(errorParser);
MockErrorParserManager epManager = new MockErrorParserManager(); MockErrorParserManager epManager = new MockErrorParserManager();
return errorParser.processLine(line, epManager); return errorParser.processLine(line, epManager);