1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 08:46:02 +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;
import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@ -17,8 +19,6 @@ import java.util.Map;
import java.util.Set;
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.IPropertiesUpdateListener;
import org.eclipse.debug.internal.ui.viewers.model.ILabelUpdateListener;
@ -245,13 +245,13 @@ public class ViewerUpdatesListener
}
if (fFailOnRedundantUpdates && !fRedundantUpdates.isEmpty()) {
Assert.fail("Redundant Updates: " + fRedundantUpdates.toString());
fail("Redundant Updates: " + fRedundantUpdates.toString());
}
if (fFailOnMultipleLabelUpdateSequences && !fMultipleLabelUpdateSequencesObserved) {
Assert.fail("Multiple label update sequences detected");
fail("Multiple label update sequences detected");
}
if (fFailOnMultipleModelUpdateSequences && fMultipleModelUpdateSequencesObserved) {
Assert.fail("Multiple viewer update sequences detected");
fail("Multiple viewer update sequences detected");
}
if ( (flags & LABEL_SEQUENCE_COMPLETE) != 0) {

View file

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

View file

@ -10,13 +10,13 @@
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.concurrent;
import static org.junit.Assert.*;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
@ -64,15 +64,15 @@ public class DsfQueryTests {
}
};
// Check initial state
Assert.assertTrue(!q.isDone());
Assert.assertTrue(!q.isCancelled());
assertTrue(!q.isDone());
assertTrue(!q.isCancelled());
fExecutor.execute(q);
Assert.assertEquals(1, (int)q.get());
assertEquals(1, (int)q.get());
// Check final state
Assert.assertTrue(q.isDone());
Assert.assertTrue(!q.isCancelled());
assertTrue(q.isDone());
assertTrue(!q.isCancelled());
}
@ -89,21 +89,21 @@ public class DsfQueryTests {
};
// Check initial state
Assert.assertTrue(!q.isDone());
Assert.assertTrue(!q.isCancelled());
assertTrue(!q.isDone());
assertTrue(!q.isCancelled());
fExecutor.execute(q);
try {
q.get();
Assert.fail("Expected exception");
fail("Expected exception");
} catch (ExecutionException e) {
Assert.assertEquals(e.getCause().getMessage(), error_message);
assertEquals(e.getCause().getMessage(), error_message);
}
// Check final state
Assert.assertTrue(q.isDone());
Assert.assertTrue(!q.isCancelled());
assertTrue(q.isDone());
assertTrue(!q.isCancelled());
}
@ -118,20 +118,20 @@ public class DsfQueryTests {
};
// Check initial state
Assert.assertTrue(!q.isDone());
Assert.assertTrue(!q.isCancelled());
assertTrue(!q.isDone());
assertTrue(!q.isCancelled());
fExecutor.execute(q);
try {
q.get();
Assert.fail("Expected exception");
fail("Expected exception");
} catch (ExecutionException e) {
}
// Check final state
Assert.assertTrue(q.isDone());
Assert.assertTrue(!q.isCancelled());
assertTrue(q.isDone());
assertTrue(!q.isCancelled());
}
@ -154,7 +154,7 @@ public class DsfQueryTests {
public String toString() { return super.toString() + "\n getWithMultipleDispatchesTest() first runnable (query)"; } //$NON-NLS-1$
};
fExecutor.execute(q);
Assert.assertEquals(1, (int)q.get());
assertEquals(1, (int)q.get());
}
@Test (expected = ExecutionException.class)
@ -172,8 +172,8 @@ public class DsfQueryTests {
try {
q.get();
} finally {
Assert.assertTrue(q.isDone());
Assert.assertTrue(!q.isCancelled());
assertTrue(q.isDone());
assertTrue(!q.isCancelled());
}
}
@ -181,7 +181,7 @@ public class DsfQueryTests {
public void cancelBeforeWaitingTest() throws InterruptedException, ExecutionException {
final Query<Integer> q = new Query<Integer>() {
@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();
}
};
@ -189,8 +189,8 @@ public class DsfQueryTests {
// Cancel before invoking the query.
q.cancel(false);
Assert.assertTrue(q.isDone());
Assert.assertTrue(q.isCancelled());
assertTrue(q.isDone());
assertTrue(q.isCancelled());
// Start the query.
fExecutor.execute(q);
@ -203,10 +203,10 @@ public class DsfQueryTests {
} catch (CancellationException e) {
return; // Success
} finally {
Assert.assertTrue(q.isDone());
Assert.assertTrue(q.isCancelled());
assertTrue(q.isDone());
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
@ -244,10 +244,10 @@ public class DsfQueryTests {
// Cancel running request.
q.cancel(false);
Assert.assertTrue(cancelCalled[0]);
Assert.assertTrue(rmHolder[0].isCanceled());
Assert.assertTrue(q.isCancelled());
Assert.assertTrue(q.isDone());
assertTrue(cancelCalled[0]);
assertTrue(rmHolder[0].isCanceled());
assertTrue(q.isCancelled());
assertTrue(q.isDone());
// Retrieve data
try {
@ -255,8 +255,8 @@ public class DsfQueryTests {
} catch (CancellationException e) {
return; // Success
} finally {
Assert.assertTrue(q.isDone());
Assert.assertTrue(q.isCancelled());
assertTrue(q.isDone());
assertTrue(q.isCancelled());
}
// Complete rm and query.
@ -272,12 +272,12 @@ public class DsfQueryTests {
} catch (CancellationException e) {
return; // Success
} finally {
Assert.assertTrue(q.isDone());
Assert.assertTrue(q.isCancelled());
assertTrue(q.isDone());
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) {
return; // Success
} 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;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import junit.framework.Assert;
import junit.framework.AssertionFailedError;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
@ -191,20 +192,20 @@ public class DsfSequenceProgressTests {
System.out.println("RollBackCounter: " + rollBackCounter.fInteger);
if (sequence.isCancelled())
Assert.assertTrue(
assertTrue(
"Wrong number of steps were rolled back after cancellation.",
stepCounter.fInteger == rollBackCounter.fInteger);
else {
Assert.assertTrue(
assertTrue(
"Wrong number of steps executed.",
stepCounter.fInteger == steps.length);
Assert.assertTrue(
assertTrue(
"Some steps are mistakenly rolled back",
rollBackCounter.fInteger == 0);
}
// Check state from Future interface
Assert.assertTrue(sequence.isDone());
assertTrue(sequence.isDone());
} catch (AssertionFailedError e) {
fExceptions.add(e);
}

View file

@ -10,12 +10,12 @@
*******************************************************************************/
package org.eclipse.cdt.tests.dsf.concurrent;
import static org.junit.Assert.*;
import java.util.concurrent.CancellationException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
import org.eclipse.cdt.dsf.concurrent.ReflectionSequence;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
@ -85,18 +85,18 @@ public class DsfSequenceTests {
Sequence sequence = new Sequence(fExecutor) {
@Override public Step[] getSteps() { return steps; }
};
Assert.assertFalse(sequence.isDone());
Assert.assertFalse(sequence.isCancelled());
assertFalse(sequence.isDone());
assertFalse(sequence.isCancelled());
fExecutor.execute(sequence);
sequence.get();
// Check the count
Assert.assertTrue(stepCounter.fInteger == 2);
assertTrue(stepCounter.fInteger == 2);
// Check post conditions
Assert.assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled());
assertTrue(sequence.isDone());
assertFalse(sequence.isCancelled());
}
@ -133,18 +133,18 @@ public class DsfSequenceTests {
SimpleReflectionSequence sequence = new SimpleReflectionSequence();
//Sequence sequence = new SimpleReflectionSequence();
Assert.assertFalse(sequence.isDone());
Assert.assertFalse(sequence.isCancelled());
assertFalse(sequence.isDone());
assertFalse(sequence.isCancelled());
fExecutor.execute(sequence);
sequence.get();
// Check the count
Assert.assertTrue(sequence.fStepCounter == 2);
assertTrue(sequence.fStepCounter == 2);
// Check post conditions
Assert.assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled());
assertTrue(sequence.isDone());
assertFalse(sequence.isCancelled());
}
@ -192,15 +192,15 @@ public class DsfSequenceTests {
sequence.get();
} finally {
// Both steps should be performed
Assert.assertTrue(stepCounter.fInteger == 2);
assertTrue(stepCounter.fInteger == 2);
// Only one step is rolled back, the first one.
Assert.assertTrue(rollBackCounter.fInteger == 1);
assertTrue(rollBackCounter.fInteger == 1);
// Check state from Future interface
Assert.assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled());
assertTrue(sequence.isDone());
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)
@ -248,15 +248,15 @@ public class DsfSequenceTests {
sequence.get();
} finally {
// Both steps should be performed
Assert.assertTrue(stepCounter.fInteger == 2);
assertTrue(stepCounter.fInteger == 2);
// No steps should be rolled back.
Assert.assertTrue(rollBackCounter.fInteger == 0);
assertTrue(rollBackCounter.fInteger == 0);
// Check state from Future interface
Assert.assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled());
assertTrue(sequence.isDone());
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();
} finally {
// Both steps should be performed
Assert.assertEquals(2, sequence.fStepCounter);
assertEquals(2, sequence.fStepCounter);
// Only one step is rolled back, the first one.
Assert.assertEquals(1, sequence.fRollBackCounter);
assertEquals(1, sequence.fRollBackCounter);
// Check state from Future interface
Assert.assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled());
assertTrue(sequence.isDone());
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 {
@ -373,16 +373,16 @@ public class DsfSequenceTests {
sequence.get();
} finally {
// 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
// a rollback method.
Assert.assertEquals(1, sequence.fRollBackCounter);
assertEquals(1, sequence.fRollBackCounter);
// Check state from Future interface
Assert.assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled());
assertTrue(sequence.isDone());
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();
} finally {
// Check state from Future interface
Assert.assertTrue(sequence.isDone());
Assert.assertFalse(sequence.isCancelled());
assertTrue(sequence.isDone());
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[] {
new Sequence.Step() {
@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.
sequence.cancel(false);
Assert.assertFalse(sequence.isDone());
Assert.assertTrue(sequence.isCancelled());
assertFalse(sequence.isDone());
assertTrue(sequence.isCancelled());
// Start the sequence
fExecutor.execute(sequence);
@ -445,10 +445,10 @@ public class DsfSequenceTests {
try {
sequence.get();
} finally {
Assert.assertTrue(sequence.isDone());
Assert.assertTrue(sequence.isCancelled());
assertTrue(sequence.isDone());
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();
} finally {
// 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
// after the step is completed.
Assert.assertTrue(rollBackCounter.fInteger == 2);
assertTrue(rollBackCounter.fInteger == 2);
Assert.assertTrue(sequence.isDone());
Assert.assertTrue(sequence.isCancelled());
assertTrue(sequence.isDone());
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)
@ -517,7 +517,7 @@ public class DsfSequenceTests {
final Sequence.Step[] steps = new Sequence.Step[] {
new Sequence.Step() {
@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 {
sequence.get();
} finally {
Assert.assertTrue(sequence.isDone());
Assert.assertTrue(sequence.isCancelled());
assertTrue(sequence.isDone());
assertTrue(sequence.isCancelled());
}
}

View file

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

View file

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

View file

@ -10,6 +10,10 @@
*******************************************************************************/
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.IOException;
import java.io.InputStreamReader;
@ -17,8 +21,6 @@ import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.LinkedBlockingQueue;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.DefaultDsfExecutor;
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
@ -62,14 +64,14 @@ public class CommandControlTestsBase {
fSession = DsfSession.startSession(fExecutor, "PDA Test");
Process proc = Launching.launchPDA(fSession, null, fProgram);
Assert.assertNotNull(proc);
assertNotNull(proc);
// Remember the backend service of this session.
// Note this must be called after the above LaunchPDA().
fPDABackend = Launching.getBackendService();
fOutputReader = new BufferedReader(new InputStreamReader(proc.getInputStream()));
Assert.assertTrue(fOutputReader.readLine().contains("-debug"));
assertTrue(fOutputReader.readLine().contains("-debug"));
fCommandControl = new PDACommandControl(fSession);
@ -82,7 +84,7 @@ public class CommandControlTestsBase {
InitializeCommandServiceQuery initQuery = new InitializeCommandServiceQuery();
fExecutor.execute(initQuery);
initQuery.get();
Assert.assertEquals("debug connection accepted", fOutputReader.readLine());
assertEquals("debug connection accepted", fOutputReader.readLine());
}
@After
@ -146,7 +148,7 @@ public class CommandControlTestsBase {
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 {
Assert.assertEquals("Unexpected event received", expectedEvent, fEventsQueue.take());
assertEquals("Unexpected event received", expectedEvent, fEventsQueue.take());
}
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.concurrent.ExecutionException;
import junit.framework.Assert;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
@ -280,7 +279,7 @@ abstract public class FormattedValueTests extends TestCase implements IViewerUpd
fVMProvider.postEvent(new TestEvent(fModel.getRootElement(), IModelDelta.CONTENT));
while (!fViewerListener.isFinished(ALL_UPDATES_COMPLETE | PROPERTY_UPDATES))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
Assert.assertTrue(fFormattedValuesListener.getFormattedValuesCompleted().isEmpty());
assertTrue(fFormattedValuesListener.getFormattedValuesCompleted().isEmpty());
}
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))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
Assert.assertTrue(fFormattedValuesListener.isFinished());
assertTrue(fFormattedValuesListener.isFinished());
}
private void setUpdatePolicy(String policyId) {
@ -796,8 +795,8 @@ abstract public class FormattedValueTests extends TestCase implements IViewerUpd
if (expectCacheMissError) {
String formatProperty = FormattedValueVMUtil.getPropertyForFormatId(formatId);
Assert.assertTrue(fFormattedValuesListener.getFormattedValuesCompleted().isEmpty());
Assert.assertFalse(fFormattedValuesListener.getPropertiesUpdates().isEmpty());
assertTrue(fFormattedValuesListener.getFormattedValuesCompleted().isEmpty());
assertFalse(fFormattedValuesListener.getPropertiesUpdates().isEmpty());
for (IPropertiesUpdate update : fFormattedValuesListener.getPropertiesUpdates()) {
PropertiesUpdateStatus status = (PropertiesUpdateStatus)update.getStatus();
assertEquals(IDsfStatusConstants.INVALID_STATE, status.getCode());
@ -825,7 +824,7 @@ abstract public class FormattedValueTests extends TestCase implements IViewerUpd
}
} 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.Hashtable;
import junit.framework.Assert;
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
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.ModelDelta;
import org.eclipse.jface.viewers.TreePath;
import static org.junit.Assert.*;
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) {
TestElement element = getElement(path);
Assert.assertFalse(element.getGrayed());
assertFalse(element.getGrayed());
element.setChecked(checked, false);
}
@ -341,20 +340,20 @@ public class TestModel extends AbstractDsfService implements IFormattedValues {
IInternalTreeModelViewer viewer = (IInternalTreeModelViewer)_viewer;
TestElement element = getElement(path);
if ( Boolean.TRUE.equals(_viewer.getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)) ) {
Assert.assertEquals(element.getChecked(), viewer.getElementChecked(path));
Assert.assertEquals(element.getGrayed(), viewer.getElementGrayed(path));
assertEquals(element.getChecked(), viewer.getElementChecked(path));
assertEquals(element.getGrayed(), viewer.getElementGrayed(path));
}
if (!expandedElementsOnly || path.getSegmentCount() == 0 || viewer.getExpandedState(path) ) {
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++) {
Object viewerObject = viewer.getChildElement(path, i);
if (viewerObject instanceof TestElementVMContext) {
TreePath childPath = path.createChildPath(viewerObject);
TestElement viewerElement = ((TestElementVMContext)viewerObject).getElement();
Assert.assertEquals(children[i], viewerElement);
assertEquals(children[i], viewerElement);
if (validator != null) {
validator.validate(children[i], viewerElement, childPath);
}
@ -364,7 +363,7 @@ public class TestModel extends AbstractDsfService implements IFormattedValues {
}
} else if (!viewer.getExpandedState(path)) {
// 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) {
Assert.assertTrue(path.startsWith(fRootPath, null));
assertTrue(path.startsWith(fRootPath, null));
ModelDelta rootDelta = new ModelDelta(fInput, IModelDelta.NO_CHANGE);
ModelDelta baseDelta = getBaseDelta(rootDelta);
TreePath relativePath = getRelativePath(path);
@ -428,7 +427,7 @@ public class TestModel extends AbstractDsfService implements IFormattedValues {
}
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 baseDelta = getBaseDelta(rootDelta);
TreePath relativePath = getRelativePath(path);
@ -441,7 +440,7 @@ public class TestModel extends AbstractDsfService implements IFormattedValues {
}
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 baseDelta = getBaseDelta(rootDelta);
TreePath relativePath = getRelativePath(path);

View file

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

View file

@ -12,11 +12,12 @@
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.List;
import junit.framework.Assert;
import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.IErrorParserNamed;
import org.eclipse.cdt.core.IMarkerGenerator;
@ -43,7 +44,7 @@ public class XlcErrorParserTester {
fTempProject.create(null);
} catch (CoreException e) {
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) {
IErrorParserNamed errorParser = ErrorParserManager.getErrorParserCopy(XLC_ERROR_PARSER_ID);
Assert.assertNotNull(errorParser);
assertNotNull(errorParser);
MockErrorParserManager epManager = new MockErrorParserManager();
return errorParser.processLine(line, epManager);