Skip to content

Commit 44084b7

Browse files
committed
Revert "[breaking] deps - upgraded mongo java driver to 3.4.0 and bson4jackson to 2.7.0 to follow jongo 1.3.0 upgrade"
This reverts commit 1c07f87.
1 parent b3282a3 commit 44084b7

File tree

5 files changed

+82
-70
lines changed

5 files changed

+82
-70
lines changed

pom.xml

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

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

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

Lines changed: 71 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -38,75 +38,83 @@ 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()));
4541
try {
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++;
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();
5358
}
54-
System.out.printf("imported %s[%d] -- %s%n", given.getCollection(), count, stopwatch.stop().toString());
55-
} finally {
56-
jongo.getDatabase().getMongo().close();
57-
}
5859

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-
}
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+
}
7690

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;
8891
}
89-
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);
90112
}
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-
};
113+
}
114+
};
115+
} catch (UnknownHostException e) {
116+
throw new RuntimeException(e);
117+
}
110118
}
111119

112120
public static interface CollectionSequence {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public void onSetup(Factory.LocalMachines localMachines) {
6363
@Override
6464
public void onTearDown(Factory.LocalMachines localMachines) {
6565
System.out.println("dropping database " + uri + "/" + db);
66-
new MongoClient(new MongoClientURI(uri)).dropDatabase(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+
}
6771
}
6872
}
6973
}

restx-jongo/module.ivy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@
2222
<dependency org="com.fasterxml.jackson.core" name="jackson-annotations" rev="2.8.10" conf="default" />
2323
<dependency org="com.fasterxml.jackson.core" name="jackson-databind" rev="2.8.10" conf="default" />
2424
<dependency org="com.fasterxml.jackson.datatype" name="jackson-datatype-joda" rev="2.8.10" conf="default" />
25-
<dependency org="de.undercouch" name="bson4jackson" rev="2.7.0" conf="default" />
26-
<dependency org="org.mongodb" name="mongo-java-driver" rev="3.4.0" conf="default" />
25+
<dependency org="de.undercouch" name="bson4jackson" rev="2.3.1" conf="default" />
26+
<dependency org="org.mongodb" name="mongo-java-driver" rev="2.11.3" conf="default" />
2727
<dependency org="org.jongo" name="jongo" rev="1.3.0" conf="default" />
2828
<dependency org="org.slf4j" name="slf4j-api" rev="1.7.5" conf="default" />
2929
<dependency org="junit" name="junit" rev="4.11" conf="test->default" />

restx.build.properties.json

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

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

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

0 commit comments

Comments
 (0)