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/17 04:17:51 UTC
svn commit: r464769 [1/2] - in
/incubator/harmony/enhanced/classlib/trunk/support/src/test/java:
javax/swing/ org/apache/harmony/testframework/serialization/ tests/support/
tests/support/resource/ tests/util/
Author: ndbeyer
Date: Mon Oct 16 19:17:46 2006
New Revision: 464769
URL: http://svn.apache.org/viewvc?view=rev&rev=464769
Log:
Clean up test support project's compiler warnings.
Modified:
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/javax/swing/BasicSwingTestCase.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/javax/swing/SwingTestCase.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_AvailTest.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_BitSet.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_CollectionTest.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Configuration.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_DecimalFormat.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_DummyPKCS12Keystore.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Exec.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Format.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_GetLocal.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpServer.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpServerSocket.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpSocket.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpTests.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ListTest.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_MapTest2.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_MessageFormat.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PermissionCollection.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PortManager.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderJCE.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderRSA.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderTrust.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Proxy_ParentException.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Proxy_SubException.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_SetTest.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_SimpleDateFormat.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_StringReader.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_StringWriter.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_TestProvider.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_TestResource.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_TestResource_en.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_TestResource_en_US.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_TestResource_fr.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_TestResource_fr_FR.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_TestResource_fr_FR_VAR.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_TimeZone.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_URLConnector.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_UnmodifiableCollectionTest.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_UnmodifiableMapTest.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/resource/Support_Resources.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/util/CallVerificationStack.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/util/SerializationTester.java
incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/util/SomeTests.java
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/javax/swing/BasicSwingTestCase.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/javax/swing/BasicSwingTestCase.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/javax/swing/BasicSwingTestCase.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/javax/swing/BasicSwingTestCase.java Mon Oct 16 19:17:46 2006
@@ -69,12 +69,14 @@
}
}
+ @Override
protected void setUp() throws Exception {
timeoutDelay = defaultTimeoutDelay;
previousLF = UIManager.getLookAndFeel();
super.setUp();
}
+ @Override
protected void tearDown() throws Exception {
super.tearDown();
UIManager.getDefaults().clear();
@@ -125,6 +127,7 @@
return null;
}
+ @Override
public void runBare() throws Throwable {
final Throwable[] exception = new Throwable[1];
Thread thread = new Thread(new Runnable() {
@@ -138,6 +141,7 @@
thread.start();
thread.join(timeoutDelay);
if (thread.isAlive()) {
+ // TODO is this stop necessary?
thread.stop();
fail("Test interrupted due timeout");
}
@@ -212,6 +216,7 @@
}
private class FixedFontMetrics extends FontMetrics {
+ private static final long serialVersionUID = 1L;
private final int charWidth;
private final int charHeight;
@@ -227,37 +232,44 @@
this.charHeight = charHeight;
}
+ @Override
public int stringWidth(final String str) {
return ((str == null || str.equals("")) ? 0 : str.length() * charWidth);
}
+ @Override
public int charWidth(final int ch) {
return charWidth;
}
+ @Override
public int charWidth(final char ch) {
return charWidth;
}
+ @Override
public int getAscent() {
return charWidth;
}
+ @Override
public int getDescent() {
return charWidth*2;
}
+ @Override
public int getLeading() {
return 2;
}
+ @Override
public int getHeight() {
return charHeight;
}
};
protected abstract class ExceptionalCase {
- private Class clazz;
+ private Class<?> clazz;
private String msg;
public abstract void exceptionalAction() throws Exception;
@@ -265,12 +277,12 @@
public ExceptionalCase() {
}
- public ExceptionalCase(String msg, Class clazz) {
+ public ExceptionalCase(String msg, Class<?> clazz) {
this.msg = msg;
this.clazz = clazz;
}
- public Class expectedExceptionClass() {
+ public Class<?> expectedExceptionClass() {
return clazz;
}
@@ -280,39 +292,45 @@
}
protected abstract class BadLocationCase extends ExceptionalCase {
- public Class expectedExceptionClass() {
+ @Override
+ public Class<?> expectedExceptionClass() {
return BadLocationException.class;
}
}
protected abstract class ClassCastCase extends ExceptionalCase {
- public Class expectedExceptionClass() {
+ @Override
+ public Class<?> expectedExceptionClass() {
return ClassCastException.class;
}
}
protected abstract class IllegalArgumentCase extends ExceptionalCase {
- public Class expectedExceptionClass() {
+ @Override
+ public Class<?> expectedExceptionClass() {
return IllegalArgumentException.class;
}
}
protected abstract class NullPointerCase extends ExceptionalCase {
- public Class expectedExceptionClass() {
+ @Override
+ public Class<?> expectedExceptionClass() {
return NullPointerException.class;
}
}
protected abstract class StringIndexOutOfBoundsCase extends ExceptionalCase {
- public Class expectedExceptionClass() {
+ @Override
+ public Class<?> expectedExceptionClass() {
return StringIndexOutOfBoundsException.class;
}
}
protected static class EventsController implements Serializable {
+ private static final long serialVersionUID = 1L;
private boolean isVerbose;
private Object lastEventHappened;
- private final Map events = new HashMap();
+ private final Map<Object, Object> events = new HashMap<Object, Object>();
protected EventsController() {
this(false);
@@ -343,7 +361,7 @@
if (!isChanged() || key == null) {
return false;
}
- for (Iterator it = events.keySet().iterator(); it.hasNext(); ) {
+ for (Iterator<Object> it = events.keySet().iterator(); it.hasNext(); ) {
String property = (String)it.next();
if (key.equals(property)) {
return true;
@@ -372,8 +390,8 @@
public int findMe(final Object[] listenersArray) {
int found = 0;
- for (int i = 0; i < listenersArray.length; i++) {
- if (listenersArray[i] == this) {
+ for (Object element : listenersArray) {
+ if (element == this) {
found++;
}
}
@@ -383,6 +401,7 @@
}
protected class PropertyChangeController extends EventsController implements PropertyChangeListener {
+ private static final long serialVersionUID = 1L;
public PropertyChangeController() {
super(false);
}
@@ -422,6 +441,8 @@
}
protected class ChangeController extends EventsController implements ChangeListener {
+ private static final long serialVersionUID = 1L;
+
public ChangeController() {
super(false);
}
@@ -541,14 +562,14 @@
}
}
- protected boolean hasListener(final EventListener[] listeners, final Class listenerClass) {
+ protected boolean hasListener(final EventListener[] listeners, final Class<?> listenerClass) {
return getListener(listeners, listenerClass) != null;
}
- protected EventListener getListener(final EventListener[] listeners, final Class listenerClass) {
- for (int i = 0; i < listeners.length; i++) {
- if (listeners[i].getClass().isAssignableFrom(listenerClass)) {
- return listeners[i];
+ protected EventListener getListener(final EventListener[] listeners, final Class<?> listenerClass) {
+ for (EventListener element : listeners) {
+ if (element.getClass().isAssignableFrom(listenerClass)) {
+ return element;
}
}
@@ -573,7 +594,7 @@
return "JUnit".equals(f.getTitle());
}
- protected Component findComponent(final Container root, final Class findClass, final boolean exactClassMatch) {
+ protected Component findComponent(final Container root, final Class<?> findClass, final boolean exactClassMatch) {
if (exactClassMatch && findClass == root.getClass()
|| !exactClassMatch && findClass.isAssignableFrom(root.getClass())) {
@@ -618,8 +639,7 @@
private void closeAllFrames() {
Frame[] frames = Frame.getFrames();
- for (int i = 0; i < frames.length; i++) {
- Frame f = frames[i];
+ for (Frame f : frames) {
if (f.isDisplayable()) {
if (!isSystemWindow(f)) {
f.dispose();
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/javax/swing/SwingTestCase.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/javax/swing/SwingTestCase.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/javax/swing/SwingTestCase.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/javax/swing/SwingTestCase.java Mon Oct 16 19:17:46 2006
@@ -36,6 +36,7 @@
super(name);
}
+ @Override
protected Throwable runBareImpl() throws Throwable {
final Throwable[] exception = new Throwable[1];
EventQueue.invokeAndWait(new Runnable() {
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/org/apache/harmony/testframework/serialization/SerializationTest.java Mon Oct 16 19:17:46 2006
@@ -25,7 +25,6 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
-import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -85,7 +84,7 @@
*/
public static final String GOLDEN_PATH = "RESOURCE_DIR";
- private static String outputPath = System.getProperty(GOLDEN_PATH,
+ private static final String outputPath = System.getProperty(GOLDEN_PATH,
"test/common/unit");
/**
@@ -105,6 +104,7 @@
/**
* Depending on testing mode, produces golden files or performs testing.
*/
+ @Override
public void runBare() throws Throwable {
if (mode != null && mode.equals(SERIAL_REFERENCE_MODE)) {
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_AvailTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_AvailTest.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_AvailTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_AvailTest.java Mon Oct 16 19:17:46 2006
@@ -51,21 +51,24 @@
int c = 0;
while (true) {
c = myin.read();
- if (c == ' ' || c == -1)
- break;
+ if (c == ' ' || c == -1) {
+ break;
+ }
input.append((char) c);
}
expected = Integer.parseInt(input.toString());
// Verify correct value at start of read
- if (real != expected)
- output = "Failed avail test1 - " + real + "!=" + expected;
+ if (real != expected) {
+ output = "Failed avail test1 - " + real + "!=" + expected;
+ }
c = 0;
input = new StringBuffer("");
while (true) {
c = myin.read();
- if (c == ' ' || c == -1)
- break;
+ if (c == ' ' || c == -1) {
+ break;
+ }
input.append((char) c);
}
expected = Integer.parseInt(input.toString());
@@ -78,10 +81,11 @@
// Verify value at end of reading
// loop to EOF, then check if available = 0
// replace this:
- for (int i = 0; i < 5; i++)
- myin.read();
+ for (int i = 0; i < 5; i++) {
+ myin.read();
// with:
// while(myin.read() != -1);
+ }
// The current for loop reads exactly to the end
// of the data, but is dependent on knowing the length of the data
@@ -89,8 +93,9 @@
expected = 0;
real = myin.available();
- if (real != 0)
- output = "Failed avail test3 - " + real + "!=" + expected;
+ if (real != 0) {
+ output = "Failed avail test3 - " + real + "!=" + expected;
+ }
} catch (IOException e) {
output = "IOException during available() testing";
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_BitSet.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_BitSet.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_BitSet.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_BitSet.java Mon Oct 16 19:17:46 2006
@@ -47,10 +47,11 @@
* @see #set
*/
public Support_BitSet(int nbits) {
- if (nbits >= 0)
- bits = new long[(nbits / ELM_SIZE) + (nbits % ELM_SIZE > 0 ? 1 : 0)];
- else
- throw new NegativeArraySizeException();
+ if (nbits >= 0) {
+ bits = new long[(nbits / ELM_SIZE) + (nbits % ELM_SIZE > 0 ? 1 : 0)];
+ } else {
+ throw new NegativeArraySizeException();
+ }
}
/**
@@ -65,12 +66,14 @@
*/
public void clear(int pos) {
if (pos >= 0) {
- if (pos < bits.length * ELM_SIZE)
- bits[pos / ELM_SIZE] &= ~(1L << (pos % ELM_SIZE));
- else
- growBits(pos); // Bit is cleared for free if we have to grow
- } else
- throw new IndexOutOfBoundsException("Negative index specified");
+ if (pos < bits.length * ELM_SIZE) {
+ bits[pos / ELM_SIZE] &= ~(1L << (pos % ELM_SIZE));
+ } else {
+ growBits(pos); // Bit is cleared for free if we have to grow
+ }
+ } else {
+ throw new IndexOutOfBoundsException("Negative index specified");
+ }
}
/**
@@ -88,11 +91,12 @@
*/
public boolean get(int pos) {
if (pos >= 0) {
- if (pos < bits.length * ELM_SIZE)
- return (bits[pos / ELM_SIZE] & (1L << (pos % ELM_SIZE))) != 0;
+ if (pos < bits.length * ELM_SIZE) {
+ return (bits[pos / ELM_SIZE] & (1L << (pos % ELM_SIZE))) != 0;
+ }
return false;
- } else
- throw new IndexOutOfBoundsException("Negative index specified");
+ }
+ throw new IndexOutOfBoundsException("Negative index specified");
}
/**
@@ -122,11 +126,13 @@
*/
public void set(int pos) {
if (pos >= 0) {
- if (pos >= bits.length * ELM_SIZE)
- growBits(pos);
+ if (pos >= bits.length * ELM_SIZE) {
+ growBits(pos);
+ }
bits[pos / ELM_SIZE] |= 1L << (pos % ELM_SIZE);
- } else
- throw new IndexOutOfBoundsException("Negative index specified");
+ } else {
+ throw new IndexOutOfBoundsException("Negative index specified");
+ }
}
/**
@@ -148,20 +154,22 @@
*
* @return A comma delimited list of the indices of all bits that are set.
*/
- public String toString() {
+ @Override
+ public String toString() {
StringBuffer sb = new StringBuffer(bits.length / 2);
int bitCount = 0;
sb.append('{');
boolean comma = false;
- for (int i = 0; i < bits.length; i++) {
- if (bits[i] == 0) {
+ for (long element : bits) {
+ if (element == 0) {
bitCount += ELM_SIZE;
continue;
}
for (int j = 0; j < ELM_SIZE; j++) {
- if (((bits[i] & (1L << j)) != 0)) {
- if (comma)
- sb.append(", ");
+ if (((element & (1L << j)) != 0)) {
+ if (comma) {
+ sb.append(", ");
+ }
sb.append(bitCount);
comma = true;
}
@@ -178,14 +186,17 @@
*/
public int length() {
int idx = bits.length - 1;
- while (idx >= 0 && bits[idx] == 0)
- --idx;
- if (idx == -1)
- return 0;
+ while (idx >= 0 && bits[idx] == 0) {
+ --idx;
+ }
+ if (idx == -1) {
+ return 0;
+ }
int i = ELM_SIZE - 1;
long val = bits[idx];
- while ((val & (1L << i)) == 0 && i > 0)
- i--;
+ while ((val & (1L << i)) == 0 && i > 0) {
+ i--;
+ }
return idx * ELM_SIZE + i + 1;
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_CollectionTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_CollectionTest.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_CollectionTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_CollectionTest.java Mon Oct 16 19:17:46 2006
@@ -25,22 +25,23 @@
*/
public class Support_CollectionTest extends junit.framework.TestCase {
- Collection col; // must contain the Integers 0 to 99
+ Collection<Integer> col; // must contain the Integers 0 to 99
public Support_CollectionTest(String p1) {
super(p1);
}
- public Support_CollectionTest(String p1, Collection c) {
+ public Support_CollectionTest(String p1, Collection<Integer> c) {
super(p1);
col = c;
}
- public void runTest() {
+ @Override
+ public void runTest() {
new Support_UnmodifiableCollectionTest("", col).runTest();
// setup
- Collection myCollection = new TreeSet();
+ Collection<Integer> myCollection = new TreeSet<Integer>();
myCollection.add(new Integer(101));
myCollection.add(new Integer(102));
myCollection.add(new Integer(103));
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Configuration.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Configuration.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Configuration.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Configuration.java Mon Oct 16 19:17:46 2006
@@ -125,7 +125,7 @@
public static String Port2 = "COM2";
- static Hashtable props = null;
+ static Hashtable<String, String> props = null;
static {
loadProperties();
HomeAddress = WebName + DomainAddress;
@@ -134,7 +134,7 @@
static void loadProperties() {
InputStream in = null;
- Hashtable props = new Hashtable();
+ Hashtable<String, String> props = new Hashtable<String, String>();
String iniName = System.getProperty("test.ini.file", "JCLAuto.ini");
if (System.getProperty("test.comm") != null) {
@@ -151,7 +151,7 @@
}
if (in == null) {
try {
- Class cl = Class
+ Class<?> cl = Class
.forName("com.ibm.support.Support_Configuration");
in = cl.getResourceAsStream(iniName);
} catch (ClassNotFoundException e) {
@@ -163,50 +163,61 @@
}
} catch (IOException e) {
}
- if (props.size() == 0)
- return;
+ if (props.size() == 0) {
+ return;
+ }
String value;
- value = (String) props.get("DomainAddress");
- if (value != null)
- DomainAddress = value;
-
- value = (String) props.get("WebName");
- if (value != null)
- WebName = value;
-
- value = (String) props.get("TestResourcesDir");
- if (value != null)
- TestResourcesDir = value;
- value = (String) props.get("HomeAddressResponse");
- if (value != null)
- HomeAddressResponse = value;
-
- value = (String) props.get("HomeAddressSoftware");
- if (value != null)
- HomeAddressSoftware = value;
-
- value = (String) props.get("ProxyServerTestHost");
- if (value != null)
- ProxyServerTestHost = value;
-
- value = (String) props.get("SocksServerTestHost");
- if (value != null)
- SocksServerTestHost = value;
-
- value = (String) props.get("SocksServerTestPort");
- if (value != null)
- SocksServerTestPort = Integer.parseInt(value);
-
- value = (String) props.get("UnresolvedIP");
- if (value != null)
- UnresolvedIP = value;
-
- value = (String) props.get("InetTestAddress");
- if (value != null)
- InetTestAddress = value;
+ value = props.get("DomainAddress");
+ if (value != null) {
+ DomainAddress = value;
+ }
+
+ value = props.get("WebName");
+ if (value != null) {
+ WebName = value;
+ }
+
+ value = props.get("TestResourcesDir");
+ if (value != null) {
+ TestResourcesDir = value;
+ }
+ value = props.get("HomeAddressResponse");
+ if (value != null) {
+ HomeAddressResponse = value;
+ }
+
+ value = props.get("HomeAddressSoftware");
+ if (value != null) {
+ HomeAddressSoftware = value;
+ }
- value = (String) props.get("InetTestIP");
+ value = props.get("ProxyServerTestHost");
+ if (value != null) {
+ ProxyServerTestHost = value;
+ }
+
+ value = props.get("SocksServerTestHost");
+ if (value != null) {
+ SocksServerTestHost = value;
+ }
+
+ value = props.get("SocksServerTestPort");
+ if (value != null) {
+ SocksServerTestPort = Integer.parseInt(value);
+ }
+
+ value = props.get("UnresolvedIP");
+ if (value != null) {
+ UnresolvedIP = value;
+ }
+
+ value = props.get("InetTestAddress");
+ if (value != null) {
+ InetTestAddress = value;
+ }
+
+ value = props.get("InetTestIP");
if (value != null) {
InetTestIP = value;
byte[] addr = new byte[4];
@@ -227,7 +238,7 @@
}
}
- value = (String) props.get("NonLocalAddressBytes");
+ value = props.get("NonLocalAddressBytes");
if (value != null) {
String nonLocalAddressBytesString = value;
byte[] addr = new byte[4];
@@ -250,81 +261,99 @@
}
}
- value = (String) props.get("InetTestAddress2");
- if (value != null)
- InetTestAddress2 = value;
-
- value = (String) props.get("InetTestIP2");
- if (value != null)
- InetTestIP2 = value;
-
- value = (String) props.get("InetTestHashcode");
- if (value != null)
- InetTestHashcode = Integer.parseInt(value);
-
- value = (String) props.get("SpecialInetTestAddress");
- if (value != null)
- SpecialInetTestAddress = value;
-
- value = (String) props.get("SpecialInetTestAddressNumber");
- if (value != null)
- SpecialInetTestAddressNumber = Integer.parseInt(value);
-
- value = (String) props.get("FTPTestAddress");
- if (value != null)
- FTPTestAddress = value;
-
- value = (String) props.get("URLConnectionLastModifiedString");
- if (value != null)
- URLConnectionLastModifiedString = value;
-
- value = (String) props.get("URLConnectionLastModified");
- if (value != null)
- URLConnectionLastModified = Long.parseLong(value);
-
- value = (String) props.get("URLConnectionDate");
- if (value != null)
- URLConnectionDate = Long.parseLong(value);
-
- value = (String) props.get("Port1");
- if (value != null)
- Port1 = value;
-
- value = (String) props.get("Port2");
- if (value != null)
- Port2 = value;
-
- value = (String) props.get("InetTestIP6");
- if (value != null)
- InetTestIP6 = value;
-
- value = (String) props.get("InetTestIP6LO");
- if (value != null)
- InetTestIP6LO = value;
-
- value = (String) props.get("ProxyServerTestHostIPv6");
- if (value != null)
- ProxyServerTestHostIPv6 = value;
-
- value = (String) props.get("ResolvedNotExistingHost");
- if (value != null)
- ResolvedNotExistingHost = value;
-
- value = (String) props.get("InetAlias1");
- if (value != null)
- InetAlias1 = value;
-
- value = (String) props.get("InetAlias2");
- if (value != null)
- InetAlias2 = value;
-
- value = (String) props.get("IPv6GlobalAddressJcl4");
- if (value != null)
- IPv6GlobalAddressJcl4 = value;
+ value = props.get("InetTestAddress2");
+ if (value != null) {
+ InetTestAddress2 = value;
+ }
+
+ value = props.get("InetTestIP2");
+ if (value != null) {
+ InetTestIP2 = value;
+ }
+
+ value = props.get("InetTestHashcode");
+ if (value != null) {
+ InetTestHashcode = Integer.parseInt(value);
+ }
+
+ value = props.get("SpecialInetTestAddress");
+ if (value != null) {
+ SpecialInetTestAddress = value;
+ }
+
+ value = props.get("SpecialInetTestAddressNumber");
+ if (value != null) {
+ SpecialInetTestAddressNumber = Integer.parseInt(value);
+ }
+
+ value = props.get("FTPTestAddress");
+ if (value != null) {
+ FTPTestAddress = value;
+ }
+
+ value = props.get("URLConnectionLastModifiedString");
+ if (value != null) {
+ URLConnectionLastModifiedString = value;
+ }
+
+ value = props.get("URLConnectionLastModified");
+ if (value != null) {
+ URLConnectionLastModified = Long.parseLong(value);
+ }
+
+ value = props.get("URLConnectionDate");
+ if (value != null) {
+ URLConnectionDate = Long.parseLong(value);
+ }
+
+ value = props.get("Port1");
+ if (value != null) {
+ Port1 = value;
+ }
+
+ value = props.get("Port2");
+ if (value != null) {
+ Port2 = value;
+ }
+
+ value = props.get("InetTestIP6");
+ if (value != null) {
+ InetTestIP6 = value;
+ }
+
+ value = props.get("InetTestIP6LO");
+ if (value != null) {
+ InetTestIP6LO = value;
+ }
+
+ value = props.get("ProxyServerTestHostIPv6");
+ if (value != null) {
+ ProxyServerTestHostIPv6 = value;
+ }
+
+ value = props.get("ResolvedNotExistingHost");
+ if (value != null) {
+ ResolvedNotExistingHost = value;
+ }
+
+ value = props.get("InetAlias1");
+ if (value != null) {
+ InetAlias1 = value;
+ }
+
+ value = props.get("InetAlias2");
+ if (value != null) {
+ InetAlias2 = value;
+ }
+
+ value = props.get("IPv6GlobalAddressJcl4");
+ if (value != null) {
+ IPv6GlobalAddressJcl4 = value;
+ }
}
- static void load(InputStream in, Hashtable result) throws IOException {
+ static void load(InputStream in, Hashtable<String, String> result) throws IOException {
int NONE = 0, SLASH = 1, UNICODE = 2, CONTINUE = 3, DONE = 4, IGNORE = 5;
int mode = NONE, unicode = 0, count = 0, nextChar;
StringBuffer key = new StringBuffer(), value = new StringBuffer(), buffer = key;
@@ -335,13 +364,15 @@
int digit = Character.digit((char) nextChar, 16);
if (digit >= 0) {
unicode = (unicode << 4) + digit;
- if (++count < 4)
- continue;
+ if (++count < 4) {
+ continue;
+ }
}
mode = NONE;
buffer.append((char) unicode);
- if (nextChar != '\n')
- continue;
+ if (nextChar != '\n') {
+ continue;
+ }
}
if (mode == SLASH) {
mode = NONE;
@@ -377,9 +408,11 @@
case '#':
case '!':
if (firstChar) {
- while ((nextChar = in.read()) != -1)
- if (nextChar == '\r' || nextChar == '\n')
- break;
+ while ((nextChar = in.read()) != -1) {
+ if (nextChar == '\r' || nextChar == '\n') {
+ break;
+ }
+ }
continue;
}
break;
@@ -392,8 +425,9 @@
case '\r':
mode = NONE;
firstChar = true;
- if (key.length() > 0 || buffer == value)
- result.put(key.toString(), value.toString());
+ if (key.length() > 0 || buffer == value) {
+ result.put(key.toString(), value.toString());
+ }
key.setLength(0);
value.setLength(0);
buffer = key;
@@ -411,17 +445,20 @@
}
char c = (char) nextChar;
if ((c >= 0x1c && c <= 0x20) || (c >= 0x9 && c <= 0xd)) {
- if (mode == CONTINUE)
- mode = IGNORE;
- if (buffer.length() == 0 || mode == IGNORE)
- continue;
+ if (mode == CONTINUE) {
+ mode = IGNORE;
+ }
+ if (buffer.length() == 0 || mode == IGNORE) {
+ continue;
+ }
if (buffer == key) {
mode = DONE;
continue;
}
}
- if (mode == IGNORE || mode == CONTINUE)
- mode = NONE;
+ if (mode == IGNORE || mode == CONTINUE) {
+ mode = NONE;
+ }
}
firstChar = false;
if (mode == DONE) {
@@ -430,8 +467,9 @@
}
buffer.append((char) nextChar);
}
- if (key.length() > 0 || buffer == value)
- result.put(key.toString(), value.toString());
+ if (key.length() > 0 || buffer == value) {
+ result.put(key.toString(), value.toString());
+ }
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_DecimalFormat.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_DecimalFormat.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_DecimalFormat.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_DecimalFormat.java Mon Oct 16 19:17:46 2006
@@ -28,7 +28,8 @@
super(p1);
}
- public void runTest() {
+ @Override
+ public void runTest() {
t_formatToCharacterIterator();
t_format_with_FieldPosition();
}
@@ -185,31 +186,31 @@
getZeroVector());
}
- private static Vector getNumberVectorUS() {
- Vector v = new Vector();
+ private static Vector<FieldContainer> getNumberVectorUS() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(0, 3, NumberFormat.Field.INTEGER));
v.add(new FieldContainer(3, 4, NumberFormat.Field.DECIMAL_SEPARATOR));
v.add(new FieldContainer(4, 6, NumberFormat.Field.FRACTION));
return v;
}
- private static Vector getPositiveCurrencyVectorTR() {
- Vector v = new Vector();
+ private static Vector<FieldContainer> getPositiveCurrencyVectorTR() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(0, 3, NumberFormat.Field.INTEGER));
v.add(new FieldContainer(4, 6, NumberFormat.Field.CURRENCY));
return v;
}
- private static Vector getNegativeCurrencyVectorTR() {
- Vector v = new Vector();
+ private static Vector<FieldContainer> getNegativeCurrencyVectorTR() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(0, 1, NumberFormat.Field.SIGN));
v.add(new FieldContainer(1, 4, NumberFormat.Field.INTEGER));
v.add(new FieldContainer(5, 7, NumberFormat.Field.CURRENCY));
return v;
}
- private static Vector getPositiveCurrencyVectorUS() {
- Vector v = new Vector();
+ private static Vector<FieldContainer> getPositiveCurrencyVectorUS() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(0, 1, NumberFormat.Field.CURRENCY));
v.add(new FieldContainer(1, 4, NumberFormat.Field.INTEGER));
v.add(new FieldContainer(4, 5, NumberFormat.Field.DECIMAL_SEPARATOR));
@@ -217,8 +218,8 @@
return v;
}
- private static Vector getNegativeCurrencyVectorUS() {
- Vector v = new Vector();
+ private static Vector<FieldContainer> getNegativeCurrencyVectorUS() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(1, 2, NumberFormat.Field.CURRENCY));
v.add(new FieldContainer(2, 5, NumberFormat.Field.INTEGER));
v.add(new FieldContainer(5, 6, NumberFormat.Field.DECIMAL_SEPARATOR));
@@ -226,8 +227,8 @@
return v;
}
- private static Vector getPercentVectorUS() {
- Vector v = new Vector();
+ private static Vector<FieldContainer> getPercentVectorUS() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(0, 2, NumberFormat.Field.INTEGER));
v.add(new FieldContainer(2, 3, NumberFormat.Field.INTEGER));
v.add(new FieldContainer(2, 3, NumberFormat.Field.GROUPING_SEPARATOR));
@@ -236,15 +237,15 @@
return v;
}
- private static Vector getPermilleVector() {
- Vector v = new Vector();
+ private static Vector<FieldContainer> getPermilleVector() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(0, 6, NumberFormat.Field.INTEGER));
v.add(new FieldContainer(6, 7, NumberFormat.Field.PERMILLE));
return v;
}
- private static Vector getNegativeExponentVector() {
- Vector v = new Vector();
+ private static Vector<FieldContainer> getNegativeExponentVector() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(0, 4, NumberFormat.Field.INTEGER));
v.add(new FieldContainer(4, 5, NumberFormat.Field.DECIMAL_SEPARATOR));
v.add(new FieldContainer(5, 6, NumberFormat.Field.FRACTION));
@@ -254,8 +255,8 @@
return v;
}
- private static Vector getPositiveExponentVector() {
- Vector v = new Vector();
+ private static Vector<FieldContainer> getPositiveExponentVector() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(0, 2, NumberFormat.Field.INTEGER));
v.add(new FieldContainer(2, 3, NumberFormat.Field.DECIMAL_SEPARATOR));
v.add(new FieldContainer(3, 5, NumberFormat.Field.FRACTION));
@@ -264,8 +265,8 @@
return v;
}
- private static Vector getNumberVector2US() {
- Vector v = new Vector();
+ private static Vector<FieldContainer> getNumberVector2US() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(0, 3, NumberFormat.Field.INTEGER));
v.add(new FieldContainer(3, 4, NumberFormat.Field.GROUPING_SEPARATOR));
v.add(new FieldContainer(3, 4, NumberFormat.Field.INTEGER));
@@ -276,8 +277,8 @@
return v;
}
- private static Vector getZeroVector() {
- Vector v = new Vector();
+ private static Vector<FieldContainer> getZeroVector() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(0, 1, NumberFormat.Field.INTEGER));
return v;
}
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_DummyPKCS12Keystore.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_DummyPKCS12Keystore.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_DummyPKCS12Keystore.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_DummyPKCS12Keystore.java Mon Oct 16 19:17:46 2006
@@ -35,179 +35,87 @@
*/
public class Support_DummyPKCS12Keystore extends KeyStoreSpi {
- /**
- *
- */
public Support_DummyPKCS12Keystore() {
super();
- // TODO Auto-generated constructor stub
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineGetKey(java.lang.String, char[])
- */
- public Key engineGetKey(String arg0, char[] arg1)
+ @Override
+ public Key engineGetKey(String arg0, char[] arg1)
throws NoSuchAlgorithmException, UnrecoverableKeyException {
- // TODO Auto-generated method stub
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineGetCertificateChain(java.lang.String)
- */
- public Certificate[] engineGetCertificateChain(String arg0) {
- // TODO Auto-generated method stub
+ @Override
+ public Certificate[] engineGetCertificateChain(String arg0) {
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineGetCertificate(java.lang.String)
- */
- public Certificate engineGetCertificate(String arg0) {
- // TODO Auto-generated method stub
+ @Override
+ public Certificate engineGetCertificate(String arg0) {
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineGetCreationDate(java.lang.String)
- */
- public Date engineGetCreationDate(String arg0) {
- // TODO Auto-generated method stub
+ @Override
+ public Date engineGetCreationDate(String arg0) {
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineSetKeyEntry(java.lang.String,
- * java.security.Key, char[], java.security.cert.Certificate[])
- */
- public void engineSetKeyEntry(String arg0, Key arg1, char[] arg2,
+ @Override
+ public void engineSetKeyEntry(String arg0, Key arg1, char[] arg2,
Certificate[] arg3) throws KeyStoreException {
- // TODO Auto-generated method stub
-
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineSetKeyEntry(java.lang.String,
- * byte[], java.security.cert.Certificate[])
- */
- public void engineSetKeyEntry(String arg0, byte[] arg1, Certificate[] arg2)
+ @Override
+ public void engineSetKeyEntry(String arg0, byte[] arg1, Certificate[] arg2)
throws KeyStoreException {
- // TODO Auto-generated method stub
-
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineSetCertificateEntry(java.lang.String,
- * java.security.cert.Certificate)
- */
- public void engineSetCertificateEntry(String arg0, Certificate arg1)
+ @Override
+ public void engineSetCertificateEntry(String arg0, Certificate arg1)
throws KeyStoreException {
- // TODO Auto-generated method stub
-
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineDeleteEntry(java.lang.String)
- */
- public void engineDeleteEntry(String arg0) throws KeyStoreException {
- // TODO Auto-generated method stub
-
+ @Override
+ public void engineDeleteEntry(String arg0) throws KeyStoreException {
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineAliases()
- */
- public Enumeration engineAliases() {
- // TODO Auto-generated method stub
+ @Override
+ public Enumeration<String> engineAliases() {
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineContainsAlias(java.lang.String)
- */
- public boolean engineContainsAlias(String arg0) {
- // TODO Auto-generated method stub
+ @Override
+ public boolean engineContainsAlias(String arg0) {
return false;
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineSize()
- */
- public int engineSize() {
- // TODO Auto-generated method stub
+ @Override
+ public int engineSize() {
return 0;
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineIsKeyEntry(java.lang.String)
- */
- public boolean engineIsKeyEntry(String arg0) {
- // TODO Auto-generated method stub
+ @Override
+ public boolean engineIsKeyEntry(String arg0) {
return false;
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineIsCertificateEntry(java.lang.String)
- */
- public boolean engineIsCertificateEntry(String arg0) {
- // TODO Auto-generated method stub
+ @Override
+ public boolean engineIsCertificateEntry(String arg0) {
return false;
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineGetCertificateAlias(java.security.cert.Certificate)
- */
- public String engineGetCertificateAlias(Certificate arg0) {
- // TODO Auto-generated method stub
+ @Override
+ public String engineGetCertificateAlias(Certificate arg0) {
return null;
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineStore(java.io.OutputStream, char[])
- */
- public void engineStore(OutputStream arg0, char[] arg1) throws IOException,
+ @Override
+ public void engineStore(OutputStream arg0, char[] arg1) throws IOException,
NoSuchAlgorithmException, CertificateException {
- // TODO Auto-generated method stub
-
}
- /*
- * (non-Javadoc)
- *
- * @see java.security.KeyStoreSpi#engineLoad(java.io.InputStream, char[])
- */
- public void engineLoad(InputStream arg0, char[] arg1) throws IOException,
+ @Override
+ public void engineLoad(InputStream arg0, char[] arg1) throws IOException,
NoSuchAlgorithmException, CertificateException {
- // TODO Auto-generated method stub
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Exec.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Exec.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Exec.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Exec.java Mon Oct 16 19:17:46 2006
@@ -39,8 +39,9 @@
byte[] bytes = new byte[1024];
while ((result = in.read(bytes)) != -1) {
output.append(new String(bytes, 0, result));
- if (displayOutput)
- System.out.write(bytes, 0, result);
+ if (displayOutput) {
+ System.out.write(bytes, 0, result);
+ }
}
in.close();
proc.waitFor();
@@ -50,7 +51,6 @@
}
public static void checkStderr(Object[] execArgs) {
- Process proc = (Process) execArgs[0];
StringBuffer errBuf = (StringBuffer) execArgs[1];
synchronized (errBuf) {
if (errBuf.length() > 0) {
@@ -64,29 +64,32 @@
// this function returns the resulting process from the exec
int baseArgs = 0;
String[] execArgs = null;
- String vendor = System.getProperty("java.vendor");
- boolean onUnix = File.separatorChar == '/';
+// String vendor = System.getProperty("java.vendor");
String classPathString = "";
if (classpath != null)
- for (int i = 0; i < classpath.length; i++)
- classPathString += File.pathSeparator + classpath[i];
+ for (String element : classpath) {
+ classPathString += File.pathSeparator + element;
+ }
baseArgs = 3;
execArgs = new String[baseArgs + args.length];
String executable = System.getProperty("java.home");
- if (!executable.endsWith(File.separator))
+ if (!executable.endsWith(File.separator)) {
executable += File.separator;
+ }
executable += "bin" + File.separator;
execArgs[0] = executable + "java";
execArgs[1] = "-cp";
execArgs[2] = "\"" + System.getProperty("java.class.path")
+ classPathString + "\"";
- for (int i = 0; i < args.length; i++)
+ for (int i = 0; i < args.length; i++) {
execArgs[baseArgs + i] = args[i];
+ }
StringBuffer command = new StringBuffer(execArgs[0]);
- for (int i = 1; i < execArgs.length; i++)
+ for (int i = 1; i < execArgs.length; i++) {
command.append(" " + execArgs[i]);
+ }
System.out.println();
System.out.println("Exec: " + command.toString());
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Format.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Format.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Format.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_Format.java Mon Oct 16 19:17:46 2006
@@ -23,10 +23,11 @@
import java.text.AttributedCharacterIterator.Attribute;
import java.util.Iterator;
import java.util.Vector;
+import junit.framework.TestCase;
-public class Support_Format extends junit.framework.TestCase {
+public class Support_Format extends TestCase {
- protected String text = null;
+ protected String text;
public Support_Format(String p1) {
super(p1);
@@ -41,12 +42,13 @@
// System.out.println(buffer);
// System.out.println(pos);
- if (text == null)
- assertEquals("Test " + count + ": incorrect formatted text",
+ if (text == null) {
+ assertEquals("Test " + count + ": incorrect formatted text",
this.text, buffer.toString());
- else
- assertEquals("Test " + count + ": incorrect formatted text", text,
+ } else {
+ assertEquals("Test " + count + ": incorrect formatted text", text,
buffer.toString());
+ }
assertEquals("Test " + count + ": incorrect begin index for field "
+ field, begin, pos.getBeginIndex());
@@ -55,9 +57,9 @@
}
protected void t_Format(int count, Object object, Format format,
- Vector expectedResults) {
+ Vector<FieldContainer> expectedResults) {
// System.out.println(format.format(object));
- Vector results = findFields(format.formatToCharacterIterator(object));
+ Vector<FieldContainer> results = findFields(format.formatToCharacterIterator(object));
assertTrue("Test " + count
+ ": Format returned incorrect CharacterIterator for "
+ format.format(object), compare(results, expectedResults));
@@ -66,7 +68,7 @@
/**
* compares two vectors regardless of the order of their elements
*/
- protected static boolean compare(Vector vector1, Vector vector2) {
+ protected static boolean compare(Vector<FieldContainer> vector1, Vector<FieldContainer> vector2) {
return vector1.size() == vector2.size() && vector1.containsAll(vector2);
}
@@ -79,16 +81,15 @@
* which stores start and end indexes and an attribute this range
* has
*/
- protected static Vector findFields(AttributedCharacterIterator iterator) {
- Vector result = new Vector();
+ protected static Vector<FieldContainer> findFields(AttributedCharacterIterator iterator) {
+ Vector<FieldContainer> result = new Vector<FieldContainer>();
while (iterator.getIndex() != iterator.getEndIndex()) {
int start = iterator.getRunStart();
int end = iterator.getRunLimit();
- Iterator it = iterator.getAttributes().keySet().iterator();
+ Iterator<Attribute> it = iterator.getAttributes().keySet().iterator();
while (it.hasNext()) {
- AttributedCharacterIterator.Attribute attribute = (AttributedCharacterIterator.Attribute) it
- .next();
+ AttributedCharacterIterator.Attribute attribute = it.next();
Object value = iterator.getAttribute(attribute);
result.add(new FieldContainer(start, end, attribute, value));
// System.out.println(start + " " + end + ": " + attribute + ",
@@ -128,9 +129,11 @@
this.value = value;
}
- public boolean equals(Object obj) {
- if (!(obj instanceof FieldContainer))
- return false;
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof FieldContainer)) {
+ return false;
+ }
FieldContainer fc = (FieldContainer) obj;
return (start == fc.start && end == fc.end
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_GetLocal.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_GetLocal.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_GetLocal.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_GetLocal.java Mon Oct 16 19:17:46 2006
@@ -32,12 +32,12 @@
public class Support_GetLocal {
- static Hashtable cache = new Hashtable(20);
+ static Hashtable<String, File> cache = new Hashtable<String, File>(20);
public static File getLocalFile(String url) throws IOException,
MalformedURLException {
url = Support_Resources.RESOURCE_PACKAGE + url;
- File temp = (File) cache.get(url);
+ File temp = cache.get(url);
if (temp == null) {
InputStream in = Support_GetLocal.class.getResourceAsStream(url);
temp = File.createTempFile("hyts_local", ".tmp", null);
@@ -45,8 +45,9 @@
FileOutputStream out = new FileOutputStream(temp);
int result;
byte[] buf = new byte[4096];
- while ((result = in.read(buf)) != -1)
- out.write(buf, 0, result);
+ while ((result = in.read(buf)) != -1) {
+ out.write(buf, 0, result);
+ }
in.close();
out.close();
cache.put(url, temp);
@@ -56,7 +57,7 @@
public static File getExternalLocalFile(String url) throws IOException,
MalformedURLException {
- File temp = (File) cache.get(url);
+ File temp = cache.get(url);
if (temp == null) {
InputStream in = new URL(url).openStream();
temp = File.createTempFile("hyts_local", ".tmp", null);
@@ -64,8 +65,9 @@
FileOutputStream out = new FileOutputStream(temp);
int result;
byte[] buf = new byte[4096];
- while ((result = in.read(buf)) != -1)
- out.write(buf, 0, result);
+ while ((result = in.read(buf)) != -1) {
+ out.write(buf, 0, result);
+ }
in.close();
out.close();
cache.put(url, temp);
@@ -79,8 +81,9 @@
ByteArrayOutputStream out = new ByteArrayOutputStream(256);
int result;
byte[] buf = new byte[256];
- while ((result = in.read(buf)) != -1)
- out.write(buf, 0, result);
+ while ((result = in.read(buf)) != -1) {
+ out.write(buf, 0, result);
+ }
return new ByteArrayInputStream(out.toByteArray());
}
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpServer.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpServer.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpServer.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpServer.java Mon Oct 16 19:17:46 2006
@@ -24,6 +24,7 @@
import java.io.OutputStream;
import java.util.Vector;
+import junit.framework.Assert;
import junit.framework.TestCase;
public class Support_HttpServer {
@@ -79,7 +80,7 @@
private boolean shuttingDown = false;
// synchronization
- private Object lock = new Object();
+ private final Object lock = new Object();
TestCase testcase = null;
@@ -93,8 +94,9 @@
}
public void startServer(final int port) {
- if (started)
- return;
+ if (started) {
+ return;
+ }
started = true;
this.port = port;
Thread serverThread = new Thread(new Runnable() {
@@ -119,15 +121,16 @@
.println("Wait timed out. Test HTTP Server shut down.");
started = false;
try {
- if (serversocket != null)
- serversocket.close();
+ if (serversocket != null) {
+ serversocket.close();
+ }
} catch (IOException e2) {
}
} catch (IOException e) {
// release the lock so the tests will finish running
if (!shuttingDown) {
e.printStackTrace();
- TestCase.fail("Test server error on HTTP Server on port "
+ Assert.fail("Test server error on HTTP Server on port "
+ port + ": " + e);
}
synchronized (lock) {
@@ -135,8 +138,9 @@
}
} finally {
try {
- if (serversocket != null)
- serversocket.close();
+ if (serversocket != null) {
+ serversocket.close();
+ }
} catch (IOException e) {
e.printStackTrace();
}
@@ -181,20 +185,23 @@
boolean lastCr = false;
StringBuffer result = new StringBuffer();
int c = is.read();
- if (c < 0)
- return null;
+ if (c < 0) {
+ return null;
+ }
while (c != '\n') {
if (lastCr) {
result.append('\r');
lastCr = false;
}
- if (c == '\r')
- lastCr = true;
- else
- result.append((char) c);
+ if (c == '\r') {
+ lastCr = true;
+ } else {
+ result.append((char) c);
+ }
c = is.read();
- if (c < 0)
- break;
+ if (c < 0) {
+ break;
+ }
}
return result.toString();
}
@@ -213,7 +220,7 @@
boolean authenticated = false, contentLength = false, chunked = false;
int length = -1;
String resourceName = "";
- Vector headers = new Vector();
+ Vector<String> headers = new Vector<String>();
while (((line = readln(in)) != null) && (line.length() > 1)) {
headers.addElement(line);
String lline = line.toLowerCase();
@@ -221,59 +228,65 @@
if (lline.startsWith("get") || lline.startsWith("post")) {
int start = line.indexOf(' ') + 1;
int end = line.indexOf(' ', start);
- if (start > 0 && end > -1)
- resourceName = line.substring(start, end);
+ if (start > 0 && end > -1) {
+ resourceName = line.substring(start, end);
+ }
}
if (lline.startsWith("authorization:")) {
authenticated = true;
}
if (lline.startsWith("content-length")) {
- if (contentLength)
- TestCase.fail("Duplicate Content-Length: " + line);
+ if (contentLength) {
+ Assert.fail("Duplicate Content-Length: " + line);
+ }
contentLength = true;
length = Integer.parseInt(line.substring(line
.indexOf(' ') + 1));
}
if (line.startsWith("transfer-encoding")) {
- if (chunked)
- TestCase.fail("Duplicate Transfer-Encoding: "
+ if (chunked) {
+ Assert.fail("Duplicate Transfer-Encoding: "
+ line);
+ }
chunked = true;
String encoding = line.substring(line.indexOf(' ') + 1);
- if ("chunked".equals(encoding))
- TestCase.fail("Unknown Transfer-Encoding: "
+ if ("chunked".equals(encoding)) {
+ Assert.fail("Unknown Transfer-Encoding: "
+ encoding);
+ }
}
}
- if (contentLength && chunked)
- TestCase.fail("Found both Content-Length and Transfer-Encoding");
+ if (contentLength && chunked) {
+ Assert.fail("Found both Content-Length and Transfer-Encoding");
+ }
// call the test function based on the requested resource
- if (resourceName.equals(CHUNKEDTEST))
- chunkedTest();
- else if (resourceName.equals(CONTENTTEST))
- contentTest();
- else if (resourceName.equals(AUTHTEST))
- authenticateTest(authenticated);
- else if (resourceName.startsWith(REDIRECTTEST))
- redirectTest(resourceName);
- else if (portRedirectTestEnable
- && resourceName.equals(PORTREDIRTEST))
- contentTest();
- else if (resourceName.equals(OTHERTEST))
- otherTest();
- else if (resourceName.equals(HEADERSTEST))
- headersTest(headers);
- else if (resourceName.startsWith("http://")
- && resourceName.indexOf(OTHERTEST) > -1)
- // redirection to a proxy passes an absolute URI to the
+ if (resourceName.equals(CHUNKEDTEST)) {
+ chunkedTest();
+ } else if (resourceName.equals(CONTENTTEST)) {
+ contentTest();
+ } else if (resourceName.equals(AUTHTEST)) {
+ authenticateTest(authenticated);
+ } else if (resourceName.startsWith(REDIRECTTEST)) {
+ redirectTest(resourceName);
+ } else if (portRedirectTestEnable
+ && resourceName.equals(PORTREDIRTEST)) {
+ contentTest();
+ } else if (resourceName.equals(OTHERTEST)) {
+ otherTest();
+ } else if (resourceName.equals(HEADERSTEST)) {
+ headersTest(headers);
+ } else if (resourceName.startsWith("http://")
+ && resourceName.indexOf(OTHERTEST) > -1) {
+ // redirection to a proxy passes an absolute URI to the
// proxy server
otherTest();
- else if (resourceName.equals(POSTTEST)) {
+ } else if (resourceName.equals(POSTTEST)) {
postTest(length, in);
- } else
- notFound(); // return a not found error
+ } else {
+ notFound(); // return a not found error
+ }
in.close();
socket.close();
@@ -401,15 +414,15 @@
}
- private void headersTest(Vector headers) {
+ private void headersTest(Vector<String> headers) {
int found = 0;
for (int i = 0; i < headers.size(); i++) {
- String header = (String) headers.elementAt(i);
+ String header = headers.elementAt(i);
if (header.startsWith("header1:")) {
found++;
- TestCase.assertTrue("unexpected header: " + header,
+ Assert.assertTrue("unexpected header: " + header,
found == 1);
- TestCase.assertTrue("invalid header: " + header,
+ Assert.assertTrue("invalid header: " + header,
"header1: value2".equals(header));
}
}
@@ -435,8 +448,9 @@
try {
ByteArrayOutputStream data = new ByteArrayOutputStream();
// read content-length specified data
- for (int i = 0; i < length; i++)
- data.write(in.read());
+ for (int i = 0; i < length; i++) {
+ data.write(in.read());
+ }
// read chunked-encoding data
if (length == -1) {
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpServerSocket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpServerSocket.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpServerSocket.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpServerSocket.java Mon Oct 16 19:17:46 2006
@@ -39,10 +39,12 @@
* @see tests.support.Support_ServerSocket#accept()
*/
public Support_Socket accept() throws IOException {
- if (port == -1)
- return null;
- if (instance == null)
- return null;
+ if (port == -1) {
+ return null;
+ }
+ if (instance == null) {
+ return null;
+ }
instance.setSoTimeout(timeout);
Socket s = instance.accept();
return new Support_HttpSocket(s);
@@ -71,8 +73,9 @@
* @see tests.support.Support_ServerSocket#close()
*/
public void close() throws IOException {
- if (instance != null)
- instance.close();
+ if (instance != null) {
+ instance.close();
+ }
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpSocket.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpSocket.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpSocket.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpSocket.java Mon Oct 16 19:17:46 2006
@@ -27,7 +27,7 @@
*/
public class Support_HttpSocket implements Support_Socket {
- private Socket instance;
+ private final Socket instance;
private boolean streamOpen = false;
@@ -46,8 +46,9 @@
}
public void close() throws IOException {
- if (!streamOpen && instance != null)
- instance.close();
+ if (!streamOpen && instance != null) {
+ instance.close();
+ }
}
}
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpTests.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpTests.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpTests.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_HttpTests.java Mon Oct 16 19:17:46 2006
@@ -21,8 +21,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-
-import junit.framework.TestCase;
+import junit.framework.Assert;
/**
* Performs some basic testing of either HttpConnection or HttpURLConnection
@@ -76,16 +75,17 @@
// receive the data, and then read again after EOF
c = is.read();
- while (c > 0)
- c = is.read();
+ while (c > 0) {
+ c = is.read();
+ }
c = is.read();
is.close();
connector.close();
- TestCase.assertEquals("Error receiving chunked transfer coded data",
+ Assert.assertEquals("Error receiving chunked transfer coded data",
-1, c);
} catch (Exception e) {
e.printStackTrace();
- TestCase.fail("Exception during test a: " + e);
+ Assert.fail("Exception during test a: " + e);
}
// Content-Length Test
@@ -95,17 +95,18 @@
bout.reset();
do {
c = is.read();
- if (c != -1)
- bout.write(c);
+ if (c != -1) {
+ bout.write(c);
+ }
} while (c != -1);
is.close();
connector.close();
String result = new String(bout.toByteArray(), "ISO8859_1");
- TestCase.assertTrue("Error receiving content coded data: " + result,
+ Assert.assertTrue("Error receiving content coded data: " + result,
"ABCDE".equals(result));
} catch (Exception e) {
e.printStackTrace();
- TestCase.fail("Exception during test b: " + e);
+ Assert.fail("Exception during test b: " + e);
}
// Headers Test
@@ -118,22 +119,23 @@
"private", "no-transform" };
while (true) {
String key = connector.getHeaderFieldKey(i);
- if (key == null && i > 0)
- break;
+ if (key == null && i > 0) {
+ break;
+ }
if ("Cache-Control".equals(key)) {
- TestCase.assertTrue("Too many headers at: " + i, found <= 2);
+ Assert.assertTrue("Too many headers at: " + i, found <= 2);
String value = connector.getHeaderField(i);
- TestCase.assertTrue("Invalid header value: " + found + ": "
+ Assert.assertTrue("Invalid header value: " + found + ": "
+ value, expected[found].equals(value));
found++;
}
i++;
}
- TestCase.assertTrue("Invalid headers: " + found, found == 3);
+ Assert.assertTrue("Invalid headers: " + found, found == 3);
connector.close();
} catch (Exception e) {
e.printStackTrace();
- TestCase.fail("Exception during test c: " + e);
+ Assert.fail("Exception during test c: " + e);
}
// Post Test
@@ -149,17 +151,18 @@
bout.reset();
do {
c = is.read();
- if (c != -1)
- bout.write(c);
+ if (c != -1) {
+ bout.write(c);
+ }
} while (c != -1);
is.close();
connector.close();
String result = new String(bout.toByteArray(), "ISO8859_1");
- TestCase.assertTrue("Error sending data 1: " + result, toWrite
+ Assert.assertTrue("Error sending data 1: " + result, toWrite
.equals(result));
} catch (Exception e) {
e.printStackTrace();
- TestCase.fail("Exception during test d: " + e);
+ Assert.fail("Exception during test d: " + e);
}
// Post Test chunked
@@ -174,17 +177,18 @@
bout.reset();
do {
c = is.read();
- if (c != -1)
- bout.write(c);
+ if (c != -1) {
+ bout.write(c);
+ }
} while (c != -1);
is.close();
connector.close();
String result = new String(bout.toByteArray(), "ISO8859_1");
- TestCase.assertTrue("Error sending data 2: " + result, ("C" + toWrite)
+ Assert.assertTrue("Error sending data 2: " + result, ("C" + toWrite)
.equals(result));
} catch (Exception e) {
e.printStackTrace();
- TestCase.fail("Exception during test e: " + e);
+ Assert.fail("Exception during test e: " + e);
}
OutputStream os = null;
@@ -203,18 +207,19 @@
len = 0;
do {
int r = is.read(data, len, data.length - len);
- if (r == -1)
- break;
+ if (r == -1) {
+ break;
+ }
len += r;
} while (true);
is.close();
connector.close();
String result = new String(data, 0, len, "ISO8859_1");
- TestCase.assertTrue("Basic port error: " + result, message
+ Assert.assertTrue("Basic port error: " + result, message
.equals(result));
} catch (IOException e) {
e.printStackTrace();
- TestCase.fail("Exception during basic post test: " + e);
+ Assert.fail("Exception during basic post test: " + e);
}
String chunkChar = connector.isChunkedOnFlush() ? "C" : "";
@@ -232,18 +237,19 @@
len = 0;
do {
int r = is.read(data, len, data.length - len);
- if (r == -1)
- break;
+ if (r == -1) {
+ break;
+ }
len += r;
} while (true);
is.close();
connector.close();
String result = new String(data, 0, len, "ISO8859_1");
- TestCase.assertTrue("Flushing with post: " + result, (chunkChar
+ Assert.assertTrue("Flushing with post: " + result, (chunkChar
+ message1 + chunkChar + message2).equals(result));
} catch (IOException e) {
e.printStackTrace();
- TestCase.fail("Exception during flushing post test: " + e);
+ Assert.fail("Exception during flushing post test: " + e);
}
// Flushing with post and setting content-length
@@ -260,19 +266,20 @@
len = 0;
do {
int r = is.read(data, len, data.length - len);
- if (r == -1)
- break;
+ if (r == -1) {
+ break;
+ }
len += r;
} while (true);
is.close();
connector.close();
String result = new String(data, 0, len, "ISO8859_1");
- TestCase.assertTrue("Flushing with post and setting content-length: "
+ Assert.assertTrue("Flushing with post and setting content-length: "
+ result, (chunkChar + message1 + chunkChar + message2)
.equals(result));
} catch (IOException e) {
e.printStackTrace();
- TestCase.fail("Exception during flushing with content-length post test: "
+ Assert.fail("Exception during flushing with content-length post test: "
+ e);
}
@@ -288,18 +295,19 @@
len = 0;
do {
int r = is.read(data, len, data.length - len);
- if (r == -1)
- break;
+ if (r == -1) {
+ break;
+ }
len += r;
} while (true);
is.close();
connector.close();
String result = new String(data, 0, len, "ISO8859_1");
- TestCase.assertTrue("Flushing followed immediately by a close(): "
+ Assert.assertTrue("Flushing followed immediately by a close(): "
+ result, (chunkChar + message).equals(result));
} catch (IOException e) {
e.printStackTrace();
- TestCase.fail("Exception during flush followed by close post test: "
+ Assert.fail("Exception during flush followed by close post test: "
+ e);
}
@@ -333,25 +341,26 @@
// says there MUST NOT be a message body on 304 responses.
// But Java returns the message-body
if (!(c == results[i] || c == -1)) {
- TestCase.fail("Incorrect data returned on test of HTTP response "
+ Assert.fail("Incorrect data returned on test of HTTP response "
+ testCodes[i]);
}
} else if (c != results[i]) {
- TestCase.fail("Incorrect data returned on test of HTTP response "
+ Assert.fail("Incorrect data returned on test of HTTP response "
+ testCodes[i]);
}
- while (c > 0)
- c = is.read();
+ while (c > 0) {
+ c = is.read();
+ }
c = is.read();
is.close();
} catch (Exception e) {
e.printStackTrace();
- TestCase.fail("Error during redirection test " + i + ": " + e);
+ Assert.fail("Error during redirection test " + i + ": " + e);
}
}
// Test redirecting to a location on a different port
- Class serversocketclass = serversocket.getClass();
+ Class<?> serversocketclass = serversocket.getClass();
try {
Support_ServerSocket serversocket2 = (Support_ServerSocket) serversocketclass
.newInstance();
@@ -377,21 +386,22 @@
connector.close();
c = is.read();
- TestCase.assertEquals("Incorrect data returned on redirection to a different port.",
+ Assert.assertEquals("Incorrect data returned on redirection to a different port.",
'A', c);
- while (c > 0)
- c = is.read();
+ while (c > 0) {
+ c = is.read();
+ }
c = is.read();
is.close();
} catch (Exception e) {
e.printStackTrace();
- TestCase.fail("Exception during test f: " + e);
+ Assert.fail("Exception during test f: " + e);
}
server2.stopServer();
} catch (IllegalAccessException e) {
- TestCase.fail("Exception during redirection to a different port:" + e);
+ Assert.fail("Exception during redirection to a different port:" + e);
} catch (InstantiationException e) {
- TestCase.fail("Exception during redirection to a different port:" + e);
+ Assert.fail("Exception during redirection to a different port:" + e);
}
// test redirecting to a relative URL on the same host
@@ -403,15 +413,16 @@
connector.close();
c = is.read();
- TestCase.assertEquals("Incorrect data returned on redirect to relative URI.",
+ Assert.assertEquals("Incorrect data returned on redirect to relative URI.",
'A', c);
- while (c > 0)
- c = is.read();
+ while (c > 0) {
+ c = is.read();
+ }
c = is.read();
is.close();
} catch (Exception e) {
e.printStackTrace();
- TestCase.fail("Exception during redirection test to a relative URL: " + e);
+ Assert.fail("Exception during redirection test to a relative URL: " + e);
}
server.stopServer();
}
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ListTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ListTest.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ListTest.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ListTest.java Mon Oct 16 19:17:46 2006
@@ -24,18 +24,19 @@
public class Support_ListTest extends junit.framework.TestCase {
- List list; // must contain the Integers 0 to 99 in order
+ List<Integer> list; // must contain the Integers 0 to 99 in order
public Support_ListTest(String p1) {
super(p1);
}
- public Support_ListTest(String p1, List l) {
+ public Support_ListTest(String p1, List<Integer> l) {
super(p1);
list = l;
}
- public void runTest() {
+ @Override
+ public void runTest() {
int hashCode = 1;
for (int counter = 0; counter < 100; counter++) {
Object elem;
@@ -74,7 +75,7 @@
"ListTest - c) remove with index failed--affected previous elements",
list.get(49).equals(new Integer(49)));
- List myList = new LinkedList();
+ List<Integer> myList = new LinkedList<Integer>();
myList.add(new Integer(500));
myList.add(new Integer(501));
myList.add(new Integer(502));
@@ -93,7 +94,7 @@
"ListTest - e) addAll with index failed--affected previous elements",
list.get(49).equals(new Integer(49)));
- List mySubList = list.subList(50, 53);
+ List<Integer> mySubList = list.subList(50, 53);
assertEquals(3, mySubList.size());
assertTrue(
"ListTest - a) sublist Failed--does not contain correct elements",
@@ -112,7 +113,7 @@
100, list.size());
t_listIterator(list);
- ListIterator li = list.listIterator();
+ ListIterator<Integer> li = list.listIterator();
for (int counter = 0; li.hasNext(); counter++) {
Object elem;
elem = li.next();
@@ -124,23 +125,25 @@
}
- public void t_listIterator(List list) {
- ListIterator li = list.listIterator(1);
+ public void t_listIterator(List<Integer> list) {
+ ListIterator<Integer> li = list.listIterator(1);
assertTrue("listIterator(1)", li.next() == list.get(1));
int orgSize = list.size();
li = list.listIterator();
for (int i = 0; i <= orgSize; i++) {
- if (i == 0)
- assertTrue("list iterator hasPrevious(): " + i, !li
+ if (i == 0) {
+ assertTrue("list iterator hasPrevious(): " + i, !li
.hasPrevious());
- else
- assertTrue("list iterator hasPrevious(): " + i, li
+ } else {
+ assertTrue("list iterator hasPrevious(): " + i, li
.hasPrevious());
- if (i == list.size())
- assertTrue("list iterator hasNext(): " + i, !li.hasNext());
- else
- assertTrue("list iterator hasNext(): " + i, li.hasNext());
+ }
+ if (i == list.size()) {
+ assertTrue("list iterator hasNext(): " + i, !li.hasNext());
+ } else {
+ assertTrue("list iterator hasNext(): " + i, li.hasNext());
+ }
assertTrue("list iterator nextIndex(): " + i, li.nextIndex() == i);
assertTrue("list iterator previousIndex(): " + i, li
.previousIndex() == i - 1);
@@ -151,10 +154,11 @@
} catch (NoSuchElementException e) {
exception = true;
}
- if (i == list.size())
- assertTrue("list iterator next() exception: " + i, exception);
- else
- assertTrue("list iterator next() exception: " + i, !exception);
+ if (i == list.size()) {
+ assertTrue("list iterator next() exception: " + i, exception);
+ } else {
+ assertTrue("list iterator next() exception: " + i, !exception);
+ }
}
for (int i = orgSize - 1; i >= 0; i--) {
@@ -163,12 +167,13 @@
assertTrue("list iterator nextIndex()2: " + i, li.nextIndex() == i);
assertTrue("list iterator previousIndex()2: " + i, li
.previousIndex() == i - 1);
- if (i == 0)
- assertTrue("list iterator hasPrevious()2: " + i, !li
+ if (i == 0) {
+ assertTrue("list iterator hasPrevious()2: " + i, !li
.hasPrevious());
- else
- assertTrue("list iterator hasPrevious()2: " + i, li
+ } else {
+ assertTrue("list iterator hasPrevious()2: " + i, li
.hasPrevious());
+ }
assertTrue("list iterator hasNext()2: " + i, li.hasNext());
}
boolean exception = false;
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_MapTest2.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_MapTest2.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_MapTest2.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_MapTest2.java Mon Oct 16 19:17:46 2006
@@ -18,12 +18,13 @@
package tests.support;
import java.util.Map;
+import junit.framework.TestCase;
-public class Support_MapTest2 extends junit.framework.TestCase {
+public class Support_MapTest2 extends TestCase {
- Map map;
+ Map<String, String> map;
- public Support_MapTest2(Map m) {
+ public Support_MapTest2(Map<String, String> m) {
super();
map = m;
if (!map.isEmpty()) {
@@ -31,7 +32,8 @@
}
}
- public void runTest() {
+ @Override
+ public void runTest() {
try {
map.put("one", "1");
assertEquals("size should be one", 1, map.size());
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_MessageFormat.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_MessageFormat.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_MessageFormat.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_MessageFormat.java Mon Oct 16 19:17:46 2006
@@ -32,7 +32,8 @@
super(p1);
}
- public void runTest() {
+ @Override
+ public void runTest() {
t_formatToCharacterIterator();
t_format_with_FieldPosition();
}
@@ -81,8 +82,8 @@
t_Format(1, objects, format, getMessageVector1());
}
- private Vector getMessageVector1() {
- Vector v = new Vector();
+ private Vector<FieldContainer> getMessageVector1() {
+ Vector<FieldContainer> v = new Vector<FieldContainer>();
v.add(new FieldContainer(3, 6, Field.ARGUMENT, 4));
v.add(new FieldContainer(3, 6, DateFormat.Field.MONTH));
v.add(new FieldContainer(6, 7, Field.ARGUMENT, 4));
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PermissionCollection.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PermissionCollection.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PermissionCollection.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PermissionCollection.java Mon Oct 16 19:17:46 2006
@@ -29,7 +29,7 @@
public static void main(String[] args) throws Exception {
System.setSecurityManager(new SecurityManager());
java.net.URL[] urls = new java.net.URL[1];
- Class c = null;
+ Class<?> c = null;
java.net.URLClassLoader ucl = null;
try {
URL url = new URL(args[0]);
@@ -41,7 +41,7 @@
}
ProtectionDomain pd = c.getProtectionDomain();
PermissionCollection coll = Policy.getPolicy().getPermissions(pd);
- Class myPermission = Class.forName("mypackage.MyPermission");
+ Class<?> myPermission = Class.forName("mypackage.MyPermission");
BasicPermission myperm = (BasicPermission) myPermission.newInstance();
System.out.println(coll.implies(new java.io.FilePermission("test1.txt",
"write"))
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PortManager.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PortManager.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PortManager.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_PortManager.java Mon Oct 16 19:17:46 2006
@@ -17,15 +17,17 @@
package tests.support;
-import java.util.Date;
+import java.util.Calendar;
+import java.util.TimeZone;
public class Support_PortManager extends java.lang.Object {
private static int lastAssignedPort = somewhatRandomPort();
public static synchronized int getNextPort() {
- if (++lastAssignedPort > 65534)
- lastAssignedPort = 6000;
+ if (++lastAssignedPort > 65534) {
+ lastAssignedPort = 6000;
+ }
return lastAssignedPort;
}
@@ -34,9 +36,9 @@
* should be about += 100 at each 6 second interval
*/
private static int somewhatRandomPort() {
- Date date = new Date();
- int minutes = date.getMinutes();
- int seconds = date.getSeconds();
+ Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ int minutes = c.get(Calendar.MINUTE);
+ int seconds = c.get(Calendar.SECOND);
return 6000 + (1000 * minutes) + ((seconds / 6) * 100);
}
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderJCE.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderJCE.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderJCE.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderJCE.java Mon Oct 16 19:17:46 2006
@@ -25,7 +25,9 @@
* This class implements a dummy security provider
*/
public class Support_ProviderJCE extends Provider {
- // Provider name
+ private static final long serialVersionUID = 1L;
+
+ // Provider name
private static final String NAME = "ProviderJCE";
// Version of the services
@@ -46,8 +48,8 @@
* Register the services the receiver provides.
*/
private void registerServices() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
// Digest engine
put("MessageDigest.SHA",
"made.up.provider.name.MessageDigestSHA");
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderRSA.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderRSA.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderRSA.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderRSA.java Mon Oct 16 19:17:46 2006
@@ -25,7 +25,9 @@
* This class implements a dummy provider.
*/
public class Support_ProviderRSA extends Provider {
- // Provider name
+ private static final long serialVersionUID = 1L;
+
+ // Provider name
private static final String NAME = "ProviderRSA";
// Version of the services provided
@@ -46,8 +48,8 @@
* Register the services the receiver provides.
*/
private void registerServices() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
// Digest engine
put("MessageDigest.SHA",
"made.up.provider.name.MessageDigestSHA");
Modified: incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderTrust.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderTrust.java?view=diff&rev=464769&r1=464768&r2=464769
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderTrust.java (original)
+++ incubator/harmony/enhanced/classlib/trunk/support/src/test/java/tests/support/Support_ProviderTrust.java Mon Oct 16 19:17:46 2006
@@ -26,7 +26,9 @@
*
*/
public class Support_ProviderTrust extends Provider {
- // Provider name
+ private static final long serialVersionUID = 1L;
+
+ // Provider name
private static final String NAME = "ProviderTrust";
// Version of the services
@@ -48,8 +50,8 @@
* Register the services the receiver provides.
*/
private void registerServices() {
- AccessController.doPrivileged(new PrivilegedAction() {
- public Object run() {
+ AccessController.doPrivileged(new PrivilegedAction<Void>() {
+ public Void run() {
// Digest engine
put("MessageDigest.SHA",
"made.up.provider.name.MessageDigestSHA");