Package org.apache.torque.test

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


            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

Related Classes of org.apache.torque.test.BlobTest

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.