Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2018-05-27 05:30:50 -0400
committerEike Stepper2018-05-27 05:30:50 -0400
commitad54bdbd490bf43fa1cdabf4b4a0e1c6934deb8c (patch)
tree668436b90b9590b2d687ddeca1e2ba303c970068 /plugins/org.eclipse.emf.cdo.tests/src
parentbaa83a0936ece0e0edbd705fdf41b9b06b5555db (diff)
downloadcdo-ad54bdbd490bf43fa1cdabf4b4a0e1c6934deb8c.tar.gz
cdo-ad54bdbd490bf43fa1cdabf4b4a0e1c6934deb8c.tar.xz
cdo-ad54bdbd490bf43fa1cdabf4b4a0e1c6934deb8c.zip
[535161] Implement a buffer tracer
https://bugs.eclipse.org/bugs/show_bug.cgi?id=535161
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.tests/src')
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitPerformanceTest.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_381472_Test.java4
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_387564_Test.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_469301_Test.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayedTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockReplicationTest.java3
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockingTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener.java103
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener2.java249
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/Timer.java75
14 files changed, 14 insertions, 439 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java
index 937088f6cc..425260e4a0 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AbstractSyncingTest.java
@@ -26,7 +26,6 @@ import org.eclipse.emf.cdo.spi.server.InternalStore;
import org.eclipse.emf.cdo.spi.server.InternalSynchronizableRepository;
import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
import org.eclipse.emf.cdo.tests.config.impl.RepositoryConfig.OfflineConfig;
-import org.eclipse.emf.cdo.tests.util.TestListener;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitException;
@@ -35,6 +34,7 @@ import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.concurrent.ConcurrencyUtil;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.tests.TestListener;
import org.eclipse.emf.ecore.EObject;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitPerformanceTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitPerformanceTest.java
index abeee22db4..6074aa563c 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitPerformanceTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/CommitPerformanceTest.java
@@ -18,9 +18,10 @@ import org.eclipse.emf.cdo.tests.model1.Category;
import org.eclipse.emf.cdo.tests.model1.Company;
import org.eclipse.emf.cdo.tests.model1.Product1;
import org.eclipse.emf.cdo.tests.model1.VAT;
-import org.eclipse.emf.cdo.tests.util.Timer;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.net4j.util.tests.Timer;
+
import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
index 90dcd97b2e..afa4ce1bc2 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/LockingNotificationsTest.java
@@ -22,7 +22,6 @@ import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestListener2;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitException;
@@ -31,6 +30,7 @@ import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.tests.TestListener2;
import java.util.List;
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 97e663c35e..729e9ae0a5 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
@@ -29,8 +29,6 @@ import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesAfter;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
-import org.eclipse.emf.cdo.tests.util.TestListener;
-import org.eclipse.emf.cdo.tests.util.TestListener.EventAssertion;
import org.eclipse.net4j.connector.IConnector;
import org.eclipse.net4j.util.container.IContainerDelta;
@@ -39,6 +37,8 @@ import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.factory.ProductCreationException;
import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.tests.TestListener;
+import org.eclipse.net4j.util.tests.TestListener.EventAssertion;
import java.util.Collections;
import java.util.HashMap;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_387564_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_387564_Test.java
index 94c70b95d6..03b603e9c0 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_387564_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_387564_Test.java
@@ -21,7 +21,6 @@ import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
import org.eclipse.emf.cdo.tests.config.impl.SessionConfig;
import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestListener2;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitException;
@@ -32,6 +31,7 @@ import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.tests.TestListener2;
import org.eclipse.emf.spi.cdo.InternalCDOSession;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_469301_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_469301_Test.java
index 1918e6dd97..f00b951b1b 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_469301_Test.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_469301_Test.java
@@ -20,7 +20,6 @@ import org.eclipse.emf.cdo.server.IView;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.tests.AbstractCDOTest;
import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestListener2;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
@@ -28,6 +27,7 @@ import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
import org.eclipse.net4j.util.concurrent.RWOLockManager.LockState;
+import org.eclipse.net4j.util.tests.TestListener2;
import org.eclipse.emf.spi.cdo.InternalCDOObject;
import org.eclipse.emf.spi.cdo.InternalCDOTransaction;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java
index 689f970803..1b70959a8e 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/FailoverTest.java
@@ -16,12 +16,12 @@ import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestListener;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.net4j.acceptor.IAcceptor;
import org.eclipse.net4j.util.container.IManagedContainer;
import org.eclipse.net4j.util.io.IOUtil;
+import org.eclipse.net4j.util.tests.TestListener;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayedTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayedTest.java
index 0e55e4b157..7dcffa2f0f 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayedTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineDelayedTest.java
@@ -15,10 +15,10 @@ import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestListener;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.net4j.util.event.IEvent;
+import org.eclipse.net4j.util.tests.TestListener;
/**
* @author Eike Stepper
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockReplicationTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockReplicationTest.java
index 4853c27447..243372c804 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockReplicationTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockReplicationTest.java
@@ -17,12 +17,13 @@ import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.spi.server.InternalRepository;
import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestListener2;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.util.CommitException;
import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
+import org.eclipse.net4j.util.tests.TestListener2;
+
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockingTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockingTest.java
index b470da4524..9153cb6774 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockingTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineLockingTest.java
@@ -19,13 +19,13 @@ import org.eclipse.emf.cdo.session.CDOSessionInvalidationEvent;
import org.eclipse.emf.cdo.session.CDOSessionLocksChangedEvent;
import org.eclipse.emf.cdo.tests.AbstractSyncingTest;
import org.eclipse.emf.cdo.tests.model1.Company;
-import org.eclipse.emf.cdo.tests.util.TestListener2;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.cdo.view.CDOViewLocksChangedEvent;
import org.eclipse.net4j.util.concurrent.IRWLockManager.LockType;
+import org.eclipse.net4j.util.tests.TestListener2;
/**
* @author Caspar De Groot
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
index b02cdc7535..0732d3e5e8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/offline/OfflineTest.java
@@ -31,13 +31,13 @@ import org.eclipse.emf.cdo.tests.bundle.OM;
import org.eclipse.emf.cdo.tests.model1.Company;
import org.eclipse.emf.cdo.tests.model3.File;
import org.eclipse.emf.cdo.tests.model3.Image;
-import org.eclipse.emf.cdo.tests.util.TestListener;
import org.eclipse.emf.cdo.transaction.CDOTransaction;
import org.eclipse.emf.cdo.view.CDOViewInvalidationEvent;
import org.eclipse.net4j.util.event.IEvent;
import org.eclipse.net4j.util.io.IOUtil;
import org.eclipse.net4j.util.om.monitor.NotifyingMonitor.ProgressEvent;
+import org.eclipse.net4j.util.tests.TestListener;
import org.eclipse.emf.spi.cdo.DefaultCDOMerger;
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
deleted file mode 100644
index 652aa0f28c..0000000000
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2011-2013, 2016 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.util;
-
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.AssertionFailedError;
-
-/**
- * @author Eike Stepper
- */
-public class TestListener implements IListener
-{
- private List<IEvent> events = new ArrayList<IEvent>();
-
- private int nextAssertion;
-
- public TestListener()
- {
- }
-
- public <T extends IEvent> void assertEvent(final Class<?> eventType, final EventAssertion<T> assertion) throws Exception
- {
- new AbstractOMTest.PollingTimeOuter()
- {
- @SuppressWarnings("unchecked")
- @Override
- protected boolean successful()
- {
- synchronized (events)
- {
- for (int i = nextAssertion; i < events.size(); i++)
- {
- IEvent event = events.get(i);
- System.out.println(event);
- ++nextAssertion;
-
- 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 false;
- }
- }.assertNoTimeOut();
- }
-
- public IEvent[] getEvents()
- {
- synchronized (events)
- {
- return events.toArray(new IEvent[events.size()]);
- }
- }
-
- public void clearEvents()
- {
- synchronized (events)
- {
- events.clear();
- nextAssertion = 0;
- }
- }
-
- public void notifyEvent(IEvent event)
- {
- synchronized (events)
- {
- events.add(event);
- }
- }
-
- /**
- * @author Eike Stepper
- */
- public interface EventAssertion<T extends IEvent>
- {
- public void execute(T event);
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener2.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener2.java
deleted file mode 100644
index bac7fec4a4..0000000000
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/TestListener2.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright (c) 2011-2013, 2016 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.util;
-
-import org.eclipse.net4j.util.WrappedException;
-import org.eclipse.net4j.util.event.IEvent;
-import org.eclipse.net4j.util.event.IListener;
-
-import org.junit.Assert;
-
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-/**
- * @author Caspar De Groot
- */
-public class TestListener2 implements IListener
-{
- public static final int NO_TIME_STAMP = 0;
-
- private static final Set<Class<? extends IEvent>> NO_EVENT_CLASSES = Collections.emptySet();
-
- private static final long DEFAULT_TIMEOUT = 3000; // 3 seconds
-
- private final Map<IEvent, Long> events = new LinkedHashMap<IEvent, Long>();
-
- private final Collection<Class<? extends IEvent>> eventClasses;
-
- private long timeout;
-
- private String name;
-
- public TestListener2(Collection<Class<? extends IEvent>> eventClasses)
- {
- this(eventClasses, null);
- }
-
- public TestListener2(Class<? extends IEvent> eventClass)
- {
- this(singleton(eventClass));
- }
-
- public TestListener2(Collection<Class<? extends IEvent>> eventClasses, String name)
- {
- this.eventClasses = eventClasses != null ? eventClasses : NO_EVENT_CLASSES;
- this.name = name;
- timeout = DEFAULT_TIMEOUT;
- }
-
- public TestListener2(Class<? extends IEvent> eventClass, String name)
- {
- this(singleton(eventClass), name);
- }
-
- public boolean isApplicable(IEvent event)
- {
- if (eventClasses.isEmpty())
- {
- return true;
- }
-
- Class<? extends IEvent> theClass = event.getClass();
- for (Class<? extends IEvent> eventClass : eventClasses)
- {
- if (eventClass.isAssignableFrom(theClass))
- {
- return true;
- }
- }
-
- return false;
- }
-
- public void notifyEvent(IEvent event)
- {
- if (isApplicable(event))
- {
- long timeStamp = System.currentTimeMillis();
- if (timeStamp == NO_TIME_STAMP)
- {
- throw new IllegalStateException("Regular time stamp is equal to NO_TIME_STAMP");
- }
-
- synchronized (this)
- {
- events.put(event, timeStamp);
- notify();
- }
- }
- }
-
- public List<IEvent> getEvents()
- {
- synchronized (this)
- {
- return new ArrayList<IEvent>(events.keySet());
- }
- }
-
- public long getTimeStamp(IEvent event)
- {
- Long timeStamp;
- synchronized (this)
- {
- timeStamp = events.get(event);
- }
-
- if (timeStamp == null)
- {
- return NO_TIME_STAMP;
- }
-
- return timeStamp;
- }
-
- public void setTimeout(long timeout)
- {
- this.timeout = timeout;
- }
-
- public synchronized void waitFor(int n, long timeout)
- {
- long t = 0;
-
- synchronized (this)
- {
- while (events.size() < n)
- {
- if (timeout <= 0)
- {
- Assert.fail("Timed out");
- }
-
- try
- {
- t = System.currentTimeMillis();
- wait(timeout);
- }
- catch (InterruptedException ex)
- {
- throw WrappedException.wrap(ex);
- }
-
- timeout -= System.currentTimeMillis() - t;
- }
- }
- }
-
- public void waitFor(int i)
- {
- waitFor(i, timeout);
- }
-
- public void clearEvents()
- {
- synchronized (this)
- {
- events.clear();
- }
- }
-
- public String formatEvents(String prefix, String suffix)
- {
- StringBuilder builder = new StringBuilder();
-
- synchronized (this)
- {
- for (Entry<IEvent, Long> entry : events.entrySet())
- {
- builder.append(prefix + entry.getValue() + ": " + entry.getKey() + suffix);
- }
- }
-
- return builder.toString();
- }
-
- public void dump(PrintStream out)
- {
- out.println(this);
- out.print(formatEvents(" ", "\n"));
- }
-
- @Override
- public String toString()
- {
- StringBuilder builder = new StringBuilder(TestListener2.class.getSimpleName());
- builder.append('[');
-
- if (name != null)
- {
- builder.append("name=\"");
- builder.append(name);
- builder.append('\"');
- }
-
- if (!eventClasses.isEmpty())
- {
- if (name != null)
- {
- builder.append(", ");
- }
-
- builder.append("eventClasses=[");
- boolean first = true;
-
- for (Class<? extends IEvent> eventClass : eventClasses)
- {
- if (first)
- {
- first = false;
- }
- else
- {
- builder.append(", ");
- }
-
- builder.append(eventClass.getSimpleName());
- }
-
- builder.append(']');
- }
-
- builder.append(']');
- return builder.toString();
- }
-
- private static Set<Class<? extends IEvent>> singleton(Class<? extends IEvent> eventClass)
- {
- Set<Class<? extends IEvent>> singleton = new HashSet<Class<? extends IEvent>>();
- singleton.add(eventClass);
- return singleton;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/Timer.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/Timer.java
deleted file mode 100644
index 3c798ed5d7..0000000000
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/util/Timer.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2012 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.tests.util;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.TimeUnit;
-
-/**
- * @author Eike Stepper
- */
-public class Timer
-{
- private long sum;
-
- private long start;
-
- public Timer()
- {
- start();
- }
-
- public void start()
- {
- start = System.nanoTime();
- }
-
- public void stop()
- {
- if (start > 0)
- {
- long nanos = System.nanoTime() - start;
- sum += nanos;
- start = 0;
- }
- }
-
- public void done()
- {
- done(TimeUnit.NANOSECONDS);
- }
-
- public void done(TimeUnit timeUnit)
- {
- stop();
- long converted = timeUnit.convert(sum, TimeUnit.NANOSECONDS);
- System.out.println(converted);
- }
-
- public static <T> T execute(Callable<T> callable) throws Exception
- {
- return execute(TimeUnit.NANOSECONDS, callable);
- }
-
- public static <T> T execute(TimeUnit timeUnit, Callable<T> callable) throws Exception
- {
- Timer timer = new Timer();
-
- try
- {
- return callable.call();
- }
- finally
- {
- timer.done(timeUnit);
- }
- }
-}

Back to the top