You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by nd...@apache.org on 2006/10/16 00:40:33 UTC
svn commit: r464315 - in
/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java:
org/apache/harmony/tests/internal/net/www/protocol/http/
org/apache/harmony/tests/java/net/ tests/api/java/io/
Author: ndbeyer
Date: Sun Oct 15 15:40:31 2006
New Revision: 464315
URL: http://svn.apache.org/viewvc?view=rev&rev=464315
Log:
Clean up tests, eliminate compiler warnings.
Modified:
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java
incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java?view=diff&rev=464315&r1=464314&r2=464315
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/internal/net/www/protocol/http/HttpURLConnectionTest.java Sun Oct 15 15:40:31 2006
@@ -57,6 +57,7 @@
return serverSocket.getLocalPort();
}
+ @Override
public void run() {
try {
synchronized (bound) {
@@ -82,6 +83,7 @@
super(name);
}
+ @Override
public void run() {
try {
Socket socket = serverSocket.accept();
@@ -132,6 +134,7 @@
this.proxy_port = proxy_port;
}
+ @Override
public java.util.List<Proxy> select(URI uri) {
Proxy proxy = Proxy.NO_PROXY;
if (("localhost".equals(uri.getHost()))
@@ -144,6 +147,7 @@
return result;
}
+ @Override
public void connectFailed(URI uri, SocketAddress sa, IOException ioe) {
// do nothing
}
@@ -257,6 +261,7 @@
public void testProxyAuthorization() throws Exception {
// Set up test Authenticator
Authenticator.setDefault(new Authenticator() {
+ @Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
"user", "password".toCharArray());
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java?view=diff&rev=464315&r1=464314&r2=464315
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/tests/java/net/URLConnectionTest.java Sun Oct 15 15:40:31 2006
@@ -112,15 +112,16 @@
// expected
}
}
-}
+
+ static class MockURLConnection extends URLConnection {
-class MockURLConnection extends URLConnection {
+ public MockURLConnection(URL url) {
+ super(url);
+ }
- public MockURLConnection(URL url) {
- super(url);
- }
-
- public void connect() {
- connected = true;
+ @Override
+ public void connect() {
+ connected = true;
+ }
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java?view=diff&rev=464315&r1=464314&r2=464315
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/io/BufferedInputStreamTest.java Sun Oct 15 15:40:31 2006
@@ -19,32 +19,28 @@
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
-
+import java.io.OutputStream;
+import junit.framework.TestCase;
import tests.support.Support_PlatformFile;
-public class BufferedInputStreamTest extends junit.framework.TestCase {
+public class BufferedInputStreamTest extends TestCase {
public String fileName;
- private java.io.BufferedInputStream is;
+ private BufferedInputStream is;
- private java.io.FileInputStream isFile;
+ private FileInputStream isFile;
byte[] ibuf = new byte[4096];
public String fileString = "Test_All_Tests\nTest_BufferedInputStream\nTest_java_io_BufferedOutputStream\nTest_java_io_ByteArrayInputStream\nTest_java_io_ByteArrayOutputStream\nTest_java_io_DataInputStream\nTest_java_io_File\nTest_java_io_FileDescriptor\nTest_java_io_FileInputStream\nTest_java_io_FileNotFoundException\nTest_java_io_FileOutputStream\nTest_java_io_FilterInputStream\nTest_java_io_FilterOutputStream\nTest_java_io_InputStream\nTest_java_io_IOException\nTest_java_io_OutputStream\nTest_java_io_PrintStream\nTest_java_io_RandomAccessFile\nTest_java_io_SyncFailedException\nTest_java_lang_AbstractMethodError\nTest_java_lang_ArithmeticException\nTest_java_lang_ArrayIndexOutOfBoundsException\nTest_java_lang_ArrayStoreException\nTest_java_lang_Boolean\nTest_java_lang_Byte\nTest_java_lang_Character\nTest_java_lang_Class\nTest_java_lang_ClassCastException\nTest_java_lang_ClassCircularityError\nTest_java_lang_ClassFormatError\nTest_java_lang_ClassLoader\nTest_java_lang_Class
NotFoundException\nTest_java_lang_CloneNotSupportedException\nTest_java_lang_Double\nTest_java_lang_Error\nTest_java_lang_Exception\nTest_java_lang_ExceptionInInitializerError\nTest_java_lang_Float\nTest_java_lang_IllegalAccessError\nTest_java_lang_IllegalAccessException\nTest_java_lang_IllegalArgumentException\nTest_java_lang_IllegalMonitorStateException\nTest_java_lang_IllegalThreadStateException\nTest_java_lang_IncompatibleClassChangeError\nTest_java_lang_IndexOutOfBoundsException\nTest_java_lang_InstantiationError\nTest_java_lang_InstantiationException\nTest_java_lang_Integer\nTest_java_lang_InternalError\nTest_java_lang_InterruptedException\nTest_java_lang_LinkageError\nTest_java_lang_Long\nTest_java_lang_Math\nTest_java_lang_NegativeArraySizeException\nTest_java_lang_NoClassDefFoundError\nTest_java_lang_NoSuchFieldError\nTest_java_lang_NoSuchMethodError\nTest_java_lang_NullPointerException\nTest_java_lang_Number\nTest_java_lang_NumberFormatException\nTest_java_lang_Obj
ect\nTest_java_lang_OutOfMemoryError\nTest_java_lang_RuntimeException\nTest_java_lang_SecurityManager\nTest_java_lang_Short\nTest_java_lang_StackOverflowError\nTest_java_lang_String\nTest_java_lang_StringBuffer\nTest_java_lang_StringIndexOutOfBoundsException\nTest_java_lang_System\nTest_java_lang_Thread\nTest_java_lang_ThreadDeath\nTest_java_lang_ThreadGroup\nTest_java_lang_Throwable\nTest_java_lang_UnknownError\nTest_java_lang_UnsatisfiedLinkError\nTest_java_lang_VerifyError\nTest_java_lang_VirtualMachineError\nTest_java_lang_vm_Image\nTest_java_lang_vm_MemorySegment\nTest_java_lang_vm_ROMStoreException\nTest_java_lang_vm_VM\nTest_java_lang_Void\nTest_java_net_BindException\nTest_java_net_ConnectException\nTest_java_net_DatagramPacket\nTest_java_net_DatagramSocket\nTest_java_net_DatagramSocketImpl\nTest_java_net_InetAddress\nTest_java_net_NoRouteToHostException\nTest_java_net_PlainDatagramSocketImpl\nTest_java_net_PlainSocketImpl\nTest_java_net_Socket\nTest_java_net_SocketE
xception\nTest_java_net_SocketImpl\nTest_java_net_SocketInputStream\nTest_java_net_SocketOutputStream\nTest_java_net_UnknownHostException\nTest_java_util_ArrayEnumerator\nTest_java_util_Date\nTest_java_util_EventObject\nTest_java_util_HashEnumerator\nTest_java_util_Hashtable\nTest_java_util_Properties\nTest_java_util_ResourceBundle\nTest_java_util_tm\nTest_java_util_Vector\n";
/**
- * @tests java.io.BufferedInputStream#BufferedInputStream(java.io.InputStream)
- */
- public void test_ConstructorLjava_io_InputStream() {
- // Test for method java.io.BufferedInputStream(java.io.InputStream)
- assertTrue("Cannot run any tests without one", true);
- }
-
- /**
* @tests java.io.BufferedInputStream#BufferedInputStream(java.io.InputStream,
* int)
*/
@@ -53,7 +49,7 @@
boolean exceptionFired = false;
try {
// Create buffer with exact size of file
- is = new java.io.BufferedInputStream(isFile, this.fileString
+ is = new BufferedInputStream(isFile, this.fileString
.length());
// Ensure buffer gets filled by evaluating one read
is.read();
@@ -68,12 +64,12 @@
// is.read should now throw an exception because it will have to
// be filled.
is.read();
- } catch (java.io.IOException e) {
+ } catch (IOException e) {
exceptionFired = true;
}
assertTrue("Exception should have been triggered by read()",
exceptionFired);
- } catch (java.io.IOException e) {
+ } catch (IOException e) {
fail("Exception during test_1_Constructor");
}
}
@@ -86,7 +82,7 @@
try {
assertTrue("Returned incorrect number of available bytes", is
.available() == fileString.length());
- } catch (java.io.IOException e) {
+ } catch (IOException e) {
fail("Exception during available test");
}
@@ -146,13 +142,14 @@
assertTrue("Failed to mark correct position", new String(buf1, 0,
buf1.length).equals(new String(buf2, 0, buf2.length)));
- } catch (java.io.IOException e) {
+ } catch (IOException e) {
fail("Exception during mark test");
}
byte[] bytes = new byte[256];
- for (int i = 0; i < 256; i++)
- bytes[i] = (byte) i;
+ for (int i = 0; i < 256; i++) {
+ bytes[i] = (byte) i;
+ }
InputStream in = new BufferedInputStream(
new ByteArrayInputStream(bytes), 12);
try {
@@ -196,13 +193,14 @@
int c = is.read();
assertTrue("read returned incorrect char", c == fileString
.charAt(0));
- } catch (java.io.IOException e) {
+ } catch (IOException e) {
fail("Exception during read test" + e.toString());
}
byte[] bytes = new byte[256];
- for (int i = 0; i < 256; i++)
- bytes[i] = (byte) i;
+ for (int i = 0; i < 256; i++) {
+ bytes[i] = (byte) i;
+ }
InputStream in = new BufferedInputStream(
new ByteArrayInputStream(bytes), 12);
try {
@@ -276,7 +274,7 @@
assertTrue("Failed to read correct data", new String(buf1, 0,
buf1.length).equals(fileString.substring(3000, 3100)));
- } catch (java.io.IOException e) {
+ } catch (IOException e) {
fail("Exception during read test");
}
@@ -285,24 +283,30 @@
byte[] contents = new byte[size];
- public int read() throws IOException {
- if (pos >= size)
- throw new IOException("Read past end of data");
+ @Override
+ public int read() throws IOException {
+ if (pos >= size) {
+ throw new IOException("Read past end of data");
+ }
return contents[pos++];
}
- public int read(byte[] buf, int off, int len) throws IOException {
- if (pos >= size)
- throw new IOException("Read past end of data");
+ @Override
+ public int read(byte[] buf, int off, int len) throws IOException {
+ if (pos >= size) {
+ throw new IOException("Read past end of data");
+ }
int toRead = len;
- if (toRead > available())
- toRead = available();
+ if (toRead > available()) {
+ toRead = available();
+ }
System.arraycopy(contents, pos, buf, off, toRead);
pos += toRead;
return toRead;
}
- public int available() {
+ @Override
+ public int available() {
return size - pos;
}
});
@@ -340,7 +344,7 @@
}
bIn.reset();
- } catch (java.io.IOException e) {
+ } catch (IOException e) {
fail("Exception during reset test");
}
}
@@ -388,7 +392,7 @@
is.reset();
assertTrue("Failed to skip to correct position", new String(buf1,
0, buf1.length).equals(fileString.substring(1000, 1010)));
- } catch (java.io.IOException e) {
+ } catch (IOException e) {
fail("Exception during skip test");
}
@@ -406,23 +410,25 @@
* Sets up the fixture, for example, open a network connection. This method
* is called before a test is executed.
*/
- protected void setUp() {
+ @Override
+ protected void setUp() {
try {
fileName = System.getProperty("user.dir");
String separator = System.getProperty("file.separator");
- if (fileName.charAt(fileName.length() - 1) == separator.charAt(0))
- fileName = Support_PlatformFile.getNewPlatformFile(fileName,
+ if (fileName.charAt(fileName.length() - 1) == separator.charAt(0)) {
+ fileName = Support_PlatformFile.getNewPlatformFile(fileName,
"input.tst");
- else
- fileName = Support_PlatformFile.getNewPlatformFile(fileName
+ } else {
+ fileName = Support_PlatformFile.getNewPlatformFile(fileName
+ separator, "input.tst");
- java.io.OutputStream fos = new java.io.FileOutputStream(fileName);
+ }
+ OutputStream fos = new FileOutputStream(fileName);
fos.write(fileString.getBytes());
fos.close();
- isFile = new java.io.FileInputStream(fileName);
- is = new java.io.BufferedInputStream(isFile);
- } catch (java.io.IOException e) {
+ isFile = new FileInputStream(fileName);
+ is = new BufferedInputStream(isFile);
+ } catch (IOException e) {
System.out.println("Exception during setup");
e.printStackTrace();
}
@@ -433,7 +439,8 @@
* Tears down the fixture, for example, close a network connection. This
* method is called after a test is executed.
*/
- protected void tearDown() {
+ @Override
+ protected void tearDown() {
try {
is.close();
@@ -441,7 +448,7 @@
System.out.println("Exception during BIS tearDown");
}
try {
- java.io.File f = new java.io.File(fileName);
+ File f = new File(fileName);
f.delete();
} catch (Exception e) {
System.out.println("Exception during BIS tearDown");