usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From toddn...@apache.org
Subject [3/5] Major refactor complete. Need to work on scheduling of futures.
Date Wed, 04 Dec 2013 03:45:17 GMT
http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb9ec94e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategyImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategyImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategyImplTest.java
deleted file mode 100644
index ffa868e..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/MvccEntitySerializationStrategyImplTest.java
+++ /dev/null
@@ -1,430 +0,0 @@
-package org.apache.usergrid.persistence.collection.serialization;
-
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.UUID;
-
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.cassandra.db.marshal.UUIDType;
-
-import org.apache.usergrid.persistence.collection.CollectionContext;
-import org.apache.usergrid.persistence.collection.CollectionContextImpl;
-import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntityImpl;
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.field.BooleanField;
-import org.apache.usergrid.persistence.model.field.DoubleField;
-import org.apache.usergrid.persistence.model.field.Field;
-import org.apache.usergrid.persistence.model.field.IntegerField;
-import org.apache.usergrid.persistence.model.field.LongField;
-import org.apache.usergrid.persistence.model.field.StringField;
-import org.apache.usergrid.persistence.model.field.UUIDField;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.persistence.test.CassandraRule;
-
-import com.google.common.base.Optional;
-import com.google.guiceberry.junit4.GuiceBerryRule;
-import com.google.inject.Inject;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-import com.netflix.astyanax.serializers.UUIDSerializer;
-import com.netflix.astyanax.util.TimeUUIDUtils;
-
-import static junit.framework.Assert.assertEquals;
-import static junit.framework.Assert.assertSame;
-import static junit.framework.TestCase.assertFalse;
-import static junit.framework.TestCase.assertNull;
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * @author tnine
- */
-public class MvccEntitySerializationStrategyImplTest {
-
-    @Rule
-    public final GuiceBerryRule guiceBerry = new GuiceBerryRule( TestCollectionModule.class );
-
-    @Rule
-    public final CassandraRule rule = new CassandraRule();
-
-    @Inject
-    private MvccEntitySerializationStrategy serializationStrategy;
-
-
-    @Test
-    public void writeLoadDelete() throws ConnectionException {
-
-        final UUID applicationId = UUIDGenerator.newTimeUUID();
-        final String name = "test";
-
-        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
-
-
-        final UUID entityId = UUIDGenerator.newTimeUUID();
-        final UUID version = UUIDGenerator.newTimeUUID();
-        final String type = "test";
-        final long created = 1l;
-        final long updated = 2l;
-
-        Entity entity = new Entity( entityId, type );
-
-        entity.setVersion( version );
-        entity.setCreated( created );
-        entity.setUpdated( updated );
-
-
-        BooleanField boolField = new BooleanField( "boolean", false );
-        DoubleField doubleField = new DoubleField( "double", 1d );
-        IntegerField intField = new IntegerField( "long", 1 );
-        LongField longField = new LongField( "int", 1l );
-        StringField stringField = new StringField( "name", "test" );
-        UUIDField uuidField = new UUIDField( "uuid", UUIDGenerator.newTimeUUID() );
-
-        entity.setField( boolField );
-        entity.setField( doubleField );
-        entity.setField( intField );
-        entity.setField( longField );
-        entity.setField( stringField );
-        entity.setField( uuidField );
-
-
-        MvccEntity saved = new MvccEntityImpl( context, entityId, version, Optional.of( entity ) );
-
-
-        //persist the entity
-        serializationStrategy.write( saved ).execute();
-
-        //now read it back
-
-        MvccEntity returned = serializationStrategy.load( context, entityId, version );
-
-        assertEquals( "Mvcc entities are the same", saved, returned );
-
-
-        assertEquals( entityId, entity.getUuid() );
-        assertEquals( type, entity.getType() );
-        assertEquals( created, entity.getCreated() );
-        assertEquals( updated, entity.getUpdated() );
-
-
-        Field<Boolean> boolFieldReturned = entity.getField( boolField.getName() );
-
-        assertSame( boolField, boolFieldReturned );
-
-        Field<Double> doubleFieldReturned = entity.getField( doubleField.getName() );
-
-        assertSame( doubleField, doubleFieldReturned );
-
-        Field<Integer> intFieldReturned = entity.getField( intField.getName() );
-
-        assertSame( intField, intFieldReturned );
-
-        Field<Long> longFieldReturned = entity.getField( longField.getName() );
-
-        assertSame( longField, longFieldReturned );
-
-        Field<String> stringFieldReturned = entity.getField( stringField.getName() );
-
-        assertSame( stringField, stringFieldReturned );
-
-        Field<UUID> uuidFieldReturned = entity.getField( uuidField.getName() );
-
-        assertSame( uuidField, uuidFieldReturned );
-
-
-        Set<Field> results = new HashSet<Field>();
-        results.addAll( entity.getFields() );
-
-
-        assertTrue( results.contains( boolField ) );
-        assertTrue( results.contains( doubleField ) );
-        assertTrue( results.contains( intField ) );
-        assertTrue( results.contains( longField ) );
-        assertTrue( results.contains( stringField ) );
-        assertTrue( results.contains( uuidField ) );
-
-        assertEquals( 6, results.size() );
-
-
-        assertEquals( entityId, entity.getUuid() );
-        assertEquals( version, entity.getVersion() );
-
-
-        //now delete it
-        serializationStrategy.delete( context, entityId, version ).execute();
-
-        //now get it, should be gone
-
-        returned = serializationStrategy.load( context, entityId, version );
-
-        assertNull( returned );
-    }
-
-
-    @Test
-    public void writeLoadClearDelete() throws ConnectionException {
-
-        final UUID applicationId = UUIDGenerator.newTimeUUID();
-        final String name = "test";
-
-        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
-
-
-        final UUID entityId = UUIDGenerator.newTimeUUID();
-        final UUID version = UUIDGenerator.newTimeUUID();
-        final String type = "test";
-        final long created = 1l;
-        final long updated = 2l;
-
-        Entity entity = new Entity( entityId, type );
-
-        entity.setVersion( version );
-        entity.setCreated( created );
-        entity.setUpdated( updated );
-
-
-        MvccEntity saved = new MvccEntityImpl( context, entityId, version, Optional.of( entity ) );
-
-
-        //persist the entity
-        serializationStrategy.write( saved ).execute();
-
-        //now read it back
-
-        MvccEntity returned = serializationStrategy.load( context, entityId, version );
-
-        assertEquals( "Mvcc entities are the same", saved, returned );
-
-
-        assertEquals( entityId, entity.getUuid() );
-        assertEquals( type, entity.getType() );
-        assertEquals( created, entity.getCreated() );
-        assertEquals( updated, entity.getUpdated() );
-
-
-        //now clear it
-
-        serializationStrategy.clear( context, entityId, version ).execute();
-
-        returned = serializationStrategy.load( context, entityId, version );
-
-        assertEquals( context, returned.getContext() );
-        assertEquals( entityId, returned.getUuid() );
-        assertEquals( version, returned.getVersion() );
-        assertFalse( returned.getEntity().isPresent() );
-
-        //now delete it
-        serializationStrategy.delete( context, entityId, version ).execute();
-
-        //now get it, should be gone
-
-        returned = serializationStrategy.load( context, entityId, version );
-
-        assertNull( returned );
-    }
-
-
-    @Test
-    public void writeX2ClearDelete() throws ConnectionException {
-
-        final UUID applicationId = UUIDGenerator.newTimeUUID();
-        final String name = "test";
-
-        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
-
-
-        final UUID entityId = UUIDGenerator.newTimeUUID();
-        final UUID version1 = UUIDGenerator.newTimeUUID();
-        final String type = "test";
-
-        Entity entityv1 = new Entity( entityId, type );
-
-        entityv1.setVersion( version1 );
-
-
-        MvccEntity saved = new MvccEntityImpl( context, entityId, version1, Optional.of( entityv1 ) );
-
-
-        //persist the entity
-        serializationStrategy.write( saved ).execute();
-
-        //now read it back
-
-        MvccEntity returnedV1 = serializationStrategy.load( context, entityId, version1 );
-
-        assertEquals( "Mvcc entities are the same", saved, returnedV1 );
-
-
-        assertEquals( entityId, entityv1.getUuid() );
-        assertEquals( type, entityv1.getType() );
-
-
-        //now write a new version of it
-
-
-        Entity entityv2 = new Entity( entityId, type );
-
-        UUID version2 = UUIDGenerator.newTimeUUID();
-        entityv2.setVersion( version2 );
-
-
-        UUIDType comparator = UUIDType.instance;
-
-        int value = comparator.compare( UUIDSerializer.get().toByteBuffer( version1 ), UUIDSerializer.get().toByteBuffer( version2 ) );
-
-        assertTrue(value < 0);
-
-        value = comparator.compare( UUIDSerializer.get().toByteBuffer( version2 ), UUIDSerializer.get().toByteBuffer( version2 ) );
-
-        assertEquals(0, value);
-
-        MvccEntity savedV2 = new MvccEntityImpl( context, entityId, version2, Optional.of( entityv2 ) );
-
-        serializationStrategy.write( savedV2 ).execute();
-
-        MvccEntity returnedV2 = serializationStrategy.load( context, entityId, version2 );
-
-        assertEquals( "Mvcc entities are the same", savedV2, returnedV2 );
-
-
-        //now clear it at v3
-
-        UUID version3 = UUIDGenerator.newTimeUUID();
-
-        serializationStrategy.clear( context, entityId, version3 ).execute();
-
-
-        final Optional<Entity> empty = Optional.absent();
-
-        MvccEntity clearedV3 = new MvccEntityImpl( context, entityId, version3, empty );
-
-        MvccEntity returnedV3 = serializationStrategy.load( context, entityId, version3 );
-
-        assertEquals("entities are the same", clearedV3, returnedV3);
-
-        //now ask for up to 10 versions from the current version, we should get cleared, v2, v1
-        UUID current = UUIDGenerator.newTimeUUID();
-
-        List<MvccEntity> entities = serializationStrategy.load( context, entityId, current, 3 );
-
-        assertEquals( 3, entities.size() );
-
-        assertEquals( clearedV3, entities.get( 0 ) );
-
-        assertEquals( returnedV2, entities.get( 1 ) );
-
-        assertEquals( returnedV1, entities.get( 2 ) );
-
-
-        //now delete v2 and v1, we should still get v3
-        serializationStrategy.delete( context, entityId, version1 ).execute();
-        serializationStrategy.delete( context, entityId, version2 ).execute();
-
-        entities = serializationStrategy.load( context, entityId, current, 3 );
-
-        assertEquals( 1, entities.size() );
-
-        assertEquals( clearedV3, entities.get( 0 ) );
-
-
-        //now get it, should be gone
-        serializationStrategy.delete( context, entityId, version3 ).execute();
-
-
-        entities = serializationStrategy.load( context, entityId, current, 3 );
-
-        assertEquals( 0, entities.size() );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void writeParams() throws ConnectionException {
-       serializationStrategy.write( null );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void deleteParamContext() throws ConnectionException {
-       serializationStrategy.delete( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID() );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void deleteParamEntityId() throws ConnectionException {
-
-        serializationStrategy
-                .delete( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        null, UUIDGenerator.newTimeUUID() );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void deleteParamVersion() throws ConnectionException {
-
-        serializationStrategy
-                .delete( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        UUIDGenerator.newTimeUUID(), null );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadParamContext() throws ConnectionException {
-       serializationStrategy.load( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID() );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadParamEntityId() throws ConnectionException {
-
-        serializationStrategy
-                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        null, UUIDGenerator.newTimeUUID() );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadParamVersion() throws ConnectionException {
-
-        serializationStrategy
-                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        UUIDGenerator.newTimeUUID(), null );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadListParamContext() throws ConnectionException {
-       serializationStrategy.load( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), 1 );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadListParamEntityId() throws ConnectionException {
-
-        serializationStrategy
-                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        null, UUIDGenerator.newTimeUUID(), 1 );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadListParamVersion() throws ConnectionException {
-
-        serializationStrategy
-                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        UUIDGenerator.newTimeUUID(), null, 1 );
-    }
-
-
-    @Test(expected = IllegalArgumentException.class)
-    public void loadListParamSize() throws ConnectionException {
-
-        serializationStrategy
-                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), 0 );
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb9ec94e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/MvccLogEntrySerializationStrategyImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/MvccLogEntrySerializationStrategyImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/MvccLogEntrySerializationStrategyImplTest.java
deleted file mode 100644
index 195443e..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/MvccLogEntrySerializationStrategyImplTest.java
+++ /dev/null
@@ -1,311 +0,0 @@
-package org.apache.usergrid.persistence.collection.serialization;
-
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-
-import org.junit.Rule;
-import org.junit.Test;
-
-import org.apache.usergrid.persistence.collection.CollectionContext;
-import org.apache.usergrid.persistence.collection.CollectionContextImpl;
-import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntryImpl;
-import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.persistence.test.CassandraRule;
-
-import com.google.guiceberry.GuiceBerryEnvSelector;
-import com.google.guiceberry.TestDescription;
-import com.google.guiceberry.junit4.GuiceBerryRule;
-import com.google.inject.Inject;
-import com.google.inject.Module;
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-
-import static junit.framework.Assert.assertNotNull;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-
-
-/** @author tnine */
-public class MvccLogEntrySerializationStrategyImplTest {
-
-
-    /** Set our timeout to 1 seconds.  If it works for 1 seconds, we'll be good a any value */
-    private static final int TIMEOUT = 1;
-
-
-    @Rule
-    public final GuiceBerryRule guiceBerry = new GuiceBerryRule( new TimeoutModMapper() );
-
-    @Rule
-    public final CassandraRule rule = new CassandraRule();
-
-    @Inject
-    private MvccLogEntrySerializationStrategy logEntryStrategy;
-
-
-    @Test
-    public void createAndDelete() throws ConnectionException {
-
-        final UUID applicationId = UUIDGenerator.newTimeUUID();
-        final String name = "test";
-
-
-        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
-
-
-        final UUID uuid = UUIDGenerator.newTimeUUID();
-        final UUID version = UUIDGenerator.newTimeUUID();
-
-        for ( Stage stage : Stage.values() ) {
-            MvccLogEntry saved = new MvccLogEntryImpl( context, uuid, version, stage );
-            logEntryStrategy.write( saved ).execute();
-
-            //Read it back
-
-            MvccLogEntry returned = logEntryStrategy.load( context, uuid, version );
-
-            assertNotNull( "Returned value should not be null", returned );
-
-            assertEquals( "Returned should equal the saved", saved, returned );
-        }
-    }
-
-
-    @Test
-    public void loadNoData() throws ConnectionException {
-
-        final UUID applicationId = UUIDGenerator.newTimeUUID();
-        final String name = "test";
-
-
-        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
-
-
-        final UUID uuid = UUIDGenerator.newTimeUUID();
-        final UUID version = UUIDGenerator.newTimeUUID();
-
-
-        MvccLogEntry returned = logEntryStrategy.load( context, uuid, version );
-
-        assertNull( "Returned value should not exist", returned );
-    }
-
-
-    @Test
-    public void getMultipleEntries() throws ConnectionException {
-
-        final UUID applicationId = UUIDGenerator.newTimeUUID();
-        final String name = "test";
-
-
-        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
-
-
-        final UUID uuid = UUIDGenerator.newTimeUUID();
-
-        int count = 10;
-
-        final UUID[] versions = new UUID[count];
-        final Stage COMPLETE = Stage.COMPLETE;
-        final MvccLogEntry[] entries = new MvccLogEntry[count];
-
-
-        for ( int i = 0; i < count; i++ ) {
-            versions[i] = UUIDGenerator.newTimeUUID();
-
-            entries[i] = new MvccLogEntryImpl( context, uuid, versions[i], COMPLETE );
-            logEntryStrategy.write( entries[i] ).execute();
-
-            //Read it back
-
-            MvccLogEntry returned = logEntryStrategy.load( context, uuid, versions[i] );
-
-            assertNotNull( "Returned value should not be null", returned );
-
-            assertEquals( "Returned should equal the saved", entries[i], returned );
-        }
-
-        //now do a range scan from the end
-
-        List<MvccLogEntry> results = logEntryStrategy.load( context, uuid, versions[count - 1], count );
-
-        assertEquals( count, results.size() );
-
-        for ( int i = 0; i < count; i++ ) {
-            final MvccLogEntry saved = entries[count - i - 1];
-            final MvccLogEntry returned = results.get( i );
-
-            assertEquals( "Entry was not equal to the saved value", saved, returned );
-        }
-
-        //now delete them all and ensure we get no results back
-        for ( int i = 0; i < count; i++ ) {
-            logEntryStrategy.delete( context, uuid, versions[i] ).execute();
-        }
-
-        results = logEntryStrategy.load( context, uuid, versions[versions.length - 1], versions.length );
-
-        assertEquals( "All log entries were deleted", 0, results.size() );
-    }
-
-
-    @Test
-    public void transientTimeout() throws ConnectionException, InterruptedException {
-
-        final UUID applicationId = UUIDGenerator.newTimeUUID();
-        final String name = "test";
-
-
-        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
-
-
-        final UUID uuid = UUIDGenerator.newTimeUUID();
-        final UUID version = UUIDGenerator.newTimeUUID();
-
-        for ( Stage stage : Stage.values() ) {
-
-            MvccLogEntry saved = new MvccLogEntryImpl( context, uuid, version, stage );
-            logEntryStrategy.write( saved ).execute();
-
-            //Read it back after the timeout
-
-            Thread.sleep( TIMEOUT * 1000 );
-
-            MvccLogEntry returned = logEntryStrategy.load( context, uuid, version );
-
-
-            if ( stage.isTransient() ) {
-
-                assertNull( "Active is transient and should time out", returned );
-            }
-            else {
-                assertNotNull( "Committed is not transient and should be returned", returned );
-
-                assertEquals( "Returned should equal the saved", saved, returned );
-            }
-        }
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void writeParams() throws ConnectionException {
-        logEntryStrategy.write( null );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void deleteParamContext() throws ConnectionException {
-        logEntryStrategy.delete( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID() );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void deleteParamEntityId() throws ConnectionException {
-
-        logEntryStrategy
-                .delete( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        null, UUIDGenerator.newTimeUUID() );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void deleteParamVersion() throws ConnectionException {
-
-        logEntryStrategy
-                .delete( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        UUIDGenerator.newTimeUUID(), null );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadParamContext() throws ConnectionException {
-        logEntryStrategy.load( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID() );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadParamEntityId() throws ConnectionException {
-
-        logEntryStrategy
-                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        null, UUIDGenerator.newTimeUUID() );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadParamVersion() throws ConnectionException {
-
-        logEntryStrategy
-                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        UUIDGenerator.newTimeUUID(), null );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadListParamContext() throws ConnectionException {
-        logEntryStrategy.load( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), 1 );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadListParamEntityId() throws ConnectionException {
-
-        logEntryStrategy
-                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        null, UUIDGenerator.newTimeUUID(), 1 );
-    }
-
-
-    @Test(expected = NullPointerException.class)
-    public void loadListParamVersion() throws ConnectionException {
-
-        logEntryStrategy
-                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        UUIDGenerator.newTimeUUID(), null, 1 );
-    }
-
-
-    @Test(expected = IllegalArgumentException.class)
-    public void loadListParamSize() throws ConnectionException {
-
-        logEntryStrategy
-                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
-                        UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), 0 );
-    }
-
-
-    /** Mapper that will change which module we implement based on the test case */
-    public static class TimeoutModMapper implements GuiceBerryEnvSelector {
-
-        @Override
-        public Class<? extends Module> guiceBerryEnvToUse( final TestDescription testDescription ) {
-
-            //in this edge case, we want to truncate the timeout to 1 second for this test, override the env to use
-            //this module setup
-            if ( ( MvccLogEntrySerializationStrategyImplTest.class.getName() + ".transientTimeout" )
-                    .equals( testDescription.getName() ) ) {
-                return TimeoutEnv.class;
-            }
-
-            //by default, we wnat to run the TestCollectionModule
-            return TestCollectionModule.class;
-        }
-    }
-
-
-    public static class TimeoutEnv extends TestCollectionModule {
-
-        @Override
-        public Map<String, String> getOverrides() {
-            Map<String, String> timeout = new HashMap<String, String>();
-            timeout.put( MvccLogEntrySerializationStrategyImpl.TIMEOUT_PROP, TIMEOUT + "" );
-            return timeout;
-        }
-    }
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb9ec94e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/SerializationComparison.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/SerializationComparison.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/SerializationComparison.java
deleted file mode 100644
index a78293b..0000000
--- a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/SerializationComparison.java
+++ /dev/null
@@ -1,182 +0,0 @@
-package org.apache.usergrid.persistence.collection.serialization;
-
-
-import java.io.IOException;
-import java.nio.ByteBuffer;
-import java.util.UUID;
-
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.smile.SmileFactory;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.usergrid.persistence.model.entity.Entity;
-import org.apache.usergrid.persistence.model.field.ArrayField;
-import org.apache.usergrid.persistence.model.field.BooleanField;
-import org.apache.usergrid.persistence.model.field.ByteBufferField;
-import org.apache.usergrid.persistence.model.field.DoubleField;
-import org.apache.usergrid.persistence.model.field.EntityObjectField;
-import org.apache.usergrid.persistence.model.field.IntegerField;
-import org.apache.usergrid.persistence.model.field.ListField;
-import org.apache.usergrid.persistence.model.field.LocationField;
-import org.apache.usergrid.persistence.model.field.LongField;
-import org.apache.usergrid.persistence.model.field.SetField;
-import org.apache.usergrid.persistence.model.field.StringField;
-import org.apache.usergrid.persistence.model.field.UUIDField;
-import org.apache.usergrid.persistence.model.util.UUIDGenerator;
-import org.apache.usergrid.persistence.model.value.EntityObject;
-import org.apache.usergrid.persistence.model.value.Location;
-
-import com.esotericsoftware.kryo.Kryo;
-import com.esotericsoftware.kryo.io.ByteBufferInputStream;
-import com.esotericsoftware.kryo.io.ByteBufferOutputStream;
-import com.esotericsoftware.kryo.io.Input;
-import com.esotericsoftware.kryo.io.Output;
-
-
-/**
- * TODO We need to get both of these serialization methods working, and benchmark them for comparison
- * Neither works out of the box for us without custom work.
- * @author tnine
- */
-public class SerializationComparison {
-
-    private static final Logger logger = LoggerFactory.getLogger( SerializationComparison.class );
-
-    private static final int count = 10000;
-
-
-    @Test
-    @Ignore
-    public void smileSerialization() throws IOException {
-        SmileFactory smile = new SmileFactory();
-
-        ObjectMapper smileMapper = new ObjectMapper( smile );
-
-
-        Entity entity = createEntity();
-
-        long writeTime = 0;
-        long readTime = 0;
-
-        for ( int i = 0; i < count; i++ ) {
-
-            //capture time in nannos for write
-            long writeStart = System.nanoTime();
-
-            byte[] smileData = smileMapper.writeValueAsBytes( entity );
-
-            writeTime += System.nanoTime() - writeStart;
-
-            long readStart = System.nanoTime();
-
-            Entity otherValue = smileMapper.readValue( smileData, Entity.class );
-
-            readTime += System.nanoTime() - readStart;
-        }
-
-        logger.info( "Smile took {} nanos for writing {} entities", writeTime, count );
-        logger.info( "Smile took {} nanos for reading {} entities", readTime, count );
-    }
-
-
-    @Test
-    @Ignore
-    public void kyroSerialization() {
-        Kryo kryo = new Kryo();
-
-        //container classes
-        kryo.register( Entity.class );
-
-        kryo.register( EntityObject.class );
-        kryo.register( Location.class );
-
-
-        //field classes
-        kryo.register( ArrayField.class );
-        kryo.register( BooleanField.class );
-        kryo.register( ByteBufferField.class );
-        kryo.register( DoubleField.class );
-        kryo.register( EntityObjectField.class );
-        kryo.register( IntegerField.class );
-        kryo.register( ListField.class );
-        kryo.register( LocationField.class );
-        kryo.register( LongField.class );
-        kryo.register( SetField.class );
-        kryo.register( StringField.class );
-        kryo.register( UUIDField.class, new de.javakaffee.kryoserializers.UUIDSerializer() );
-
-
-        long writeTime = 0;
-        long readTime = 0;
-
-        for ( int i = 0; i < count; i++ ) {
-
-            //capture time in nanos for write
-            long writeStart = System.nanoTime();
-
-            ByteBuffer data = ByteBuffer.allocate( 1024 );
-            ByteBufferOutputStream byteBuffOutputStream = new ByteBufferOutputStream(data);
-            Output output = new Output( byteBuffOutputStream );
-
-            Entity entity = createEntity();
-
-            kryo.writeObject( output, entity );
-            output.close();
-
-            writeTime += System.nanoTime() - writeStart;
-
-            data.rewind();
-
-            long readStart = System.nanoTime();
-
-
-            Input input = new Input( new ByteBufferInputStream( data ) );
-            Entity loaded = kryo.readObject( input, Entity.class );
-            input.close();
-
-            readTime += System.nanoTime() - readStart;
-        }
-
-        logger.info( "Smile took {} nanos for writing {} entities", writeTime, count );
-        logger.info( "Smile took {} nanos for reading {} entities", readTime, count );
-    }
-
-
-    private Entity createEntity() {
-
-        final UUID entityId = UUIDGenerator.newTimeUUID();
-
-        final UUID version = UUIDGenerator.newTimeUUID();
-
-        Entity entity = new Entity( entityId, "test" );
-        entity.setCreated( 1l );
-        entity.setUpdated( 2l );
-        entity.setVersion( version );
-
-
-        BooleanField boolField = new BooleanField( "boolean", false );
-        DoubleField doubleField = new DoubleField( "double", 1d );
-        IntegerField intField = new IntegerField( "long", 1 );
-        LongField longField = new LongField( "int", 1l );
-        StringField stringField = new StringField( "name", "test" );
-        UUIDField uuidField = new UUIDField( "uuid", UUIDGenerator.newTimeUUID() );
-
-        entity.setField( boolField );
-        entity.setField( doubleField );
-        entity.setField( intField );
-        entity.setField( longField );
-        entity.setField( stringField );
-        entity.setField( uuidField );
-
-        return entity;
-    }
-
-
-}
-
-
-
-

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb9ec94e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
new file mode 100644
index 0000000..daa9edd
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccEntitySerializationStrategyImplTest.java
@@ -0,0 +1,438 @@
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.UUID;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.cassandra.db.marshal.UUIDType;
+
+import org.apache.usergrid.persistence.collection.CollectionContext;
+import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
+import org.apache.usergrid.persistence.collection.impl.CollectionContextImpl;
+import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
+import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
+import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.field.BooleanField;
+import org.apache.usergrid.persistence.model.field.DoubleField;
+import org.apache.usergrid.persistence.model.field.Field;
+import org.apache.usergrid.persistence.model.field.IntegerField;
+import org.apache.usergrid.persistence.model.field.LongField;
+import org.apache.usergrid.persistence.model.field.StringField;
+import org.apache.usergrid.persistence.model.field.UUIDField;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.apache.usergrid.persistence.test.CassandraRule;
+
+import com.google.common.base.Optional;
+import com.google.guiceberry.junit4.GuiceBerryRule;
+import com.google.inject.Inject;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+import com.netflix.astyanax.serializers.UUIDSerializer;
+
+import static junit.framework.Assert.assertEquals;
+import static junit.framework.Assert.assertSame;
+import static junit.framework.TestCase.assertFalse;
+import static junit.framework.TestCase.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
+
+/** @author tnine */
+public class MvccEntitySerializationStrategyImplTest {
+
+    @Rule
+    public final GuiceBerryRule guiceBerry = new GuiceBerryRule( TestCollectionModule.class );
+
+    @Rule
+    public final CassandraRule rule = new CassandraRule();
+
+    @Inject
+    private MvccEntitySerializationStrategy serializationStrategy;
+
+
+    @Test
+    public void writeLoadDelete() throws ConnectionException {
+
+        final UUID applicationId = UUIDGenerator.newTimeUUID();
+        final String name = "test";
+
+        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
+
+
+        final UUID entityId = UUIDGenerator.newTimeUUID();
+        final UUID version = UUIDGenerator.newTimeUUID();
+        final String type = "test";
+        final long created = 1l;
+        final long updated = 2l;
+
+        Entity entity = new Entity( entityId, type );
+
+        entity.setVersion( version );
+        entity.setCreated( created );
+        entity.setUpdated( updated );
+
+
+        BooleanField boolField = new BooleanField( "boolean", false );
+        DoubleField doubleField = new DoubleField( "double", 1d );
+        IntegerField intField = new IntegerField( "long", 1 );
+        LongField longField = new LongField( "int", 1l );
+        StringField stringField = new StringField( "name", "test" );
+        UUIDField uuidField = new UUIDField( "uuid", UUIDGenerator.newTimeUUID() );
+
+        entity.setField( boolField );
+        entity.setField( doubleField );
+        entity.setField( intField );
+        entity.setField( longField );
+        entity.setField( stringField );
+        entity.setField( uuidField );
+
+
+        MvccEntity saved = new MvccEntityImpl( entityId, version, Optional.of( entity ) );
+
+
+        //persist the entity
+        serializationStrategy.write( context, saved ).execute();
+
+        //now read it back
+
+        MvccEntity returned = serializationStrategy.load( context, entityId, version );
+
+        assertEquals( "Mvcc entities are the same", saved, returned );
+
+
+        assertEquals( entityId, entity.getUuid() );
+        assertEquals( type, entity.getType() );
+        assertEquals( created, entity.getCreated() );
+        assertEquals( updated, entity.getUpdated() );
+
+
+        Field<Boolean> boolFieldReturned = entity.getField( boolField.getName() );
+
+        assertSame( boolField, boolFieldReturned );
+
+        Field<Double> doubleFieldReturned = entity.getField( doubleField.getName() );
+
+        assertSame( doubleField, doubleFieldReturned );
+
+        Field<Integer> intFieldReturned = entity.getField( intField.getName() );
+
+        assertSame( intField, intFieldReturned );
+
+        Field<Long> longFieldReturned = entity.getField( longField.getName() );
+
+        assertSame( longField, longFieldReturned );
+
+        Field<String> stringFieldReturned = entity.getField( stringField.getName() );
+
+        assertSame( stringField, stringFieldReturned );
+
+        Field<UUID> uuidFieldReturned = entity.getField( uuidField.getName() );
+
+        assertSame( uuidField, uuidFieldReturned );
+
+
+        Set<Field> results = new HashSet<Field>();
+        results.addAll( entity.getFields() );
+
+
+        assertTrue( results.contains( boolField ) );
+        assertTrue( results.contains( doubleField ) );
+        assertTrue( results.contains( intField ) );
+        assertTrue( results.contains( longField ) );
+        assertTrue( results.contains( stringField ) );
+        assertTrue( results.contains( uuidField ) );
+
+        assertEquals( 6, results.size() );
+
+
+        assertEquals( entityId, entity.getUuid() );
+        assertEquals( version, entity.getVersion() );
+
+
+        //now delete it
+        serializationStrategy.delete( context, entityId, version ).execute();
+
+        //now get it, should be gone
+
+        returned = serializationStrategy.load( context, entityId, version );
+
+        assertNull( returned );
+    }
+
+
+    @Test
+    public void writeLoadClearDelete() throws ConnectionException {
+
+        final UUID applicationId = UUIDGenerator.newTimeUUID();
+        final String name = "test";
+
+        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
+
+
+        final UUID entityId = UUIDGenerator.newTimeUUID();
+        final UUID version = UUIDGenerator.newTimeUUID();
+        final String type = "test";
+        final long created = 1l;
+        final long updated = 2l;
+
+        Entity entity = new Entity( entityId, type );
+
+        entity.setVersion( version );
+        entity.setCreated( created );
+        entity.setUpdated( updated );
+
+
+        MvccEntity saved = new MvccEntityImpl( entityId, version, Optional.of( entity ) );
+
+
+        //persist the entity
+        serializationStrategy.write( context, saved ).execute();
+
+        //now read it back
+
+        MvccEntity returned = serializationStrategy.load( context, entityId, version );
+
+        assertEquals( "Mvcc entities are the same", saved, returned );
+
+
+        assertEquals( entityId, entity.getUuid() );
+        assertEquals( type, entity.getType() );
+        assertEquals( created, entity.getCreated() );
+        assertEquals( updated, entity.getUpdated() );
+
+
+        //now clear it
+
+        serializationStrategy.clear( context, entityId, version ).execute();
+
+        returned = serializationStrategy.load( context, entityId, version );
+
+        assertEquals( entityId, returned.getUuid() );
+        assertEquals( version, returned.getVersion() );
+        assertFalse( returned.getEntity().isPresent() );
+
+        //now delete it
+        serializationStrategy.delete( context, entityId, version ).execute();
+
+        //now get it, should be gone
+
+        returned = serializationStrategy.load( context, entityId, version );
+
+        assertNull( returned );
+    }
+
+
+    @Test
+    public void writeX2ClearDelete() throws ConnectionException {
+
+        final UUID applicationId = UUIDGenerator.newTimeUUID();
+        final String name = "test";
+
+        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
+
+
+        final UUID entityId = UUIDGenerator.newTimeUUID();
+        final UUID version1 = UUIDGenerator.newTimeUUID();
+        final String type = "test";
+
+        Entity entityv1 = new Entity( entityId, type );
+
+        entityv1.setVersion( version1 );
+
+
+        MvccEntity saved = new MvccEntityImpl( entityId, version1, Optional.of( entityv1 ) );
+
+
+        //persist the entity
+        serializationStrategy.write( context, saved ).execute();
+
+        //now read it back
+
+        MvccEntity returnedV1 = serializationStrategy.load( context, entityId, version1 );
+
+        assertEquals( "Mvcc entities are the same", saved, returnedV1 );
+
+
+        assertEquals( entityId, entityv1.getUuid() );
+        assertEquals( type, entityv1.getType() );
+
+
+        //now write a new version of it
+
+
+        Entity entityv2 = new Entity( entityId, type );
+
+        UUID version2 = UUIDGenerator.newTimeUUID();
+        entityv2.setVersion( version2 );
+
+
+        UUIDType comparator = UUIDType.instance;
+
+        int value = comparator.compare( UUIDSerializer.get().toByteBuffer( version1 ),
+                UUIDSerializer.get().toByteBuffer( version2 ) );
+
+        assertTrue( value < 0 );
+
+        value = comparator.compare( UUIDSerializer.get().toByteBuffer( version2 ),
+                UUIDSerializer.get().toByteBuffer( version2 ) );
+
+        assertEquals( 0, value );
+
+        MvccEntity savedV2 = new MvccEntityImpl( entityId, version2, Optional.of( entityv2 ) );
+
+        serializationStrategy.write( context, savedV2 ).execute();
+
+        MvccEntity returnedV2 = serializationStrategy.load( context, entityId, version2 );
+
+        assertEquals( "Mvcc entities are the same", savedV2, returnedV2 );
+
+
+        //now clear it at v3
+
+        UUID version3 = UUIDGenerator.newTimeUUID();
+
+        serializationStrategy.clear( context, entityId, version3 ).execute();
+
+
+        final Optional<Entity> empty = Optional.absent();
+
+        MvccEntity clearedV3 = new MvccEntityImpl( entityId, version3, empty );
+
+        MvccEntity returnedV3 = serializationStrategy.load( context, entityId, version3 );
+
+        assertEquals( "entities are the same", clearedV3, returnedV3 );
+
+        //now ask for up to 10 versions from the current version, we should get cleared, v2, v1
+        UUID current = UUIDGenerator.newTimeUUID();
+
+        List<MvccEntity> entities = serializationStrategy.load( context, entityId, current, 3 );
+
+        assertEquals( 3, entities.size() );
+
+        assertEquals( clearedV3, entities.get( 0 ) );
+
+        assertEquals( returnedV2, entities.get( 1 ) );
+
+        assertEquals( returnedV1, entities.get( 2 ) );
+
+
+        //now delete v2 and v1, we should still get v3
+        serializationStrategy.delete( context, entityId, version1 ).execute();
+        serializationStrategy.delete( context, entityId, version2 ).execute();
+
+        entities = serializationStrategy.load( context, entityId, current, 3 );
+
+        assertEquals( 1, entities.size() );
+
+        assertEquals( clearedV3, entities.get( 0 ) );
+
+
+        //now get it, should be gone
+        serializationStrategy.delete( context, entityId, version3 ).execute();
+
+
+        entities = serializationStrategy.load( context, entityId, current, 3 );
+
+        assertEquals( 0, entities.size() );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void writeParamsContext() throws ConnectionException {
+        serializationStrategy.write( null, mock( MvccEntity.class ) );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void writeParamsEntity() throws ConnectionException {
+        serializationStrategy
+                .write( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        null );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void deleteParamContext() throws ConnectionException {
+        serializationStrategy.delete( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID() );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void deleteParamEntityId() throws ConnectionException {
+
+        serializationStrategy
+                .delete( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        null, UUIDGenerator.newTimeUUID() );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void deleteParamVersion() throws ConnectionException {
+
+        serializationStrategy
+                .delete( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        UUIDGenerator.newTimeUUID(), null );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void loadParamContext() throws ConnectionException {
+        serializationStrategy.load( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID() );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void loadParamEntityId() throws ConnectionException {
+
+        serializationStrategy
+                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        null, UUIDGenerator.newTimeUUID() );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void loadParamVersion() throws ConnectionException {
+
+        serializationStrategy
+                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        UUIDGenerator.newTimeUUID(), null );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void loadListParamContext() throws ConnectionException {
+        serializationStrategy.load( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), 1 );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void loadListParamEntityId() throws ConnectionException {
+
+        serializationStrategy
+                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        null, UUIDGenerator.newTimeUUID(), 1 );
+    }
+
+
+    @Test( expected = NullPointerException.class )
+    public void loadListParamVersion() throws ConnectionException {
+
+        serializationStrategy
+                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        UUIDGenerator.newTimeUUID(), null, 1 );
+    }
+
+
+    @Test( expected = IllegalArgumentException.class )
+    public void loadListParamSize() throws ConnectionException {
+
+        serializationStrategy
+                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), 0 );
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb9ec94e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImplTest.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImplTest.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImplTest.java
new file mode 100644
index 0000000..9c47e08
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/MvccLogEntrySerializationStrategyImplTest.java
@@ -0,0 +1,319 @@
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.apache.usergrid.persistence.collection.CollectionContext;
+import org.apache.usergrid.persistence.collection.impl.CollectionContextImpl;
+import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
+import org.apache.usergrid.persistence.collection.mvcc.entity.MvccLogEntry;
+import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccLogEntryImpl;
+import org.apache.usergrid.persistence.collection.mvcc.entity.Stage;
+import org.apache.usergrid.persistence.collection.serialization.MvccLogEntrySerializationStrategy;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.apache.usergrid.persistence.test.CassandraRule;
+
+import com.google.guiceberry.GuiceBerryEnvSelector;
+import com.google.guiceberry.TestDescription;
+import com.google.guiceberry.junit4.GuiceBerryRule;
+import com.google.inject.Inject;
+import com.google.inject.Module;
+import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.mockito.Mockito.mock;
+
+
+/** @author tnine */
+public class MvccLogEntrySerializationStrategyImplTest {
+
+
+    /** Set our timeout to 1 seconds.  If it works for 1 seconds, we'll be good a any value */
+    private static final int TIMEOUT = 1;
+
+
+    @Rule
+    public final GuiceBerryRule guiceBerry = new GuiceBerryRule( new TimeoutModMapper() );
+
+    @Rule
+    public final CassandraRule rule = new CassandraRule();
+
+    @Inject
+    private MvccLogEntrySerializationStrategy logEntryStrategy;
+
+
+    @Test
+    public void createAndDelete() throws ConnectionException {
+
+        final UUID applicationId = UUIDGenerator.newTimeUUID();
+        final String name = "test";
+
+
+        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
+
+
+        final UUID uuid = UUIDGenerator.newTimeUUID();
+        final UUID version = UUIDGenerator.newTimeUUID();
+
+        for ( Stage stage : Stage.values() ) {
+            MvccLogEntry saved = new MvccLogEntryImpl(  uuid, version, stage );
+            logEntryStrategy.write( context, saved ).execute();
+
+            //Read it back
+
+            MvccLogEntry returned = logEntryStrategy.load( context, uuid, version );
+
+            assertNotNull( "Returned value should not be null", returned );
+
+            assertEquals( "Returned should equal the saved", saved, returned );
+        }
+    }
+
+
+    @Test
+    public void loadNoData() throws ConnectionException {
+
+        final UUID applicationId = UUIDGenerator.newTimeUUID();
+        final String name = "test";
+
+
+        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
+
+
+        final UUID uuid = UUIDGenerator.newTimeUUID();
+        final UUID version = UUIDGenerator.newTimeUUID();
+
+
+        MvccLogEntry returned = logEntryStrategy.load( context, uuid, version );
+
+        assertNull( "Returned value should not exist", returned );
+    }
+
+
+    @Test
+    public void getMultipleEntries() throws ConnectionException {
+
+        final UUID applicationId = UUIDGenerator.newTimeUUID();
+        final String name = "test";
+
+
+        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
+
+
+        final UUID uuid = UUIDGenerator.newTimeUUID();
+
+        int count = 10;
+
+        final UUID[] versions = new UUID[count];
+        final Stage COMPLETE = Stage.COMPLETE;
+        final MvccLogEntry[] entries = new MvccLogEntry[count];
+
+
+        for ( int i = 0; i < count; i++ ) {
+            versions[i] = UUIDGenerator.newTimeUUID();
+
+            entries[i] = new MvccLogEntryImpl( uuid, versions[i], COMPLETE );
+            logEntryStrategy.write( context,  entries[i] ).execute();
+
+            //Read it back
+
+            MvccLogEntry returned = logEntryStrategy.load( context, uuid, versions[i] );
+
+            assertNotNull( "Returned value should not be null", returned );
+
+            assertEquals( "Returned should equal the saved", entries[i], returned );
+        }
+
+        //now do a range scan from the end
+
+        List<MvccLogEntry> results = logEntryStrategy.load( context, uuid, versions[count - 1], count );
+
+        assertEquals( count, results.size() );
+
+        for ( int i = 0; i < count; i++ ) {
+            final MvccLogEntry saved = entries[count - i - 1];
+            final MvccLogEntry returned = results.get( i );
+
+            assertEquals( "Entry was not equal to the saved value", saved, returned );
+        }
+
+        //now delete them all and ensure we get no results back
+        for ( int i = 0; i < count; i++ ) {
+            logEntryStrategy.delete( context, uuid, versions[i] ).execute();
+        }
+
+        results = logEntryStrategy.load( context, uuid, versions[versions.length - 1], versions.length );
+
+        assertEquals( "All log entries were deleted", 0, results.size() );
+    }
+
+
+    @Test
+    public void transientTimeout() throws ConnectionException, InterruptedException {
+
+        final UUID applicationId = UUIDGenerator.newTimeUUID();
+        final String name = "test";
+
+
+        CollectionContext context = new CollectionContextImpl( applicationId, applicationId, name );
+
+
+        final UUID uuid = UUIDGenerator.newTimeUUID();
+        final UUID version = UUIDGenerator.newTimeUUID();
+
+        for ( Stage stage : Stage.values() ) {
+
+            MvccLogEntry saved = new MvccLogEntryImpl( uuid, version, stage );
+            logEntryStrategy.write(context,  saved ).execute();
+
+            //Read it back after the timeout
+
+            Thread.sleep( TIMEOUT * 1000 );
+
+            MvccLogEntry returned = logEntryStrategy.load( context, uuid, version );
+
+
+            if ( stage.isTransient() ) {
+
+                assertNull( "Active is transient and should time out", returned );
+            }
+            else {
+                assertNotNull( "Committed is not transient and should be returned", returned );
+
+                assertEquals( "Returned should equal the saved", saved, returned );
+            }
+        }
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void writeParamsNoContext() throws ConnectionException {
+        logEntryStrategy.write( null, mock(MvccLogEntry.class) );
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void writeParams() throws ConnectionException {
+        logEntryStrategy.write( mock(CollectionContext.class), null );
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void deleteParamContext() throws ConnectionException {
+        logEntryStrategy.delete( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID() );
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void deleteParamEntityId() throws ConnectionException {
+
+        logEntryStrategy
+                .delete( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        null, UUIDGenerator.newTimeUUID() );
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void deleteParamVersion() throws ConnectionException {
+
+        logEntryStrategy
+                .delete( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        UUIDGenerator.newTimeUUID(), null );
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void loadParamContext() throws ConnectionException {
+        logEntryStrategy.load( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID() );
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void loadParamEntityId() throws ConnectionException {
+
+        logEntryStrategy
+                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        null, UUIDGenerator.newTimeUUID() );
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void loadParamVersion() throws ConnectionException {
+
+        logEntryStrategy
+                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        UUIDGenerator.newTimeUUID(), null );
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void loadListParamContext() throws ConnectionException {
+        logEntryStrategy.load( null, UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), 1 );
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void loadListParamEntityId() throws ConnectionException {
+
+        logEntryStrategy
+                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        null, UUIDGenerator.newTimeUUID(), 1 );
+    }
+
+
+    @Test(expected = NullPointerException.class)
+    public void loadListParamVersion() throws ConnectionException {
+
+        logEntryStrategy
+                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        UUIDGenerator.newTimeUUID(), null, 1 );
+    }
+
+
+    @Test(expected = IllegalArgumentException.class)
+    public void loadListParamSize() throws ConnectionException {
+
+        logEntryStrategy
+                .load( new CollectionContextImpl( UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), "test" ),
+                        UUIDGenerator.newTimeUUID(), UUIDGenerator.newTimeUUID(), 0 );
+    }
+
+
+    /** Mapper that will change which module we implement based on the test case */
+    public static class TimeoutModMapper implements GuiceBerryEnvSelector {
+
+        @Override
+        public Class<? extends Module> guiceBerryEnvToUse( final TestDescription testDescription ) {
+
+            //in this edge case, we want to truncate the timeout to 1 second for this test, override the env to use
+            //this module setup
+            if ( ( MvccLogEntrySerializationStrategyImplTest.class.getName() + ".transientTimeout" )
+                    .equals( testDescription.getName() ) ) {
+                return TimeoutEnv.class;
+            }
+
+            //by default, we wnat to run the TestCollectionModule
+            return TestCollectionModule.class;
+        }
+    }
+
+
+    public static class TimeoutEnv extends TestCollectionModule {
+
+        @Override
+        public Map<String, String> getOverrides() {
+            Map<String, String> timeout = new HashMap<String, String>();
+            timeout.put( MvccLogEntrySerializationStrategyImpl.TIMEOUT_PROP, TIMEOUT + "" );
+            return timeout;
+        }
+    }
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb9ec94e/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationComparison.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationComparison.java b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationComparison.java
new file mode 100644
index 0000000..e3dc3b1
--- /dev/null
+++ b/stack/corepersistence/collection/src/test/java/org/apache/usergrid/persistence/collection/serialization/impl/SerializationComparison.java
@@ -0,0 +1,182 @@
+package org.apache.usergrid.persistence.collection.serialization.impl;
+
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.UUID;
+
+import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.smile.SmileFactory;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.usergrid.persistence.model.entity.Entity;
+import org.apache.usergrid.persistence.model.field.ArrayField;
+import org.apache.usergrid.persistence.model.field.BooleanField;
+import org.apache.usergrid.persistence.model.field.ByteBufferField;
+import org.apache.usergrid.persistence.model.field.DoubleField;
+import org.apache.usergrid.persistence.model.field.EntityObjectField;
+import org.apache.usergrid.persistence.model.field.IntegerField;
+import org.apache.usergrid.persistence.model.field.ListField;
+import org.apache.usergrid.persistence.model.field.LocationField;
+import org.apache.usergrid.persistence.model.field.LongField;
+import org.apache.usergrid.persistence.model.field.SetField;
+import org.apache.usergrid.persistence.model.field.StringField;
+import org.apache.usergrid.persistence.model.field.UUIDField;
+import org.apache.usergrid.persistence.model.util.UUIDGenerator;
+import org.apache.usergrid.persistence.model.value.EntityObject;
+import org.apache.usergrid.persistence.model.value.Location;
+
+import com.esotericsoftware.kryo.Kryo;
+import com.esotericsoftware.kryo.io.ByteBufferInputStream;
+import com.esotericsoftware.kryo.io.ByteBufferOutputStream;
+import com.esotericsoftware.kryo.io.Input;
+import com.esotericsoftware.kryo.io.Output;
+
+
+/**
+ * TODO We need to get both of these serialization methods working, and benchmark them for comparison
+ * Neither works out of the box for us without custom work.
+ * @author tnine
+ */
+public class SerializationComparison {
+
+    private static final Logger logger = LoggerFactory.getLogger( SerializationComparison.class );
+
+    private static final int count = 10000;
+
+
+    @Test
+    @Ignore
+    public void smileSerialization() throws IOException {
+        SmileFactory smile = new SmileFactory();
+
+        ObjectMapper smileMapper = new ObjectMapper( smile );
+
+
+        Entity entity = createEntity();
+
+        long writeTime = 0;
+        long readTime = 0;
+
+        for ( int i = 0; i < count; i++ ) {
+
+            //capture time in nannos for write
+            long writeStart = System.nanoTime();
+
+            byte[] smileData = smileMapper.writeValueAsBytes( entity );
+
+            writeTime += System.nanoTime() - writeStart;
+
+            long readStart = System.nanoTime();
+
+            Entity otherValue = smileMapper.readValue( smileData, Entity.class );
+
+            readTime += System.nanoTime() - readStart;
+        }
+
+        logger.info( "Smile took {} nanos for writing {} entities", writeTime, count );
+        logger.info( "Smile took {} nanos for reading {} entities", readTime, count );
+    }
+
+
+    @Test
+    @Ignore
+    public void kyroSerialization() {
+        Kryo kryo = new Kryo();
+
+        //container classes
+        kryo.register( Entity.class );
+
+        kryo.register( EntityObject.class );
+        kryo.register( Location.class );
+
+
+        //field classes
+        kryo.register( ArrayField.class );
+        kryo.register( BooleanField.class );
+        kryo.register( ByteBufferField.class );
+        kryo.register( DoubleField.class );
+        kryo.register( EntityObjectField.class );
+        kryo.register( IntegerField.class );
+        kryo.register( ListField.class );
+        kryo.register( LocationField.class );
+        kryo.register( LongField.class );
+        kryo.register( SetField.class );
+        kryo.register( StringField.class );
+        kryo.register( UUIDField.class, new de.javakaffee.kryoserializers.UUIDSerializer() );
+
+
+        long writeTime = 0;
+        long readTime = 0;
+
+        for ( int i = 0; i < count; i++ ) {
+
+            //capture time in nanos for write
+            long writeStart = System.nanoTime();
+
+            ByteBuffer data = ByteBuffer.allocate( 1024 );
+            ByteBufferOutputStream byteBuffOutputStream = new ByteBufferOutputStream(data);
+            Output output = new Output( byteBuffOutputStream );
+
+            Entity entity = createEntity();
+
+            kryo.writeObject( output, entity );
+            output.close();
+
+            writeTime += System.nanoTime() - writeStart;
+
+            data.rewind();
+
+            long readStart = System.nanoTime();
+
+
+            Input input = new Input( new ByteBufferInputStream( data ) );
+            Entity loaded = kryo.readObject( input, Entity.class );
+            input.close();
+
+            readTime += System.nanoTime() - readStart;
+        }
+
+        logger.info( "Smile took {} nanos for writing {} entities", writeTime, count );
+        logger.info( "Smile took {} nanos for reading {} entities", readTime, count );
+    }
+
+
+    private Entity createEntity() {
+
+        final UUID entityId = UUIDGenerator.newTimeUUID();
+
+        final UUID version = UUIDGenerator.newTimeUUID();
+
+        Entity entity = new Entity( entityId, "test" );
+        entity.setCreated( 1l );
+        entity.setUpdated( 2l );
+        entity.setVersion( version );
+
+
+        BooleanField boolField = new BooleanField( "boolean", false );
+        DoubleField doubleField = new DoubleField( "double", 1d );
+        IntegerField intField = new IntegerField( "long", 1 );
+        LongField longField = new LongField( "int", 1l );
+        StringField stringField = new StringField( "name", "test" );
+        UUIDField uuidField = new UUIDField( "uuid", UUIDGenerator.newTimeUUID() );
+
+        entity.setField( boolField );
+        entity.setField( doubleField );
+        entity.setField( intField );
+        entity.setField( longField );
+        entity.setField( stringField );
+        entity.setField( uuidField );
+
+        return entity;
+    }
+
+
+}
+
+
+
+

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb9ec94e/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Complete.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Complete.java b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Complete.java
index cc0bc35..dad2b21 100644
--- a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Complete.java
+++ b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Complete.java
@@ -1,7 +1,6 @@
 package org.apache.usergrid.persistence.index.stage;
 
 
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
 import org.apache.usergrid.persistence.collection.mvcc.stage.WriteContext;
 import org.apache.usergrid.persistence.collection.mvcc.stage.WriteStage;
 
@@ -15,8 +14,8 @@ public class Complete implements WriteStage
 {
 
     @Override
-    public void performStage( WriteContext context, final MvccEntity entity ) {
-
-    }
+        public void performStage( final WriteContext context ) {
+            //To change body of implemented methods use File | Settings | File Templates.
+        }
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb9ec94e/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Start.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Start.java b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Start.java
index d97b81c..05ecb1d 100644
--- a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Start.java
+++ b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Start.java
@@ -1,20 +1,16 @@
 package org.apache.usergrid.persistence.index.stage;
 
 
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
 import org.apache.usergrid.persistence.collection.mvcc.stage.WriteContext;
 import org.apache.usergrid.persistence.collection.mvcc.stage.WriteStage;
 
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-
 
 /** This state should signal an index update has started */
 public class Start implements WriteStage
 {
 
-
     @Override
-    public void performStage( final WriteContext context, final MvccEntity entity ) throws ConnectionException {
+    public void performStage( final WriteContext context ) {
         //To change body of implemented methods use File | Settings | File Templates.
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/cb9ec94e/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Write.java
----------------------------------------------------------------------
diff --git a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Write.java b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Write.java
index e143a6b..cff6d97 100644
--- a/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Write.java
+++ b/stack/corepersistence/index/src/main/java/org/apache/usergrid/persistence/index/stage/Write.java
@@ -1,21 +1,18 @@
 package org.apache.usergrid.persistence.index.stage;
 
 
-import org.apache.usergrid.persistence.collection.mvcc.entity.MvccEntity;
 import org.apache.usergrid.persistence.collection.mvcc.stage.WriteContext;
 import org.apache.usergrid.persistence.collection.mvcc.stage.WriteStage;
 
-import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;
-
 
 /** This state should perform an update of the index. */
 public class Write implements WriteStage
 {
 
 
-    @Override
-    public void performStage( final WriteContext context, final MvccEntity entity ) throws ConnectionException {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
+@Override
+       public void performStage( final WriteContext context ) {
+           //To change body of implemented methods use File | Settings | File Templates.
+       }
 }
 


Mime
View raw message