Package test.feed

Source Code of test.feed.TestMongoDB2

package test.feed;

import org.junit.BeforeClass;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.Mongo;

public class TestMongoDB2 {

  private static Mongo mongo;

  @BeforeClass
  public static void init() {
    ApplicationContext ctx = new ClassPathXmlApplicationContext("config/context/applicationContext.xml");
    mongo = (Mongo) ctx.getBean("mongo");
  }
 
  @Test
  public void test(){
   
   
     DB testDB=mongo.getDB("skyline");
     testDB.authenticate("skyline", "skyline".toCharArray());
     long beginTime=System.currentTimeMillis();
     @SuppressWarnings("unused")
     DBCollection collection=testDB.getCollection("skyline")
     long endTime=System.currentTimeMillis();
     collection.toString();
     System.out.println(endTime-beginTime);
   
  }
}
TOP

Related Classes of test.feed.TestMongoDB2

TOP
Copyright © 2018 www.massapi.com. 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.