类com.mongodb.client.MongoDatabase源码实例Demo

下面列出了怎么用com.mongodb.client.MongoDatabase的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: ByteTCC   文件: MongoCompensableLock.java
private boolean takeOverTransactionInMongoDB(TransactionXid transactionXid, String source, String target) {
	byte[] global = transactionXid.getGlobalTransactionId();
	String instanceId = ByteUtils.byteArrayToString(global);

	try {
		String application = CommonUtils.getApplication(this.endpoint);
		String databaseName = application.replaceAll("\\W", "_");
		MongoDatabase mdb = this.mongoClient.getDatabase(databaseName);
		MongoCollection<Document> collection = mdb.getCollection(CONSTANTS_TB_LOCKS);

		Bson globalFilter = Filters.eq(CONSTANTS_FD_GLOBAL, instanceId);
		Bson instIdFilter = Filters.eq("identifier", source);

		Document document = new Document("$set", new Document("identifier", target));

		UpdateResult result = collection.updateOne(Filters.and(globalFilter, instIdFilter), document);
		return result.getMatchedCount() == 1;
	} catch (RuntimeException rex) {
		logger.error("Error occurred while locking transaction(gxid= {}).", instanceId, rex);
		return false;
	}
}
 
源代码2 项目: jpa-unit   文件: MongoDbDecoratorTest.java
@Test
public void testMongoClientIsClosedEvenIfExecuteAfterTestFails() throws Throwable {
    // GIVEN
    when(invocation.getException()).thenReturn(Optional.of(new Exception()));
    doThrow(RuntimeException.class).when(executor).executeAfterTest(any(MongoDatabase.class), anyBoolean());

    // WHEN
    try {
        decorator.afterTest(invocation);
        fail("Exception expected");
    } catch (final Exception e) {
        // expected
    }

    // THEN
    verifyZeroInteractions(mongoClient);
}
 
源代码3 项目: mongobee   文件: ChangeEntryDaoTest.java
@Test
public void shouldReleaseLockFromLockDao() throws Exception {

  // given
  MongoClient mongoClient = mock(MongoClient.class);
  MongoDatabase db = new Fongo(TEST_SERVER).getDatabase(DB_NAME);
  when(mongoClient.getDatabase(anyString())).thenReturn(db);

  ChangeEntryDao dao = new ChangeEntryDao(CHANGELOG_COLLECTION_NAME, LOCK_COLLECTION_NAME, WAIT_FOR_LOCK,
      CHANGE_LOG_LOCK_WAIT_TIME, CHANGE_LOG_LOCK_POLL_RATE, THROW_EXCEPTION_IF_CANNOT_OBTAIN_LOCK);

  LockDao lockDao = mock(LockDao.class);
  dao.setLockDao(lockDao);

  dao.connectMongoDb(mongoClient, DB_NAME);

  // when
  dao.releaseProcessLock();

  // then
  verify(lockDao).releaseLock(any(MongoDatabase.class));
}
 
源代码4 项目: hazelcast-simulator   文件: ReadWriteTest.java
@Setup
public void setUp() {
    if (itemCount <= 0) {
        throw new IllegalStateException("size must be larger than 0");
    }

    MongoDatabase database = client.getDatabase(databaseName);
    col = database.getCollection(collectionName);

    values = new Document[idArraySize][itemCount];
    for (int i = 0; i < idArraySize; i++) {
        for (int j = 0; j < itemCount; j++) {
            values[i][j] = createEntry(j);
        }
    }
}
 
源代码5 项目: medical-data-android   文件: RegisterActivity.java
@Override
protected Integer doInBackground(User... params) {
    try {
        MongoClientURI mongoClientURI = new MongoClientURI(Variables.mongo_uri);
        MongoClient mongoClient = new MongoClient(mongoClientURI);
        MongoDatabase dbMongo = mongoClient.getDatabase(mongoClientURI.getDatabase());
        MongoCollection<Document> coll = dbMongo.getCollection("users");
        User local_user = params[0];
        if (coll.find(eq("email", local_user.getEmail())).first() != null) {
            mongoClient.close();
            return 1; // Repeated email
        }
        Document document = local_user.getRegisterDocument();
        coll.insertOne(document);
        local_user.setId(document.getObjectId("_id").toString());
        mongoClient.close();
        return 0; //Successfully saved
    } catch (Exception e) {
        return 2; // Error
    }
}
 
