You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by ad...@apache.org on 2011/07/31 19:32:01 UTC
svn commit: r1152600 [3/3] - in /mina/sandbox/adc/ahc:
api/src/main/java/org/apache/ahc/ api/src/main/java/org/apache/ahc/api/
api/src/main/java/org/apache/ahc/api/listeners/
api/src/main/java/org/apache/ahc/api/mime/ api/src/test/java/com/acme/ahc/
ap...
Modified: mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/ahc/BenchMark.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/ahc/BenchMark.java?rev=1152600&r1=1152599&r2=1152600&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/ahc/BenchMark.java (original)
+++ mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/ahc/BenchMark.java Sun Jul 31 17:31:47 2011
@@ -30,7 +30,7 @@ import org.apache.ahc.mina3.EquipmentSta
/**
- * @version $Revision: $ $Date: $
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public class BenchMark
{
@@ -39,7 +39,7 @@ public class BenchMark
{
EquipmentStack stack = new EquipmentStack();
- for (int i = 0; i < 1000; i++) stack.addPair("" + i, new Object());
+ for (int i = 0; i < 1000; i++) stack.equipWith("" + i, new Object());
long start = System.currentTimeMillis();
final int COUNT = 100000;
Modified: mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/ahc/SSLEngineSimpleDemo.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/ahc/SSLEngineSimpleDemo.java?rev=1152600&r1=1152599&r2=1152600&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/ahc/SSLEngineSimpleDemo.java (original)
+++ mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/ahc/SSLEngineSimpleDemo.java Sun Jul 31 17:31:47 2011
@@ -64,7 +64,7 @@ import java.security.KeyStore;
* unwrap() ... ChangeCipherSpec
* unwrap() ... Finished
*
- * @version $Revision: $ $Date: $
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
public class SSLEngineSimpleDemo
{
Added: mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/EchoServerTest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/EchoServerTest.java?rev=1152600&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/EchoServerTest.java (added)
+++ mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/EchoServerTest.java Sun Jul 31 17:31:47 2011
@@ -0,0 +1,33 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.mina;
+
+import org.junit.Test;
+
+
+/**
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class EchoServerTest
+{
+ @Test
+ public void test()
+ {
+ }
+}
Modified: mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/core/AbstractIoFutureTest.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/core/AbstractIoFutureTest.java?rev=1152600&r1=1152599&r2=1152600&view=diff
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/core/AbstractIoFutureTest.java (original)
+++ mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/core/AbstractIoFutureTest.java Sun Jul 31 17:31:47 2011
@@ -23,9 +23,14 @@ import java.util.concurrent.ExecutionExc
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
+import org.hamcrest.BaseMatcher;
+import org.hamcrest.Description;
+import org.hamcrest.Matcher;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import org.junit.Test;
+import org.mockito.Matchers;
import static org.mockito.Matchers.anyBoolean;
import static org.mockito.Matchers.argThat;
import static org.mockito.Mockito.doReturn;
@@ -33,21 +38,17 @@ import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
-import org.hamcrest.BaseMatcher;
-import org.hamcrest.Description;
-import org.hamcrest.Matcher;
-import org.junit.Test;
-import org.mockito.Matchers;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
/**
* @author <a href="http://mina.apache.org">Apache MINA Project</a>
*/
-public class AbstractIoFutureTest {
+public class AbstractIoFutureTest
+{
@Test
- public void testSet() {
+ public void testSet()
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
assertFalse(future.isCancelled());
@@ -61,7 +62,8 @@ public class AbstractIoFutureTest {
@Test
@SuppressWarnings({"unchecked", "ThrowableResultOfMethodCallIgnored"})
- public void testSetListeners() {
+ public void testSetListeners()
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
IoFutureListener<Boolean> listener = mock(IoFutureListener.class);
@@ -81,7 +83,8 @@ public class AbstractIoFutureTest {
@Test
@SuppressWarnings({"unchecked", "ThrowableResultOfMethodCallIgnored"})
- public void testSetListenersAlreadySet() {
+ public void testSetListenersAlreadySet()
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
IoFutureListener<Boolean> listener = mock(IoFutureListener.class);
@@ -99,38 +102,52 @@ public class AbstractIoFutureTest {
}
@Test
- public void testTimedGet() {
+ public void testTimedGet()
+ {
final MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
assertFalse(future.isCancelled());
assertFalse(future.isDone());
- new Thread(new Runnable() {
+ new Thread(new Runnable()
+ {
@Override
- public void run() {
- try {
+ public void run()
+ {
+ try
+ {
Thread.sleep(1000);
future.setResult(true);
- } catch (InterruptedException ignored) {
+ }
+ catch (InterruptedException ignored)
+ {
}
}
}).start();
- try {
+ try
+ {
assertTrue(future.get(1, TimeUnit.DAYS));
assertFalse(future.isCancelled());
assertTrue(future.isDone());
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
fail("This future was not interrupted");
- } catch (ExecutionException ee) {
+ }
+ catch (ExecutionException ee)
+ {
fail("This future did not have an execution exception");
- } catch (TimeoutException e) {
+ }
+ catch (TimeoutException e)
+ {
fail("This future was not interrupted");
}
}
@Test
- public void testException() {
+ public void testException()
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
assertFalse(future.isCancelled());
@@ -141,12 +158,17 @@ public class AbstractIoFutureTest {
assertFalse(future.isCancelled());
assertTrue(future.isDone());
- try {
+ try
+ {
future.get();
fail("This future had an execution exception");
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
fail("This future was not interrupted");
- } catch (ExecutionException ee) {
+ }
+ catch (ExecutionException ee)
+ {
assertTrue(ee.getCause() instanceof NullPointerException);
}
@@ -156,7 +178,8 @@ public class AbstractIoFutureTest {
@Test
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "unchecked"})
- public void testExceptionListeners() {
+ public void testExceptionListeners()
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
IoFutureListener<Boolean> listener = mock(IoFutureListener.class);
@@ -176,7 +199,8 @@ public class AbstractIoFutureTest {
@Test
@SuppressWarnings({"ThrowableResultOfMethodCallIgnored", "unchecked"})
- public void testExceptionListenersExceptionAlreadySet() {
+ public void testExceptionListenersExceptionAlreadySet()
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
IoFutureListener<Boolean> listener = mock(IoFutureListener.class);
@@ -194,7 +218,8 @@ public class AbstractIoFutureTest {
}
@Test
- public void testImmediateExceptionForTimedGet() {
+ public void testImmediateExceptionForTimedGet()
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
assertFalse(future.isCancelled());
@@ -205,14 +230,21 @@ public class AbstractIoFutureTest {
assertFalse(future.isCancelled());
assertTrue(future.isDone());
- try {
+ try
+ {
future.get(1, TimeUnit.DAYS);
fail("This future had an execution exception");
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
fail("This future was not interrupted");
- } catch (ExecutionException ee) {
+ }
+ catch (ExecutionException ee)
+ {
assertTrue(ee.getCause() instanceof NullPointerException);
- } catch (TimeoutException e) {
+ }
+ catch (TimeoutException e)
+ {
fail("This future was not interrupted");
}
@@ -221,29 +253,42 @@ public class AbstractIoFutureTest {
}
@Test
- public void testTimedExceptionForTimedGet() {
+ public void testTimedExceptionForTimedGet()
+ {
final MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
assertFalse(future.isCancelled());
assertFalse(future.isDone());
- new Thread(new Runnable() {
+ new Thread(new Runnable()
+ {
@Override
- public void run() {
- try {
+ public void run()
+ {
+ try
+ {
Thread.sleep(1000);
future.setException(new NullPointerException());
- } catch (InterruptedException ignored) {
+ }
+ catch (InterruptedException ignored)
+ {
}
}
}).start();
- try {
+ try
+ {
assertTrue(future.get(1, TimeUnit.DAYS));
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
fail("This future was not interrupted");
- } catch (ExecutionException ee) {
- } catch (TimeoutException e) {
+ }
+ catch (ExecutionException ee)
+ {
+ }
+ catch (TimeoutException e)
+ {
fail("This future was not interrupted");
}
@@ -252,7 +297,8 @@ public class AbstractIoFutureTest {
}
@Test
- public void testCancel() throws Exception {
+ public void testCancel() throws Exception
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
doReturn(true).when(future).cancelOwner(anyBoolean());
@@ -265,15 +311,19 @@ public class AbstractIoFutureTest {
assertTrue(future.isCancelled());
assertTrue(future.isDone());
- try {
+ try
+ {
future.get();
fail("This future was canceled");
- } catch (CancellationException ignore) {
+ }
+ catch (CancellationException ignore)
+ {
}
}
@Test
- public void testCancelUncancelableOwner() throws Exception {
+ public void testCancelUncancelableOwner() throws Exception
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
doReturn(false).when(future).cancelOwner(anyBoolean());
@@ -285,7 +335,8 @@ public class AbstractIoFutureTest {
}
@Test
- public void testCancelFinishedFuture() throws Exception {
+ public void testCancelFinishedFuture() throws Exception
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
doReturn(true).when(future).cancelOwner(anyBoolean());
@@ -302,7 +353,8 @@ public class AbstractIoFutureTest {
@Test
@SuppressWarnings({"unchecked", "ThrowableResultOfMethodCallIgnored"})
- public void testCanceledListeners() {
+ public void testCanceledListeners()
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
doReturn(true).when(future).cancelOwner(anyBoolean());
IoFutureListener<Boolean> listener = mock(IoFutureListener.class);
@@ -323,7 +375,8 @@ public class AbstractIoFutureTest {
@Test
@SuppressWarnings({"unchecked", "ThrowableResultOfMethodCallIgnored"})
- public void testCanceledListenersAlreadySet() {
+ public void testCanceledListenersAlreadySet()
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
doReturn(true).when(future).cancelOwner(anyBoolean());
IoFutureListener<Boolean> listener = mock(IoFutureListener.class);
@@ -342,41 +395,55 @@ public class AbstractIoFutureTest {
}
@Test
- public void testTimeout() {
+ public void testTimeout()
+ {
MockAbstractIoFuture<Boolean> future = spy(new MockAbstractIoFuture<Boolean>());
assertFalse(future.isCancelled());
assertFalse(future.isDone());
- try {
+ try
+ {
future.get(10, TimeUnit.MILLISECONDS);
fail("This future has timed out");
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
fail("This future was not interrupted");
- } catch (ExecutionException ee) {
+ }
+ catch (ExecutionException ee)
+ {
fail("This future did not have an execution exception");
- } catch (TimeoutException e) {
+ }
+ catch (TimeoutException e)
+ {
}
}
- private static Matcher<Throwable> matchesExecutionException() {
- return new BaseMatcher<Throwable>() {
+ private static Matcher<Throwable> matchesExecutionException()
+ {
+ return new BaseMatcher<Throwable>()
+ {
@Override
- public boolean matches(Object item) {
- return item instanceof ExecutionException && ((ExecutionException) item).getCause() instanceof NullPointerException;
+ public boolean matches(Object item)
+ {
+ return item instanceof ExecutionException && ((ExecutionException)item).getCause() instanceof NullPointerException;
}
@Override
- public void describeTo(Description description) {
+ public void describeTo(Description description)
+ {
description.appendText("ExecutionException(NullPointerException)");
}
};
}
- public static class MockAbstractIoFuture<V> extends AbstractIoFuture<V> {
+ public static class MockAbstractIoFuture<V> extends AbstractIoFuture<V>
+ {
@Override
- protected boolean cancelOwner(boolean mayInterruptIfRunning) {
+ protected boolean cancelOwner(boolean mayInterruptIfRunning)
+ {
throw new UnsupportedOperationException();
}
}
Added: mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/echo/EchoNioServer.java
URL: http://svn.apache.org/viewvc/mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/echo/EchoNioServer.java?rev=1152600&view=auto
==============================================================================
--- mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/echo/EchoNioServer.java (added)
+++ mina/sandbox/adc/ahc/mina3/src/test/java/org/apache/mina/echo/EchoNioServer.java Sun Jul 31 17:31:47 2011
@@ -0,0 +1,31 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.mina.echo;
+
+import java.util.logging.Logger;
+
+
+/**
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class EchoNioServer
+{
+ private final static String CLASS_NAME = EchoNioServer.class.getName();
+ private final static Logger LOGGER = Logger.getLogger(CLASS_NAME);
+}