Package org.mokai.persist.mongo

Examples of org.mokai.persist.mongo.MongoMessageStore


  }

  @SuppressWarnings("unchecked")
  @Test
  public void shouldSaveConnectionMessage() throws Exception {
    MongoMessageStore store = new MongoMessageStore();
    store.setMongo(db);

    Message message = new Message();
    message.setDirection(Direction.TO_CONNECTIONS);
    message.setSource("source");
    message.setDestination("destination");

    message.setProperty("to", "3001111111");
    message.setProperty("from", "3542");
    message.setProperty("text", "this is a test");

    store.saveOrUpdate(message); // try to save the message

    Assert.assertNotNull(message.getId());

    DBCollection col = db.getCollection(MongoMessageStore.CONNECTIONS_MSGS);
    BasicDBObject obj = (BasicDBObject) col.findOne();
View Full Code Here


  }

  @SuppressWarnings("unchecked")
  @Test
  public void shouldSaveApplicationMessage() throws Exception {
    MongoMessageStore store = new MongoMessageStore();
    store.setMongo(db);

    Message message = new Message();
    message.setDirection(Direction.TO_APPLICATIONS);
    message.setSource("source");
    message.setDestination("destination");
    message.setProperty("to", "3001111111");
    message.setProperty("from", "3542");
    message.setProperty("text", "this is a test");

    store.saveOrUpdate(message);

    Assert.assertNotNull(message.getId());

    DBCollection col = db.getCollection(MongoMessageStore.APPLICATIONS_MSGS);
    BasicDBObject obj = (BasicDBObject) col.findOne();
View Full Code Here

    Assert.assertEquals( properties.get("text"), "this is a test" );
  }

  @Test(expectedExceptions=RejectedException.class)
  public void shouldFailToSaveOrUpdateWithUnknownDirection() throws Exception {
    MongoMessageStore store = new MongoMessageStore();
    store.setMongo(db);

    Message message = new Message();
    store.saveOrUpdate(message);
  }
View Full Code Here

    store.saveOrUpdate(message);
  }

  @Test(expectedExceptions=IllegalArgumentException.class)
  public void shouldFailToSaveOrUpdateWithNullMessage() throws Exception {
    MongoMessageStore store = new MongoMessageStore();
    store.setMongo(db);

    store.saveOrUpdate(null);
  }
View Full Code Here

  @Test
  public void shouldUpdateConnectionMessage() throws Exception {
    DBCollection col = db.getCollection(MongoMessageStore.CONNECTIONS_MSGS);
    String id = createMessageForUpdate(col);

    MongoMessageStore store = new MongoMessageStore();
    store.setMongo(db);

    Message message = new Message();
    message.setId(id.toString());
    message.setDirection(Direction.TO_CONNECTIONS);
    message.setSource("source");
    message.setDestination("destination");
    message.setReference("54321");
    message.setModificationTime(new Date());
    message.setProperty("to", "3002222222");
    message.setProperty("from", "2453");
    message.setProperty("text", "this is a test");

    store.saveOrUpdate(message);

    BasicDBObject obj = (BasicDBObject) col.findOne();

    Assert.assertNotNull(obj);
    Assert.assertEquals( (byte) obj.getInt("status"), Message.STATUS_CREATED );
View Full Code Here

  @Test
  public void shouldUpdateApplicationMessage() throws Exception {
    DBCollection col = db.getCollection(MongoMessageStore.APPLICATIONS_MSGS);
    String id = createMessageForUpdate(col);

    MongoMessageStore store = new MongoMessageStore();
    store.setMongo(db);

    Message message = new Message();
    message.setId(id.toString());
    message.setDirection(Direction.TO_APPLICATIONS);
    message.setSource("source");
    message.setDestination("destination");
    message.setReference("54321");
    message.setModificationTime(new Date());
    message.setProperty("to", "3002222222");
    message.setProperty("from", "2453");
    message.setProperty("text", "this is a test");

    store.saveOrUpdate(message);

    BasicDBObject obj = (BasicDBObject) col.findOne();

    Assert.assertNotNull(obj);
    Assert.assertEquals( (byte) obj.getInt("status"), Message.STATUS_CREATED );
View Full Code Here

    DBCollection connectionsCol = db.getCollection(MongoMessageStore.CONNECTIONS_MSGS);

    createMessageForUpdate(applicationsCol, Message.STATUS_FAILED);
    createMessageForUpdate(connectionsCol, Message.STATUS_RETRYING);

    MongoMessageStore store = new MongoMessageStore();
    store.setMongo(db);

    store.updateStatus(new MessageCriteria(), Message.STATUS_PROCESSED);

    BasicDBObject obj = (BasicDBObject) applicationsCol.findOne();
    Assert.assertEquals( (byte) obj.getInt("status"), Message.STATUS_PROCESSED);

    obj = (BasicDBObject) connectionsCol.findOne();
View Full Code Here

    DBCollection connectionsCol = db.getCollection(MongoMessageStore.CONNECTIONS_MSGS);

    createMessageForUpdate(applicationsCol, Message.STATUS_FAILED);
    createMessageForUpdate(connectionsCol, Message.STATUS_RETRYING);

    MongoMessageStore store = new MongoMessageStore();
    store.setMongo(db);

    store.updateStatus(null, Message.STATUS_PROCESSED);

    BasicDBObject obj = (BasicDBObject) applicationsCol.findOne();
    Assert.assertEquals( (byte) obj.getInt("status"), Message.STATUS_PROCESSED);

    obj = (BasicDBObject) connectionsCol.findOne();
View Full Code Here

    createMessageForUpdate(applicationsCol, Message.STATUS_FAILED);
    String failedId = createMessageForUpdate(connectionsCol, Message.STATUS_FAILED);
    String retryingId = createMessageForUpdate(connectionsCol, Message.STATUS_RETRYING);
    String unroutableId = createMessageForUpdate(connectionsCol, Message.STATUS_UNROUTABLE);

    MongoMessageStore store = new MongoMessageStore();
    store.setMongo(db);

    MessageCriteria criteria = new MessageCriteria();
    criteria.setDirection(Direction.TO_CONNECTIONS);
    criteria.addStatus(Message.STATUS_FAILED);
    criteria.addStatus(Message.STATUS_RETRYING);
    store.updateStatus(criteria, Message.STATUS_PROCESSED);

    BasicDBObject obj = (BasicDBObject) applicationsCol.findOne();
    Assert.assertNotNull(obj);
    Assert.assertEquals( (byte) obj.getInt("status"), Message.STATUS_FAILED);
View Full Code Here

    createMessageForUpdate(connectionsCol, Message.STATUS_FAILED);
    String failedId = createMessageForUpdate(applicationsCol, Message.STATUS_FAILED);
    String retryingId = createMessageForUpdate(applicationsCol, Message.STATUS_RETRYING);
    String unroutableId = createMessageForUpdate(applicationsCol, Message.STATUS_UNROUTABLE);

    MongoMessageStore store = new MongoMessageStore();
    store.setMongo(db);

    MessageCriteria criteria = new MessageCriteria();
    criteria.setDirection(Direction.TO_APPLICATIONS);
    criteria.addStatus(Message.STATUS_FAILED);
    criteria.addStatus(Message.STATUS_RETRYING);
    store.updateStatus(criteria, Message.STATUS_PROCESSED);

    BasicDBObject obj = (BasicDBObject) connectionsCol.findOne();
    Assert.assertNotNull(obj);
    Assert.assertEquals( (byte) obj.getInt("status"), Message.STATUS_FAILED);
View Full Code Here

TOP

Related Classes of org.mokai.persist.mongo.MongoMessageStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.