Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-08-06 04:07:27 -0400
committerEike Stepper2013-08-06 04:09:24 -0400
commit768ac9122ff2cb4abbc7cdc92261de7aa3d0e8a1 (patch)
treec01ca2026bd2ccbcdbfb80787ca614437690ddef
parentc58fb4de474c05d9e936f63f9cc97f34a8ee0db9 (diff)
downloadcdo-768ac9122ff2cb4abbc7cdc92261de7aa3d0e8a1.tar.gz
cdo-768ac9122ff2cb4abbc7cdc92261de7aa3d0e8a1.tar.xz
cdo-768ac9122ff2cb4abbc7cdc92261de7aa3d0e8a1.zip
Stabilize Bugzilla_381472_Test
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_381472_Test.java36
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener.java60
2 files changed, 44 insertions, 52 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_381472_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_381472_Test.java
index d94e92d715..2c78358514 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_381472_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_381472_Test.java
@@ -321,9 +321,9 @@ public class Bugzilla_381472_Test extends AbstractCDOTest
getRepository("repo2");
admin.waitForRepository("repo2");
- listener.assertEvent(new EventAssertion<IContainerEvent<CDOAdminRepository>>()
+ listener.assertEvent(IContainerEvent.class, new EventAssertion<IContainerEvent<CDOAdminRepository>>()
{
- public void execute(IContainerEvent<CDOAdminRepository> event) throws Exception
+ public void execute(IContainerEvent<CDOAdminRepository> event)
{
assertEquals(IContainerDelta.Kind.ADDED, event.getDeltaKind());
assertEquals("repo2", event.getDeltaElement().getName());
@@ -358,9 +358,9 @@ public class Bugzilla_381472_Test extends AbstractCDOTest
}
}.assertNoTimeOut();
- listener.assertEvent(new EventAssertion<IContainerEvent<CDOAdminRepository>>()
+ listener.assertEvent(IContainerEvent.class, new EventAssertion<IContainerEvent<CDOAdminRepository>>()
{
- public void execute(IContainerEvent<CDOAdminRepository> event) throws Exception
+ public void execute(IContainerEvent<CDOAdminRepository> event)
{
assertEquals(IContainerDelta.Kind.REMOVED, event.getDeltaKind());
assertEquals("repo1", event.getDeltaElement().getName());
@@ -386,9 +386,9 @@ public class Bugzilla_381472_Test extends AbstractCDOTest
getRepository().setType(Type.BACKUP);
- listener.assertEvent(new EventAssertion<RepositoryTypeChangedEvent>()
+ listener.assertEvent(RepositoryTypeChangedEvent.class, new EventAssertion<RepositoryTypeChangedEvent>()
{
- public void execute(RepositoryTypeChangedEvent event) throws Exception
+ public void execute(RepositoryTypeChangedEvent event)
{
assertEquals(Type.MASTER, event.getOldType());
assertEquals(Type.BACKUP, event.getNewType());
@@ -414,9 +414,9 @@ public class Bugzilla_381472_Test extends AbstractCDOTest
getRepository().setState(State.OFFLINE);
- listener.assertEvent(new EventAssertion<RepositoryStateChangedEvent>()
+ listener.assertEvent(RepositoryStateChangedEvent.class, new EventAssertion<RepositoryStateChangedEvent>()
{
- public void execute(RepositoryStateChangedEvent event) throws Exception
+ public void execute(RepositoryStateChangedEvent event)
{
assertEquals(State.ONLINE, event.getOldState());
assertEquals(State.OFFLINE, event.getNewState());
@@ -446,9 +446,9 @@ public class Bugzilla_381472_Test extends AbstractCDOTest
assertEquals(getRepository().getName(), repositories[0].getName());
assertEquals(repo2.getName(), repositories[1].getName());
- listener.assertEvent(new EventAssertion<IContainerEvent<CDOAdminRepository>>()
+ listener.assertEvent(IContainerEvent.class, new EventAssertion<IContainerEvent<CDOAdminRepository>>()
{
- public void execute(IContainerEvent<CDOAdminRepository> event) throws Exception
+ public void execute(IContainerEvent<CDOAdminRepository> event)
{
assertEquals(IContainerDelta.Kind.ADDED, event.getDeltaKind());
assertEquals("repo2", event.getDeltaElement().getName());
@@ -479,9 +479,9 @@ public class Bugzilla_381472_Test extends AbstractCDOTest
assertEquals(getRepository().getName(), repositories[0].getName());
assertEquals(repo2.getName(), repositories[1].getName());
- listener.assertEvent(new EventAssertion<IContainerEvent<CDOAdminRepository>>()
+ listener.assertEvent(IContainerEvent.class, new EventAssertion<IContainerEvent<CDOAdminRepository>>()
{
- public void execute(IContainerEvent<CDOAdminRepository> event) throws Exception
+ public void execute(IContainerEvent<CDOAdminRepository> event)
{
assertEquals(IContainerDelta.Kind.ADDED, event.getDeltaKind());
assertEquals("repo2", event.getDeltaElement().getName());
@@ -514,9 +514,9 @@ public class Bugzilla_381472_Test extends AbstractCDOTest
assertEquals(getRepository().getName(), repositories[0].getName());
assertEquals(repo2.getName(), repositories[1].getName());
- listener.assertEvent(new EventAssertion<IContainerEvent<CDOAdminRepository>>()
+ listener.assertEvent(IContainerEvent.class, new EventAssertion<IContainerEvent<CDOAdminRepository>>()
{
- public void execute(IContainerEvent<CDOAdminRepository> event) throws Exception
+ public void execute(IContainerEvent<CDOAdminRepository> event)
{
assertEquals(IContainerDelta.Kind.ADDED, event.getDeltaKind());
assertEquals("repo2", event.getDeltaElement().getName());
@@ -549,9 +549,9 @@ public class Bugzilla_381472_Test extends AbstractCDOTest
assertEquals(getRepository().getName(), repositories[0].getName());
assertEquals(repo2.getName(), repositories[1].getName());
- listener.assertEvent(new EventAssertion<IContainerEvent<CDOAdminRepository>>()
+ listener.assertEvent(IContainerEvent.class, new EventAssertion<IContainerEvent<CDOAdminRepository>>()
{
- public void execute(IContainerEvent<CDOAdminRepository> event) throws Exception
+ public void execute(IContainerEvent<CDOAdminRepository> event)
{
assertEquals(IContainerDelta.Kind.ADDED, event.getDeltaKind());
assertEquals("repo2", event.getDeltaElement().getName());
@@ -596,9 +596,9 @@ public class Bugzilla_381472_Test extends AbstractCDOTest
repo1.delete(ADMIN_HANDLER_TYPE);
assertEquals(null, admin.getRepository("repo1"));
- listener.assertEvent(new EventAssertion<IContainerEvent<CDOAdminRepository>>()
+ listener.assertEvent(IContainerEvent.class, new EventAssertion<IContainerEvent<CDOAdminRepository>>()
{
- public void execute(IContainerEvent<CDOAdminRepository> event) throws Exception
+ public void execute(IContainerEvent<CDOAdminRepository> event)
{
assertEquals(IContainerDelta.Kind.REMOVED, event.getDeltaKind());
assertEquals("repo1", event.getDeltaElement().getName());
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener.java
index feaac13656..b345e14241 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener.java
@@ -17,6 +17,8 @@ import org.eclipse.net4j.util.tests.AbstractOMTest;
import java.util.ArrayList;
import java.util.List;
+import junit.framework.AssertionFailedError;
+
/**
* @author Eike Stepper
*/
@@ -24,58 +26,47 @@ public class TestListener implements IListener
{
private List<IEvent> events = new ArrayList<IEvent>();
+ private int nextAssertion;
+
public TestListener()
{
}
- public <T extends IEvent> void assertEvent(final EventAssertion<T> assertion) throws Exception
+ public <T extends IEvent> void assertEvent(final Class<?> eventType, final EventAssertion<T> assertion)
+ throws Exception
{
- final Exception[] exception = { null };
- final Error[] error = { null };
-
new AbstractOMTest.PollingTimeOuter()
{
@SuppressWarnings("unchecked")
@Override
protected boolean successful()
{
- T event;
synchronized (events)
{
- if (events.size() != 1)
+ for (int i = nextAssertion; i < events.size(); i++)
{
- return false;
- }
+ IEvent event = events.get(i);
+ System.out.println(event);
+ ++nextAssertion;
- event = (T)events.get(0);
- }
-
- try
- {
- assertion.execute(event);
- }
- catch (Exception ex)
- {
- exception[0] = ex;
- }
- catch (Error err)
- {
- error[0] = err;
+ if (eventType.isAssignableFrom(event.getClass()))
+ {
+ try
+ {
+ assertion.execute((T)event);
+ return true;
+ }
+ catch (AssertionFailedError ignore)
+ {
+ // This is not the expected event. Either it'll come later or we'll time out below.
+ }
+ }
+ }
}
- return true;
+ return false;
}
}.assertNoTimeOut();
-
- if (exception[0] != null)
- {
- throw exception[0];
- }
-
- if (error[0] != null)
- {
- throw error[0];
- }
}
public IEvent[] getEvents()
@@ -91,6 +82,7 @@ public class TestListener implements IListener
synchronized (events)
{
events.clear();
+ nextAssertion = 0;
}
}
@@ -107,6 +99,6 @@ public class TestListener implements IListener
*/
public interface EventAssertion<T extends IEvent>
{
- public void execute(T event) throws Exception;
+ public void execute(T event);
}
}

Back to the top