Author: jvermillard
Date: Tue Apr 17 06:01:19 2007
New Revision: 529588

URL: http://svn.apache.org/viewvc?view=rev&rev=529588
Log:
Unit test for the impossibility to find a serial port.

Added:
    mina/sandbox/jvermillard/serial/src/test/java/org/
    mina/sandbox/jvermillard/serial/src/test/java/org/apache/
    mina/sandbox/jvermillard/serial/src/test/java/org/apache/mina/
    mina/sandbox/jvermillard/serial/src/test/java/org/apache/mina/transport/
    
mina/sandbox/jvermillard/serial/src/test/java/org/apache/mina/transport/serial/
    
mina/sandbox/jvermillard/serial/src/test/java/org/apache/mina/transport/serial/OpenUnknonwSerialPort.java
   (with props)

Added: 
mina/sandbox/jvermillard/serial/src/test/java/org/apache/mina/transport/serial/OpenUnknonwSerialPort.java
URL: 
http://svn.apache.org/viewvc/mina/sandbox/jvermillard/serial/src/test/java/org/apache/mina/transport/serial/OpenUnknonwSerialPort.java?view=auto&rev=529588
==============================================================================
--- 
mina/sandbox/jvermillard/serial/src/test/java/org/apache/mina/transport/serial/OpenUnknonwSerialPort.java
 (added)
+++ 
mina/sandbox/jvermillard/serial/src/test/java/org/apache/mina/transport/serial/OpenUnknonwSerialPort.java
 Tue Apr 17 06:01:19 2007
@@ -0,0 +1,78 @@
+/*
+ *  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.serial;
+
+import junit.framework.TestCase;
+
+import org.apache.mina.common.ConnectFuture;
+import org.apache.mina.common.IdleStatus;
+import org.apache.mina.common.IoConnector;
+import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoSession;
+import org.apache.mina.transport.serial.SerialAddress.FlowControl;
+import org.apache.mina.transport.serial.SerialAddress.Parity;
+import org.apache.mina.transport.serial.SerialAddress.StopBits;
+
+/**
+ * A base implementation of [EMAIL PROTECTED] IoConnector}.
+ * 
+ * @author The Apache MINA Project ([EMAIL PROTECTED])
+ * @version $Rev: $, $Date: $
+ */
+public class OpenUnknonwSerialPort extends TestCase {
+    
+    
+    public void testFailingOpening() {
+        // trying to connect a really unkonw port
+        SerialConnector connector= new SerialConnector();
+        connector.setHandler(new IoHandler(){
+            public void exceptionCaught(IoSession session, Throwable cause) 
throws Exception {
+            }
+
+            public void messageReceived(IoSession session, Object message) 
throws Exception {
+            }
+
+            public void messageSent(IoSession session, Object message) throws 
Exception {
+            }
+
+            public void sessionClosed(IoSession session) throws Exception {
+            }
+
+            public void sessionCreated(IoSession session) throws Exception {
+            }
+
+            public void sessionIdle(IoSession session, IdleStatus status) 
throws Exception {
+            }
+
+            public void sessionOpened(IoSession session) throws Exception {
+            }
+        });
+        
+        ConnectFuture future=connector.connect(new 
SerialAddress("/dev/ttySXXX",38400,8,StopBits.BITS_1,Parity.NONE,FlowControl.NONE));
+        try {
+            future.getSession();
+        } catch(SerialPortUnavailableException e) {
+            return;
+        }
+        fail("The SerialPortUnavailableException exception wasn't thrown !");
+    }
+
+}

Propchange: 
mina/sandbox/jvermillard/serial/src/test/java/org/apache/mina/transport/serial/OpenUnknonwSerialPort.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date


Reply via email to