源代码6 项目: ByteTCC   文件: MongoCompensableLock.java
private String getTransactionOwnerInMongoDB(TransactionXid transactionXid) {
	byte[] global = transactionXid.getGlobalTransactionId();
	String instanceId = ByteUtils.byteArrayToString(global);

	try {
		String application = CommonUtils.getApplication(this.endpoint);
		String databaseName = application.replaceAll("\\W", "_");
		MongoDatabase mdb = this.mongoClient.getDatabase(databaseName);
		MongoCollection<Document> collection = mdb.getCollection(CONSTANTS_TB_LOCKS);

		FindIterable<Document> findIterable = collection.find(Filters.eq(CONSTANTS_FD_GLOBAL, instanceId));
		MongoCursor<Document> cursor = findIterable.iterator();
		if (cursor.hasNext()) {
			Document document = cursor.next();
			return document.getString("identifier");
		} else {
			return null;
		}
	} catch (RuntimeException rex) {
		logger.error("Error occurred while querying the lock-owner of transaction(gxid= {}).", instanceId, rex);
		return null;
	}
}
 
源代码7 项目: mongobee   文件: ChangeEntryDaoTest.java
@Test(expected = MongobeeLockException.class)
public void shouldThrowLockExceptionIfThrowExceptionIsTrue() throws Exception {
  // given
  MongoClient mongoClient = mock(MongoClient.class);
  MongoDatabase db = new Fongo(TEST_SERVER).getDatabase(DB_NAME);
  when(mongoClient.getDatabase(anyString())).thenReturn(db);

  ChangeEntryDao dao = new ChangeEntryDao(CHANGELOG_COLLECTION_NAME, LOCK_COLLECTION_NAME, WAIT_FOR_LOCK,
      CHANGE_LOG_LOCK_WAIT_TIME, CHANGE_LOG_LOCK_POLL_RATE, true);

  LockDao lockDao = mock(LockDao.class);
  when(lockDao.acquireLock(any(MongoDatabase.class))).thenReturn(false);
  dao.setLockDao(lockDao);

  dao.connectMongoDb(mongoClient, DB_NAME);

  // when
  boolean hasLock = dao.acquireProcessLock();

  // then
  assertFalse(hasLock);
}
 
源代码8 项目: mongo-kafka   文件: ConnectorValidationTest.java
private void dropUserAndRoles() {
  if (isAuthEnabled()) {
    List<MongoDatabase> databases =
        asList(
            getMongoClient().getDatabase(getConnectionString().getCredential().getSource()),
            getMongoClient().getDatabase(CUSTOM_DATABASE));

    for (final MongoDatabase database : databases) {
      tryAndIgnore(
          () -> database.runCommand(Document.parse(format("{dropUser: '%s'}", CUSTOM_USER))));
      tryAndIgnore(
          () -> database.runCommand(Document.parse(format("{dropRole: '%s'}", CUSTOM_ROLE))));
      tryAndIgnore(() -> database.runCommand(Document.parse("{invalidateUserCache: 1}")));
    }
  }
}
 
源代码9 项目: medical-data-android   文件: ProfileActivity.java
@Override
protected Integer doInBackground(User... params) {
    try {
        MongoClientURI mongoClientURI = new MongoClientURI(Variables.mongo_uri);
        MongoClient mongoClient = new MongoClient(mongoClientURI);
        MongoDatabase dbMongo = mongoClient.getDatabase(mongoClientURI.getDatabase());
        MongoCollection<Document> coll = dbMongo.getCollection("users");
        User local_user = params[0];
        if (!local_user.getEmail().equals(original_email)) {
            Document user = coll.find(eq("email", local_user.getEmail())).first();
            if (user != null) {
                return 1; // Repeated email
            }
        }

        Document search = new Document("_id", new ObjectId(local_user.getId()));
        Document replacement = new Document("$set", local_user.getRegisterDocument());
        // We update some fields of the documents without affecting the rest
        coll.updateOne(search, replacement);
        mongoClient.close();
        return 0; //Successfully saved
    } catch (Exception e) {
        return 2; // Error
    }
}
 
源代码10 项目: openbd-core   文件: MongoCollectionStats.java
@SuppressWarnings( "rawtypes" )
public cfData execute(cfSession _session, cfArgStructData argStruct ) throws cfmRunTimeException {
	MongoDatabase	db	= getMongoDatabase( _session, argStruct );
	
	String collection	= getNamedStringParam(argStruct, "collection", null);
	if ( collection == null )
		throwException(_session, "please specify a collection");
	
	try{
		Document result	= db.runCommand( new Document("collection",collection).append( "verbose", true ) );
		return tagUtils.convertToCfData((Map)result);	 	
	} catch (MongoException me){
		throwException(_session, me.getMessage());
		return null;
	}

}
 
