@@ -77,13 +77,15 @@ public class ExtentKlovReporter extends AbstractReporter
7777 private static final String DEFAULT_MONGODB_HOST_PROP = "mongodb.host" ;
7878 private static final String DEFAULT_MONGODB_PORT_PROP = "mongodb.port" ;
7979 private static final String DEFAULT_MONGODB_URI_PROP = "mongodb.uri" ;
80+ private static final String DEFAULT_DATABASE_NAME_PROP = "database.name" ;
8081 private static final String DEFAULT_KLOV_HOST_PROP = "klov.host" ;
8182 private static final String DEFAULT_KLOV_PORT_PROP = "klov.port" ;
82- private static final String DB_NAME = "klov" ;
8383 private static final String DEFAULT_PROJECT_NAME = "Default" ;
84-
84+ private static final String DB_NAME = "klov" ;
85+
8586 private final AtomicBoolean initiated = new AtomicBoolean ();
8687
88+ private String databaseName = DB_NAME ;
8789 private String url ;
8890 private Boolean appendExisting = false ;
8991
@@ -283,6 +285,17 @@ public ExtentKlovReporter initKlovServerConnection(String url) {
283285 this .url = url ;
284286 return this ;
285287 }
288+
289+ /**
290+ * Specify a database name instead of default: "Klov"
291+ *
292+ * @param name Name of the database
293+ * @return a {@link ExtentKlovReporter} object
294+ */
295+ public ExtentKlovReporter setDatabaseName (String name ) {
296+ databaseName = name ;
297+ return this ;
298+ }
286299
287300 /**
288301 * Initializes KlovReporter with default Klov and MongoDB settings. This
@@ -312,6 +325,10 @@ private Properties loadProperties(InputStream is) throws IOException {
312325 }
313326
314327 private void loadInitializationParams (Properties props ) {
328+ String databaseName = props .getProperty (DEFAULT_DATABASE_NAME_PROP );
329+ if (databaseName != null && !databaseName .isEmpty ())
330+ this .databaseName = databaseName ;
331+
315332 String mongoUri = props .getProperty (DEFAULT_MONGODB_URI_PROP );
316333 String mongoHost = props .getProperty (DEFAULT_MONGODB_HOST_PROP );
317334 String mongoPort = props .getProperty (DEFAULT_MONGODB_PORT_PROP );
@@ -800,7 +817,7 @@ public void onComplete() {
800817 private final void start () {
801818 CodecRegistry pojoCodecRegistry = CodecRegistries .fromRegistries (MongoClient .getDefaultCodecRegistry (),
802819 CodecRegistries .fromProviders (PojoCodecProvider .builder ().automatic (true ).build ()));
803- MongoDatabase db = mongoClient .getDatabase (DB_NAME ).withCodecRegistry (pojoCodecRegistry );
820+ MongoDatabase db = mongoClient .getDatabase (databaseName ).withCodecRegistry (pojoCodecRegistry );
804821 initCollections (db );
805822 setupProject ();
806823 }
0 commit comments