Permalink
Browse files

JAVA-725: Removing use of deprecated methods/constructors, mostly in …

…tests
  • Loading branch information...
1 parent 093a2cb commit 1d2e6faa80aeb5287a26d0348f18f4b51d566759 @jyemin jyemin committed Mar 5, 2013
Showing with 288 additions and 311 deletions.
  1. +1 −0 src/main/com/mongodb/ConnectionStatus.java
  2. +1 −0 src/main/com/mongodb/DBPort.java
  3. +3 −0 src/main/com/mongodb/MongoClient.java
  4. +1 −0 src/main/com/mongodb/MongoURI.java
  5. +8 −5 src/main/com/mongodb/gridfs/CLI.java
  6. +8 −10 src/test/com/mongodb/ByteTest.java
  7. +1 −2 src/test/com/mongodb/DBCollectionTest.java
  8. +4 −6 src/test/com/mongodb/DBCursorTest.java
  9. +9 −16 src/test/com/mongodb/DBObjectTest.java
  10. +2 −0 src/test/com/mongodb/DBPortPoolTest.java
  11. +2 −1 src/test/com/mongodb/DBPortTest.java
  12. +2 −9 src/test/com/mongodb/DBRefTest.java
  13. +64 −35 src/test/com/mongodb/DBTCPConnectorTest.java
  14. +2 −4 src/test/com/mongodb/DBTest.java
  15. +4 −6 src/test/com/mongodb/DBTests.java
  16. +0 −1 src/test/com/mongodb/ErrorTest.java
  17. +26 −16 src/test/com/mongodb/JavaClientTest.java
  18. +17 −17 src/test/com/mongodb/LazyDBObjectTest.java
  19. +1 −0 src/test/com/mongodb/MongoClientTest.java
  20. +2 −0 src/test/com/mongodb/MongoOptionsTest.java
  21. +3 −2 src/test/com/mongodb/MongoTest.java
  22. +1 −0 src/test/com/mongodb/MongoURITest.java
  23. +6 −9 src/test/com/mongodb/ObjectIdTest.java
  24. +1 −1 src/test/com/mongodb/OutMessageTest.java
  25. +5 −4 src/test/com/mongodb/PerformanceTest.java
  26. +1 −5 src/test/com/mongodb/QueryBuilderTest.java
  27. +2 −7 src/test/com/mongodb/ReflectionTest.java
  28. +1 −1 src/test/com/mongodb/ReplPairTest.java
  29. +2 −2 src/test/com/mongodb/ReplSetTest.java
  30. +1 −0 src/test/com/mongodb/ReplicaSetStatusDomainModelTest.java
  31. +20 −18 src/test/com/mongodb/ReplicaSetStatusTest.java
  32. +3 −2 src/test/com/mongodb/SecondaryReadTest.java
  33. +3 −3 src/test/com/mongodb/SingleThreadedMongoPerfTest.java
  34. +0 −50 src/test/com/mongodb/ThreadingTest.java
  35. +8 −5 src/test/com/mongodb/framework/Capped.java
  36. +1 −1 src/test/com/mongodb/framework/Circular.java
  37. +1 −1 src/test/com/mongodb/framework/Count1.java
  38. +10 −5 src/test/com/mongodb/framework/Dbs.java
  39. +6 −4 src/test/com/mongodb/framework/Find.java
  40. +6 −6 src/test/com/mongodb/framework/Find1.java
  41. +5 −6 src/test/com/mongodb/framework/Remove.java
  42. +1 −1 src/test/com/mongodb/framework/Stress1.java
  43. +6 −6 src/test/com/mongodb/framework/Test1.java
  44. +14 −30 src/test/com/mongodb/gridfs/GridFSTest.java
  45. +0 −6 src/test/com/mongodb/tools/ConnectionPoolStatTest.java
  46. +18 −3 src/test/com/mongodb/util/TestCase.java
  47. +5 −5 src/test/com/mongodb/util/TestNGListener.java