源代码11 项目: tutorials   文件: BsonToJsonLiveTest.java
@Test
public void givenBsonDocument_whenUsingCustomJsonTransformation_thenJsonDateIsStringField() {

    String json = null;
    try (MongoClient mongoClient = new MongoClient()) {
        MongoDatabase mongoDatabase = mongoClient.getDatabase(DB_NAME);
        Document bson = mongoDatabase.getCollection("Books").find().first();
        json = bson.toJson(JsonWriterSettings
            .builder()
            .dateTimeConverter(new JsonDateTimeConverter())
            .build());
    }

    String expectedJson = "{\"_id\": \"isbn\", " + 
        "\"className\": \"com.baeldung.bsontojson.Book\", " + 
        "\"title\": \"title\", " + 
        "\"author\": \"author\", " + 
        "\"publisher\": {\"_id\": {\"$oid\": \"fffffffffffffffffffffffa\"}, " + 
        "\"name\": \"publisher\"}, " + 
        "\"price\": 3.95, " + 
        "\"publishDate\": \"2020-01-01T17:13:32Z\"}";

    assertEquals(expectedJson, json);

}
 
源代码12 项目: baleen   文件: RealMongoFactory.java
@Override
public MongoDatabase createDatabase() {

  int port =
      argumentsMap.containsKey(PORT) ? Integer.parseInt(argumentsMap.get(PORT)) : DEFAULT_PORT;
  String host = argumentsMap.getOrDefault(HOST, DEFAULT_HOST);
  String databaseName = argumentsMap.getOrDefault(DATABASE_NAME, DEFAULT_DATABASE_NAME);
  String username = argumentsMap.getOrDefault(USERNAME, DEFAULT_USERNAME);
  String password = argumentsMap.getOrDefault(PASSWORD, DEFAULT_PASSWORD);

  List<ServerAddress> seeds = new ArrayList<>();
  List<MongoCredential> credentials = new ArrayList<>();
  seeds.add(new ServerAddress(host, port));
  credentials.add(
      MongoCredential.createScramSha1Credential(username, databaseName, password.toCharArray()));

  Boolean useAuthentication =
      Boolean.valueOf(argumentsMap.getOrDefault(USE_AUTHENTICATION, FALSE));

  client = useAuthentication ? new MongoClient(seeds, credentials) : new MongoClient(seeds);

  String dbName = argumentsMap.getOrDefault(DATABASE_NAME, DEFAULT_DATABASE_NAME);
  return client.getDatabase(dbName);
}
 
源代码13 项目: DBus   文件: MongoWrapperDefaultHandler.java
/**
 * 根据oid去数据库回查数据
 *
 * @param oid
 * @return
 */
private Document fetchData(String schemaName, String tableName, String oid) {
    Document result = null;
    DbusDatasource datasource = GlobalCache.getDatasource();
    MongoClientURI uri = new MongoClientURI(datasource.getMasterUrl());
    MongoClient client = new MongoClient(uri);
    MongoDatabase database = client.getDatabase(schemaName);
    MongoCollection<Document> collection = database.getCollection(tableName);
    MongoCursor<Document> cursor = collection.find(new BasicDBObject().append("_id", new ObjectId(oid))).iterator();
    if (cursor.hasNext()) {
        result = cursor.next();
    } else {
        logger.error("get source data error. schemaName:{}, tableName:{}, oid:{}", schemaName, tableName, oid);
    }
    client.close();
    return result;

}
 
源代码14 项目: heimdall   文件: MongoDBAppender.java
@Override
public void start() {
	log.info("Initializing Mongodb Appender");
	if (this.uri != null) {
		this.mongoClient = new MongoClient(new MongoClientURI(this.uri));
	} else {
		MongoClientOptions options = new MongoClientOptions.Builder().build();
		ServerAddress address = new ServerAddress(this.url, this.port.intValue());
		this.mongoClient = new MongoClient(address, options);
	}

	MongoDatabase database = this.mongoClient.getDatabase(this.dataBase);
	this.collection = database.getCollection(this.collectionName);
	log.info("Starting connection with url: {} - port: {}", this.url, this.port);
	log.info("Database used: {} - Collection: {}", this.dataBase, this.collectionName);
	super.start();
}
 
