public static synchronized IRepositoryService createRepositoryService(MongoDataSource ds, String clientName, WriteConcern writeConcern) { IRepositoryService service = repoServices.get(ds); if (service == null) { CMSDBConfig dbConfig = new CMSDBConfig(ds); int cacheSize = (Integer) dbConfig.get(CMSDBConfig.REPOSITORY_CACHE_SIZE_KEY); int expireSeconds = (Integer) dbConfig.get(CMSDBConfig.REPOSITORY_CACHE_EXPIRE_SECONDS_KEY); int collectionCountCacheSize = (Integer) dbConfig.get(CMSDBConfig.COLLECTION_COUNT_CACHE_SIZE_KEY); int collectionCountCacheExpiredTime = (Integer) dbConfig.get(CMSDBConfig.COLLECTION_COUNT_CACHE_EXPIRE_SECONDS_KEY); ICMSLock lock = createMetadataLock(ds.getMongoInstance(), dbConfig, clientName); service = new MongoRepositoryServiceImpl(ds.getMongoInstance(), cacheSize, expireSeconds, collectionCountCacheSize, collectionCountCacheExpiredTime, lock, writeConcern); repoServices.put(ds, service); } return service; } }
@SuppressWarnings("deprecation") @Test public void testRepoServiceInvalidArg() { try { new MongoRepositoryServiceImpl(null, 1, 1, 1, 1, null, WriteConcern.SAFE); } catch (Exception e) { // expected } try { new MongoRepositoryServiceImpl(new Mongo(), 0, 1, 1, 1, null, WriteConcern.SAFE); } catch (Exception e) { // expected } try { new MongoRepositoryServiceImpl(new Mongo(), 1, 0, 1, 1, null, WriteConcern.SAFE); } catch (Exception e) { // expected } try { new MongoRepositoryServiceImpl(new Mongo(), 1, 1, 1, 1, null, WriteConcern.SAFE); } catch (Exception e) { // expected } }