Examples of BlobTest


Examples of org.apache.openjpa.persistence.kernel.common.apps.BlobTest

    public void testStoreBlob() {
        OpenJPAEntityManager pm;

        pm = getPM(false, false);
        startTx(pm);
        BlobTest blob = new BlobTest();
        byte[] bytes = new byte[2048];
        for (int i = 0; i < bytes.length; i++)
            bytes[i] = randomByte().byteValue();

        blob.setBlob(bytes);
        pm.persist(blob);
        int id = blob.getId();
        endTx(pm);

        byte[] b1 = blob.getBlob();
        endEm(pm);

        pm = getPM(false, false);
        startTx(pm);
        BlobTest blob2 = pm.find(BlobTest.class, id);

        byte[] b2 = blob2.getBlob();

        assertNotNull("Original blob was null", b1);
        assertNotNull("Retrieved blob was null", b2);
        assertEquals("Blob length was not the same", b1.length, b2.length);
        assertBytesEquals("Blob contents did not match", b1, b2);
View Full Code Here

Examples of org.apache.openjpa.persistence.kernel.common.apps.BlobTest

    public void testStoreBlob() {
        OpenJPAEntityManager pm;

        pm = getPM(false, false);
        startTx(pm);
        BlobTest blob = new BlobTest();
        byte[] bytes = new byte[2048];
        for (int i = 0; i < bytes.length; i++)
            bytes[i] = randomByte().byteValue();

        blob.setBlob(bytes);
        pm.persist(blob);
        int id = blob.getId();
        endTx(pm);

        byte[] b1 = blob.getBlob();
        endEm(pm);

        pm = getPM(false, false);
        startTx(pm);
        BlobTest blob2 = pm.find(BlobTest.class, id);

        byte[] b2 = blob2.getBlob();

        assertNotNull("Original blob was null", b1);
        assertNotNull("Retrieved blob was null", b2);
        assertEquals("Blob length was not the same", b1.length, b2.length);
        assertBytesEquals("Blob contents did not match", b1, b2);
View Full Code Here

Examples of org.apache.torque.test.BlobTest

            BlobTestPeer.doDelete(criteria);
        }

        // create a new BlobTest Object with large blob and clob values
        // and save it
        BlobTest blobTest = new BlobTest();
        {
            int length = 100000;
            byte[] bytes = new byte[length];
            StringBuffer chars = new StringBuffer();
            String charTemplate = "1234567890abcdefghijklmnopqrstuvwxyz";
            for (int i = 0; i < length; ++i)
            {
                bytes[i] = new Integer(i % 256).byteValue();
                chars.append(charTemplate.charAt(i % charTemplate.length()));
            }
            blobTest.setBlobValue(bytes);
        }
        blobTest.save();

        // read the BlobTests from the database
        // and check the values against the original values
        List blobTestList = BlobTestPeer.doSelect(new Criteria());
        assertTrue("blobTestList should contain 1 object but contains "
                + blobTestList.size(),
                blobTestList.size() == 1);

        BlobTest readBlobTest = (BlobTest) blobTestList.get(0);
        assertTrue("read and written blobs should be equal. "
                + "Size of read blob is"
                + readBlobTest.getBlobValue().length
                + " size of written blob is "
                + blobTest.getBlobValue().length,
                Arrays.equals(
                        blobTest.getBlobValue(),
                        readBlobTest.getBlobValue()));
    }
View Full Code Here

Examples of org.apache.torque.test.BlobTest

            BlobTestPeer.doDelete(criteria);
        }

        // create a new BlobTest Object with large blob and clob values
        // and save it
        BlobTest blobTest = new BlobTest();
        {
            int length = 100000;
            byte[] bytes = new byte[length];
            StringBuffer chars = new StringBuffer();
            String charTemplate = "1234567890abcdefghijklmnopqrstuvwxyz";
            for (int i = 0; i < length; ++i)
            {
                bytes[i] = new Integer(i % 256).byteValue();
                chars.append(charTemplate.charAt(i % charTemplate.length()));
            }
            blobTest.setBlobValue(bytes);
        }
        blobTest.save();
       
        // read the BlobTests from the database
        // and check the values against the original values
        List blobTestList = BlobTestPeer.doSelect(new Criteria());
        assertTrue("blobTestList should contain 1 object but contains "
                + blobTestList.size(),
                blobTestList.size() == 1);
       
        BlobTest readBlobTest = (BlobTest) blobTestList.get(0);       
        assertTrue("read and written blobs should be equal. "
                + "Size of read blob is"
                + readBlobTest.getBlobValue().length
                + " size of written blob is "
                + blobTest.getBlobValue().length,
                Arrays.equals(
                        blobTest.getBlobValue(),
                        readBlobTest.getBlobValue()));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.