源代码15 项目: logging-log4j2   文件: MongoDb4Test.java
@Test
public void test() {
    final Logger logger = LogManager.getLogger();
    logger.info("Hello log");
    try (final MongoClient mongoClient = mongoDbTestRule.getMongoClient()) {
        final MongoDatabase database = mongoClient.getDatabase("testDb");
        Assert.assertNotNull(database);
        final MongoCollection<Document> collection = database.getCollection("testCollection");
        Assert.assertNotNull(collection);
        final Document first = collection.find().first();
        Assert.assertNotNull(first);
        Assert.assertEquals(first.toJson(), "Hello log", first.getString("message"));
        Assert.assertEquals(first.toJson(), "INFO", first.getString("level"));
    }
}
 
@BeforeEach
public void setUp() {
    mongoClient = mongoDBService.getClient();

    MongoDatabase database = mongoClient.getDatabase("testDatabase");

    /*
     The consume operation needs taliable cursors which require capped
     collections
     */
    CreateCollectionOptions options = new CreateCollectionOptions();
    options.capped(true);
    options.sizeInBytes(1024 * 1024);

    database.createCollection("testCollection", options);

    MongoCollection<Document> collection = database.getCollection("testCollection");

    List<Document> documents = new ArrayList<>(expect);
    for (int i = 0; i < expect; i++) {
        Document doc = new Document();

        doc.append("name", "test");
        doc.append("value", "value " + i);

        documents.add(doc);
    }

    collection.insertMany(documents);
}
 
源代码17 项目: lumongo   文件: MongoDocumentStorage.java
@Override
public void deleteSourceDocument(String uniqueId) throws Exception {
	MongoDatabase db = mongoClient.getDatabase(database);
	MongoCollection<Document> coll = db.getCollection(rawCollectionName);
	Document search = new Document(MongoConstants.StandardFields._ID, uniqueId);
	coll.deleteOne(search);
}
 
源代码18 项目: glowroot   文件: MongoDbPluginIT.java
@Override
public void transactionMarker() {
    MongoDatabase database = mongoClient.getDatabase("testdb");
    MongoCollection<Document> collection = database.getCollection("test");
    Document document = new Document("test1", "test2")
            .append("test3", "test4");
    collection.insertOne(document);
}
 
源代码19 项目: vividus   文件: MongoDbStepsTests.java
@PrepareForTest(MongoClients.class)
@Test
public void testExecuteCommand()
{
    MongoDatabase database = mockDatabase();
    when(database.runCommand(COMMAND)).thenReturn(DOCUMENT);

    MongoDbSteps steps = new MongoDbSteps(Map.of(LOCAL_KEY, CONNECTION_KEY), jsonUtils, context);
    steps.executeCommand(COMMAND, LOCAL_KEY, LOCAL_KEY, Set.of(VariableScope.STORY), VARIABLE_KEY);

    verify(context).putVariable(Set.of(VariableScope.STORY), VARIABLE_KEY, Map.of("id", "1"));
}
 
源代码20 项目: spring-data-dev-tools   文件: CallbacksBenchmark.java
@Setup
public void setUp() {

	MongoClient client = Mockito.mock(MongoClient.class);
	MongoDatabase db = Mockito.mock(MongoDatabase.class);
	MongoCollection<Document> collection = Mockito.mock(MongoCollection.class);

	Mockito.when(client.getDatabase(Mockito.anyString())).thenReturn(db);
	Mockito.when(db.getCollection(Mockito.anyString(), Mockito.eq(Document.class))).thenReturn(collection);

	MongoDatabaseFactory factory = new SimpleMongoClientDatabaseFactory(client, "mock-database");

	templateWithoutContext = new MongoTemplate(factory);

	templateWithEmptyContext = new MongoTemplate(factory);
	templateWithEmptyContext.setApplicationContext(new AnnotationConfigApplicationContext(EmptyConfig.class));

	templateWithContext = new MongoTemplate(factory);
	templateWithContext.setApplicationContext(new AnnotationConfigApplicationContext(EntityCallbackConfig.class));

	source = new Person();
	source.id = "luke-skywalker";
	source.firstname = "luke";
	source.lastname = "skywalker";

	source.address = new Address();
	source.address.street = "melenium falcon 1";
	source.address.city = "deathstar";
}
 