@@ -41,6 +41,7 @@
protected static int updaterIntervalMS;
protected static int updaterIntervalNoMasterMS;
+ @SuppressWarnings("deprecation")
protected static final MongoOptions mongoOptionsDefaults = new MongoOptions();
protected static final float latencySmoothFactor;
protected static final DBObject isMasterCmd = new BasicDBObject("ismaster", 1);
@@ -67,6 +67,7 @@
* creates a new DBPort
* @param addr the server address
*/
+ @SuppressWarnings("deprecation")
public DBPort( ServerAddress addr ){
this( addr , null , new MongoOptions() );
}
@@ -163,6 +163,7 @@ public MongoClient(ServerAddress addr, MongoClientOptions options) {
* @see com.mongodb.ServerAddress
* @since 2.11.0
*/
+ @SuppressWarnings("deprecation")
public MongoClient(ServerAddress addr, List<MongoCredential> credentialsList, MongoClientOptions options) {
super(MongoAuthority.direct(addr, new MongoCredentialsStore(credentialsList)), new MongoOptions(options));
this.options = options;
@@ -247,6 +248,7 @@ public MongoClient(List<ServerAddress> seeds, MongoClientOptions options) {
* @see com.mongodb.ServerAddress
* @since 2.11.0
*/
+ @SuppressWarnings("deprecation")
public MongoClient(List<ServerAddress> seeds, List<MongoCredential> credentialsList, MongoClientOptions options) {
super(MongoAuthority.dynamicSet(seeds, new MongoCredentialsStore(credentialsList)), new MongoOptions(options));
this.options = options;
@@ -262,6 +264,7 @@ public MongoClient(List<ServerAddress> seeds, List<MongoCredential> credentialsL
* @see MongoURI
* @dochub connections
*/
+ @SuppressWarnings("deprecation")
public MongoClient(MongoClientURI uri) throws UnknownHostException {
super(new MongoURI(uri));
this.options = uri.getOptions();
@@ -215,6 +215,7 @@ public MongoOptions getOptions(){
* @throws MongoException
* @throws UnknownHostException
*/
+ @SuppressWarnings("deprecation")
public Mongo connect()
throws UnknownHostException {
// TODO caching?
@@ -18,14 +18,15 @@
package com.mongodb.gridfs;
-import java.io.File;
-import java.security.DigestInputStream;
-import java.security.MessageDigest;
-
import com.mongodb.DBObject;
import com.mongodb.Mongo;
+import com.mongodb.MongoClient;
import com.mongodb.util.Util;
+import java.io.File;
+import java.security.DigestInputStream;
+import java.security.MessageDigest;
+
/**
* a simple CLI for Gridfs
@@ -48,10 +49,12 @@ private static void printUsage() {
private static String db = "test";
private static Mongo _mongo = null;
+
+ @SuppressWarnings("deprecation")
private static Mongo getMongo()
throws Exception {
if ( _mongo == null )
- _mongo = new Mongo( host );
+ _mongo = new MongoClient( host );
return _mongo;
}
@@ -16,6 +16,14 @@
package com.mongodb;
+import com.mongodb.util.TestCase;
+import org.bson.BSON;
+import org.bson.BSONDecoder;
+import org.bson.BSONObject;
+import org.bson.BasicBSONDecoder;
+import org.bson.types.ObjectId;
+import org.testng.annotations.Test;
+
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
@@ -28,22 +36,12 @@
import java.util.Set;
import java.util.regex.Pattern;
-import org.bson.BSON;
-import org.bson.BSONDecoder;
-import org.bson.BSONObject;
-import org.bson.BasicBSONDecoder;
-import org.bson.types.ObjectId;
-import org.testng.annotations.Test;
-
-import com.mongodb.util.TestCase;
-
@SuppressWarnings({"unchecked", "rawtypes"})
public class ByteTest extends TestCase {
public ByteTest() throws IOException , MongoException {
super();
- cleanupMongo = new Mongo( "127.0.0.1" );
cleanupDB = "com_mongodb_unittest_ByteTest";
_db = cleanupMongo.getDB( cleanupDB );
}
@@ -30,7 +30,6 @@
public DBCollectionTest()
throws IOException , MongoException {
super();
- cleanupMongo = new Mongo( "127.0.0.1" );
cleanupDB = "com_mongodb_unittest_DBCollectionTest";
_db = cleanupMongo.getDB( cleanupDB );
}
@@ -166,7 +165,7 @@ public void testFindOneSort(){
*/
@Test
public void testDropDatabase() throws Exception {
- final Mongo mongo = new Mongo( "127.0.0.1" );
+ final Mongo mongo = new MongoClient( "127.0.0.1" );
mongo.getDB("com_mongodb_unittest_dropDatabaseTest").dropDatabase();
mongo.close();
}
@@ -35,9 +35,8 @@
public DBCursorTest() throws IOException , MongoException {
super();
- cleanupMongo = new Mongo( "127.0.0.1" );
- cleanupDB = "com_mongodb_unittest_DBCursorTest";
- _db = cleanupMongo.getDB( cleanupDB );
+ cleanupDB = "com_mongodb_unittest_DBCursorTest";
+ _db = cleanupMongo.getDB(cleanupDB);
}
@Test(groups = {"basic"})
@@ -502,9 +501,8 @@ public void testHasFinalizer() throws UnknownHostException {
cursor.close();
// finally, no finalizer if disabled in mongo options
- MongoOptions mongoOptions = new MongoOptions();
- mongoOptions.cursorFinalizerEnabled = false;
- Mongo m = new Mongo("127.0.0.1", mongoOptions);
+ MongoClientOptions mongoOptions = new MongoClientOptions.Builder().cursorFinalizerEnabled(false).build();
+ Mongo m = new MongoClient("127.0.0.1", mongoOptions);
try {
c = m.getDB(cleanupDB).getCollection("HasFinalizerTest");
cursor = c.find();
@@ -16,30 +16,23 @@
package com.mongodb;
-import java.net.*;
-import java.util.*;
-
-
+import com.mongodb.util.TestCase;
+import org.bson.types.BasicBSONList;
+import org.bson.types.ObjectId;
import org.testng.annotations.Test;
-import com.mongodb.util.*;
-
-import org.bson.*;
-import org.bson.types.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
@SuppressWarnings({"unchecked", "deprecation"})
public class DBObjectTest extends TestCase {
public DBObjectTest() {
super();
- try {
- cleanupMongo = new Mongo( "127.0.0.1" );
- cleanupDB = "com_monogodb_unittest_DBObjectTest";
- _db = cleanupMongo.getDB( cleanupDB );
- }
- catch(UnknownHostException e) {
- throw new MongoException("couldn't connect");
- }
+ cleanupDB = "com_monogodb_unittest_DBObjectTest";
+ _db = cleanupMongo.getDB(cleanupDB);
}
@Test(groups = {"basic"})
@@ -33,6 +33,7 @@
public class DBPortPoolTest extends com.mongodb.util.TestCase {
@Test
+ @SuppressWarnings("deprecation")
public void testReuse() throws Exception {
MongoOptions options = new MongoOptions();
options.connectionsPerHost = 10;
@@ -85,6 +86,7 @@ public void run(){
}
@Test
+ @SuppressWarnings("deprecation")
public void testInterruptedException() throws UnknownHostException, InterruptedException {
MongoOptions options = new MongoOptions();
options.connectionsPerHost = 1;
@@ -26,8 +26,9 @@
public class DBPortTest extends TestCase {
@Test
+ @SuppressWarnings("deprecation")
public void testAuthentication() throws IOException {
- Mongo m = new Mongo();
+ Mongo m = new MongoClient();
DB db1 = m.getDB("DBPortTest1");
DB db2 = m.getDB("DBPortTest2");
db1.dropDatabase();
@@ -24,21 +24,14 @@
import org.bson.types.ObjectId;
import org.testng.annotations.Test;
-import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.List;
public class DBRefTest extends TestCase {
public DBRefTest() {
- try {
- cleanupMongo = new Mongo( "127.0.0.1" );
- cleanupDB = "com_monogodb_unittest_DBRefTest";
- _db = cleanupMongo.getDB( cleanupDB );
- }
- catch(UnknownHostException e) {
- throw new MongoException("couldn't connect");
- }
+ cleanupDB = "com_monogodb_unittest_DBRefTest";
+ _db = cleanupMongo.getDB(cleanupDB);
}
@Test(groups = {"basic"})
Oops, something went wrong.

0 comments on commit 1d2e6fa

Please sign in to comment.