@Test public void getCollection() { DBCollection collection = template.getCollection(false); assertEquals("simple", collection.getName()); assertEquals(ReadPreference.PRIMARY, collection.getReadPreference()); collection = template.getCollection(true); assertEquals(ReadPreference.SECONDARY, collection.getReadPreference()); collection = template.getCollection(); assertEquals(mds.getDb().getReadPreference(), collection.getReadPreference()); }
@Test public void readWriteData() { Date date = new Date(); SimpleBean bean = new SimpleBean(); bean.setAlive(true); bean.setBirthdate(date); bean.setName("Special Name"); bean.setRating(RAND.nextFloat()); bean.setWeight(RAND.nextInt(500)); bean.setId(template.generateId()); assertNull(template.findById(bean.getId())); template.save(bean); assertNotNull(template.findById(bean.getId())); }
@Test public void getDb() { DB db = template.getCollection().getDB(); assertEquals("junit", db.getName()); }