Package com.mongodb

Examples of com.mongodb.Mongo$CursorCleanerThread


        properties = new Properties();
        InputStream is = MongoDbConversionsTest.class.getResourceAsStream("/mongodb.test.properties");
        properties.load(is);
        // ping Mongo and populate db and collection
        try {
            mongo = new Mongo(new MongoURI(properties.getProperty("mongodb.connectionURI")));
            mongo.getDatabaseNames();
            dbName = properties.getProperty("mongodb.testDb");
            db = mongo.getDB(dbName);
        } catch (Exception e) {
            Assume.assumeNoException(e);
View Full Code Here


    /**
     * Should access a singleton of type Mongo
     */
    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
        Mongo db = CamelContextHelper.mandatoryLookup(getCamelContext(), remaining, Mongo.class);

        Endpoint endpoint = new MongoDbEndpoint(uri, this);
        parameters.put("mongoConnection", db);
        setProperties(endpoint, parameters);
       
View Full Code Here

    public static UpdateableDataContext createMongoDbDataContext(String hostname, Integer port, String databaseName,
            String username, char[] password, SimpleTableDef[] tableDefs) {
        try {
            DB mongoDb;
            if (port == null) {
                mongoDb = new Mongo(hostname).getDB(databaseName);
            } else {
                mongoDb = new Mongo(hostname, port).getDB(databaseName);
            }
            if (username != null) {
                mongoDb.authenticate(username, password);
            }
View Full Code Here

                NucleusLogger.CONNECTION.debug(LOCALISER.msg("MongoDB.ServerConnect", dbName, serverAddrs.size(),
                    StringUtils.collectionToString(serverAddrs)));
            }
            if (serverAddrs.size() == 1)
            {
                mongo = new Mongo(serverAddrs.get(0));
            }
            else
            {
                mongo = new Mongo(serverAddrs);
            }
        }
        catch (UnknownHostException e)
        {
            throw new NucleusDataStoreException("Unable to connect to mongodb", e);
View Full Code Here

        properties = new Properties();
        InputStream is = MongoDbConversionsTest.class.getResourceAsStream("/mongodb.test.properties");
        properties.load(is);
        // ping Mongo and populate db and collection
        try {
            mongo = new Mongo(new MongoURI(properties.getProperty("mongodb.connectionURI")));
            mongo.getDatabaseNames();
            dbName = properties.getProperty("mongodb.testDb");
            db = mongo.getDB(dbName);
        } catch (Exception e) {
            Assume.assumeNoException(e);
View Full Code Here

    }

    public static Operation putDatabaseDetails(Operation op, DB db) {
        op.put("dbName", db.getName());

        Mongo mongo = db.getMongo();
        ServerAddress address = mongo.getAddress();
        op.put("host", address.getHost());
        op.put("port", address.getPort());
        return op;
    }
View Full Code Here

        assertEquals(MongoDBCollectionExternalResourceAnalyzer.TYPE, op.getType());
        assertEquals("my_super_collection.hello", op.get("collection"));
    }

    private DBCollection getMeACollection() {
        Mongo mongo = mock(Mongo.class);
        DB db = new DBDummy(mongo, "my_super_collection");

        DBCollection col = new DBCollectionDummy(db, "hello");
        return col;
    }
View Full Code Here

    @SuppressWarnings("boxing")
    @Test
    public void testDbCommandWithHost() throws Exception {
        final String HOST = "7.3.6.5";
        final int PORT = 27017;
        Mongo mongo = mock(Mongo.class);
        ServerAddress address = mock(ServerAddress.class);
        when(address.getHost()).thenReturn(HOST);
        when(address.getPort()).thenReturn(PORT);
        when(mongo.getAddress()).thenReturn(address);

        Operation op = assertCommandOperation(new DBDummy(mongo, "testDbCommandWithHost"));
        assertEquals("Mismatched host", HOST, op.get("host", String.class));
        assertEquals("Mismatched port", 27017, op.getInt("port", (-1)));
    }
View Full Code Here

        assertEquals("Mismatched port", 27017, op.getInt("port", (-1)));
    }

    @Test
    public void testDbCommandNoHost() throws Exception {
        Mongo mongo = mock(Mongo.class);
        Operation op = assertCommandOperation(new DBDummy(mongo, "testDbCommandNoHost"));

        for (String key : new String[]{"host", "port"}) {
            assertNullValue("Unexpected value for " + key, op.get(key));
        }
View Full Code Here

     * @param port The port.
     * @param database The database name.
     * @throws Exception If an error occurred while trying to connect.
     */
    public MongoConnection(String host, int port, String database) throws Exception {
        db = new Mongo(host, port).getDB(database);
        gridFS = new GridFS(db);
    }
View Full Code Here

TOP

Related Classes of com.mongodb.Mongo$CursorCleanerThread

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.