Java 类javax.sql.rowset.serial.SQLInputImpl 实例源码

项目:cn1    文件:SQLInputImplTest.java   
/**
 * @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");
    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" };
    SQLInputImpl impl = new SQLInputImpl(attributes, types);
    Object obj = impl.readObject();
    assertTrue(obj instanceof MockSQLData);
    MockSQLData sqlData = (MockSQLData) obj;
    assertEquals(structAttributes[0], sqlData.firstAttribute);
    assertEquals(structAttributes[1], sqlData.secondAttribute);
    assertEquals(structAttributes[2], sqlData.thirdAttribute);
    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);
}
项目:cn1    文件:SQLInputImplTest.java   
/**
 * @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<?>>());
    assertFalse(impl.wasNull());
    assertEquals(null, impl.readString());
    assertTrue(impl.wasNull());
    assertEquals("hello", impl.readString());
    assertFalse(impl.wasNull());
    try {
        impl.readString();
        fail("should throw SQLException");
    } catch (SQLException e) {
        // expected
    }
    assertFalse(impl.wasNull());
    assertFalse(impl.wasNull());
}
项目:freeVM    文件:SQLInputImplTest.java   
/**
 * @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");
    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" };
    SQLInputImpl impl = new SQLInputImpl(attributes, types);
    Object obj = impl.readObject();
    assertTrue(obj instanceof MockSQLData);
    MockSQLData sqlData = (MockSQLData) obj;
    assertEquals(structAttributes[0], sqlData.firstAttribute);
    assertEquals(structAttributes[1], sqlData.secondAttribute);
    assertEquals(structAttributes[2], sqlData.thirdAttribute);
    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);
}
项目:freeVM    文件:SQLInputImplTest.java   
/**
 * @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<?>>());
    assertFalse(impl.wasNull());
    assertEquals(null, impl.readString());
    assertTrue(impl.wasNull());
    assertEquals("hello", impl.readString());
    assertFalse(impl.wasNull());
    try {
        impl.readString();
        fail("should throw SQLException");
    } catch (SQLException e) {
        // expected
    }
    assertFalse(impl.wasNull());
    assertFalse(impl.wasNull());
}
项目:jdk8u-jdk    文件:SQLOutputImplTests.java   
@Test()
public void test03() throws Exception {
    impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
    impl.writeSQL(outImpl);
    assertTrue(Arrays.equals(results.toArray(), typeValues));
    // Null out a field and make sure the arrays do not match
    typeValues[2] = null;
    assertFalse(Arrays.equals(results.toArray(), typeValues));
}
项目:jdk8u-jdk    文件:SQLInputImplTests.java   
@Test()
public void test03() throws Exception {
    impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
    assertTrue(Arrays.equals(impl.toArray(), typeValues));
    // Null out a field and make sure the arrays do not match
    typeValues[2] = null;
    assertFalse(Arrays.equals(impl.toArray(), typeValues));
}
项目:jdk8u-jdk    文件:SQLInputImplTests.java   
@Test()
public void test04() throws Exception {
    Object[] values = {"Hello", null, 1};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    String s = sqli.readString();
    assertFalse(sqli.wasNull());
    s = sqli.readString();
    assertTrue(sqli.wasNull());
    int i = sqli.readInt();
    assertFalse(sqli.wasNull());
}
项目:jdk8u-jdk    文件:SQLInputImplTests.java   
@Test()
public void test05() throws Exception {
    Object[] values = {hero};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Object o = sqli.readObject();
    assertTrue(hero.equals(o));

}
项目:jdk8u-jdk    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test06() throws Exception {
    Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast",
        "Cappuccino"};
    Array a = new StubArray("VARCHAR", coffees);
    Object[] values = {a};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Array a2 = sqli.readArray();
    assertTrue(Arrays.equals((Object[]) a2.getArray(), (Object[]) a.getArray()));
    assertTrue(a.getBaseTypeName().equals(a2.getBaseTypeName()));
}
项目:jdk8u-jdk    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test07() throws Exception {
    Blob b = new StubBlob();
    Object[] values = {b};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Blob b2 = sqli.readBlob();
    assertTrue(Arrays.equals(
            b.getBytes(1, (int) b.length()),
            b2.getBytes(1, (int) b2.length())));
}
项目:jdk8u-jdk    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test08() throws Exception {
    Clob c = new StubClob();
    Object[] values = {c};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Clob c2 = sqli.readClob();
    assertTrue(c.getSubString(1,
            (int) c.length()).equals(c2.getSubString(1, (int) c2.length())));
}
项目:jdk8u-jdk    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test09() throws Exception {
    Ref ref = new StubRef(sqlType, hero);
    Object[] values = {ref};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Ref ref2 = sqli.readRef();
    assertTrue(ref.getObject().equals(ref2.getObject()));
    assertTrue(ref.getBaseTypeName().equals(ref2.getBaseTypeName()));
}
项目:jdk8u-jdk    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test10() throws Exception {
    URL u = new URL("http://www.oracle.com/");;
    Object[] values = {u};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    URL u2 = sqli.readURL();
    assertTrue(u2.equals(u));
    assertTrue(u2.sameFile(u));
}
项目:jdk8u-jdk    文件:SQLInputImplTests.java   
@Test()
public void test11() throws Exception {
    Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
        "Batman"};
    map.put(sqlType, Class.forName("util.SuperHero"));
    Struct struct = new StubStruct(sqlType, attributes);
    Object[] values = {struct};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Object o = sqli.readObject();

    assertTrue(hero.equals(o));

}
项目:openjdk-jdk10    文件:SQLOutputImplTests.java   
@Test()
public void test03() throws Exception {
    impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
    impl.writeSQL(outImpl);
    assertTrue(Arrays.equals(results.toArray(), typeValues));
    // Null out a field and make sure the arrays do not match
    typeValues[2] = null;
    assertFalse(Arrays.equals(results.toArray(), typeValues));
}
项目:openjdk-jdk10    文件:SQLInputImplTests.java   
@Test()
public void test03() throws Exception {
    impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
    assertTrue(Arrays.equals(impl.toArray(), typeValues));
    // Null out a field and make sure the arrays do not match
    typeValues[2] = null;
    assertFalse(Arrays.equals(impl.toArray(), typeValues));
}
项目:openjdk-jdk10    文件:SQLInputImplTests.java   
@Test()
public void test04() throws Exception {
    Object[] values = {"Hello", null, 1};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    String s = sqli.readString();
    assertFalse(sqli.wasNull());
    s = sqli.readString();
    assertTrue(sqli.wasNull());
    int i = sqli.readInt();
    assertFalse(sqli.wasNull());
}
项目:openjdk-jdk10    文件:SQLInputImplTests.java   
@Test()
public void test05() throws Exception {
    Object[] values = {hero};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Object o = sqli.readObject();
    assertTrue(hero.equals(o));

}
项目:openjdk-jdk10    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test06() throws Exception {
    Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast",
        "Cappuccino"};
    Array a = new StubArray("VARCHAR", coffees);
    Object[] values = {a};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Array a2 = sqli.readArray();
    assertTrue(Arrays.equals((Object[]) a2.getArray(), (Object[]) a.getArray()));
    assertTrue(a.getBaseTypeName().equals(a2.getBaseTypeName()));
}
项目:openjdk-jdk10    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test07() throws Exception {
    Blob b = new StubBlob();
    Object[] values = {b};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Blob b2 = sqli.readBlob();
    assertTrue(Arrays.equals(
            b.getBytes(1, (int) b.length()),
            b2.getBytes(1, (int) b2.length())));
}
项目:openjdk-jdk10    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test08() throws Exception {
    Clob c = new StubClob();
    Object[] values = {c};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Clob c2 = sqli.readClob();
    assertTrue(c.getSubString(1,
            (int) c.length()).equals(c2.getSubString(1, (int) c2.length())));
}
项目:openjdk-jdk10    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test09() throws Exception {
    Ref ref = new StubRef(sqlType, hero);
    Object[] values = {ref};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Ref ref2 = sqli.readRef();
    assertTrue(ref.getObject().equals(ref2.getObject()));
    assertTrue(ref.getBaseTypeName().equals(ref2.getBaseTypeName()));
}
项目:openjdk-jdk10    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test10() throws Exception {
    URL u = new URL("http://www.oracle.com/");;
    Object[] values = {u};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    URL u2 = sqli.readURL();
    assertTrue(u2.equals(u));
    assertTrue(u2.sameFile(u));
}
项目:openjdk-jdk10    文件:SQLInputImplTests.java   
@Test()
public void test11() throws Exception {
    Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
        "Batman"};
    map.put(sqlType, Class.forName("util.SuperHero"));
    Struct struct = new StubStruct(sqlType, attributes);
    Object[] values = {struct};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Object o = sqli.readObject();

    assertTrue(hero.equals(o));

}
项目:openjdk9    文件:SQLOutputImplTests.java   
@Test()
public void test03() throws Exception {
    impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
    impl.writeSQL(outImpl);
    assertTrue(Arrays.equals(results.toArray(), typeValues));
    // Null out a field and make sure the arrays do not match
    typeValues[2] = null;
    assertFalse(Arrays.equals(results.toArray(), typeValues));
}
项目:openjdk9    文件:SQLInputImplTests.java   
@Test()
public void test03() throws Exception {
    impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
    assertTrue(Arrays.equals(impl.toArray(), typeValues));
    // Null out a field and make sure the arrays do not match
    typeValues[2] = null;
    assertFalse(Arrays.equals(impl.toArray(), typeValues));
}
项目:openjdk9    文件:SQLInputImplTests.java   
@Test()
public void test04() throws Exception {
    Object[] values = {"Hello", null, 1};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    String s = sqli.readString();
    assertFalse(sqli.wasNull());
    s = sqli.readString();
    assertTrue(sqli.wasNull());
    int i = sqli.readInt();
    assertFalse(sqli.wasNull());
}
项目:openjdk9    文件:SQLInputImplTests.java   
@Test()
public void test05() throws Exception {
    Object[] values = {hero};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Object o = sqli.readObject();
    assertTrue(hero.equals(o));

}
项目:openjdk9    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test06() throws Exception {
    Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast",
        "Cappuccino"};
    Array a = new StubArray("VARCHAR", coffees);
    Object[] values = {a};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Array a2 = sqli.readArray();
    assertTrue(Arrays.equals((Object[]) a2.getArray(), (Object[]) a.getArray()));
    assertTrue(a.getBaseTypeName().equals(a2.getBaseTypeName()));
}
项目:openjdk9    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test07() throws Exception {
    Blob b = new StubBlob();
    Object[] values = {b};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Blob b2 = sqli.readBlob();
    assertTrue(Arrays.equals(
            b.getBytes(1, (int) b.length()),
            b2.getBytes(1, (int) b2.length())));
}
项目:openjdk9    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test08() throws Exception {
    Clob c = new StubClob();
    Object[] values = {c};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Clob c2 = sqli.readClob();
    assertTrue(c.getSubString(1,
            (int) c.length()).equals(c2.getSubString(1, (int) c2.length())));
}
项目:openjdk9    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test09() throws Exception {
    Ref ref = new StubRef(sqlType, hero);
    Object[] values = {ref};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Ref ref2 = sqli.readRef();
    assertTrue(ref.getObject().equals(ref2.getObject()));
    assertTrue(ref.getBaseTypeName().equals(ref2.getBaseTypeName()));
}
项目:openjdk9    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test10() throws Exception {
    URL u = new URL("http://www.oracle.com/");;
    Object[] values = {u};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    URL u2 = sqli.readURL();
    assertTrue(u2.equals(u));
    assertTrue(u2.sameFile(u));
}
项目:openjdk9    文件:SQLInputImplTests.java   
@Test()
public void test11() throws Exception {
    Object[] attributes = new Object[]{"Bruce", "Wayne", 1939,
        "Batman"};
    map.put(sqlType, Class.forName("util.SuperHero"));
    Struct struct = new StubStruct(sqlType, attributes);
    Object[] values = {struct};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Object o = sqli.readObject();

    assertTrue(hero.equals(o));

}
项目:jdk8u_jdk    文件:SQLOutputImplTests.java   
@Test()
public void test03() throws Exception {
    impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
    impl.writeSQL(outImpl);
    assertTrue(Arrays.equals(results.toArray(), typeValues));
    // Null out a field and make sure the arrays do not match
    typeValues[2] = null;
    assertFalse(Arrays.equals(results.toArray(), typeValues));
}
项目:jdk8u_jdk    文件:SQLInputImplTests.java   
@Test()
public void test03() throws Exception {
    impl.readSQL(new SQLInputImpl(typeValues, map), "misc");
    assertTrue(Arrays.equals(impl.toArray(), typeValues));
    // Null out a field and make sure the arrays do not match
    typeValues[2] = null;
    assertFalse(Arrays.equals(impl.toArray(), typeValues));
}
项目:jdk8u_jdk    文件:SQLInputImplTests.java   
@Test()
public void test04() throws Exception {
    Object[] values = {"Hello", null, 1};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    String s = sqli.readString();
    assertFalse(sqli.wasNull());
    s = sqli.readString();
    assertTrue(sqli.wasNull());
    int i = sqli.readInt();
    assertFalse(sqli.wasNull());
}
项目:jdk8u_jdk    文件:SQLInputImplTests.java   
@Test()
public void test05() throws Exception {
    Object[] values = {hero};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Object o = sqli.readObject();
    assertTrue(hero.equals(o));

}
项目:jdk8u_jdk    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test06() throws Exception {
    Object[] coffees = new Object[]{"Espresso", "Colombian", "French Roast",
        "Cappuccino"};
    Array a = new StubArray("VARCHAR", coffees);
    Object[] values = {a};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Array a2 = sqli.readArray();
    assertTrue(Arrays.equals((Object[]) a2.getArray(), (Object[]) a.getArray()));
    assertTrue(a.getBaseTypeName().equals(a2.getBaseTypeName()));
}
项目:jdk8u_jdk    文件:SQLInputImplTests.java   
@Test(enabled = true)
public void test07() throws Exception {
    Blob b = new StubBlob();
    Object[] values = {b};
    SQLInputImpl sqli = new SQLInputImpl(values, map);
    Blob b2 = sqli.readBlob();
    assertTrue(Arrays.equals(
            b.getBytes(1, (int) b.length()),
            b2.getBytes(1, (int) b2.length())));
}