use of de.flapdoodle.embed.mongo.config.MongodConfigBuilder in project vertx-auth by vert-x3.
the class MongoBaseTest method startMongo.
@BeforeClass
public static void startMongo() throws Exception {
if (getConnectionString() == null) {
IMongodConfig config = new MongodConfigBuilder().version(Version.Main.PRODUCTION).net(new Net(27018, Network.localhostIsIPv6())).build();
exe = MongodStarter.getDefaultInstance().prepare(config);
exe.start();
}
}
use of de.flapdoodle.embed.mongo.config.MongodConfigBuilder in project beam by apache.
the class MongoDbReadWriteIT method setUp.
@BeforeClass
public static void setUp() throws Exception {
int port = NetworkTestHelper.getAvailableLocalPort();
LOG.info("Starting MongoDB embedded instance on {}", port);
IMongodConfig mongodConfig = new MongodConfigBuilder().version(Version.Main.PRODUCTION).configServer(false).replication(new Storage(MONGODB_LOCATION.getRoot().getPath(), null, 0)).net(new Net(hostname, port, Network.localhostIsIPv6())).cmdOptions(new MongoCmdOptionsBuilder().syncDelay(10).useNoPrealloc(true).useSmallFiles(true).useNoJournal(true).verbose(false).build()).build();
mongodExecutable = mongodStarter.prepare(mongodConfig);
mongodProcess = mongodExecutable.start();
client = new MongoClient(hostname, port);
mongoSqlUrl = String.format("mongodb://%s:%d/%s/%s", hostname, port, database, collection);
}
use of de.flapdoodle.embed.mongo.config.MongodConfigBuilder in project beam by apache.
the class MongoDBGridFSIOTest method start.
@BeforeClass
public static void start() throws Exception {
port = NetworkTestHelper.getAvailableLocalPort();
LOG.info("Starting MongoDB embedded instance on {}", port);
IMongodConfig mongodConfig = new MongodConfigBuilder().version(Version.Main.PRODUCTION).configServer(false).replication(new Storage(MONGODB_LOCATION.getRoot().getPath(), null, 0)).net(new Net("localhost", port, Network.localhostIsIPv6())).cmdOptions(new MongoCmdOptionsBuilder().syncDelay(10).useNoPrealloc(true).useSmallFiles(true).useNoJournal(true).verbose(false).build()).build();
mongodExecutable = mongodStarter.prepare(mongodConfig);
mongodProcess = mongodExecutable.start();
LOG.info("Insert test data");
MongoClient client = new MongoClient("localhost", port);
DB database = client.getDB(DATABASE);
GridFS gridfs = new GridFS(database);
ByteArrayOutputStream out = new ByteArrayOutputStream();
for (int x = 0; x < 100; x++) {
out.write(("Einstein\nDarwin\nCopernicus\nPasteur\n" + "Curie\nFaraday\nNewton\nBohr\nGalilei\nMaxwell\n").getBytes(StandardCharsets.UTF_8));
}
for (int x = 0; x < 5; x++) {
gridfs.createFile(new ByteArrayInputStream(out.toByteArray()), "file" + x).save();
}
gridfs = new GridFS(database, "mapBucket");
long now = System.currentTimeMillis();
Random random = new Random();
String[] scientists = { "Einstein", "Darwin", "Copernicus", "Pasteur", "Curie", "Faraday", "Newton", "Bohr", "Galilei", "Maxwell" };
for (int x = 0; x < 10; x++) {
GridFSInputFile file = gridfs.createFile("file_" + x);
OutputStream outf = file.getOutputStream();
OutputStreamWriter writer = new OutputStreamWriter(outf, StandardCharsets.UTF_8);
for (int y = 0; y < 5000; y++) {
long time = now - random.nextInt(3600000);
String name = scientists[y % scientists.length];
writer.write(time + "\t");
writer.write(name + "\t");
writer.write(Integer.toString(random.nextInt(100)));
writer.write("\n");
}
for (int y = 0; y < scientists.length; y++) {
String name = scientists[y % scientists.length];
writer.write(now + "\t");
writer.write(name + "\t");
writer.write("101");
writer.write("\n");
}
writer.flush();
writer.close();
}
client.close();
}
use of de.flapdoodle.embed.mongo.config.MongodConfigBuilder in project beam by apache.
the class MongoDbIOTest method beforeClass.
@BeforeClass
public static void beforeClass() throws Exception {
port = NetworkTestHelper.getAvailableLocalPort();
LOG.info("Starting MongoDB embedded instance on {}", port);
IMongodConfig mongodConfig = new MongodConfigBuilder().version(Version.Main.PRODUCTION).configServer(false).replication(new Storage(MONGODB_LOCATION.getRoot().getPath(), null, 0)).net(new Net("localhost", port, Network.localhostIsIPv6())).cmdOptions(new MongoCmdOptionsBuilder().syncDelay(10).useNoPrealloc(true).useSmallFiles(true).useNoJournal(true).verbose(false).build()).build();
mongodExecutable = mongodStarter.prepare(mongodConfig);
mongodProcess = mongodExecutable.start();
client = new MongoClient("localhost", port);
LOG.info("Insert test data");
List<Document> documents = createDocuments(1000, false);
MongoCollection<Document> collection = getCollection(COLLECTION);
collection.insertMany(documents);
}
Aggregations