Skip to content

Commit

Permalink
Run test cases for persisted CQ storage + install depends on jar
Browse files Browse the repository at this point in the history
  • Loading branch information
codingchili committed Sep 5, 2017
1 parent 259cffb commit 623e1cb
Show file tree
Hide file tree
Showing 9 changed files with 257 additions and 217 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project.group = 'com.codingchili'

subprojects {
apply plugin: 'java'
apply plugin: 'maven'
apply plugin: 'idea'

version = rootProject.version
Expand Down
84 changes: 43 additions & 41 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
task sourcesJar(type: Jar) {
classifier 'sources'
from sourceSets.main.allSource
}

jar {
from {
(configurations.runtime).collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest {
attributes 'Implementation-Title': 'chili-core',
'Implementation-Version': version,
'Main-Class': 'com.codingchili.core.Launcher'
}
}

test {
maxHeapSize = "512m"
}

dependencies {
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'io.vertx', name: 'vertx-core', version: '3.4.1'
compile group: 'io.vertx', name: 'vertx-unit', version: '3.4.1'
compile group: 'io.vertx', name: 'vertx-web', version: '3.4.1'
compile group: 'io.vertx', name: 'vertx-hazelcast', version: '3.4.1'
compile group: 'io.vertx', name: 'vertx-mongo-client', version: '3.4.1'
compile group: 'io.vertx', name: 'vertx-dropwizard-metrics', version: '3.4.1'
compile group: 'de.neuland-bfi', name: 'jade4j', version: '1.2.5'
compile group: 'de.mkammerer', name: 'argon2-jvm', version: '2.2'
compile group: 'org.fusesource.jansi', name: 'jansi', version: '1.14'

// the following dependencies are about 25MB in size..
compile group: 'org.elasticsearch.client', name: 'transport', version: '5.3.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.6.2'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.6.2'

compile group: 'com.googlecode.cqengine', name: 'cqengine', version: '2.9.3'
}
task sourcesJar(type: Jar) {
classifier 'sources'
from sourceSets.main.allSource
}

install.dependsOn jar

jar {
from {
(configurations.runtime).collect {
it.isDirectory() ? it : zipTree(it)
}
}
manifest {
attributes 'Implementation-Title': 'chili-core',
'Implementation-Version': version,
'Main-Class': 'com.codingchili.core.Launcher'
}
}

test {
maxHeapSize = "512m"
}

dependencies {
compile group: 'junit', name: 'junit', version: '4.12'
compile group: 'io.vertx', name: 'vertx-core', version: '3.4.2'
compile group: 'io.vertx', name: 'vertx-unit', version: '3.4.2'
compile group: 'io.vertx', name: 'vertx-web', version: '3.4.2'
compile group: 'io.vertx', name: 'vertx-hazelcast', version: '3.4.2'
compile group: 'io.vertx', name: 'vertx-mongo-client', version: '3.4.2'
compile group: 'io.vertx', name: 'vertx-dropwizard-metrics', version: '3.4.2'
compile group: 'de.neuland-bfi', name: 'jade4j', version: '1.2.5'
compile group: 'de.mkammerer', name: 'argon2-jvm', version: '2.2'
compile group: 'org.fusesource.jansi', name: 'jansi', version: '1.14'

// the following dependencies are about 25MB in size..
compile group: 'org.elasticsearch.client', name: 'transport', version: '5.3.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.6.2'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.6.2'

compile group: 'com.googlecode.cqengine', name: 'cqengine', version: '2.12.1'
}
3 changes: 1 addition & 2 deletions core/main/java/com/codingchili/core/storage/IndexedMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.codingchili.core.context.StorageContext;
import com.codingchili.core.protocol.Serializer;
import com.codingchili.core.security.Account;
import com.codingchili.core.storage.exception.NothingToRemoveException;
import com.codingchili.core.storage.exception.NothingToReplaceException;
import com.codingchili.core.storage.exception.ValueAlreadyPresentException;
Expand Down Expand Up @@ -46,7 +45,7 @@ public abstract class IndexedMap<Value extends Storable> implements AsyncStorage
private SharedIndexCollection<Value> db;

@SuppressWarnings("unchecked")
protected IndexedMap(Future<AsyncStorage<Value>> future, StorageContext<Value> context) {
public IndexedMap(Future<AsyncStorage<Value>> future, StorageContext<Value> context) {
this.context = context;
FIELD_ID = attribute(context.clazz(), String.class, Storable.idField, Storable::id);
fields.put(Storable.idField, FIELD_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*/
public class IndexedMapVolatile<Value extends Storable> extends IndexedMap<Value> {

protected IndexedMapVolatile(Future<AsyncStorage<Value>> future, StorageContext<Value> context) {
public IndexedMapVolatile(Future<AsyncStorage<Value>> future, StorageContext<Value> context) {
super(future, context);
}

Expand Down
11 changes: 7 additions & 4 deletions core/main/java/com/codingchili/core/testing/MapTestCases.java
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,13 @@ public void testPut(TestContext test) {
store.put(OBJECT_ONE, put -> {
test.assertTrue(put.succeeded());

store.get(ONE, get -> {
test.assertEquals(OBJECT_ONE, get.result());
test.assertTrue(get.succeeded());
async.complete();
store.size(size -> {
test.assertEquals(TEST_ITEM_COUNT.intValue(), size.result());
store.get(ONE, get -> {
test.assertEquals(OBJECT_ONE, get.result());
test.assertTrue(get.succeeded());
async.complete();
});
});
});
}
Expand Down
195 changes: 98 additions & 97 deletions core/main/java/com/codingchili/core/testing/StorageObject.java
Original file line number Diff line number Diff line change
@@ -1,97 +1,98 @@
package com.codingchili.core.testing;

import java.util.ArrayList;
import java.util.List;

import com.codingchili.core.storage.Storable;

/**
* @author Robin Duda
* <p>
* Test class to simulate a stored object.
*/
public class StorageObject implements Storable {
public static final String NESTED_PREFIX = "nested.";
public static String levelField = "level";
private String name;
private Integer level;
private NestedObject nested;
private List<String> keywords = new ArrayList<>();

public StorageObject() {
keywords.add("Z");
}

public StorageObject(String name, Integer level) {
this();
this.name = name;
this.level = level;
this.nested = new NestedObject(NESTED_PREFIX + name);
}

public Integer getLevel() {
return level;
}

public StorageObject setLevel(Integer level) {
this.level = level;
return this;
}

public String id() {
return name;
}

public String getName() {
return name;
}

public StorageObject setName(String name) {
this.name = name;
return this;
}

public NestedObject getNested() {
return nested;
}

public void setNested(NestedObject nested) {
this.nested = nested;
}

public List<String> getKeywords() {
return keywords;
}

public void setKeywords(List<String> keywords) {
this.keywords = keywords;
}

public String toString() {
return "name=" + name + " " + "level=" + level;
}

@Override
public int hashCode() {
return name.hashCode();
}

@Override
public boolean equals(Object other) {
return compareTo(other) == 0;
}

@Override
public int compareToAttribute(Storable other, String attribute) {
StorageObject item = (StorageObject) other;

switch (attribute) {
case "level":
return level.compareTo(item.getLevel());
case "nested.name":
return nested.getName().compareTo(item.getNested().getName());
default:
return 0;
}
}
}
package com.codingchili.core.testing;

import java.util.ArrayList;
import java.util.List;

import com.codingchili.core.storage.Storable;

/**
* @author Robin Duda
* <p>
* Test class to simulate a stored object.
*/
public class StorageObject implements Storable {
public static final String NESTED_PREFIX = "nested.";
public static String levelField = "level";
private String name;
private Integer level;
private NestedObject nested;
private List<String> keywords = new ArrayList<>();

public StorageObject() {
keywords.add("Z");
}

public StorageObject(String name, Integer level) {
this();
this.name = name;
this.level = level;
this.nested = new NestedObject(NESTED_PREFIX + name);
}

public Integer getLevel() {
return level;
}

public StorageObject setLevel(Integer level) {
this.level = level;
return this;
}

@Override
public String id() {
return name;
}

public String getName() {
return name;
}

public StorageObject setName(String name) {
this.name = name;
return this;
}

public NestedObject getNested() {
return nested;
}

public void setNested(NestedObject nested) {
this.nested = nested;
}

public List<String> getKeywords() {
return keywords;
}

public void setKeywords(List<String> keywords) {
this.keywords = keywords;
}

public String toString() {
return "name=" + name + " " + "level=" + level;
}

@Override
public int hashCode() {
return name.hashCode();
}

@Override
public boolean equals(Object other) {
return compareTo(other) == 0;
}

@Override
public int compareToAttribute(Storable other, String attribute) {
StorageObject item = (StorageObject) other;

switch (attribute) {
case "level":
return level.compareTo(item.getLevel());
case "nested.name":
return nested.getName().compareTo(item.getNested().getName());
default:
return 0;
}
}
}
Loading

0 comments on commit 623e1cb

Please sign in to comment.