You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mina.apache.org by jv...@apache.org on 2012/12/29 15:19:26 UTC
svn commit: r1426769 - in /mina/mina/trunk/core/src:
main/java/org/apache/mina/service/AbstractIoService.java
test/java/org/apache/mina/transport/tcp/NioTcpClientTimeoutTest.java
Author: jvermillard
Date: Sat Dec 29 14:19:26 2012
New Revision: 1426769
URL: http://svn.apache.org/viewvc?rev=1426769&view=rev
Log:
failing connect timeout test
Added:
mina/mina/trunk/core/src/test/java/org/apache/mina/transport/tcp/NioTcpClientTimeoutTest.java
Modified:
mina/mina/trunk/core/src/main/java/org/apache/mina/service/AbstractIoService.java
Modified: mina/mina/trunk/core/src/main/java/org/apache/mina/service/AbstractIoService.java
URL: http://svn.apache.org/viewvc/mina/mina/trunk/core/src/main/java/org/apache/mina/service/AbstractIoService.java?rev=1426769&r1=1426768&r2=1426769&view=diff
==============================================================================
--- mina/mina/trunk/core/src/main/java/org/apache/mina/service/AbstractIoService.java (original)
+++ mina/mina/trunk/core/src/main/java/org/apache/mina/service/AbstractIoService.java Sat Dec 29 14:19:26 2012
@@ -48,6 +48,9 @@ public abstract class AbstractIoService
/** The high level business logic */
private IoHandler handler;
+ /** Filters chain */
+ private IoFilter[] filters = new IoFilter[0];
+
/** used for executing IoHandler event in another pool of thread (not in the low level I/O one) */
protected final IoHandlerExecutor ioHandlerExecutor;
@@ -208,8 +211,6 @@ public abstract class AbstractIoService
}
}
- private IoFilter[] filters;
-
/**
* {@inheritDoc}
*/
Added: mina/mina/trunk/core/src/test/java/org/apache/mina/transport/tcp/NioTcpClientTimeoutTest.java
URL: http://svn.apache.org/viewvc/mina/mina/trunk/core/src/test/java/org/apache/mina/transport/tcp/NioTcpClientTimeoutTest.java?rev=1426769&view=auto
==============================================================================
--- mina/mina/trunk/core/src/test/java/org/apache/mina/transport/tcp/NioTcpClientTimeoutTest.java (added)
+++ mina/mina/trunk/core/src/test/java/org/apache/mina/transport/tcp/NioTcpClientTimeoutTest.java Sat Dec 29 14:19:26 2012
@@ -0,0 +1,61 @@
+/*
+ * 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.transport.tcp;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.ServerSocket;
+import java.util.concurrent.ExecutionException;
+
+import org.apache.mina.api.IoFuture;
+import org.apache.mina.api.IoSession;
+import org.apache.mina.transport.nio.NioTcpClient;
+import org.junit.Assert;
+import org.junit.Test;
+
+/**
+ * Test if the {@link NioTcpClient} handle correctly session connection timeout.
+ *
+ * @author <a href="http://mina.apache.org">Apache MINA Project</a>
+ */
+public class NioTcpClientTimeoutTest {
+
+ @Test
+ public void timeout() throws IOException, InterruptedException {
+ NioTcpClient client = new NioTcpClient();
+ client.setConnectTimeoutMillis(1000);
+
+ ServerSocket server = new ServerSocket();
+ try {
+ server.bind(null);
+ IoFuture<IoSession> cf = client.connect(new InetSocketAddress("localhost", server.getLocalPort()));
+ Thread.sleep(5000);
+ IoSession session = cf.get();
+ System.err.println(session);
+ Assert.fail();
+ } catch (ExecutionException ex) {
+ // happy
+ ex.printStackTrace();
+ } finally {
+ server.close();
+ }
+
+ }
+}