try {
// createDatabase();
byte[] content = copyToBytesFromClasspath(TEST_ATTACHMENT_HTML);
logger.debug("Content in bytes: {}", content.length);
GridFS gridFS = new GridFS(mongoDB);
GridFSInputFile in = gridFS.createFile(content);
in.setFilename("test-attachment.html");
in.setContentType("text/html");
BasicDBObject metadata = new BasicDBObject();
metadata.put("attribut1", "value1");
metadata.put("attribut2", "value2");
in.put("metadata", metadata);
in.save();
in.validate();
String id = in.getId().toString();
logger.debug("GridFS in: {}", in);
logger.debug("Document created with id: {}", id);
GridFSDBFile out = gridFS.findOne(in.getFilename());
logger.debug("GridFS from findOne: {}", out);
out = gridFS.findOne(new ObjectId(id));
logger.debug("GridFS from findOne: {}", out);
Assert.assertEquals(out.getId(), in.getId());
Thread.sleep(wait);
refreshIndex();
CountResponse countResponse = getNode().client().count(countRequest(getIndex())).actionGet();