|
| 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