示例#1
0
  @Before
  public void setUp() throws Exception {
    mdc =
        new MongoConnector(
            DatabaseConfigurationFactory.getDatabaseConfiguration("junit-QueryTest"));
    mdc.waitForWrites(true);

    test = new MongoDocument();
    test.setAction(Action.ADD);
    test.putContentField("name", "test");
    test.putMetadataField("date", new Date());

    test2 = new MongoDocument();
    test2.setAction(Action.DELETE);
    test2.putContentField("name", "test");
    test2.putContentField("number", 2);
    test2.putMetadataField("date", new Date());

    random = new MongoDocument();

    try {
      mdc.connect();
    } catch (IOException e) {
      fail("IOException when establishing connection");
    }

    DatabaseDocument<MongoType> d;
    while ((d = mdc.getDocumentReader().getDocument(new MongoQuery())) != null) {
      mdc.getDocumentWriter().delete(d);
    }

    mdc.getDocumentWriter().insert(test);
    mdc.getDocumentWriter().insert(test2);
    mdc.getDocumentWriter().insert(random);
  }
示例#2
0
  private void createAndConnect() throws Exception {
    mdc =
        Guice.createInjector(new TestModule("junit-TaggingModelTest"))
            .getInstance(MongoConnector.class);

    mdc.waitForWrites(true);

    mdc.connect();
  }