All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.elepy.mongo.InMemoryClientFactory Maven / Gradle / Ivy

There is a newer version: 3.0.0-alpha-29
Show newest version
package com.elepy.mongo;

import com.mongodb.MongoClient;
import com.mongodb.ServerAddress;
import de.bwaldvogel.mongo.MongoServer;
import de.bwaldvogel.mongo.backend.memory.MemoryBackend;

import java.net.InetSocketAddress;

public class InMemoryClientFactory {

    private InMemoryClientFactory() {
    }


    public static MongoClient createInMemoryClient() {
        MongoServer mongoServer = new MongoServer(new MemoryBackend());

        InetSocketAddress serverAddress = mongoServer.bind();
        return new MongoClient(new ServerAddress(serverAddress));

    }
} 




© 2015 - 2024 Weber Informatics LLC | Privacy Policy