源代码21 项目: presto   文件: MongoSession.java
private Document getTableMetadata(SchemaTableName schemaTableName)
        throws TableNotFoundException
{
    String schemaName = toRemoteSchemaName(schemaTableName.getSchemaName());
    String tableName = toRemoteTableName(schemaName, schemaTableName.getTableName());

    MongoDatabase db = client.getDatabase(schemaName);
    MongoCollection<Document> schema = db.getCollection(schemaCollection);

    Document doc = schema
            .find(new Document(TABLE_NAME_KEY, tableName)).first();

    if (doc == null) {
        if (!collectionExists(db, tableName)) {
            throw new TableNotFoundException(schemaTableName);
        }
        else {
            Document metadata = new Document(TABLE_NAME_KEY, tableName);
            metadata.append(FIELDS_KEY, guessTableFields(schemaName, tableName));

            schema.createIndex(new Document(TABLE_NAME_KEY, 1), new IndexOptions().unique(true));
            schema.insertOne(metadata);

            return metadata;
        }
    }

    return doc;
}
 
源代码22 项目: fiware-cygnus   文件: MongoBackendImpl.java
/**
 * Inserts a new document in the given raw collection within the given database (row-like mode).
 * @param dbName
 * @param collectionName
 * @param aggregation
 * @throws Exception
 */
@Override
public void insertContextDataRaw(String dbName, String collectionName, ArrayList<Document> aggregation)
    throws Exception {
    MongoDatabase db = getDatabase(dbName);
    MongoCollection collection = db.getCollection(collectionName);
    collection.insertMany(aggregation);
}
 
源代码23 项目: presto   文件: MongoSession.java
private List<Document> guessTableFields(String schemaName, String tableName)
{
    MongoDatabase db = client.getDatabase(schemaName);
    Document doc = db.getCollection(tableName).find().first();
    if (doc == null) {
        // no records at the collection
        return ImmutableList.of();
    }

    ImmutableList.Builder<Document> builder = ImmutableList.builder();

    for (String key : doc.keySet()) {
        Object value = doc.get(key);
        Optional<TypeSignature> fieldType = guessFieldType(value);
        if (fieldType.isPresent()) {
            Document metadata = new Document();
            metadata.append(FIELDS_NAME_KEY, key);
            metadata.append(FIELDS_TYPE_KEY, fieldType.get().toString());
            metadata.append(FIELDS_HIDDEN_KEY,
                    key.equals("_id") && fieldType.get().equals(OBJECT_ID.getTypeSignature()));

            builder.add(metadata);
        }
        else {
            log.debug("Unable to guess field type from %s : %s", value == null ? "null" : value.getClass().getName(), value);
        }
    }

    return builder.build();
}
 
源代码24 项目: baleen   文件: MaxEntClassifierTrainer.java
@Override
public void initialize(UimaContext context) throws ResourceInitializationException {
  super.initialize(context);

  MongoDatabase db = mongo.getDB();
  documentsCollection = db.getCollection(documentCollectionName);
  labelsAndFeatures = readLabelsAndFeaturesFromFile(labelsFile);
  stopwords = stopwordResource.getStopwords(stoplist);
}
 
源代码25 项目: logging-log4j2   文件: MongoDb4AuthFailureTest.java
@Test
public void test() {
    final Logger logger = LogManager.getLogger();
    logger.info("Hello log");
    try (final MongoClient mongoClient = mongoDbTestRule.getMongoClient()) {
        final MongoDatabase database = mongoClient.getDatabase("testDb");
        Assert.assertNotNull(database);
        final MongoCollection<Document> collection = database.getCollection("testCollection");
        Assert.assertNotNull(collection);
        final Document first = collection.find().first();
        Assert.assertNull(first);
    }
}
 
源代码26 项目: render   文件: MongoUtil.java
public static boolean exists(final MongoDatabase database,
                             final String collectionName) {
    for (final String name : database.listCollectionNames()) {
        if (name.equals(collectionName)) {
            return true;
        }
    }
    return false;
}
 
