javax.sql.rowset.serial.SerialBlob Java Examples

The following examples show how to use javax.sql.rowset.serial.SerialBlob. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SerialBlobTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test29() throws Exception {
    long expectedPos = 2; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{4, 6};
    SerialBlob sb = new SerialBlob(new StubBlob());
    long pos = sb.position(pattern, 1);
    assertEquals(pos, expectedPos);
}
 
Example #2
Source File: TradePortfolioV1DMLStmt.java    From gemfirexd-oss with Apache License 2.0 5 votes vote down vote up
protected void getBlobData(int size, Blob[] data) {
  int regBlobSize = 10000;
  int maxBlobSize = useMD5Checksum ? 2000000 : regBlobSize;
  try {
    for (int i=0; i<size; i++) {
      if (rand.nextBoolean()) {     
        byte[] bytes = (rand.nextInt(10) != 0) ? 
            getByteArray(regBlobSize) : (rand.nextInt(100) == 0 ? getMaxByteArray(maxBlobSize): new byte[0]);
        data[i] = new SerialBlob(bytes); 
      }
    }
  } catch (SQLException se) {
    SQLHelper.handleSQLException(se);
  }      
}
 
Example #3
Source File: SQLOutputImplTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(enabled = true)
public void test05() throws Exception {
    Blob b = new StubBlob();
    outImpl.writeBlob(b);
    SerialBlob sb = (SerialBlob) results.get(0);
    assertTrue(Arrays.equals(
            b.getBytes(1, (int) b.length()),
            sb.getBytes(1, (int) sb.length())));
}
 
Example #4
Source File: SerialBlobTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test25() throws Exception {
    byte[] expected = bytes;
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream();
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
 
Example #5
Source File: SerialBlobTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test25() throws Exception {
    byte[] expected = bytes;
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream();
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
 
Example #6
Source File: SerialBlobTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test23() throws Exception {
    int bytesToWrite = 3;
    byte[] diff = new byte[]{7, 8, 9, 0};
    byte[] expected = new byte[]{1, 8, 9, 0, 5};
    SerialBlob sb = new SerialBlob(bytes);
    int written = sb.setBytes(2, diff, 1, bytesToWrite);
    assertEquals(written, bytesToWrite);
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    expected),
            "arrays do not match ");
}
 
Example #7
Source File: SerialBlobTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test25() throws Exception {
    byte[] expected = bytes;
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream();
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
 
Example #8
Source File: SerialBlobTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test25() throws Exception {
    byte[] expected = bytes;
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream();
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
 
Example #9
Source File: SerialBlobTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test28() throws Exception {
    long expectedPos = 3; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{3, 4, 5};
    SerialBlob sb = new SerialBlob(bytes);
    long pos = sb.position(pattern, 2);
    assertEquals(pos, expectedPos);
}
 
Example #10
Source File: SerialBlobTests.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test29() throws Exception {
    long expectedPos = 2; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{4, 6};
    SerialBlob sb = new SerialBlob(new StubBlob());
    long pos = sb.position(pattern, 1);
    assertEquals(pos, expectedPos);
}
 
Example #11
Source File: SerialBlobTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test30() throws Exception {
    long expectedPos = 3; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{6, 8};
    SerialBlob sb = new SerialBlob(new StubBlob());
    long pos = sb.position(pattern, 2);
    assertEquals(pos, expectedPos);
}
 
Example #12
Source File: SetBinaryStream.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    SerialBlob blob = new SerialBlob(new byte[0]);
    try {
        blob.setBinaryStream(0);
    } catch (SerialException e) {
        System.out.println("Test PASSED");
    }
}
 
Example #13
Source File: SerialBlobTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test18() throws Exception {
    SerialBlob sb = new SerialBlob(bytes);
    SerialBlob sb2 = (SerialBlob) sb.clone();
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    sb2.getBytes(1, (int) sb2.length())),
            "arrays do not match ");
}
 
Example #14
Source File: SerialBlobTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test18() throws Exception {
    SerialBlob sb = new SerialBlob(bytes);
    SerialBlob sb2 = (SerialBlob) sb.clone();
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    sb2.getBytes(1, (int) sb2.length())),
            "arrays do not match ");
}
 
Example #15
Source File: SerialBlobTests.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test11() throws Exception {
    byte[] expected = new byte[]{1, 2, 3};
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream(1, 3);
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
 
Example #16
Source File: SerialBlobTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test18() throws Exception {
    SerialBlob sb = new SerialBlob(bytes);
    SerialBlob sb2 = (SerialBlob) sb.clone();
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    sb2.getBytes(1, (int) sb2.length())),
            "arrays do not match ");
}
 
