You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by py...@apache.org on 2007/07/16 11:03:03 UTC
svn commit: r556562 [6/6] - in
/harmony/enhanced/classlib/trunk/modules/sql/src: main/java/java/sql/
main/java/javax/sql/ main/java/javax/sql/rowset/
main/java/javax/sql/rowset/serial/ main/java/javax/sql/rowset/spi/
main/java/javax/transaction/xa/ mai...
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SQLInputImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SQLInputImplTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SQLInputImplTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SQLInputImplTest.java Mon Jul 16 02:02:56 2007
@@ -51,27 +51,26 @@
public class SQLInputImplTest extends TestCase {
-
/**
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#SQLInputImpl(Object[], Map)}
*/
@SuppressWarnings("unchecked")
public void test_Constructor() {
-
+
try {
new SQLInputImpl(null, new HashMap());
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
+
try {
new SQLInputImpl(null, null);
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
+
try {
new SQLInputImpl(new Object[0], null);
fail("should throw SQLException");
@@ -79,24 +78,25 @@
// expected
}
}
-
+
/**
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#readArray()}
*/
public void testReadArray() throws SQLException {
Array array = new MockArray();
- Object[] attributes = new Object[] {array};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { array };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(array, impl.readArray());
-
+
try {
impl.readArray();
fail("should throw SQLException");
- } catch (SQLException e) {
+ } catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readArray());
}
@@ -106,18 +106,19 @@
*/
public void testReadAsciiStream() throws SQLException {
InputStream stream = new ByteArrayInputStream("abc".getBytes());
- Object[] attributes = new Object[] {stream};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { stream };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(stream, impl.readAsciiStream());
-
+
try {
impl.readAsciiStream();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readAsciiStream());
}
@@ -127,18 +128,19 @@
*/
public void testReadBigDecimal() throws SQLException {
BigDecimal bd = new BigDecimal("12.5");
- Object[] attributes = new Object[] {bd};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { bd };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(bd, impl.readBigDecimal());
-
+
try {
impl.readBigDecimal();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readBigDecimal());
}
@@ -148,11 +150,12 @@
*/
public void testReadBinaryStream() throws SQLException {
InputStream stream = new ByteArrayInputStream("abc".getBytes());
- Object[] attributes = new Object[] {stream};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { stream };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(stream, impl.readBinaryStream());
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readBinaryStream());
}
@@ -162,18 +165,19 @@
*/
public void testReadBlob() throws SQLException {
Blob blob = new MockBlob();
- Object[] attributes = new Object[] {blob};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { blob };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(blob, impl.readBlob());
-
+
try {
impl.readBlob();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readBlob());
}
@@ -182,18 +186,19 @@
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#readBoolean()}
*/
public void testReadBoolean() throws SQLException {
- Object[] attributes = new Object[] {Boolean.TRUE};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { Boolean.TRUE };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(true, impl.readBoolean());
-
+
try {
impl.readBoolean();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertFalse(impl.readBoolean());
}
@@ -202,39 +207,41 @@
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#readByte()}
*/
public void testReadByte() throws SQLException {
- Object[] attributes = new Object[] {Byte.valueOf("3")};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
- assertEquals((byte)3, impl.readByte());
-
+ Object[] attributes = new Object[] { Byte.valueOf("3") };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
+ assertEquals((byte) 3, impl.readByte());
+
try {
impl.readByte();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
- assertEquals((byte)0, impl.readByte());
+ assertEquals((byte) 0, impl.readByte());
}
/**
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#readBytes()}
*/
public void testReadBytes() throws SQLException {
- byte[] bytes = new byte[] {1, 2, 3};
- Object[] attributes = new Object[] {bytes};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ byte[] bytes = new byte[] { 1, 2, 3 };
+ Object[] attributes = new Object[] { bytes };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(bytes, impl.readBytes());
-
+
try {
impl.readBytes();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readBytes());
}
@@ -244,18 +251,19 @@
*/
public void testReadCharacterStream() throws SQLException {
Reader stream = new StringReader("abc");
- Object[] attributes = new Object[] {stream};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { stream };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(stream, impl.readCharacterStream());
-
+
try {
impl.readCharacterStream();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readCharacterStream());
}
@@ -265,18 +273,19 @@
*/
public void testReadClob() throws SQLException {
Clob clob = new MockClob();
- Object[] attributes = new Object[] {clob};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { clob };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(clob, impl.readClob());
-
+
try {
impl.readClob();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readClob());
}
@@ -286,18 +295,19 @@
*/
public void testReadDate() throws SQLException {
Date date = new Date(12);
- Object[] attributes = new Object[] {date};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { date };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(date, impl.readDate());
-
+
try {
impl.readDate();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readDate());
}
@@ -306,18 +316,19 @@
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#readDouble()}
*/
public void testReadDouble() throws SQLException {
- Object[] attributes = new Object[] {Double.valueOf("3")};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
- assertEquals((double)3, impl.readDouble());
-
+ Object[] attributes = new Object[] { Double.valueOf("3") };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
+ assertEquals((double) 3, impl.readDouble());
+
try {
impl.readDouble();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertEquals(0, impl.readDouble(), 0);
}
@@ -326,18 +337,19 @@
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#readFloat()}
*/
public void testReadFloat() throws SQLException {
- Object[] attributes = new Object[] {Float.valueOf("3.5")};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
- assertEquals((float)3.5, impl.readFloat());
-
+ Object[] attributes = new Object[] { Float.valueOf("3.5") };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
+ assertEquals((float) 3.5, impl.readFloat());
+
try {
impl.readFloat();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertEquals(0f, impl.readFloat(), 0);
}
@@ -346,18 +358,19 @@
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#readInt()}
*/
public void testReadInt() throws SQLException {
- Object[] attributes = new Object[] {Integer.valueOf("3")};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { Integer.valueOf("3") };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(3, impl.readInt());
-
+
try {
impl.readInt();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertEquals(0, impl.readInt());
}
@@ -366,18 +379,19 @@
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#readLong()}
*/
public void testReadLong() throws SQLException {
- Object[] attributes = new Object[] {Long.valueOf("3")};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
- assertEquals((long)3, impl.readLong());
-
+ Object[] attributes = new Object[] { Long.valueOf("3") };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
+ assertEquals((long) 3, impl.readLong());
+
try {
impl.readLong();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertEquals(0, impl.readLong());
}
@@ -386,26 +400,28 @@
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#readObject()}
*/
public void testReadObject() throws SQLException {
- Object[] structAttributes = {"hello", Boolean.TRUE, "abc", Integer.valueOf(99)};
- Struct struct = new MockStruct(structAttributes, "harmonytests.MockSQLData");
+ Object[] structAttributes = { "hello", Boolean.TRUE, "abc",
+ Integer.valueOf(99) };
+ Struct struct = new MockStruct(structAttributes,
+ "harmonytests.MockSQLData");
Struct struct2 = new MockStruct(structAttributes, "not stored name");
HashMap<String, Class<?>> types = new HashMap<String, Class<?>>();
types.put("harmonytests.MockSQLData", MockSQLData.class);
- Object[] attributes = new Object[] {struct, struct2, null, "xyz"};
+ Object[] attributes = new Object[] { struct, struct2, null, "xyz" };
SQLInputImpl impl = new SQLInputImpl(attributes, types);
Object obj = impl.readObject();
assertTrue(obj instanceof MockSQLData);
- MockSQLData sqlData = (MockSQLData)obj;
+ MockSQLData sqlData = (MockSQLData) obj;
assertEquals(structAttributes[0], sqlData.firstAttribute);
assertEquals(structAttributes[1], sqlData.secondAttribute);
assertEquals(structAttributes[2], sqlData.thirdAttribute);
- assertEquals(structAttributes[3], sqlData.fourthAttribute);
+ assertEquals(structAttributes[3], sqlData.fourthAttribute);
Object obj2 = impl.readObject();
assertEquals(struct2, obj2);
Object obj3 = impl.readObject();
assertNull(obj3);
Object obj4 = impl.readObject();
- assertEquals(attributes[3], obj4);
+ assertEquals(attributes[3], obj4);
}
/**
@@ -413,18 +429,19 @@
*/
public void testReadRef() throws SQLException {
Ref ref = new MockRef();
- Object[] attributes = new Object[] {ref};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { ref };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(ref, impl.readRef());
-
+
try {
impl.readRef();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readRef());
}
@@ -433,38 +450,40 @@
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#readShort()}
*/
public void testReadShort() throws SQLException {
- Object[] attributes = new Object[] {Short.valueOf("3")};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
- assertEquals((short)3, impl.readShort());
-
+ Object[] attributes = new Object[] { Short.valueOf("3") };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
+ assertEquals((short) 3, impl.readShort());
+
try {
impl.readShort();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
- assertEquals((short)0, impl.readShort());
+ assertEquals((short) 0, impl.readShort());
}
/**
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#readString()}
*/
public void testReadString() throws SQLException {
- Object[] attributes = new Object[] {"hello"};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { "hello" };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals("hello", impl.readString());
-
+
try {
impl.readString();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readString());
}
@@ -474,18 +493,19 @@
*/
public void testReadTime() throws SQLException {
Time time = new Time(345);
- Object[] attributes = new Object[] {time};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { time };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(time, impl.readTime());
-
+
try {
impl.readTime();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
- attributes = new Object[] {null};
+
+ attributes = new Object[] { null };
impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
assertNull(impl.readTime());
}
@@ -495,10 +515,11 @@
*/
public void testReadTimestamp() throws SQLException {
Timestamp time = new Timestamp(345);
- Object[] attributes = new Object[] {time};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { time };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertEquals(time, impl.readTimestamp());
-
+
try {
impl.readTimestamp();
fail("should throw SQLException");
@@ -513,15 +534,16 @@
public void testReadURL() throws SQLException, MalformedURLException {
URL url = new URL("http://www.apache.org");
SerialDatalink link = new SerialDatalink(url);
- Object[] attributes = new Object[] {link};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { link };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
try {
impl.readURL();
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
+
try {
impl.readURL();
fail("should throw SQLException");
@@ -534,8 +556,9 @@
* @tests {@link javax.sql.rowset.serial.SQLInputImpl#wasNull()}
*/
public void testWasNull() throws SQLException {
- Object[] attributes = new Object[] {null, "hello"};
- SQLInputImpl impl = new SQLInputImpl(attributes, new HashMap<String, Class<?>>());
+ Object[] attributes = new Object[] { null, "hello" };
+ SQLInputImpl impl = new SQLInputImpl(attributes,
+ new HashMap<String, Class<?>>());
assertFalse(impl.wasNull());
assertEquals(null, impl.readString());
assertTrue(impl.wasNull());
@@ -551,28 +574,28 @@
assertFalse(impl.wasNull());
}
-
/*
* Mock classes used by both this test and SQLOutputImplTest to test
* readObject and writeObject methods respectively.
*/
-
+
public static class MockStruct implements Struct {
-
+
private String sqlTypeName;
public MockStruct(Object[] attributes, String sqlTypeName) {
this.attributes = attributes;
this.sqlTypeName = sqlTypeName;
}
-
+
Object[] attributes;
public Object[] getAttributes() throws SQLException {
return attributes;
}
- public Object[] getAttributes(Map<String, Class<?>> theMap) throws SQLException {
+ public Object[] getAttributes(Map<String, Class<?>> theMap)
+ throws SQLException {
return attributes;
}
@@ -580,19 +603,23 @@
return sqlTypeName;
}
}
-
+
public static class MockSQLData implements SQLData {
-
+
public String firstAttribute;
+
public Boolean secondAttribute;
+
public String thirdAttribute;
+
public Integer fourthAttribute;
public String getSQLTypeName() throws SQLException {
return "harmonytests.MockSQLData";
}
- public void readSQL(SQLInput stream, String typeName) throws SQLException {
+ public void readSQL(SQLInput stream, String typeName)
+ throws SQLException {
firstAttribute = stream.readString();
secondAttribute = stream.readBoolean();
thirdAttribute = stream.readString();
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SQLOutputImplTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SQLOutputImplTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SQLOutputImplTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SQLOutputImplTest.java Mon Jul 16 02:02:56 2007
@@ -55,31 +55,31 @@
import junit.framework.TestCase;
public class SQLOutputImplTest extends TestCase {
-
+
private static SQLOutputImpl impl;
-
+
private static Vector attr;
-
+
/**
* @tests {@link javax.sql.rowset.serial.SQLOutputImpl#SQLOutputImpl(Vector, Map)}
*/
public void test_ConstructorLjava_util_VectorLjava_util_Map() {
assertNotNull(impl);
-
+
try {
new SQLOutputImpl(null, new HashMap());
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
+
try {
new SQLOutputImpl(null, null);
fail("should throw SQLException");
} catch (SQLException e) {
// expected
}
-
+
try {
new SQLOutputImpl(new Vector(), null);
fail("should throw SQLException");
@@ -96,7 +96,7 @@
impl.writeArray(array);
assertEquals(1, attr.size());
assertTrue(attr.get(0) instanceof SerialArray);
-
+
impl.writeArray(null);
assertNull(attr.get(1));
}
@@ -109,7 +109,7 @@
impl.writeAsciiStream(stream);
assertEquals(1, attr.size());
assertEquals("abc", attr.get(0));
-
+
try {
impl.writeAsciiStream(null);
fail("should throw NullPointerException");
@@ -125,7 +125,7 @@
impl.writeBigDecimal(BigDecimal.ONE);
impl.writeBigDecimal(BigDecimal.ONE);
assertSame(attr.get(0), attr.get(1));
-
+
impl.writeBigDecimal(null);
assertNull(attr.get(2));
}
@@ -133,7 +133,8 @@
/**
* @tests {@link javax.sql.rowset.serial.SQLOutputImpl#writeBinaryStream(InputStream)}
*/
- public void test_writeBinaryStreamLjava_io_InputStream() throws SQLException {
+ public void test_writeBinaryStreamLjava_io_InputStream()
+ throws SQLException {
InputStream stream = new ByteArrayInputStream("abc".getBytes());
impl.writeBinaryStream(stream);
assertEquals(1, attr.size());
@@ -148,7 +149,7 @@
impl.writeBlob(blob);
assertEquals(1, attr.size());
assertTrue(attr.get(0) instanceof SerialBlob);
-
+
impl.writeBlob(null);
assertNull(attr.get(1));
}
@@ -158,13 +159,13 @@
*/
public void test_writeBooleanZ() throws SQLException {
impl.writeBoolean(true);
- assertTrue(((Boolean)attr.get(0)).booleanValue());
-
+ assertTrue(((Boolean) attr.get(0)).booleanValue());
+
impl.writeBoolean(false);
- assertFalse(((Boolean)attr.get(1)).booleanValue());
-
+ assertFalse(((Boolean) attr.get(1)).booleanValue());
+
impl.writeBoolean(true);
- assertTrue(((Boolean)attr.get(2)).booleanValue());
+ assertTrue(((Boolean) attr.get(2)).booleanValue());
}
/**
@@ -172,26 +173,26 @@
*/
public void test_writeByteB() throws SQLException {
assertEquals(0, attr.size());
- impl.writeByte((byte)1);
+ impl.writeByte((byte) 1);
assertEquals(1, attr.size());
- assertEquals(Byte.parseByte("1"), ((Byte)attr.get(0)).byteValue());
-
+ assertEquals(Byte.parseByte("1"), ((Byte) attr.get(0)).byteValue());
+
impl.writeByte((byte) 256);
assertEquals(2, attr.size());
- assertEquals(Byte.parseByte("0"), ((Byte)attr.get(1)).byteValue());
+ assertEquals(Byte.parseByte("0"), ((Byte) attr.get(1)).byteValue());
}
/**
* @tests {@link javax.sql.rowset.serial.SQLOutputImpl#writeBytes(byte[])}
*/
public void test_writeBytes$B() throws SQLException {
- byte[] bytes = new byte[] {4, 5, (byte)256};
+ byte[] bytes = new byte[] { 4, 5, (byte) 256 };
impl.writeBytes(bytes);
assertEquals(1, attr.size());
-
- byte[] attrBytes = (byte[])attr.get(0);
- assertEquals((byte)4, attrBytes[0]);
- assertEquals((byte)0, attrBytes[2]);
+
+ byte[] attrBytes = (byte[]) attr.get(0);
+ assertEquals((byte) 4, attrBytes[0]);
+ assertEquals((byte) 0, attrBytes[2]);
}
/**
@@ -201,7 +202,7 @@
Reader stream = new StringReader("abc");
impl.writeCharacterStream(stream);
assertEquals(1, attr.size());
- assertEquals("abc", attr.get(0));
+ assertEquals("abc", attr.get(0));
}
/**
@@ -232,9 +233,9 @@
attr.add(obj);
impl.writeDouble(3.1415926);
assertEquals(2, attr.size());
-
+
assertEquals(obj, attr.get(0));
- assertEquals(3.1415926, ((Double)attr.get(1)).doubleValue(), 0);
+ assertEquals(3.1415926, ((Double) attr.get(1)).doubleValue(), 0);
}
/**
@@ -254,7 +255,7 @@
*/
public void test_writeIntI() throws SQLException {
impl.writeInt(Integer.MAX_VALUE);
- assertEquals(Integer.MAX_VALUE, ((Integer)attr.get(0)).intValue());
+ assertEquals(Integer.MAX_VALUE, ((Integer) attr.get(0)).intValue());
}
/**
@@ -263,9 +264,9 @@
public void test_writeLongJ() throws SQLException {
impl.writeInt(Integer.MIN_VALUE);
impl.writeLong(Long.MAX_VALUE);
- assertEquals(Long.MAX_VALUE, ((Long)attr.get(1)).longValue());
- }
-
+ assertEquals(Long.MAX_VALUE, ((Long) attr.get(1)).longValue());
+ }
+
/**
* @tests {@link javax.sql.rowset.serial.SQLOutputImpl#writeObject(java.sql.SQLData)}
*/
@@ -285,7 +286,7 @@
assertEquals(sqlData.fourthAttribute, attributes[3]);
assertEquals("harmonytests.MockSQLData", struct.getSQLTypeName());
}
-
+
/**
* @tests {@link javax.sql.rowset.serial.SQLOutputImpl#writeRef(Ref)}
*/
@@ -315,7 +316,7 @@
impl.writeString("def");
assertEquals("def", ((String) attr.get(1)));
}
-
+
/**
* @tests {@link javax.sql.rowset.serial.SQLOutputImpl#writeStruct(java.sql.Struct)}
*/
@@ -336,7 +337,7 @@
Time time = new Time(200);
impl.writeTime(time);
assertEquals(1, attr.size());
- assertEquals(attr.get(0), time);
+ assertEquals(attr.get(0), time);
}
/**
@@ -346,20 +347,21 @@
Timestamp time = new Timestamp(200);
impl.writeTimestamp(time);
assertEquals(1, attr.size());
- assertEquals(attr.get(0), time);
+ assertEquals(attr.get(0), time);
}
/**
* @tests {@link javax.sql.rowset.serial.SQLOutputImpl#writeURL(URL)}
*/
- public void test_writeURLLjava_net_URL() throws MalformedURLException, SQLException {
+ public void test_writeURLLjava_net_URL() throws MalformedURLException,
+ SQLException {
URL url = new URL("http://www.apache.org");
impl.writeURL(url);
assertEquals(1, attr.size());
- assertTrue(attr.get(0) instanceof SerialDatalink);
- assertEquals(url, ((SerialDatalink)attr.get(0)).getDatalink());
-
+ assertTrue(attr.get(0) instanceof SerialDatalink);
+ assertEquals(url, ((SerialDatalink) attr.get(0)).getDatalink());
+
impl.writeURL(null);
assertNull(attr.get(1));
}
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialArrayTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialArrayTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialArrayTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialArrayTest.java Mon Jul 16 02:02:56 2007
@@ -41,7 +41,7 @@
Object[] testElements = new Object[4];
Map<String, Class<?>> map = new HashMap<String, Class<?>>();
-
+
Map<String, Class<?>> badmap = new HashMap<String, Class<?>>();
@Override
@@ -51,8 +51,8 @@
testElements[0] = "test1";
testElements[1] = "test2";
testElements[2] = new SQLException();
- testElements[3] = new HashMap();
- sa = new SerialArray(mock);
+ testElements[3] = new HashMap();
+ sa = new SerialArray(mock);
map = new HashMap<String, Class<?>>();
map.put("String", MockStringSQLData.class);
map.put("Object", null);
@@ -71,12 +71,12 @@
fail("should throw SQLException");
} catch (SQLException e) {
// expected
- }
+ }
testElements = new Object[5];
testElements[0] = "test1";
testElements[1] = "test2";
testElements[2] = new SQLException();
- testElements[3] = new HashMap();
+ testElements[3] = new HashMap();
try {
sa = new SerialArray(mock);
fail("should throw NullPointerException");
@@ -92,7 +92,7 @@
// expected
}
}
-
+
public void testConstructor_IntArray() throws SQLException {
mock.basetype = Types.INTEGER;
// OK
@@ -129,10 +129,10 @@
fail("should throw SQLException");
} catch (SQLException e) {
// expected
- }
- //OK
- sa = new SerialArray(mock,map);
- sa = new SerialArray(mock,badmap);
+ }
+ // OK
+ sa = new SerialArray(mock, map);
+ sa = new SerialArray(mock, badmap);
}
public void testGetArray() throws SerialException {
@@ -151,9 +151,9 @@
for (int i = 0; i < testElements.length; i++) {
assertSame(testElements[i], ((Object[]) sa.getArray(badmap))[i]);
}
-
+
}
-
+
public void testGetArrayLongInt() throws SerialException {
for (int i = 0; i < testElements.length; i++) {
assertEquals(testElements[i], ((Object[]) sa.getArray(i, 1))[0]);
@@ -168,7 +168,8 @@
assertSame(testElements[i], ((Object[]) sa.getArray(i, 1, map))[0]);
}
for (int i = 0; i < testElements.length; i++) {
- assertSame(testElements[i], ((Object[]) sa.getArray(i, 1, badmap))[0]);
+ assertSame(testElements[i],
+ ((Object[]) sa.getArray(i, 1, badmap))[0]);
}
mock.returnNull = true;
// elements force deeper copy
@@ -237,9 +238,9 @@
}
class MockArray implements Array {
-
+
public boolean returnNull = false;
-
+
public int basetype = Types.JAVA_OBJECT;
public Object getArray() throws SQLException {
@@ -268,7 +269,7 @@
}
public Object getArray(Map<String, Class<?>> map) throws SQLException {
- if (!returnNull){
+ if (!returnNull) {
return testElements;
} else {
return null;
@@ -387,7 +388,7 @@
return;
}
}
-
+
private static class SQLArray implements java.sql.Array {
Object[] array;
@@ -408,9 +409,10 @@
return java.sql.Types.CLOB;
}
- /** Everything below here is just supplied to satisfy
- the interface and is not part of this testcase.
- **/
+ /**
+ * Everything below here is just supplied to satisfy the interface and
+ * is not part of this testcase.
+ */
public Object getArray(long index, int count) {
return null;
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialClobTest.java Mon Jul 16 02:02:56 2007
@@ -71,8 +71,8 @@
fail("should throw SerialException");
} catch (SerialException e) {
// expected
- }
-
+ }
+
try {
new SerialClob((Clob) null);
fail("should throw SQLException");
@@ -94,28 +94,28 @@
InputStream is = serialClob.getAsciiStream();
assertTrue(mockClob.isGetAsciiStreamInvoked);
assertEquals(mockClob.asciiInputStream, is);
-
+
try {
serialClob = new SerialClob("helloo".toCharArray());
serialClob.getAsciiStream();
fail("should throw SerialException");
} catch (SerialException e) {
- // expected
- }
+ // expected
+ }
}
public void testGetCharacterStream() throws Exception {
char[] buf = "helloo".toCharArray();
SerialClob serialClob = new SerialClob(buf);
-
+
Reader reader = serialClob.getCharacterStream();
char[] data = new char[buf.length];
int read = reader.read(data);
assertEquals(buf.length, read);
assertTrue(Arrays.equals(buf, data));
assertFalse(reader.ready());
-
+
MockSerialClob mockClob = new MockSerialClob();
mockClob.characterStreamReader = new CharArrayReader(mockClob.buf);
mockClob.asciiInputStream = new ByteArrayInputStream(new byte[] { 1 });
@@ -144,21 +144,21 @@
} catch (SerialException e) {
// expected
}
-
+
try {
sub = serialClob.getSubString(7, 1);
fail("should throw SerialException");
} catch (SerialException e) {
// expected
}
-
+
try {
sub = serialClob.getSubString(1, 7);
fail("should throw SerialException");
} catch (SerialException e) {
// expected
}
-
+
try {
sub = serialClob.getSubString(1, -2);
fail("should throw SerialException");
@@ -171,10 +171,10 @@
} catch (SerialException e) {
// expected
}
-
+
LongLengthClob longClob = new LongLengthClob();
serialClob = new SerialClob(longClob);
-
+
try {
serialClob.getSubString(1, 3);
fail("should throw SerialException");
@@ -189,56 +189,56 @@
SerialClob searchClob = new SerialClob("llo".toCharArray());
long pos = serialClob.position(searchClob, 1);
assertEquals(3, pos);
-
+
pos = serialClob.position(searchClob, 3);
assertEquals(3, pos);
-
+
searchClob = new SerialClob("o".toCharArray());
pos = serialClob.position(searchClob, 6);
assertEquals(6, pos);
-
+
searchClob = new SerialClob("ooooooo".toCharArray());
pos = serialClob.position(searchClob, 1);
assertEquals(-1, pos);
-
+
searchClob = new SerialClob("llo".toCharArray());
pos = serialClob.position(searchClob, 4);
assertEquals(-1, pos);
-
+
pos = serialClob.position(searchClob, 0);
assertEquals(-1, pos);
-
+
pos = serialClob.position(searchClob, -1);
assertEquals(-1, pos);
-
+
pos = serialClob.position(searchClob, 10);
assertEquals(-1, pos);
}
public void testPositionLStringJ() throws Exception {
SerialClob serialClob = new SerialClob("helloo".toCharArray());
-
+
long pos = serialClob.position("llo", 1);
assertEquals(3, pos);
-
+
pos = serialClob.position("llo", 3);
assertEquals(3, pos);
-
+
pos = serialClob.position("o", 6);
assertEquals(6, pos);
-
+
pos = serialClob.position("ooooooo", 1);
assertEquals(-1, pos);
-
+
pos = serialClob.position("llo", 4);
assertEquals(-1, pos);
-
+
pos = serialClob.position("llo", 0);
assertEquals(-1, pos);
-
+
pos = serialClob.position("llo", -1);
assertEquals(-1, pos);
-
+
pos = serialClob.position("llo", 10);
assertEquals(-1, pos);
}
@@ -260,14 +260,14 @@
assertNotNull(os);
assertTrue(mockClob.isSetAsciiStreamInvoked);
assertEquals(mockClob.asciiOutputStream, os);
-
+
try {
serialClob = new SerialClob("helloo".toCharArray());
// Harmony-3491, non bug difference from RI
serialClob.setAsciiStream(1);
fail("should throw SerialException");
} catch (SerialException e) {
- // expected
+ // expected
}
}
@@ -280,14 +280,14 @@
Writer writer = serialClob.setCharacterStream(1);
assertTrue(mockClob.isSetCharacterStreamInvoked);
assertEquals(mockClob.characterStreamWriter, writer);
-
+
try {
serialClob = new SerialClob("helloo".toCharArray());
// Harmony-3491, non bug difference from RI
serialClob.setCharacterStream(1);
fail("should throw SerialException");
} catch (SerialException e) {
- // expected
+ // expected
}
}
@@ -295,31 +295,31 @@
String s = "hello";
char[] buf = s.toCharArray();
SerialClob serialClob = new SerialClob(buf);
-
+
int count = serialClob.setString(1, "olleh");
String sub = serialClob.getSubString(1, 5);
assertEquals("olleh", sub);
assertEquals(5, count);
-
+
count = serialClob.setString(2, "mm");
sub = serialClob.getSubString(1, 5);
assertEquals("ommeh", sub);
assertEquals(2, count);
-
+
try {
serialClob.setString(-1, "hello");
fail("should throw SerialException");
} catch (SerialException e) {
// expected
}
-
+
try {
serialClob.setString(6, "hello");
fail("should throw SerialException");
} catch (SerialException e) {
// expected
}
-
+
// Harmony-3335, non bug difference from RI
try {
serialClob.setString(2, "hello");
@@ -335,34 +335,34 @@
String sub = serialClob.getSubString(1, 5);
assertEquals("olleh", sub);
assertEquals(5, count);
-
- count = serialClob.setString(2, "mmnn",1, 2);
+
+ count = serialClob.setString(2, "mmnn", 1, 2);
sub = serialClob.getSubString(1, 5);
// RI's bug
assertEquals(2, count);
assertEquals("omneh", sub);
-
+
try {
serialClob.setString(-1, "hello", 0, 5);
fail("should throw SerialException");
} catch (SerialException e) {
// expected
}
-
+
try {
serialClob.setString(6, "hello", 0, 5);
fail("should throw SerialException");
} catch (SerialException e) {
// expected
}
-
+
try {
serialClob.setString(1, "hello", 0, 6);
fail("should throw SerialException");
} catch (SerialException e) {
// expected
}
-
+
// Harmony-3335, non bug difference from RI
try {
serialClob.setString(2, "hello", 0, 5);
@@ -370,7 +370,7 @@
} catch (SerialException e) {
// expected
}
-
+
try {
// Harmony-3335
serialClob.setString(1, "hello", -1, 5);
@@ -404,10 +404,11 @@
// expected
}
}
+
private static class LongLengthClob extends MockClob {
@Override
public long length() throws SQLException {
- return (long)Integer.MAX_VALUE * (long)2 + 4;
+ return (long) Integer.MAX_VALUE * (long) 2 + 4;
}
}
@@ -416,15 +417,15 @@
public char[] buf = { 1, 2, 3 };
public Reader characterStreamReader;
-
+
public Writer characterStreamWriter;
public InputStream asciiInputStream;
-
+
public OutputStream asciiOutputStream;
-
+
public boolean isGetAsciiStreamInvoked;
-
+
public boolean isSetAsciiStreamInvoked;
public boolean isSetCharacterStreamInvoked;
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialExceptionTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialExceptionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialExceptionTest.java Mon Jul 16 02:02:56 2007
@@ -24,7 +24,7 @@
import org.apache.harmony.testframework.serialization.SerializationTest;
public class SerialExceptionTest extends TestCase {
- /**
+ /**
* @tests serialization/deserialization compatibility.
*/
public void testSerializationSelf() throws Exception {
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialJavaObjectTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialJavaObjectTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialJavaObjectTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialJavaObjectTest.java Mon Jul 16 02:02:56 2007
@@ -26,8 +26,8 @@
import junit.framework.TestCase;
public class SerialJavaObjectTest extends TestCase {
- public void test_Constructor() throws Exception {
- TransientFieldClass tfc = new TransientFieldClass();
+ public void test_Constructor() throws Exception {
+ TransientFieldClass tfc = new TransientFieldClass();
SerialJavaObject sjo;
try {
sjo = new SerialJavaObject(tfc);
@@ -41,39 +41,44 @@
fail("should throw SerialException");
} catch (SerialException e) {
// excepted
- }
-
- SerializableClass sc = new SerializableClass();
- sjo = new SerialJavaObject(sc);
- assertSame(sc, sjo.getObject());
- Arrays.equals(sjo.getFields(), sc.getClass().getFields());
-
+ }
+
+ SerializableClass sc = new SerializableClass();
+ sjo = new SerialJavaObject(sc);
+ assertSame(sc, sjo.getObject());
+ Arrays.equals(sjo.getFields(), sc.getClass().getFields());
+
try {
new SerialJavaObject(null);
fail("should throw NullPointerException");
} catch (NullPointerException e) {
// expected
}
- }
-
- static class TransientFieldClass {
- transient int i;
- String s;
- }
-
- static class NonSerialiableClass {
- int i;
- String s;
- }
-
- static class StaticFieldClass {
- static int i;
- String s;
- }
-
- static class SerializableClass implements Serializable {
- private static final long serialVersionUID = 0L;
- int i;
- String s;
- }
+ }
+
+ static class TransientFieldClass {
+ transient int i;
+
+ String s;
+ }
+
+ static class NonSerialiableClass {
+ int i;
+
+ String s;
+ }
+
+ static class StaticFieldClass {
+ static int i;
+
+ String s;
+ }
+
+ static class SerializableClass implements Serializable {
+ private static final long serialVersionUID = 0L;
+
+ int i;
+
+ String s;
+ }
}
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialRefTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialRefTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialRefTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/sql/rowset/serial/SerialRefTest.java Mon Jul 16 02:02:56 2007
@@ -32,147 +32,147 @@
*/
public class SerialRefTest extends TestCase {
- private SerialRef sr;
+ private SerialRef sr;
- private SerialRef sr2;
+ private SerialRef sr2;
- private MockRef ref;
+ private MockRef ref;
- @Override
+ @Override
protected void setUp() throws Exception {
- super.setUp();
- ref = new MockRef();
- sr = new SerialRef(ref);
-
- MockAbnormalRef maf = new MockAbnormalRef();
- sr2 = new SerialRef(maf);
- }
-
- /**
- * @tests javax.sql.rowset.serial.SerialRef#SerialRef(Ref ref)
- */
- public void testConstructorRef() throws SerialException, SQLException {
- try {
- new SerialRef(null);
- fail("should throw SQLException");
- } catch (SQLException e) {
- // expected
- }
-
- try {
- ref.setBaseTypeName(null);
- new SerialRef(ref);
- fail("should throw SQLException");
- } catch (SQLException e) {
- // expected
- }
- }
-
- /**
- * @tests javax.sql.rowset.serial.SerialRef#getBaseTypeName()
- */
- public void testGetBaseTypeName() throws SQLException {
- assertEquals(MockRef.BASE_TYPE_NAME, sr.getBaseTypeName());
- }
-
- /**
- * @tests javax.sql.rowset.serial.SerialRef#getObject()
- */
- public void testGetObject() throws SQLException {
- assertSame(ref.obj1, sr.getObject());
-
- sr.setObject(null);
- assertNull(sr.getObject());
-
- Object obj = new Object();
- sr.setObject(obj);
- assertSame(obj, sr.getObject());
-
- try {
- sr2.getObject();
- fail("should throw SerialException");
- } catch (SerialException e) {
- // expected
- }
-
- try {
- sr2.setObject(obj);
- fail("should throw SerialException");
- } catch (SerialException e) {
- // expected
- }
-
- }
-
- /**
- * @tests javax.sql.rowset.serial.SerialRef#getObject(Map)
- */
- public void testGetObjectLjava_util_Map() throws SQLException {
- try {
- assertNull(sr.getObject(null));
- fail("should throw NullPointerException");
- } catch (NullPointerException e) {
- // expected
- }
-
- Map<String, Class<?>> map = new Hashtable<String, Class<?>>();
- assertNull(sr.getObject(map));
-
- map.put("MockRef", MockRef.class);
- assertNull(sr.getObject(map));
-
- sr.setObject("MockRef1");
- assertNull(sr.getObject(map));
-
- sr.setObject("MockRef");
- assertSame(MockRef.class, sr.getObject(map));
- }
-
- static class MockRef implements Ref {
- private static final String BASE_TYPE_NAME = "MockBaseTypeName";
-
- String baseTypeName = BASE_TYPE_NAME;
-
- Object obj1 = new Object();
-
- Object obj2 = new Object();
-
- public String getBaseTypeName() throws SQLException {
- return baseTypeName;
- }
-
- public Object getObject() throws SQLException {
- return obj1;
- }
-
- public Object getObject(Map<String, Class<?>> map) throws SQLException {
- return obj2;
- }
-
- public void setObject(Object value) throws SQLException {
- obj1 = value;
- }
-
- public void setBaseTypeName(String name) {
- baseTypeName = name;
- }
- };
+ super.setUp();
+ ref = new MockRef();
+ sr = new SerialRef(ref);
+
+ MockAbnormalRef maf = new MockAbnormalRef();
+ sr2 = new SerialRef(maf);
+ }
+
+ /**
+ * @tests javax.sql.rowset.serial.SerialRef#SerialRef(Ref ref)
+ */
+ public void testConstructorRef() throws SerialException, SQLException {
+ try {
+ new SerialRef(null);
+ fail("should throw SQLException");
+ } catch (SQLException e) {
+ // expected
+ }
+
+ try {
+ ref.setBaseTypeName(null);
+ new SerialRef(ref);
+ fail("should throw SQLException");
+ } catch (SQLException e) {
+ // expected
+ }
+ }
+
+ /**
+ * @tests javax.sql.rowset.serial.SerialRef#getBaseTypeName()
+ */
+ public void testGetBaseTypeName() throws SQLException {
+ assertEquals(MockRef.BASE_TYPE_NAME, sr.getBaseTypeName());
+ }
+
+ /**
+ * @tests javax.sql.rowset.serial.SerialRef#getObject()
+ */
+ public void testGetObject() throws SQLException {
+ assertSame(ref.obj1, sr.getObject());
+
+ sr.setObject(null);
+ assertNull(sr.getObject());
+
+ Object obj = new Object();
+ sr.setObject(obj);
+ assertSame(obj, sr.getObject());
+
+ try {
+ sr2.getObject();
+ fail("should throw SerialException");
+ } catch (SerialException e) {
+ // expected
+ }
+
+ try {
+ sr2.setObject(obj);
+ fail("should throw SerialException");
+ } catch (SerialException e) {
+ // expected
+ }
+
+ }
+
+ /**
+ * @tests javax.sql.rowset.serial.SerialRef#getObject(Map)
+ */
+ public void testGetObjectLjava_util_Map() throws SQLException {
+ try {
+ assertNull(sr.getObject(null));
+ fail("should throw NullPointerException");
+ } catch (NullPointerException e) {
+ // expected
+ }
+
+ Map<String, Class<?>> map = new Hashtable<String, Class<?>>();
+ assertNull(sr.getObject(map));
+
+ map.put("MockRef", MockRef.class);
+ assertNull(sr.getObject(map));
+
+ sr.setObject("MockRef1");
+ assertNull(sr.getObject(map));
+
+ sr.setObject("MockRef");
+ assertSame(MockRef.class, sr.getObject(map));
+ }
+
+ static class MockRef implements Ref {
+ private static final String BASE_TYPE_NAME = "MockBaseTypeName";
+
+ String baseTypeName = BASE_TYPE_NAME;
+
+ Object obj1 = new Object();
+
+ Object obj2 = new Object();
+
+ public String getBaseTypeName() throws SQLException {
+ return baseTypeName;
+ }
- static class MockAbnormalRef extends MockRef {
- @Override
public Object getObject() throws SQLException {
- throw new SQLException();
- }
+ return obj1;
+ }
- @Override
public Object getObject(Map<String, Class<?>> map) throws SQLException {
- throw new SQLException();
- }
+ return obj2;
+ }
- @Override
public void setObject(Object value) throws SQLException {
- throw new SQLException();
- }
- };
+ obj1 = value;
+ }
+
+ public void setBaseTypeName(String name) {
+ baseTypeName = name;
+ }
+ };
+
+ static class MockAbnormalRef extends MockRef {
+ @Override
+ public Object getObject() throws SQLException {
+ throw new SQLException();
+ }
+
+ @Override
+ public Object getObject(Map<String, Class<?>> map) throws SQLException {
+ throw new SQLException();
+ }
+
+ @Override
+ public void setObject(Object value) throws SQLException {
+ throw new SQLException();
+ }
+ };
}
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/InvalidTransactionExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/InvalidTransactionExceptionTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/InvalidTransactionExceptionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/InvalidTransactionExceptionTest.java Mon Jul 16 02:02:56 2007
@@ -23,76 +23,77 @@
public class InvalidTransactionExceptionTest extends TestCase {
- /*
- * ConstructorTest
- */
- public void testInvalidTransactionExceptionString() {
-
- String[] init1 = { "a", "1", "valid1", "----", "&valid*", null, "", "\u0000" };
-
- String[] theFinalStates1 = init1;
-
- Exception[] theExceptions = { null, null, null, null, null, null, null,
- null };
-
- InvalidTransactionException aInvalidTransactionException;
- int loopCount = init1.length;
- for (int i = 0; i < loopCount; i++) {
- try {
- aInvalidTransactionException = new InvalidTransactionException(
- init1[i]);
- if (theExceptions[i] != null) {
+ /*
+ * ConstructorTest
+ */
+ public void testInvalidTransactionExceptionString() {
+
+ String[] init1 = { "a", "1", "valid1", "----", "&valid*", null, "",
+ "\u0000" };
+
+ String[] theFinalStates1 = init1;
+
+ Exception[] theExceptions = { null, null, null, null, null, null, null,
+ null };
+
+ InvalidTransactionException aInvalidTransactionException;
+ int loopCount = init1.length;
+ for (int i = 0; i < loopCount; i++) {
+ try {
+ aInvalidTransactionException = new InvalidTransactionException(
+ init1[i]);
+ if (theExceptions[i] != null) {
fail();
}
- assertEquals(i + " Final state mismatch",
- aInvalidTransactionException.getMessage(),
- theFinalStates1[i]);
+ assertEquals(i + " Final state mismatch",
+ aInvalidTransactionException.getMessage(),
+ theFinalStates1[i]);
- } catch (Exception e) {
- if (theExceptions[i] == null) {
+ } catch (Exception e) {
+ if (theExceptions[i] == null) {
fail(i + "Unexpected exception");
}
- assertEquals(i + "Exception mismatch", e.getClass(),
- theExceptions[i].getClass());
- assertEquals(i + "Exception mismatch", e.getMessage(),
- theExceptions[i].getMessage());
- } // end try
- } // end for
-
- } // end method testInvalidTransactionExceptionString
-
- /*
- * ConstructorTest
- */
- public void testInvalidTransactionException() {
-
- String[] theFinalStates1 = { null };
-
- Exception[] theExceptions = { null };
-
- InvalidTransactionException aInvalidTransactionException;
- int loopCount = 1;
- for (int i = 0; i < loopCount; i++) {
- try {
- aInvalidTransactionException = new InvalidTransactionException();
- if (theExceptions[i] != null) {
+ assertEquals(i + "Exception mismatch", e.getClass(),
+ theExceptions[i].getClass());
+ assertEquals(i + "Exception mismatch", e.getMessage(),
+ theExceptions[i].getMessage());
+ } // end try
+ } // end for
+
+ } // end method testInvalidTransactionExceptionString
+
+ /*
+ * ConstructorTest
+ */
+ public void testInvalidTransactionException() {
+
+ String[] theFinalStates1 = { null };
+
+ Exception[] theExceptions = { null };
+
+ InvalidTransactionException aInvalidTransactionException;
+ int loopCount = 1;
+ for (int i = 0; i < loopCount; i++) {
+ try {
+ aInvalidTransactionException = new InvalidTransactionException();
+ if (theExceptions[i] != null) {
fail();
}
- assertEquals(i + " Final state mismatch",
- aInvalidTransactionException.getMessage(),
- theFinalStates1[i]);
+ assertEquals(i + " Final state mismatch",
+ aInvalidTransactionException.getMessage(),
+ theFinalStates1[i]);
- } catch (Exception e) {
- if (theExceptions[i] == null) {
+ } catch (Exception e) {
+ if (theExceptions[i] == null) {
fail(i + "Unexpected exception");
}
- assertEquals(i + "Exception mismatch", e.getClass(),
- theExceptions[i].getClass());
- assertEquals(i + "Exception mismatch", e.getMessage(),
- theExceptions[i].getMessage());
- } // end try
- } // end for
+ assertEquals(i + "Exception mismatch", e.getClass(),
+ theExceptions[i].getClass());
+ assertEquals(i + "Exception mismatch", e.getMessage(),
+ theExceptions[i].getMessage());
+ } // end try
+ } // end for
- } // end method testInvalidTransactionException
+ } // end method testInvalidTransactionException
} // end class InvalidTransactionExceptionTest
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRequiredExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRequiredExceptionTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
Binary files /tmp/tmpp3Uckw and /tmp/tmpc4tI48 differ
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRolledbackExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/TransactionRolledbackExceptionTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
Binary files /tmp/tmphowU8E and /tmp/tmpC1Al-s differ
Modified: harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/xa/XAExceptionTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/xa/XAExceptionTest.java?view=diff&rev=556562&r1=556561&r2=556562
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/xa/XAExceptionTest.java (original)
+++ harmony/enhanced/classlib/trunk/modules/sql/src/test/java/org/apache/harmony/sql/tests/javax/transaction/xa/XAExceptionTest.java Mon Jul 16 02:02:56 2007
@@ -27,198 +27,198 @@
public class XAExceptionTest extends TestCase {
- /*
- * Public statics test
- */
- public void testPublicStatics() {
-
- HashMap<String, Integer> thePublicStatics = new HashMap<String, Integer>();
- thePublicStatics.put("XAER_OUTSIDE", new Integer(-9));
- thePublicStatics.put("XAER_DUPID", new Integer(-8));
- thePublicStatics.put("XAER_RMFAIL", new Integer(-7));
- thePublicStatics.put("XAER_PROTO", new Integer(-6));
- thePublicStatics.put("XAER_INVAL", new Integer(-5));
- thePublicStatics.put("XAER_NOTA", new Integer(-4));
- thePublicStatics.put("XAER_RMERR", new Integer(-3));
- thePublicStatics.put("XAER_ASYNC", new Integer(-2));
- thePublicStatics.put("XA_RDONLY", new Integer(3));
- thePublicStatics.put("XA_RETRY", new Integer(4));
- thePublicStatics.put("XA_HEURMIX", new Integer(5));
- thePublicStatics.put("XA_HEURRB", new Integer(6));
- thePublicStatics.put("XA_HEURCOM", new Integer(7));
- thePublicStatics.put("XA_HEURHAZ", new Integer(8));
- thePublicStatics.put("XA_NOMIGRATE", new Integer(9));
- thePublicStatics.put("XA_RBEND", new Integer(107));
- thePublicStatics.put("XA_RBTRANSIENT", new Integer(107));
- thePublicStatics.put("XA_RBTIMEOUT", new Integer(106));
- thePublicStatics.put("XA_RBPROTO", new Integer(105));
- thePublicStatics.put("XA_RBOTHER", new Integer(104));
- thePublicStatics.put("XA_RBINTEGRITY", new Integer(103));
- thePublicStatics.put("XA_RBDEADLOCK", new Integer(102));
- thePublicStatics.put("XA_RBCOMMFAIL", new Integer(101));
- thePublicStatics.put("XA_RBROLLBACK", new Integer(100));
- thePublicStatics.put("XA_RBBASE", new Integer(100));
-
- Class<?> xAExceptionClass;
- try {
- xAExceptionClass = Class
- .forName("javax.transaction.xa.XAException");
- } catch (ClassNotFoundException e) {
- fail("javax.transaction.xa.XAException class not found!");
- return;
- } // end try
-
- Field[] theFields = xAExceptionClass.getDeclaredFields();
- int requiredModifier = Modifier.PUBLIC + Modifier.STATIC
- + Modifier.FINAL;
-
- int countPublicStatics = 0;
- for (Field element : theFields) {
- String fieldName = element.getName();
- int theMods = element.getModifiers();
- if (Modifier.isPublic(theMods) && Modifier.isStatic(theMods)) {
- try {
- Object fieldValue = element.get(null);
- Object expectedValue = thePublicStatics.get(fieldName);
- if (expectedValue == null) {
- fail("Field " + fieldName + " missing!");
- } // end
- assertEquals("Field " + fieldName + " value mismatch: ",
- expectedValue, fieldValue);
- assertEquals("Field " + fieldName + " modifier mismatch: ",
- requiredModifier, theMods);
- countPublicStatics++;
- } catch (IllegalAccessException e) {
- fail("Illegal access to Field " + fieldName);
- } // end try
- } // end if
- } // end for
-
- } // end method testPublicStatics
-
- /*
- * ConstructorTest
- */
- public void testXAExceptionint() {
-
- int[] init1 = { -2147483648, 2147483647, 0, 1856939228, -217759650,
- -1808025128, -69857128 };
-
- String[] theFinalStates1 = { null, null, null, null, null, null, null };
-
- Exception[] theExceptions = { null, null, null, null, null, null, null };
-
- XAException aXAException;
- int loopCount = init1.length;
- for (int i = 0; i < loopCount; i++) {
- try {
- aXAException = new XAException(init1[i]);
- if (theExceptions[i] != null) {
+ /*
+ * Public statics test
+ */
+ public void testPublicStatics() {
+
+ HashMap<String, Integer> thePublicStatics = new HashMap<String, Integer>();
+ thePublicStatics.put("XAER_OUTSIDE", new Integer(-9));
+ thePublicStatics.put("XAER_DUPID", new Integer(-8));
+ thePublicStatics.put("XAER_RMFAIL", new Integer(-7));
+ thePublicStatics.put("XAER_PROTO", new Integer(-6));
+ thePublicStatics.put("XAER_INVAL", new Integer(-5));
+ thePublicStatics.put("XAER_NOTA", new Integer(-4));
+ thePublicStatics.put("XAER_RMERR", new Integer(-3));
+ thePublicStatics.put("XAER_ASYNC", new Integer(-2));
+ thePublicStatics.put("XA_RDONLY", new Integer(3));
+ thePublicStatics.put("XA_RETRY", new Integer(4));
+ thePublicStatics.put("XA_HEURMIX", new Integer(5));
+ thePublicStatics.put("XA_HEURRB", new Integer(6));
+ thePublicStatics.put("XA_HEURCOM", new Integer(7));
+ thePublicStatics.put("XA_HEURHAZ", new Integer(8));
+ thePublicStatics.put("XA_NOMIGRATE", new Integer(9));
+ thePublicStatics.put("XA_RBEND", new Integer(107));
+ thePublicStatics.put("XA_RBTRANSIENT", new Integer(107));
+ thePublicStatics.put("XA_RBTIMEOUT", new Integer(106));
+ thePublicStatics.put("XA_RBPROTO", new Integer(105));
+ thePublicStatics.put("XA_RBOTHER", new Integer(104));
+ thePublicStatics.put("XA_RBINTEGRITY", new Integer(103));
+ thePublicStatics.put("XA_RBDEADLOCK", new Integer(102));
+ thePublicStatics.put("XA_RBCOMMFAIL", new Integer(101));
+ thePublicStatics.put("XA_RBROLLBACK", new Integer(100));
+ thePublicStatics.put("XA_RBBASE", new Integer(100));
+
+ Class<?> xAExceptionClass;
+ try {
+ xAExceptionClass = Class
+ .forName("javax.transaction.xa.XAException");
+ } catch (ClassNotFoundException e) {
+ fail("javax.transaction.xa.XAException class not found!");
+ return;
+ } // end try
+
+ Field[] theFields = xAExceptionClass.getDeclaredFields();
+ int requiredModifier = Modifier.PUBLIC + Modifier.STATIC
+ + Modifier.FINAL;
+
+ int countPublicStatics = 0;
+ for (Field element : theFields) {
+ String fieldName = element.getName();
+ int theMods = element.getModifiers();
+ if (Modifier.isPublic(theMods) && Modifier.isStatic(theMods)) {
+ try {
+ Object fieldValue = element.get(null);
+ Object expectedValue = thePublicStatics.get(fieldName);
+ if (expectedValue == null) {
+ fail("Field " + fieldName + " missing!");
+ } // end
+ assertEquals("Field " + fieldName + " value mismatch: ",
+ expectedValue, fieldValue);
+ assertEquals("Field " + fieldName + " modifier mismatch: ",
+ requiredModifier, theMods);
+ countPublicStatics++;
+ } catch (IllegalAccessException e) {
+ fail("Illegal access to Field " + fieldName);
+ } // end try
+ } // end if
+ } // end for
+
+ } // end method testPublicStatics
+
+ /*
+ * ConstructorTest
+ */
+ public void testXAExceptionint() {
+
+ int[] init1 = { -2147483648, 2147483647, 0, 1856939228, -217759650,
+ -1808025128, -69857128 };
+
+ String[] theFinalStates1 = { null, null, null, null, null, null, null };
+
+ Exception[] theExceptions = { null, null, null, null, null, null, null };
+
+ XAException aXAException;
+ int loopCount = init1.length;
+ for (int i = 0; i < loopCount; i++) {
+ try {
+ aXAException = new XAException(init1[i]);
+ if (theExceptions[i] != null) {
fail();
}
- assertEquals(i + " Final state mismatch", aXAException
- .getMessage(), theFinalStates1[i]);
+ assertEquals(i + " Final state mismatch", aXAException
+ .getMessage(), theFinalStates1[i]);
- } catch (Exception e) {
- if (theExceptions[i] == null) {
+ } catch (Exception e) {
+ if (theExceptions[i] == null) {
fail(i + "Unexpected exception");
}
- assertEquals(i + "Exception mismatch", e.getClass(),
- theExceptions[i].getClass());
- assertEquals(i + "Exception mismatch", e.getMessage(),
- theExceptions[i].getMessage());
- } // end try
- } // end for
-
- } // end method testXAExceptionint
-
- /*
- * ConstructorTest
- */
- public void testXAExceptionString() {
-
- String[] init1 = { "a", "1", "valid1", "----", "&valid*", null, "", "