Skip to content

Commit d9148a4

Browse files
committed
KeyLongMap test
1 parent ebb9932 commit d9148a4

2 files changed

Lines changed: 49 additions & 0 deletions

File tree

src/main/java/picoded/dstack/mongodb/MongoDBStack.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ protected Core_DataStructure initDataStructure(String name, String type) {
128128
ret = new MongoDB_DataObjectMap(this, name);
129129
} else if (type.equalsIgnoreCase("KeyValueMap")) {
130130
ret = new MongoDB_KeyValueMap(this, name);
131+
} else if (type.equalsIgnoreCase("KeyLongMap")) {
132+
ret = new MongoDB_KeyLongMap(this, name);
131133
}
132134

133135
// If datastrucutre initialized, setup name
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package picoded.dstack.mongodb;
2+
3+
import picoded.core.struct.*;
4+
import picoded.dstack.*;
5+
import picoded.dstack.struct.simple.*;
6+
7+
/**
8+
* ## Purpose
9+
* This class is meant to test the MongoDB_KeyLongMap implementation,
10+
* and ensure that it passes all the test layed out in StructSImple_KeyLongMap_test
11+
*
12+
*/
13+
public class MongoDB_KeyLongMap_test extends StructSimple_KeyLongMap_test {
14+
15+
// Hazelcast stack instance
16+
protected static volatile MongoDBStack instance = null;
17+
18+
// To override for implementation
19+
//-----------------------------------------------------
20+
21+
/// Impomentation constructor
22+
public KeyLongMap implementationConstructor() {
23+
24+
// Initialize server
25+
synchronized (MongoDB_KeyLongMap_test.class) {
26+
if (instance == null) {
27+
// The default config uses localhost, 27017
28+
GenericConvertMap<String, Object> mongodbConfig = new GenericConvertHashMap<>();
29+
mongodbConfig.put("host", DStackTestConfig.MONGODB_HOST());
30+
mongodbConfig.put("port", DStackTestConfig.MONGODB_PORT());
31+
32+
// Use a random DB name
33+
mongodbConfig.put("name", DStackTestConfig.randomTablePrefix());
34+
35+
GenericConvertMap<String, Object> stackConfig = new GenericConvertHashMap<>();
36+
stackConfig.put("name", "MongoDB_KeyLongMap_test");
37+
stackConfig.put("mongodb", mongodbConfig);
38+
39+
instance = new MongoDBStack(stackConfig);
40+
}
41+
}
42+
43+
// Load the KeyLongMap
44+
return instance.keyLongMap(DStackTestConfig.randomTablePrefix());
45+
}
46+
47+
}

0 commit comments

Comments
 (0)