Skip to content

Commit 1c07f87

Browse files
committed
[breaking] deps - upgraded mongo java driver to 3.4.0 and bson4jackson to 2.7.0 to follow jongo 1.3.0 upgrade
1 parent 38447ac commit 1c07f87

File tree

4 files changed

+68
-80
lines changed

4 files changed

+68
-80
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@
8282
<el.api.version>2.2</el.api.version>
8383

8484
<!-- Mongo modules -->
85-
<mongo-java-driver.version>2.11.3</mongo-java-driver.version>
86-
<bson4jackson.version>2.3.1</bson4jackson.version>
85+
<mongo-java-driver.version>3.4.0</mongo-java-driver.version>
86+
<bson4jackson.version>2.7.0</bson4jackson.version>
8787
<jongo.version>1.3.0</jongo.version>
8888
<de.flapdoodle.embed.version>1.42</de.flapdoodle.embed.version>
8989

restx-jongo-specs-tests/src/main/java/restx/jongo/specs/tests/GivenJongoCollectionRunner.java

Lines changed: 63 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -38,83 +38,75 @@ public Class<GivenJongoCollection> getGivenClass() {
3838
}
3939

4040
public GivenCleaner run(final GivenJongoCollection given, final ImmutableMap<String, String> params) {
41+
MongoClientURI mongoClientURI = new MongoClientURI(
42+
checkNotNull(params.get(DB_URI),
43+
DB_URI + " param is required"));
44+
Jongo jongo = new Jongo(new MongoClient(mongoClientURI).getDB(mongoClientURI.getDatabase()));
4145
try {
42-
MongoClientURI mongoClientURI = new MongoClientURI(
43-
checkNotNull(params.get(DB_URI),
44-
DB_URI + " param is required"));
45-
Jongo jongo = new Jongo(new MongoClient(mongoClientURI).getDB(mongoClientURI.getDatabase()));
46-
try {
47-
Stopwatch stopwatch = Stopwatch.createStarted();
48-
MongoCollection collection = jongo.getCollection(given.getCollection());
49-
Iterable<String> items = Splitter.on("\n").trimResults().omitEmptyStrings().split(given.getData());
50-
int count = 0;
51-
for (String item : items) {
52-
collection.insert(item);
53-
count++;
54-
}
55-
System.out.printf("imported %s[%d] -- %s%n", given.getCollection(), count, stopwatch.stop().toString());
56-
} finally {
57-
jongo.getDatabase().getMongo().close();
46+
Stopwatch stopwatch = Stopwatch.createStarted();
47+
MongoCollection collection = jongo.getCollection(given.getCollection());
48+
Iterable<String> items = Splitter.on("\n").trimResults().omitEmptyStrings().split(given.getData());
49+
int count = 0;
50+
for (String item : items) {
51+
collection.insert(item);
52+
count++;
5853
}
54+
System.out.printf("imported %s[%d] -- %s%n", given.getCollection(), count, stopwatch.stop().toString());
55+
} finally {
56+
jongo.getDatabase().getMongo().close();
57+
}
5958

60-
final UnmodifiableIterator<String> it = given.getSequence().iterator();
61-
final CollectionSequence iteratingSequence = new CollectionSequence() {
62-
@Override
63-
public Optional<String> next() {
64-
return it.hasNext() ? Optional.of(it.next()) : Optional.<String>absent();
65-
}
66-
};
67-
68-
final SingleNameFactoryMachine<ComponentCustomizerEngine> customizerMachine =
69-
new SingleNameFactoryMachine<>(0, new StdMachineEngine<ComponentCustomizerEngine>(
70-
Name.of(ComponentCustomizerEngine.class, "JongoCollectionSequenceSupplierOf"
71-
+ given.getCollection()),
72-
BoundlessComponentBox.FACTORY) {
73-
@Override
74-
public BillOfMaterials getBillOfMaterial() {
75-
return BillOfMaterials.of();
76-
}
77-
78-
@Override
79-
protected ComponentCustomizerEngine doNewComponent(final SatisfiedBOM satisfiedBOM) {
80-
return new SingleComponentNameCustomizerEngine<JongoCollection>(
81-
0, Name.of(JongoCollection.class, given.getCollection())) {
82-
@Override
83-
public NamedComponent<JongoCollection> customize(NamedComponent<JongoCollection> namedComponent) {
84-
if (namedComponent.getName().getName().equals(given.getCollection())) {
85-
return new NamedComponent<>(namedComponent.getName(),
86-
new SequencedJongoCollection(namedComponent.getComponent(),iteratingSequence));
87-
} else {
88-
return namedComponent;
89-
}
59+
final UnmodifiableIterator<String> it = given.getSequence().iterator();
60+
final CollectionSequence iteratingSequence = new CollectionSequence() {
61+
@Override
62+
public Optional<String> next() {
63+
return it.hasNext() ? Optional.of(it.next()) : Optional.<String>absent();
64+
}
65+
};
66+
67+
final SingleNameFactoryMachine<ComponentCustomizerEngine> customizerMachine =
68+
new SingleNameFactoryMachine<>(0, new StdMachineEngine<ComponentCustomizerEngine>(
69+
Name.of(ComponentCustomizerEngine.class, "JongoCollectionSequenceSupplierOf"
70+
+ given.getCollection()),
71+
BoundlessComponentBox.FACTORY) {
72+
@Override
73+
public BillOfMaterials getBillOfMaterial() {
74+
return BillOfMaterials.of();
75+
}
9076

77+
@Override
78+
protected ComponentCustomizerEngine doNewComponent(final SatisfiedBOM satisfiedBOM) {
79+
return new SingleComponentNameCustomizerEngine<JongoCollection>(
80+
0, Name.of(JongoCollection.class, given.getCollection())) {
81+
@Override
82+
public NamedComponent<JongoCollection> customize(NamedComponent<JongoCollection> namedComponent) {
83+
if (namedComponent.getName().getName().equals(given.getCollection())) {
84+
return new NamedComponent<>(namedComponent.getName(),
85+
new SequencedJongoCollection(namedComponent.getComponent(),iteratingSequence));
86+
} else {
87+
return namedComponent;
9188
}
92-
};
93-
}
94-
});
95-
final Factory.LocalMachines localMachines = threadLocal();
96-
localMachines.addMachine(customizerMachine);
97-
98-
return new GivenCleaner() {
99-
@Override
100-
public void cleanUp() {
101-
try {
102-
localMachines.removeMachine(customizerMachine);
103-
MongoClientURI mongoClientURI = new MongoClientURI(
104-
checkNotNull(params.get(DB_URI),
105-
DB_URI + " param is required"));
106-
Jongo jongo = new Jongo(new MongoClient(mongoClientURI).getDB(mongoClientURI.getDatabase()));
107-
Stopwatch stopwatch = Stopwatch.createStarted();
108-
jongo.getCollection(given.getCollection()).drop();
109-
System.out.printf("dropped %s -- %s%n", given.getCollection(), stopwatch.stop().toString());
110-
} catch (UnknownHostException e) {
111-
throw new RuntimeException(e);
89+
11290
}
113-
}
114-
};
115-
} catch (UnknownHostException e) {
116-
throw new RuntimeException(e);
117-
}
91+
};
92+
}
93+
});
94+
final Factory.LocalMachines localMachines = threadLocal();
95+
localMachines.addMachine(customizerMachine);
96+
97+
return new GivenCleaner() {
98+
@Override
99+
public void cleanUp() {
100+
localMachines.removeMachine(customizerMachine);
101+
MongoClientURI mongoClientURI = new MongoClientURI(
102+
checkNotNull(params.get(DB_URI),
103+
DB_URI + " param is required"));
104+
Jongo jongo = new Jongo(new MongoClient(mongoClientURI).getDB(mongoClientURI.getDatabase()));
105+
Stopwatch stopwatch = Stopwatch.createStarted();
106+
jongo.getCollection(given.getCollection()).drop();
107+
System.out.printf("dropped %s -- %s%n", given.getCollection(), stopwatch.stop().toString());
108+
}
109+
};
118110
}
119111

120112
public static interface CollectionSequence {

restx-jongo-specs-tests/src/main/java/restx/jongo/specs/tests/GivenJongoCollectionSpecRuleSupplier.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,7 @@ public void onSetup(Factory.LocalMachines localMachines) {
6363
@Override
6464
public void onTearDown(Factory.LocalMachines localMachines) {
6565
System.out.println("dropping database " + uri + "/" + db);
66-
try {
67-
new MongoClient(new MongoClientURI(uri)).dropDatabase(db);
68-
} catch (UnknownHostException e) {
69-
throw new IllegalStateException("got unknown host exception while contacting mongo db on localhost", e);
70-
}
66+
new MongoClient(new MongoClientURI(uri)).dropDatabase(db);
7167
}
7268
}
7369
}

restx.build.properties.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
"metrics.version": "3.1.0",
2727
"javax.inject.version": "1",
2828

29-
"mongo-java-driver.version": "2.11.3",
30-
"bson4jackson.version": "2.3.1",
29+
"mongo-java-driver.version": "3.4.0",
30+
"bson4jackson.version": "2.7.0",
3131
"jongo.version": "1.3.0",
3232

3333
"servlet-api.version": "2.5",

0 commit comments

Comments
 (0)