You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by gh...@apache.org on 2006/06/23 14:59:48 UTC

svn commit: r416710 - in /incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels: AllTests.java SelectableChannelTest.java

Author: gharley
Date: Fri Jun 23 05:59:47 2006
New Revision: 416710

URL: http://svn.apache.org/viewvc?rev=416710&view=rev
Log:
HARMONY 633 : Java 5 Enhancement: tests for java.nio.channels.SelectableChannel are missing

Added:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SelectableChannelTest.java   (with props)
Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/AllTests.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/AllTests.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/AllTests.java?rev=416710&r1=416709&r2=416710&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/AllTests.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/AllTests.java Fri Jun 23 05:59:47 2006
@@ -36,6 +36,7 @@
         suite.addTestSuite(SelectionKeyTest.class);
         suite.addTestSuite(SelectorTest.class);
         suite.addTestSuite(AlreadyConnectedExceptionTest.class);
+        suite.addTestSuite(SelectableChannelTest.class);
         //$JUnit-END$
         return suite;
     }

Added: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SelectableChannelTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SelectableChannelTest.java?rev=416710&view=auto
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SelectableChannelTest.java (added)
+++ incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SelectableChannelTest.java Fri Jun 23 05:59:47 2006
@@ -0,0 +1,88 @@
+/* Copyright 2006 The Apache Software Foundation or its licensors, as applicable
+ * 
+ * Licensed 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.harmony.tests.java.nio.channels;
+
+import java.io.IOException;
+import java.nio.channels.ClosedChannelException;
+import java.nio.channels.SelectableChannel;
+import java.nio.channels.SelectionKey;
+import java.nio.channels.Selector;
+import java.nio.channels.spi.SelectorProvider;
+import junit.framework.TestCase;
+
+/*
+ * Tests for SelectableChannel
+ */
+public class SelectableChannelTest extends TestCase {
+
+    /**
+     * @tests SelectableChannel#register(Selector, int)
+     */
+    public void test_register_LSelectorI() throws IOException {
+        MockSelectableChannel msc = new MockSelectableChannel();
+        // Verify that calling register(Selector, int) leads to the method
+        // register(Selector, int, Object) being called with a null value 
+        // for the third argument.
+        msc.register(Selector.open(), SelectionKey.OP_ACCEPT);
+        assertTrue(msc.isCalled);
+    }
+
+    private class MockSelectableChannel extends SelectableChannel {
+
+        private boolean isCalled = false;
+
+        public Object blockingLock() {
+            return null;
+        }
+
+        public SelectableChannel configureBlocking(boolean block)
+                throws IOException {
+            return null;
+        }
+
+        public boolean isBlocking() {
+            return false;
+        }
+
+        public boolean isRegistered() {
+            return false;
+        }
+
+        public SelectionKey keyFor(Selector sel) {
+            return null;
+        }
+
+        public SelectorProvider provider() {
+            return null;
+        }
+
+        public SelectionKey register(Selector sel, int ops, Object att)
+                throws ClosedChannelException {
+            if (null == att) {
+                isCalled = true;
+            }
+            return null;
+        }
+
+        public int validOps() {
+            return 0;
+        }
+
+        protected void implCloseChannel() throws IOException {
+            // empty
+        }
+    }
+}

Propchange: incubator/harmony/enhanced/classlib/trunk/modules/nio/src/test/java/org/apache/harmony/tests/java/nio/channels/SelectableChannelTest.java
------------------------------------------------------------------------------
    svn:eol-style = native