Java Code Examples for javax.sql.rowset.serial.SerialBlob

The following examples show how to use javax.sql.rowset.serial.SerialBlob. These examples are extracted from open source projects. 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 Project: openjdk-jdk9   Source File: SerialBlobTests.java    License: 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 2
@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 3
Source Project: openjdk-jdk9   Source File: SerialBlobTests.java    License: 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 4
@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 Project: gemfirexd-oss   Source File: TradePortfolioV1DMLStmt.java    License: 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 6
Source Project: jdk8u60   Source File: SerialBlobTests.java    License: 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 7
Source Project: jdk8u60   Source File: SerialBlobTests.java    License: 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 8
@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 9
Source Project: jdk8u_jdk   Source File: SerialBlobTests.java    License: 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 10
@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 11
Source Project: openjdk-jdk9   Source File: SerialBlobTests.java    License: 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 12
Source Project: jdk8u_jdk   Source File: SerialBlobTests.java    License: 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 13
@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 14
Source Project: hottub   Source File: SerialBlobTests.java    License: 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 15
@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 16
@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 17
@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 18
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 19
Source Project: jdk8u60   Source File: SerialBlobTests.java    License: 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 Project: hottub   Source File: SerialBlobTests.java    License: 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 21
@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
@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
@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 24
Source Project: hottub   Source File: BaseRowSetTests.java    License: 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 25
@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 26
Source Project: jdk8u_jdk   Source File: SQLOutputImplTests.java    License: 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 27
Source Project: jdk8u60   Source File: SerialBlobTests.java    License: 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 28
@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 29
Source Project: openjdk-jdk9   Source File: SerialBlobTests.java    License: 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 30
Source Project: jdk8u60   Source File: SerialBlobTests.java    License: 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);
}