Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Core tests passing.
Browse files Browse the repository at this point in the history
  • Loading branch information
Todd Nine committed Mar 3, 2015
1 parent fa69be8 commit 7925a4b
Show file tree
Hide file tree
Showing 18 changed files with 252 additions and 222 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ public void writeX2ClearDelete() throws ConnectionException {
serializationStrategy.delete( context, id, version3 ).execute();


assertFalse("Not loaded", serializationStrategy.load( context, id ).isPresent());
assertFalse( "Not loaded", serializationStrategy.load( context, id ).isPresent() );

}

Expand Down Expand Up @@ -465,7 +465,7 @@ public void loadAscendingHistory() throws ConnectionException {


/**
* We no longer support partial writes, ensure that an exception is thrown when this occurs
* We no longer support partial writes, ensure that an exception is thrown when this occurs after v3
* @throws ConnectionException
*/
@Test(expected = UnsupportedOperationException.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ public class MvccEntitySerializationStrategyProxyV1_3Test extends MvccEntitySeri
@Inject
private MvccEntitySerializationStrategyV1Impl mvccEntitySerializationStrategyV1;

@Inject
private VersionedMigrationSet<MvccEntitySerializationStrategy> migrationSet;

@Override
protected MvccEntitySerializationStrategy getMvccEntitySerializationStrategy() {
return serializationStrategy;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,34 @@
package org.apache.usergrid.persistence.collection.serialization.impl;


import java.util.UUID;

import org.junit.Test;
import org.junit.runner.RunWith;

import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.MvccEntity;
import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
import org.apache.usergrid.persistence.collection.util.EntityUtils;
import org.apache.usergrid.persistence.core.test.ITRunner;
import org.apache.usergrid.persistence.core.test.UseModules;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
import org.apache.usergrid.persistence.model.field.BooleanField;
import org.apache.usergrid.persistence.model.field.DoubleField;
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 com.google.common.base.Optional;
import com.google.inject.Inject;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;


@RunWith( ITRunner.class )
Expand All @@ -43,4 +63,55 @@ public class MvccEntitySerializationStrategyV1ImplTest extends MvccEntitySeriali
protected MvccEntitySerializationStrategy getMvccEntitySerializationStrategy() {
return serializationStrategy;
}



/**
* We no longer support partial writes, ensure that an exception is thrown when this occurs after v3
* @throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
*/
@Test
public void writeLoadDeletePartial() throws ConnectionException {

final Id organizationId = new SimpleId( "organization" );
final Id applicationId = new SimpleId( "application" );
final String name = "test";

CollectionScope context = new CollectionScopeImpl( organizationId, applicationId, name );


final UUID entityId = UUIDGenerator.newTimeUUID();
final UUID version = UUIDGenerator.newTimeUUID();
final String type = "test";

final Id id = new SimpleId( entityId, type );

Entity entity = new Entity( id );

EntityUtils.setVersion( entity, 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 );


MvccEntity saved = new MvccEntityImpl( id, version, MvccEntity.Status.PARTIAL, Optional.of( entity ) );


//persist the entity
serializationStrategy.write( context, saved ).execute();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,34 @@
package org.apache.usergrid.persistence.collection.serialization.impl;


import java.util.UUID;

import org.junit.Test;
import org.junit.runner.RunWith;

import org.apache.usergrid.persistence.collection.CollectionScope;
import org.apache.usergrid.persistence.collection.MvccEntity;
import org.apache.usergrid.persistence.collection.guice.TestCollectionModule;
import org.apache.usergrid.persistence.collection.impl.CollectionScopeImpl;
import org.apache.usergrid.persistence.collection.mvcc.entity.impl.MvccEntityImpl;
import org.apache.usergrid.persistence.collection.serialization.MvccEntitySerializationStrategy;
import org.apache.usergrid.persistence.collection.util.EntityUtils;
import org.apache.usergrid.persistence.core.test.ITRunner;
import org.apache.usergrid.persistence.core.test.UseModules;
import org.apache.usergrid.persistence.model.entity.Entity;
import org.apache.usergrid.persistence.model.entity.Id;
import org.apache.usergrid.persistence.model.entity.SimpleId;
import org.apache.usergrid.persistence.model.field.BooleanField;
import org.apache.usergrid.persistence.model.field.DoubleField;
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 com.google.common.base.Optional;
import com.google.inject.Inject;
import com.netflix.astyanax.connectionpool.exceptions.ConnectionException;


@RunWith( ITRunner.class )
Expand All @@ -43,5 +63,52 @@ protected MvccEntitySerializationStrategy getMvccEntitySerializationStrategy() {
return serializationStrategy;
}

/**
* We no longer support partial writes, ensure that an exception is thrown when this occurs after v3
* @throws com.netflix.astyanax.connectionpool.exceptions.ConnectionException
*/
@Test
public void writeLoadDeletePartial() throws ConnectionException {

final Id organizationId = new SimpleId( "organization" );
final Id applicationId = new SimpleId( "application" );
final String name = "test";

CollectionScope context = new CollectionScopeImpl( organizationId, applicationId, name );


final UUID entityId = UUIDGenerator.newTimeUUID();
final UUID version = UUIDGenerator.newTimeUUID();
final String type = "test";

final Id id = new SimpleId( entityId, type );

Entity entity = new Entity( id );

EntityUtils.setVersion( entity, 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 );


MvccEntity saved = new MvccEntityImpl( id, version, MvccEntity.Status.PARTIAL, Optional.of( entity ) );


//persist the entity
serializationStrategy.write( context, saved ).execute();

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@


/**
* Classy class class.
* Same tests as v2, we just override some methods to ensure they throw the correct exceptions
*/


@RunWith( ITRunner.class )
@UseModules( TestCollectionModule.class )
public class MvccEntitySerializationStrategyV3ImplTest extends MvccEntitySerializationStrategyV3Test {
public class MvccEntitySerializationStrategyV3ImplTest extends MvccEntitySerializationStrategyV2Test {
@Inject
private MvccEntitySerializationStrategyV3Impl serializationStrategy;

Expand Down Expand Up @@ -70,4 +68,7 @@ public void loadDescendingHistory() throws ConnectionException {

serializationStrategy.loadDescendingHistory( context, entityId, version1, 20 );
}


}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ private boolean runMigration( final ProgressObserver po ) {
//run the migration
final int newSystemVersion = migrationToExecute.migrate( version, entityIdScopeDataMigrationProvider, po );

//write the version
migrationInfoSerialization.setVersion( getName(), newSystemVersion );

//signal we've run a migration and return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
import com.google.inject.multibindings.Multibinder;


public class GraphModule extends AbstractModule {
public abstract class GraphModule extends AbstractModule {

@Override
protected void configure() {
Expand Down Expand Up @@ -190,6 +190,9 @@ protected void configure() {
bind( EdgeMetadataSerializationV2Impl.class );
bind(EdgeMetadataSerialization.class).annotatedWith( ProxyImpl.class ).to( EdgeMetadataSerializationProxyImpl.class );

//invoke the migration plugin config
configureMigrationProvider();

}


Expand Down Expand Up @@ -232,6 +235,15 @@ public VersionedMigrationSet<EdgeMetadataSerialization> getVersions(final EdgeMe
}


/**
* Gives callers the ability to to configure an instance of
*
* MigrationDataProvider<ApplicationScope> for providing data migrations
*/
public abstract void configureMigrationProvider();



}


Expand Down
Loading

0 comments on commit 7925a4b

Please sign in to comment.