Package javax.sql.rowset.serial

Examples of javax.sql.rowset.serial.SerialBlob


        }
    }

    public void testGetBinaryStream() throws Exception {
        byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
        SerialBlob serialBlob = new SerialBlob(buf);
        InputStream is = serialBlob.getBinaryStream();
        int i = 0;
        while (true) {
            int b = is.read();
            if (b == -1) {
                if (i < buf.length) {
View Full Code Here


        }
    }

    public void testGetBytesJI() throws Exception {
        byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
        SerialBlob serialBlob = new SerialBlob(buf);
        byte[] data = serialBlob.getBytes(1, 1);
        assertEquals(1, data.length);
        assertEquals(1, data[0]);

        data = serialBlob.getBytes(2, 3);
        assertEquals(3, data.length);
        assertEquals(2, data[0]);
        assertEquals(3, data[1]);
        assertEquals(4, data[2]);

        // Harmony-2725 RI's bug : RI throws SerialException here.
        data = serialBlob.getBytes(2, 1);
        assertEquals(1, data.length);
        assertEquals(2, data[0]);

        data = serialBlob.getBytes(1, 10);
        assertEquals(8, data.length);
        assertTrue(Arrays.equals(buf, data));

        try {
            data = serialBlob.getBytes(2, -1);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            data = serialBlob.getBytes(0, 2);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            data = serialBlob.getBytes(-1, 2);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            data = serialBlob.getBytes(10, 11);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
    }
View Full Code Here

    }

    public void testSetBytesJ$B() throws Exception {
        byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
        byte[] theBytes = { 9, 10, 11 };
        SerialBlob serialBlob = new SerialBlob(buf);

        int count = serialBlob.setBytes(1, theBytes);
        byte[] res = serialBlob.getBytes(1, buf.length);
        byte[] expected = { 9, 10, 11, 4, 5, 6, 7, 8 };
        assertTrue(Arrays.equals(expected, res));
        assertEquals(3, count);

        count = serialBlob.setBytes(2, theBytes);
        res = serialBlob.getBytes(1, buf.length);
        expected = new byte[] { 9, 9, 10, 11, 5, 6, 7, 8 };
        assertTrue(Arrays.equals(expected, res));
        assertEquals(3, count);

        count = serialBlob.setBytes(6, theBytes);
        res = serialBlob.getBytes(1, buf.length);
        expected = new byte[] { 9, 9, 10, 11, 5, 9, 10, 11 };
        assertTrue(Arrays.equals(expected, res));
        assertEquals(3, count);

        try {
            serialBlob.setBytes(-1, theBytes);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            serialBlob.setBytes(10, theBytes);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        // Non bug difference from RI, Harmony-2836
        try {
            serialBlob.setBytes(7, theBytes);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
View Full Code Here

    }

    public void testSetBytesJ$BII() throws Exception {
        byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
        byte[] theBytes = { 9, 10, 11 };
        SerialBlob serialBlob = new SerialBlob(buf);

        int count = serialBlob.setBytes(1, theBytes, 0, 3);
        byte[] res = serialBlob.getBytes(1, buf.length);
        byte[] expected = { 9, 10, 11, 4, 5, 6, 7, 8 };
        assertTrue(Arrays.equals(expected, res));
        assertEquals(3, count);

        count = serialBlob.setBytes(3, theBytes, 1, 2);
        res = serialBlob.getBytes(1, buf.length);
        expected = new byte[] { 9, 10, 10, 11, 5, 6, 7, 8 };
        assertTrue(Arrays.equals(expected, res));
        assertEquals(2, count);

        count = serialBlob.setBytes(6, theBytes, 0, 2);
        res = serialBlob.getBytes(1, buf.length);
        expected = new byte[] { 9, 10, 10, 11, 5, 9, 10, 8 };
        assertTrue(Arrays.equals(expected, res));
        assertEquals(2, count);

        try {
            serialBlob.setBytes(7, theBytes, 0, 10);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            serialBlob.setBytes(-1, theBytes, 0, 2);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            serialBlob.setBytes(10, theBytes, 0, 2);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            serialBlob.setBytes(1, theBytes, -1, 2);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        try {
            serialBlob.setBytes(1, theBytes, 0, 10);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        // Non bug difference from RI, Harmony-2836
        try {
            serialBlob.setBytes(7, theBytes, 0, 3);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        // Non bug difference from RI, Harmony-2836
        try {
            serialBlob.setBytes(7, theBytes, 0, -1);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
    }
View Full Code Here

        }
    }

    public void testPosition$BJ() throws Exception {
        byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
        SerialBlob serialBlob = new SerialBlob(buf);

        assertBlobPosition_BytePattern(serialBlob);

        MockSerialBlob mockBlob = new MockSerialBlob();
        mockBlob.buf = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
        serialBlob = new SerialBlob(mockBlob);
        assertBlobPosition_BytePattern(serialBlob);
    }
View Full Code Here

        assertBlobPosition_BytePattern(serialBlob);
    }

    public void testPositionLBlobJ() throws Exception {
        byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
        SerialBlob serialBlob = new SerialBlob(buf);
        assertBlobPosition_BlobPattern(serialBlob);

        MockSerialBlob mockBlob = new MockSerialBlob();
        mockBlob.buf = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
        serialBlob = new SerialBlob(mockBlob);
        assertBlobPosition_BlobPattern(serialBlob);
    }
View Full Code Here

        assertBlobPosition_BlobPattern(serialBlob);
    }

    public void testTruncateJ() throws Exception {
        byte[] buf = { 1, 2, 3, 4, 5, 6, 7, 8 };
        SerialBlob serialBlob1 = new SerialBlob(buf);
        MockSerialBlob mockBlob = new MockSerialBlob();
        mockBlob.buf = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
        SerialBlob serialBlob2 = new SerialBlob(mockBlob);
        SerialBlob[] serialBlobs = { serialBlob1, serialBlob2 };

        for (SerialBlob serialBlob : serialBlobs) {

            serialBlob.truncate(3);
View Full Code Here

    }

    public void testSetBinaryStreamJ() throws Exception {
        MockSerialBlob mockBlob = new MockSerialBlob();
        mockBlob.binaryStream = new ByteArrayOutputStream();
        SerialBlob serialBlob = new SerialBlob(mockBlob);
        OutputStream os = serialBlob.setBinaryStream(1);
        assertTrue(mockBlob.isSetBinaryStreamInvoked);
        assertEquals(1L, mockBlob.pos);
        assertSame(mockBlob.binaryStream, os);

        mockBlob.binaryStream = null;
        try {
            serialBlob.setBinaryStream(1);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }

        byte[] buf = new byte[1];
        serialBlob = new SerialBlob(buf);
        try {
            // Non bug difference from RI, Harmony-2971
            serialBlob.setBinaryStream(1);
            fail("should throw SerialException");
        } catch (SerialException e) {
            // expected
        }
    }
View Full Code Here

    }

    public void test_free() throws Exception {
        MockSerialBlob mockBlob = new MockSerialBlob();
        mockBlob.binaryStream = new ByteArrayOutputStream();
        SerialBlob serialBlob = new SerialBlob(mockBlob);
        try {
            serialBlob.free();
            fail("should throw UnsupportedOperationException");
        } catch (UnsupportedOperationException e) {
            // expected
        }
    }
View Full Code Here

    receivedSms.setOperator("SIMULATOR");
    receivedSms.setContent(executionForm.getMessage());
    receivedSms.setSubject(executionForm.getMmsSubject());
    if (executionForm.getFile() != null && executionForm.getFile().getFileSize() > 0) {
      try {
        receivedSms.setAttachment(new SerialBlob(executionForm.getFile().getFileData()));
        receivedSms.setAttachmentContentType(executionForm.getFile().getContentType());
        receivedSms.setAttachmentName(executionForm.getFile().getFileName());
      } catch (Exception e) {
        LOGGER.error("Creating blob from uploaded file faild.", e);
        throw new BugException("Creating blob from uploaded file faild.", e);
View Full Code Here

TOP

Related Classes of javax.sql.rowset.serial.SerialBlob

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.