Java Code Examples for de.bwaldvogel.mongo.MongoServer#bind()
The following examples show how to use
de.bwaldvogel.mongo.MongoServer#bind() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Main.java From elepy with Apache License 2.0 | 6 votes |
public static void main(String[] args) { MongoServer mongoServer = new MongoServer(new MemoryBackend()); InetSocketAddress serverAddress = mongoServer.bind(); MongoClient client = new MongoClient(new ServerAddress(serverAddress)); final var elepyInstance = new Elepy() .addConfiguration(MongoConfiguration.of(client, "example", "bucket")) .withPort(7331) .addModelPackage("com.elepy.tests.devfrontend") .addExtension((http, elepy) -> { http.before(context -> { context.response().header("Access-Control-Allow-Headers", "*"); context.request().addPermissions(Permissions.SUPER_USER); }); }) .addExtension(new FrontendLoader()); elepyInstance.start(); }
Example 2
Source File: MongoContext.java From immutables with Apache License 2.0 | 6 votes |
public static MongoContext create() { final String uri = System.getProperty("mongo"); final Closer closer = Closer.create(); if (uri != null) { // remote mongo server return new MongoContext(new MongoClient(new MongoClientURI(uri)), closer); } final MongoServer server = new MongoServer(new MemoryBackend()); closer.register(new Closeable() { @Override public void close() throws IOException { server.shutdownNow(); } }); final MongoClient client = new MongoClient(new ServerAddress(server.bind())); final MongoContext context = new MongoContext(client, closer); return context; }
Example 3
Source File: MongoInstance.java From immutables with Apache License 2.0 | 6 votes |
static MongoInstance create() { final String uri = System.getProperty("mongo"); if (uri != null) { // connect to remote mongo server return new MongoInstance(MongoClients.create(uri)); } final MongoServer server = new MongoServer(new MemoryBackend()); final InetSocketAddress address = server.bind(); final Closer closer = Closer.create(); closer.register(server::shutdownNow); final MongoClient client = MongoClients.create(String.format("mongodb://127.0.0.1:%d", address.getPort())); return new MongoInstance(client, closer); }
Example 4
Source File: FakeMongoConfiguration.java From hesperides with GNU General Public License v3.0 | 5 votes |
@Bean(destroyMethod = "close") public MongoClient mongoClient() { MemoryBackend backend = new MemoryBackend(); MongoServer server = new MongoServer(backend); // bind on a random local port InetSocketAddress serverAddress = server.bind(); return new MongoClient(new ServerAddress(serverAddress)); }
Example 5
Source File: RepositoryTestsConfiguration.java From microcks with Apache License 2.0 | 5 votes |
@Override public MongoClient mongoClient() { // Replacing fongo by mongo-java-server, according to // https://github.com/fakemongo/fongo/issues/337 //return new Fongo("mongo-test").getMongo(); // Create a server and bind on a random local port server = new MongoServer(new MemoryBackend()); InetSocketAddress serverAddress = server.bind(); //client = new MongoClient(new ServerAddress(serverAddress)); client = MongoClients.create("mongodb://localhost:" + serverAddress.getPort()); return client; }
Example 6
Source File: InMemoryClientFactory.java From elepy with Apache License 2.0 | 3 votes |
public static MongoClient createInMemoryClient() { MongoServer mongoServer = new MongoServer(new MemoryBackend()); InetSocketAddress serverAddress = mongoServer.bind(); return new MongoClient(new ServerAddress(serverAddress)); }
Example 7
Source File: MongoFunctionalityTest.java From elepy with Apache License 2.0 | 3 votes |
@Override public void configureElepy(Elepy elepy) { mongoServer = new MongoServer(new MemoryBackend()); InetSocketAddress serverAddress = mongoServer.bind(); MongoClient client = new MongoClient(new ServerAddress(serverAddress)); elepy.addConfiguration(MongoConfiguration.of(client, "test", "bucket")); }
Example 8
Source File: MongoFileServiceTest.java From elepy with Apache License 2.0 | 3 votes |
@BeforeAll public void setUp() { mongoServer = new MongoServer(new MemoryBackend()); InetSocketAddress serverAddress = mongoServer.bind(); client = new MongoClient(new ServerAddress(serverAddress)); super.setUp(); }
Example 9
Source File: BaseFongo.java From elepy with Apache License 2.0 | 3 votes |
public void setUp() throws Exception { mongoServer = new MongoServer(new MemoryBackend()); InetSocketAddress serverAddress = mongoServer.bind(); client = new MongoClient(new ServerAddress(serverAddress)); }
Example 10
Source File: MongoSystemTest.java From elepy with Apache License 2.0 | 3 votes |
@Override public void configureElepy(Elepy elepy) { mongoServer = new MongoServer(new MemoryBackend()); InetSocketAddress serverAddress = mongoServer.bind(); MongoClient client = new MongoClient(new ServerAddress(serverAddress)); elepy.addConfiguration(MongoConfiguration.of(client, "test", "bucket")); }
Example 11
Source File: MongoStack.java From elepy with Apache License 2.0 | 3 votes |
@Override public void configureElepy(Elepy elepy) { mongoServer = new MongoServer(new MemoryBackend()); InetSocketAddress serverAddress = mongoServer.bind(); MongoClient client = new MongoClient(new ServerAddress(serverAddress)); elepy.addConfiguration(MongoConfiguration.of(client, "test", "bucket")); }