harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From telli...@apache.org
Subject svn commit: r615900 - /harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java
Date Mon, 28 Jan 2008 14:50:04 GMT
Author: tellison
Date: Mon Jan 28 06:50:02 2008
New Revision: 615900

URL: http://svn.apache.org/viewvc?rev=615900&view=rev
Log:
Rewrite readable byte channel constructor test from socket-based to file based
and remove a reference to the port manager.

Modified:
    harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java

Modified: harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java?rev=615900&r1=615899&r2=615900&view=diff
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/luni/src/test/api/common/org/apache/harmony/luni/tests/java/util/ScannerTest.java
Mon Jan 28 06:50:02 2008
@@ -18,6 +18,7 @@
 import java.io.Closeable;
 import java.io.EOFException;
 import java.io.File;
+import java.io.FileInputStream;
 import java.io.FileNotFoundException;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -34,7 +35,6 @@
 import java.nio.CharBuffer;
 import java.nio.channels.FileChannel;
 import java.nio.channels.ReadableByteChannel;
-import java.nio.channels.ServerSocketChannel;
 import java.nio.channels.SocketChannel;
 import java.nio.charset.Charset;
 import java.util.Arrays;
@@ -45,8 +45,6 @@
 import java.util.regex.MatchResult;
 import java.util.regex.Pattern;
 
-import tests.support.Support_PortManager;
-
 import junit.framework.TestCase;
 
 public class ScannerTest extends TestCase {
@@ -271,7 +269,25 @@
             // expected
         }
 
-        // TODO: test if the default charset is used.
+        // Test if the default charset is used.
+        String sampleData = "1 2 3 4 5 6 7 8 9 10";
+        File tempFile = File.createTempFile("harmony", "test");
+        tempFile.deleteOnExit();
+        FileOutputStream os = new FileOutputStream(tempFile);
+        os.write(sampleData.getBytes());
+        os.close();
+
+        FileInputStream is = new FileInputStream(tempFile);
+        FileChannel channel = is.getChannel();
+
+        Scanner s = new Scanner(channel);
+        int count = 0;
+        while (s.hasNextInt()) {
+            s.nextInt();
+            count++;
+        }
+        channel.close();
+        assertEquals(10, count);
     }
 
     /**
@@ -5676,31 +5692,4 @@
             // do nothing
         }
     }
-    
-    /**
-     * @tests java.util.Scanner#Scanner(ReadableByteChannel)
-     */   
-    public void test_Constructor_LReadableByteChannel()
-			throws IOException {
-		InetSocketAddress localAddr = new InetSocketAddress("127.0.0.1",
-				Support_PortManager.getNextPort());
-		ServerSocketChannel ssc = ServerSocketChannel.open();
-		ssc.socket().bind(localAddr);
-
-		SocketChannel sc = SocketChannel.open();
-		sc.connect(localAddr);
-		sc.configureBlocking(false);
-		assertFalse(sc.isBlocking());
-
-		ssc.accept().close();
-		ssc.close();
-		assertFalse(sc.isBlocking());
-
-		Scanner s = new Scanner(sc);
-		while (s.hasNextInt()) {
-			s.nextInt();
-		}
-
-		sc.close();
-	}
 }



Mime
View raw message