Example #17
Source File: SerialBlobTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test11() throws Exception {
    byte[] expected = new byte[]{1, 2, 3};
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream(1, 3);
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
 
Example #18
Source File: BaseRowSetTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@DataProvider(name = "testAdvancedParameters")
private Object[][] testAdvancedParameters() throws SQLException {

    byte[] bytes = new byte[10];
    Ref aRef = new SerialRef(new StubRef("INTEGER", query));
    Array aArray = new SerialArray(new StubArray("INTEGER", new Object[1]));
    Blob aBlob = new SerialBlob(new StubBlob());
    Clob aClob = new SerialClob(new StubClob());
    Reader rdr = new StringReader(query);
    InputStream is = new StringBufferInputStream(query);;
    brs = new StubBaseRowSet();
    brs.setBytes(1, bytes);
    brs.setAsciiStream(2, is, query.length());
    brs.setRef(3, aRef);
    brs.setArray(4, aArray);
    brs.setBlob(5, aBlob);
    brs.setClob(6, aClob);
    brs.setBinaryStream(7, is, query.length());
    brs.setUnicodeStream(8, is, query.length());
    brs.setCharacterStream(9, rdr, query.length());

    return new Object[][]{
        {1, bytes},
        {2, is},
        {3, aRef},
        {4, aArray},
        {5, aBlob},
        {6, aClob},
        {7, is},
        {8, is},
        {9, rdr}
    };
}
 
Example #19
Source File: SerialBlobTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test18() throws Exception {
    SerialBlob sb = new SerialBlob(bytes);
    SerialBlob sb2 = (SerialBlob) sb.clone();
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    sb2.getBytes(1, (int) sb2.length())),
            "arrays do not match ");
}
 
Example #20
Source File: SQLOutputImplTests.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test(enabled = true)
public void test05() throws Exception {
    Blob b = new StubBlob();
    outImpl.writeBlob(b);
    SerialBlob sb = (SerialBlob) results.get(0);
    assertTrue(Arrays.equals(
            b.getBytes(1, (int) b.length()),
            sb.getBytes(1, (int) sb.length())));
}
 
Example #21
Source File: SerialBlobTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test11() throws Exception {
    byte[] expected = new byte[]{1, 2, 3};
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream(1, 3);
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
 
Example #22
Source File: SerialBlobTests.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test29() throws Exception {
    long expectedPos = 2; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{4, 6};
    SerialBlob sb = new SerialBlob(new StubBlob());
    long pos = sb.position(pattern, 1);
    assertEquals(pos, expectedPos);
}
 
Example #23
Source File: SerialBlobTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test22() throws Exception {
    byte[] diff = new byte[]{7, 8, 9};
    byte[] expected = new byte[]{1, 7, 8, 9, 5};
    SerialBlob sb = new SerialBlob(bytes);
    int written = sb.setBytes(2, diff);
    assertEquals(written, diff.length);
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    expected),
            "arrays do not match ");
}
 
Example #24
Source File: SerialBlobTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test28() throws Exception {
    long expectedPos = 3; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{3, 4, 5};
    SerialBlob sb = new SerialBlob(bytes);
    long pos = sb.position(pattern, 2);
    assertEquals(pos, expectedPos);
}
 
Example #25
Source File: SQLOutputImplTests.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
@Test(enabled = true)
public void test05() throws Exception {
    Blob b = new StubBlob();
    outImpl.writeBlob(b);
    SerialBlob sb = (SerialBlob) results.get(0);
    assertTrue(Arrays.equals(
            b.getBytes(1, (int) b.length()),
            sb.getBytes(1, (int) sb.length())));
}
 
Example #26
Source File: SerialBlobTests.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test23() throws Exception {
    int bytesToWrite = 3;
    byte[] diff = new byte[]{7, 8, 9, 0};
    byte[] expected = new byte[]{1, 8, 9, 0, 5};
    SerialBlob sb = new SerialBlob(bytes);
    int written = sb.setBytes(2, diff, 1, bytesToWrite);
    assertEquals(written, bytesToWrite);
    assertTrue(
            Arrays.equals(sb.getBytes(1, (int) sb.length()),
                    expected),
            "arrays do not match ");
}
 
Example #27
Source File: DerbyEmbeddedDatabaseType.java    From ormlite-jdbc with ISC License 5 votes vote down vote up
@Override
public Object javaToSqlArg(FieldType fieldType, Object javaObject) throws SQLException {
	ByteArrayOutputStream outStream = new ByteArrayOutputStream();
	try {
		ObjectOutputStream objOutStream = new ObjectOutputStream(outStream);
		objOutStream.writeObject(javaObject);
	} catch (Exception e) {
		throw SqlExceptionUtil.create("Could not write serialized object to output stream", e);
	}
	return new SerialBlob(outStream.toByteArray());
}
 
Example #28
Source File: SerialBlobTests.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test25() throws Exception {
    byte[] expected = bytes;
    SerialBlob sb = new SerialBlob(bytes);
    InputStream is = sb.getBinaryStream();
    for (byte b : expected) {
        byte val = (byte) is.read();
        assertTrue(b == val, val + " does not match " + b);
    }
}
 
Example #29
Source File: SerialBlobTests.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test28() throws Exception {
    long expectedPos = 3; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{3, 4, 5};
    SerialBlob sb = new SerialBlob(bytes);
    long pos = sb.position(pattern, 2);
    assertEquals(pos, expectedPos);
}
 
Example #30
Source File: SerialBlobTests.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
@Test
public void test28() throws Exception {
    long expectedPos = 3; // starting offset is 1 vs 0
    byte[] pattern = new byte[]{3, 4, 5};
    SerialBlob sb = new SerialBlob(bytes);
    long pos = sb.position(pattern, 2);
    assertEquals(pos, expectedPos);
}