Package com.fasterxml.storemate.store

Examples of com.fasterxml.storemate.store.StorableCreationResult


       
        try {
            StorableCreationMetadata metadata = new StorableCreationMetadata(null,
                            calcChecksum32(DATA_ORIG), HashConstants.NO_CHECKSUM);
            metadata.uncompressedSize = -1L;
            StorableCreationResult resp = store.insert(StoreOperationSource.REQUEST, null,
                    KEY1, new ByteArrayInputStream(DATA_ORIG),
                    metadata, ByteContainer.simple(CUSTOM_METADATA_ORIG));
            assertTrue(resp.succeeded());
           
            assertNull(resp.getPreviousEntry());
            _verifyCounts(1L, store);

            // Then try to overwrite with a newer timestamp
            timeMaster.advanceCurrentTimeMillis(1000);

            StorableCreationMetadata metadata2 = new StorableCreationMetadata(null,
                    calcChecksum32(DATA_REPLACE), HashConstants.NO_CHECKSUM);
            metadata.uncompressedSize = -1L;
            resp = store.upsertConditionally(StoreOperationSource.REQUEST, null,
                    KEY1, new ByteArrayInputStream(DATA_REPLACE),
                    metadata2, ByteContainer.simple(CUSTOM_METADATA_REPLACE),
                    true, checker);

            _verifyCounts(1L, store);

            final Storable oldEntry = resp.getPreviousEntry();
            assertNotNull(oldEntry);
            assertTrue(oldEntry.hasExternalData());
           
            if (expSuccess) { // yes, ought to overwrite:
                assertTrue("Should succeeed with checker "+checker, resp.succeeded());
            } else { // nope, original retained
                assertFalse("Should fail with checker "+checker, resp.succeeded());
            }

            // and then verify
            Storable entry = store.findEntry(StoreOperationSource.REQUEST, null, KEY1);
            assertNotNull(entry);
View Full Code Here

TOP

Related Classes of com.fasterxml.storemate.store.StorableCreationResult

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.