* @param testName the name of the testing database, used as a suffix, not null
* @param makeUnique whether to make the connector unique by date-time
* @return the Mongo connector, not null
*/
public static MongoConnector makeTestConnector(String testName, boolean makeUnique) {
MongoConnectorFactoryBean factory = new MongoConnectorFactoryBean();
factory.setName("MongoTestUtils");
Properties properties = TestProperties.getTestProperties();
factory.setHost(properties.getProperty("mongoServer.host"));
factory.setPort(Integer.parseInt(properties.getProperty("mongoServer.port")));
factory.setDatabaseName(System.getProperty("user.name").replace('.', '_') + "_unit");
String collectionSuffix = "_" + testName;
if (makeUnique) {
collectionSuffix += "_" + System.currentTimeMillis();
}
factory.setCollectionSuffix(collectionSuffix);
return factory.createObject();
}