Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2010-01-18 17:53:58 +0000
committerEike Stepper2010-01-18 17:53:58 +0000
commitc4ebeea22fba02eed76040d9fc7adcd44f86d2a0 (patch)
tree94fcdee897efd15f954a544894c90955e0bb8505 /plugins/org.eclipse.net4j.tests/src
parentda6dfefe10ed83dc74009c7424832d4d6f91cb7b (diff)
downloadcdo-c4ebeea22fba02eed76040d9fc7adcd44f86d2a0.tar.gz
cdo-c4ebeea22fba02eed76040d9fc7adcd44f86d2a0.tar.xz
cdo-c4ebeea22fba02eed76040d9fc7adcd44f86d2a0.zip
[299871] java.nio.BufferUnderFlowException
https://bugs.eclipse.org/bugs/show_bug.cgi?id=299871
Diffstat (limited to 'plugins/org.eclipse.net4j.tests/src')
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java9
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPConnectorTest.java12
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla262875_Test.java45
-rw-r--r--plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/QueueWorkerWorkSerializerTest.java (renamed from plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/QueueWorkerWorkSerializerTest.java)48
4 files changed, 28 insertions, 86 deletions
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
index b171536b73..5c0aa6a120 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/AllTests.java
@@ -11,8 +11,10 @@
package org.eclipse.net4j.tests;
import org.eclipse.net4j.tests.bugzilla.Bugzilla241463_Test;
+import org.eclipse.net4j.tests.bugzilla.Bugzilla262875_Test;
import org.eclipse.net4j.util.tests.ExtendedIOTest;
import org.eclipse.net4j.util.tests.MultiMapTest;
+import org.eclipse.net4j.util.tests.QueueWorkerWorkSerializerTest;
import org.eclipse.net4j.util.tests.ReferenceValueMapTest;
import org.eclipse.net4j.util.tests.SecurityTest;
import org.eclipse.net4j.util.tests.SortedFileMapTest;
@@ -37,7 +39,6 @@ public class AllTests
suite.addTestSuite(BufferPoolTest.class);
suite.addTestSuite(ExtendedIOTest.class);
suite.addTestSuite(StringCompressorTest.class);
- suite.addTestSuite(Bugzilla241463_Test.class);
suite.addTestSuite(ChannelTest.JVM.class);
suite.addTestSuite(ChannelTest.TCP.class);
suite.addTestSuite(TCPConnectorTest.class);
@@ -49,7 +50,11 @@ public class AllTests
suite.addTestSuite(SecurityTest.class);
suite.addTestSuite(QueueWorkerWorkSerializerTest.class);
- // defs
+ // Bugzillas
+ suite.addTestSuite(Bugzilla241463_Test.class);
+ suite.addTestSuite(Bugzilla262875_Test.class);
+
+ // Defs
// suite.addTestSuite(TestDefTest.class);
// suite.addTestSuite(TCPAcceptorDefImplTest.class);
// suite.addTestSuite(TCPConnectorDefImplTest.class);
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPConnectorTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPConnectorTest.java
index 76cb3b107c..deafb341c1 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPConnectorTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/TCPConnectorTest.java
@@ -4,7 +4,7 @@
* 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
*/
@@ -185,9 +185,9 @@ public class TCPConnectorTest extends AbstractOMTest
connector.setHost("localhost"); //$NON-NLS-1$
connector.setPort(2036);
connector.activate();
- assertEquals(false, connector.isActive());
+ // Can fail due to timing variations: assertEquals(false, connector.isActive());
- boolean connected = connector.waitForConnection(DELAY + TIMEOUT);
+ boolean connected = connector.waitForConnection(DEFAULT_TIMEOUT);
assertEquals(true, connected);
assertEquals(true, connector.isActive());
}
@@ -260,7 +260,7 @@ public class TCPConnectorTest extends AbstractOMTest
connector.setPort(2036);
connector.activate();
- boolean connected = connector.waitForConnection(TIMEOUT);
+ boolean connected = connector.waitForConnection(DEFAULT_TIMEOUT);
assertEquals(true, connected);
InternalChannel clientChannel = connector.openChannel();
@@ -343,7 +343,7 @@ public class TCPConnectorTest extends AbstractOMTest
try
{
connector.connectAsync();
- connector.waitForConnection(TIMEOUT);
+ connector.waitForConnection(DEFAULT_TIMEOUT_EXPECTED);
fail("ConnectorException expected"); //$NON-NLS-1$
}
catch (ConnectorException ex)
@@ -405,7 +405,7 @@ public class TCPConnectorTest extends AbstractOMTest
try
{
connector.connectAsync();
- connector.waitForConnection(TIMEOUT);
+ connector.waitForConnection(DEFAULT_TIMEOUT_EXPECTED);
fail("ConnectorException expected"); //$NON-NLS-1$
}
catch (ConnectorException ex)
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla262875_Test.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla262875_Test.java
index df9809b779..5c064258c2 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla262875_Test.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/bugzilla/Bugzilla262875_Test.java
@@ -41,7 +41,7 @@ public class Bugzilla262875_Test extends AbstractOMTest
{
/** the length of the metadata sent in a buffer: channelID, correlationID */
- private static final short BUFFER_METADATA_LENGHT = 10;
+ private static final short BUFFER_METADATA_LENTGH = 10;
private IManagedContainer container;
@@ -100,48 +100,7 @@ public class Bugzilla262875_Test extends AbstractOMTest
protocol.open(connector);
short bufferCapacity = protocol.getBufferProvider().getBufferCapacity();
- new TestProtocol.Request(protocol, bufferCapacity - BUFFER_METADATA_LENGHT).send();
-
- latch.await(DEFAULT_TIMEOUT_EXPECTED, TimeUnit.MILLISECONDS);
- assertEquals(false, failed.get());
- }
- finally
- {
- Worker.setGlobalErrorHandler(oldErrorHandler);
- }
- }
-
- /**
- * Tests if an illegal argument exception occurs if the data sent in a request's larger than the capacity of a buffer.
- *
- * @throws Exception
- * the exception
- */
- public void testGivenDataIsLargerThanBufferLengthThenIllegalArgumentException() throws Exception
- {
- final AtomicBoolean failed = new AtomicBoolean(false);
- final CountDownLatch latch = new CountDownLatch(1);
- IErrorHandler oldErrorHandler = Worker.setGlobalErrorHandler(new IErrorHandler()
- {
- public void handleError(Throwable t)
- {
- t.printStackTrace();
- if (t instanceof IllegalArgumentException)
- {
- failed.set(true);
- }
-
- latch.countDown();
- }
- });
-
- try
- {
- TestProtocol protocol = new TestProtocol();
- protocol.open(connector);
-
- short bufferCapacity = protocol.getBufferProvider().getBufferCapacity();
- new TestProtocol.Request(protocol, bufferCapacity + 10).send();
+ new TestProtocol.Request(protocol, bufferCapacity - BUFFER_METADATA_LENTGH).send();
latch.await(DEFAULT_TIMEOUT_EXPECTED, TimeUnit.MILLISECONDS);
assertEquals(false, failed.get());
diff --git a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/QueueWorkerWorkSerializerTest.java b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/QueueWorkerWorkSerializerTest.java
index b9d03b6e59..dc32c514d4 100644
--- a/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/tests/QueueWorkerWorkSerializerTest.java
+++ b/plugins/org.eclipse.net4j.tests/src/org/eclipse/net4j/util/tests/QueueWorkerWorkSerializerTest.java
@@ -9,11 +9,10 @@
* Andre Dietisheim - initial API and implementation
* Eike Stepper - maintenance
*/
-package org.eclipse.net4j.tests;
+package org.eclipse.net4j.util.tests;
import org.eclipse.net4j.util.concurrent.QueueWorkerWorkSerializer;
import org.eclipse.net4j.util.io.IOUtil;
-import org.eclipse.net4j.util.tests.AbstractOMTest;
import java.util.Random;
import java.util.concurrent.CountDownLatch;
@@ -23,7 +22,7 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
/**
- * A test for {@link QueueWorkerWorkSerializer}
+ * A test for {@link QueueWorkerWorkSerializer}.
*
* @author Andre Dietisheim
*/
@@ -59,10 +58,9 @@ public class QueueWorkerWorkSerializerTest extends AbstractOMTest
*/
public void testAllWorkSubmittedIsConsumed() throws Throwable
{
- createWorkProducerThreads(new AbstractWorkProducerFactory()
+ createWorkProducerThreads(new WorkProducerFactory()
{
- @Override
- Runnable create()
+ public WorkProducer createWorkProducer()
{
return new WorkProducer()
{
@@ -74,6 +72,7 @@ public class QueueWorkerWorkSerializerTest extends AbstractOMTest
};
}
});
+
waitForAllWorkExecuted();
assertEquals(workProduced.get(), NUM_WORK - workConsumedLatch.getCount());
}
@@ -84,10 +83,9 @@ public class QueueWorkerWorkSerializerTest extends AbstractOMTest
*/
public void testGivenWorkExceptionInWorkAllWorkSubmittedOnlyTheFirstWorkerIsConsumed() throws Throwable
{
- createWorkProducerThreads(new AbstractWorkProducerFactory()
+ createWorkProducerThreads(new WorkProducerFactory()
{
- @Override
- Runnable create()
+ public WorkProducer createWorkProducer()
{
return new WorkProducer()
{
@@ -107,17 +105,12 @@ public class QueueWorkerWorkSerializerTest extends AbstractOMTest
};
}
});
+
waitForAllWorkExecuted();
assertEquals(NUM_WORK, workProduced.get());
assertEquals(1, NUM_WORK - workConsumedLatch.getCount());
}
- /**
- * Wait for all work executed.
- *
- * @throws InterruptedException
- * the interrupted exception
- */
private void waitForAllWorkExecuted() throws InterruptedException
{
if (!workConsumedLatch.await(WORK_COMPLETION_TIMEOUT, TimeUnit.MILLISECONDS))
@@ -126,30 +119,20 @@ public class QueueWorkerWorkSerializerTest extends AbstractOMTest
}
}
- /**
- * Creates work producer threads.
- *
- * @see #NUM_WORKPRODUCER_THREADS
- */
- private void createWorkProducerThreads(AbstractWorkProducerFactory factory)
+ private void createWorkProducerThreads(WorkProducerFactory factory)
{
for (int i = 0; i < NUM_WORKPRODUCER_THREADS; i++)
{
- threadPool.submit(factory.create());
+ threadPool.submit(factory.createWorkProducer());
}
}
/**
* A factory that creates work units.
*/
- private abstract class AbstractWorkProducerFactory
+ private static interface WorkProducerFactory
{
- /**
- * Creates the.
- *
- * @return the runnable
- */
- abstract Runnable create();
+ public WorkProducer createWorkProducer();
}
/**
@@ -193,14 +176,12 @@ public class QueueWorkerWorkSerializerTest extends AbstractOMTest
}
/**
- * A simple work unit to be executed in the queueWorker
+ * A simple work unit to be executed in the queueWorker.
*
* @author Andre Dietisheim
*/
class Work implements Runnable
{
-
- /** The id. */
private final int id;
private Work(int id)
@@ -225,9 +206,6 @@ public class QueueWorkerWorkSerializerTest extends AbstractOMTest
workProduced = new AtomicInteger(0);
}
- /**
- * Tear down.
- */
@Override
public void tearDown()
{

Back to the top