Skip to content

Commit 5dffda3

Browse files
committed
FileWorkspaceMap test
1 parent 17747b3 commit 5dffda3

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
@@ -130,6 +130,8 @@ protected Core_DataStructure initDataStructure(String name, String type) {
130130
ret = new MongoDB_KeyValueMap(this, name);
131131
} else if (type.equalsIgnoreCase("KeyLongMap")) {
132132
ret = new MongoDB_KeyLongMap(this, name);
133+
} else if (type.equalsIgnoreCase("FileWorkspaceMap")) {
134+
ret = new MongoDB_FileWorkspaceMap(this, name);
133135
}
134136

135137
// 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_FileWorkspaceMap implementation,
10+
* and ensure that it passes all the test layed out in StructSImple_FileWorkspaceMap_test
11+
*
12+
*/
13+
public class MongoDB_FileWorkspaceMap_test extends StructSimple_FileWorkspaceMap_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 FileWorkspaceMap implementationConstructor() {
23+
24+
// Initialize server
25+
synchronized (MongoDB_FileWorkspaceMap_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_FileWorkspaceMap_test");
37+
stackConfig.put("mongodb", mongodbConfig);
38+
39+
instance = new MongoDBStack(stackConfig);
40+
}
41+
}
42+
43+
// Load the FileWorkspaceMap
44+
return instance.fileWorkspaceMap(DStackTestConfig.randomTablePrefix());
45+
}
46+
47+
}

0 commit comments

Comments
 (0)