Package com.impetus.client.mongodb

Examples of com.impetus.client.mongodb.MongoDBClient


     *
     */
    private void getDB()
    {
        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        MongoDBClient client = (MongoDBClient) clients.get(persistenceUnit);
        if (client != null)
        {
            try
            {
                Field mongodb = client.getClass().getDeclaredField("mongoDb");
                if (!mongodb.isAccessible())
                {
                    mongodb.setAccessible(true);
                }
                db = (DB) mongodb.get(client);
View Full Code Here


     */
    public static void dropDatabase(EntityManagerFactory emf, String pu)
    {
        EntityManager em = null;
        Map<String, Client> clients = null;
        MongoDBClient client = null;
        if (emf != null)
            em = emf.createEntityManager();

        if (em != null)
            clients = (Map<String, Client>) em.getDelegate();
        if (clients != null)
            client = (MongoDBClient) clients.get(pu);
        if (client != null)
        {
            try
            {
                Field db = client.getClass().getDeclaredField("mongoDb");
                if (!db.isAccessible())
                {
                    db.setAccessible(true);
                }
                DB mongoDB = (DB) db.get(client);
View Full Code Here

    @Test
    public void executeTest()
    {
        // Get properties from client
        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        MongoDBClient client = (MongoDBClient) clients.get(persistenceUnit);

        // Check default values
        WriteConcern wc = client.getWriteConcern();
        DBEncoder encoder = client.getEncoder();
        Assert.assertNotNull(wc);
        Assert.assertFalse(wc.getFsync());
        Assert.assertEquals(0, wc.getW());
        Assert.assertEquals(0, wc.getWtimeout());
        Assert.assertNotNull(encoder);
        Assert.assertTrue(encoder instanceof DefaultDBEncoder);
       
        // Set parameters into EM
        // (See http://api.mongodb.org/java/2.6/com/mongodb/WriteConcern.html)
        WriteConcern wcNew = new WriteConcern(1, 300, true);
        DBEncoder encoderNew = new LazyDBEncoder();
        em.setProperty(MongoDBClientProperties.WRITE_CONCERN, wcNew);
        em.setProperty(MongoDBClientProperties.BATCH_SIZE, 5);
      

        // Check Modified values
        WriteConcern wcModified = client.getWriteConcern();
        DBEncoder encoderModified = client.getEncoder();
        Assert.assertNotNull(wcModified);
        Assert.assertTrue(wcModified.getFsync());
        Assert.assertEquals(1, wcModified.getW());
        Assert.assertEquals(300, wcModified.getWtimeout());
        Assert.assertNotNull(encoderModified);
        Assert.assertEquals(5, client.getBatchSize());
        // Assert.assertTrue(encoderModified instanceof LazyDBEncoder);
        em.clear();
       
        em.setProperty(MongoDBClientProperties.BATCH_SIZE,""+ 2);
        Assert.assertEquals(2, client.getBatchSize());
       
        em.clear();
        // Write Entity to database
        PersonMongo person = new PersonMongo();
        person.setPersonId("1");
View Full Code Here

    private void truncateMongo()
    {
        EntityManager em = emf.createEntityManager();

        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        MongoDBClient client = (MongoDBClient) clients.get("mongoTest");
        if (client != null)
        {
            try
            {
                Field db = client.getClass().getDeclaredField("mongoDb");
                if (!db.isAccessible())
                {
                    db.setAccessible(true);
                }
                DB mongoDB = (DB) db.get(client);
View Full Code Here

    private void truncateMongo()
    {
        EntityManager em = emf.createEntityManager();

        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        MongoDBClient client = (MongoDBClient) clients.get("mongoTest");
        if (client != null)
        {
            try
            {
                Field db = client.getClass().getDeclaredField("mongoDb");
                if (!db.isAccessible())
                {
                    db.setAccessible(true);
                }
                DB mongoDB = (DB) db.get(client);
View Full Code Here

     *
     */
    private void truncateMongo()
    {
        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        MongoDBClient client = (MongoDBClient) clients.get("addMongo");
        if (client != null)
        {
            try
            {
                Field db = client.getClass().getDeclaredField("mongoDb");
                if (!db.isAccessible())
                {
                    db.setAccessible(true);
                }
                DB mongoDB = (DB) db.get(client);
View Full Code Here

     *
     */
    protected void truncateMongo(EntityManager em, final String persistenceUnit, final String tableName)
    {
        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        MongoDBClient client = (MongoDBClient) clients.get(persistenceUnit);
        if (client != null)
        {
            try
            {
                Field db = client.getClass().getDeclaredField("mongoDb");
                if (!db.isAccessible())
                {
                    db.setAccessible(true);
                }
                DB mongoDB = (DB) db.get(client);
View Full Code Here

     *
     */
    private void getDB()
    {
        Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
        MongoDBClient client = (MongoDBClient) clients.get(persistenceUnit);
        if (client != null)
        {
            try
            {
                Field mongodb = client.getClass().getDeclaredField("mongoDb");
                if (!mongodb.isAccessible())
                {
                    mongodb.setAccessible(true);
                }
                db = (DB) mongodb.get(client);
View Full Code Here

TOP

Related Classes of com.impetus.client.mongodb.MongoDBClient

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.