源代码27 项目: mongo-kafka   文件: MongoSourceTask.java
private ChangeStreamIterable<Document> getChangeStreamIterable(
    final MongoSourceConfig sourceConfig, final MongoClient mongoClient) {
  String database = sourceConfig.getString(DATABASE_CONFIG);
  String collection = sourceConfig.getString(COLLECTION_CONFIG);

  Optional<List<Document>> pipeline = sourceConfig.getPipeline();
  ChangeStreamIterable<Document> changeStream;
  if (database.isEmpty()) {
    LOGGER.info("Watching all changes on the cluster");
    changeStream = pipeline.map(mongoClient::watch).orElse(mongoClient.watch());
  } else if (collection.isEmpty()) {
    LOGGER.info("Watching for database changes on '{}'", database);
    MongoDatabase db = mongoClient.getDatabase(database);
    changeStream = pipeline.map(db::watch).orElse(db.watch());
  } else {
    LOGGER.info("Watching for collection changes on '{}.{}'", database, collection);
    MongoCollection<Document> coll = mongoClient.getDatabase(database).getCollection(collection);
    changeStream = pipeline.map(coll::watch).orElse(coll.watch());
  }

  int batchSize = sourceConfig.getInt(BATCH_SIZE_CONFIG);
  if (batchSize > 0) {
    changeStream.batchSize(batchSize);
  }
  sourceConfig.getFullDocument().ifPresent(changeStream::fullDocument);
  sourceConfig.getCollation().ifPresent(changeStream::collation);
  return changeStream;
}
 
源代码28 项目: fiware-cygnus   文件: MongoBackendImpl.java
private void insertContextDataAggregatedForResoultion(String dbName, String collectionName,
        GregorianCalendar calendar, String entityId, String entityType, String attrName, String attrType,
        HashMap<String, Integer> counts, Resolution resolution) {
    // Get database and collection
    MongoDatabase db = getDatabase(dbName);
    MongoCollection collection = db.getCollection(collectionName);

    // Build the query
    BasicDBObject query = buildQueryForInsertAggregated(calendar, entityId, entityType, attrName, resolution);

    // Prepopulate if needed
    BasicDBObject insert = buildInsertForPrepopulate(attrType, resolution, false);
    UpdateResult res = collection.updateOne(query, insert, new UpdateOptions().upsert(true));

    if (res.getMatchedCount() == 0) {
        LOGGER.debug("Prepopulating data, database=" + dbName + ", collection=" + collectionName + ", query="
                + query.toString() + ", insert=" + insert.toString());
    } // if

    // Do the update
    for (String key : counts.keySet()) {
        int count = counts.get(key);
        BasicDBObject update = buildUpdateForUpdate(attrType, resolution, calendar, key, count);
        LOGGER.debug("Updating data, database=" + dbName + ", collection=" + collectionName + ", query="
                + query.toString() + ", update=" + update.toString());
        collection.updateOne(query, update);
    } // for
}
 
源代码29 项目: repairnator   文件: CleanProjectList.java
public static void main(String[] args) throws IOException {
    String projectPath = args[0];
    String dbUrl = args[1];
    String dbName = args[2];
    String collectionName = args[3];
    String destList = args[4];

    List<String> allProjects = Files.readAllLines(new File(projectPath).toPath());
    MongoConnection mongoConnection = new MongoConnection(dbUrl, dbName);
    MongoDatabase database = mongoConnection.getMongoDatabase();
    MongoCollection collection = database.getCollection(collectionName);

    List<String> selectedProjects = new ArrayList<>();
    for (String project : allProjects) {
        Repository repo = RepositoryHelper.getRepositoryFromSlug(project);
        if (repo != null) {
            Build b = repo.getLastBuild(false);
            if (b != null) {
                if (b.getBuildTool() == BuildTool.MAVEN) {
                    long results = collection.count(and(
                            eq("repositoryName", project),
                            ne("typeOfFailures", null)
                    ));

                    if (results > 0) {
                        selectedProjects.add(project);
                    }
                }
            }
        }
    }

    File outputFile = new File(destList);
    BufferedWriter buffer = new BufferedWriter(new FileWriter(outputFile));
    buffer.write(StringUtils.join(selectedProjects,"\n"));
    buffer.close();

    System.out.println("Read projects: "+allProjects.size()+" | Selected projects : "+selectedProjects.size());
    System.out.println(StringUtils.join(selectedProjects, "\n"));
}
 
源代码30 项目: obevo   文件: MongoDbChangeAuditDaoIT.java
@Before
public void setup() {
    this.mongoClient = MongoClientFactory.getInstance().getMongoClient(MongoDbTestHelper.HOST, MongoDbTestHelper.PORT);
    MongoDatabase mydb = mongoClient.getDatabase("mydb");
    mydb.getCollection("ARTIFACTDEPLOYMENT").drop();
    mydb.getCollection("ARTIFACTEXECUTION").drop();
}
 
 类所在包
 同包方法