Permalink
Browse files

Revert "[breaking] deps - upgraded mongo java driver to 3.4.0 and bso…

…n4jackson to 2.7.0 to follow jongo 1.3.0 upgrade"

This reverts commit 1c07f87.
  • Loading branch information...
fcamblor committed Feb 25, 2018
1 parent b3282a3 commit 44084b77540fb8b601baa1c5113ef723649c4d7d
View
@@ -83,8 +83,8 @@
<el.api.version>2.2</el.api.version>
<!-- Mongo modules -->
<mongo-java-driver.version>3.4.0</mongo-java-driver.version>
<bson4jackson.version>2.7.0</bson4jackson.version>
<mongo-java-driver.version>2.11.3</mongo-java-driver.version>
<bson4jackson.version>2.3.1</bson4jackson.version>
<jongo.version>1.3.0</jongo.version>
<de.flapdoodle.embed.version>1.42</de.flapdoodle.embed.version>
@@ -38,75 +38,83 @@
}
public GivenCleaner run(final GivenJongoCollection given, final ImmutableMap<String, String> params) {
MongoClientURI mongoClientURI = new MongoClientURI(
checkNotNull(params.get(DB_URI),
DB_URI + " param is required"));
Jongo jongo = new Jongo(new MongoClient(mongoClientURI).getDB(mongoClientURI.getDatabase()));
try {
Stopwatch stopwatch = Stopwatch.createStarted();
MongoCollection collection = jongo.getCollection(given.getCollection());
Iterable<String> items = Splitter.on("\n").trimResults().omitEmptyStrings().split(given.getData());
int count = 0;
for (String item : items) {
collection.insert(item);
count++;
MongoClientURI mongoClientURI = new MongoClientURI(
checkNotNull(params.get(DB_URI),
DB_URI + " param is required"));
Jongo jongo = new Jongo(new MongoClient(mongoClientURI).getDB(mongoClientURI.getDatabase()));
try {
Stopwatch stopwatch = Stopwatch.createStarted();
MongoCollection collection = jongo.getCollection(given.getCollection());
Iterable<String> items = Splitter.on("\n").trimResults().omitEmptyStrings().split(given.getData());
int count = 0;
for (String item : items) {
collection.insert(item);
count++;
}
System.out.printf("imported %s[%d] -- %s%n", given.getCollection(), count, stopwatch.stop().toString());
} finally {
jongo.getDatabase().getMongo().close();
}
System.out.printf("imported %s[%d] -- %s%n", given.getCollection(), count, stopwatch.stop().toString());
} finally {
jongo.getDatabase().getMongo().close();
}
final UnmodifiableIterator<String> it = given.getSequence().iterator();
final CollectionSequence iteratingSequence = new CollectionSequence() {
@Override
public Optional<String> next() {
return it.hasNext() ? Optional.of(it.next()) : Optional.<String>absent();
}
};
final SingleNameFactoryMachine<ComponentCustomizerEngine> customizerMachine =
new SingleNameFactoryMachine<>(0, new StdMachineEngine<ComponentCustomizerEngine>(
Name.of(ComponentCustomizerEngine.class, "JongoCollectionSequenceSupplierOf"
+ given.getCollection()),
BoundlessComponentBox.FACTORY) {
@Override
public BillOfMaterials getBillOfMaterial() {
return BillOfMaterials.of();
}
final UnmodifiableIterator<String> it = given.getSequence().iterator();
final CollectionSequence iteratingSequence = new CollectionSequence() {
@Override
public Optional<String> next() {
return it.hasNext() ? Optional.of(it.next()) : Optional.<String>absent();
}
};
final SingleNameFactoryMachine<ComponentCustomizerEngine> customizerMachine =
new SingleNameFactoryMachine<>(0, new StdMachineEngine<ComponentCustomizerEngine>(
Name.of(ComponentCustomizerEngine.class, "JongoCollectionSequenceSupplierOf"
+ given.getCollection()),
BoundlessComponentBox.FACTORY) {
@Override
public BillOfMaterials getBillOfMaterial() {
return BillOfMaterials.of();
}
@Override
protected ComponentCustomizerEngine doNewComponent(final SatisfiedBOM satisfiedBOM) {
return new SingleComponentNameCustomizerEngine<JongoCollection>(
0, Name.of(JongoCollection.class, given.getCollection())) {
@Override
public NamedComponent<JongoCollection> customize(NamedComponent<JongoCollection> namedComponent) {
if (namedComponent.getName().getName().equals(given.getCollection())) {
return new NamedComponent<>(namedComponent.getName(),
new SequencedJongoCollection(namedComponent.getComponent(),iteratingSequence));
} else {
return namedComponent;
}
@Override
protected ComponentCustomizerEngine doNewComponent(final SatisfiedBOM satisfiedBOM) {
return new SingleComponentNameCustomizerEngine<JongoCollection>(
0, Name.of(JongoCollection.class, given.getCollection())) {
@Override
public NamedComponent<JongoCollection> customize(NamedComponent<JongoCollection> namedComponent) {
if (namedComponent.getName().getName().equals(given.getCollection())) {
return new NamedComponent<>(namedComponent.getName(),
new SequencedJongoCollection(namedComponent.getComponent(),iteratingSequence));
} else {
return namedComponent;
}
};
}
});
final Factory.LocalMachines localMachines = threadLocal();
localMachines.addMachine(customizerMachine);
return new GivenCleaner() {
@Override
public void cleanUp() {
try {
localMachines.removeMachine(customizerMachine);
MongoClientURI mongoClientURI = new MongoClientURI(
checkNotNull(params.get(DB_URI),
DB_URI + " param is required"));
Jongo jongo = new Jongo(new MongoClient(mongoClientURI).getDB(mongoClientURI.getDatabase()));
Stopwatch stopwatch = Stopwatch.createStarted();
jongo.getCollection(given.getCollection()).drop();
System.out.printf("dropped %s -- %s%n", given.getCollection(), stopwatch.stop().toString());
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
};
}
});
final Factory.LocalMachines localMachines = threadLocal();
localMachines.addMachine(customizerMachine);
return new GivenCleaner() {
@Override
public void cleanUp() {
localMachines.removeMachine(customizerMachine);
MongoClientURI mongoClientURI = new MongoClientURI(
checkNotNull(params.get(DB_URI),
DB_URI + " param is required"));
Jongo jongo = new Jongo(new MongoClient(mongoClientURI).getDB(mongoClientURI.getDatabase()));
Stopwatch stopwatch = Stopwatch.createStarted();
jongo.getCollection(given.getCollection()).drop();
System.out.printf("dropped %s -- %s%n", given.getCollection(), stopwatch.stop().toString());
}
};
}
};
} catch (UnknownHostException e) {
throw new RuntimeException(e);
}
}
public static interface CollectionSequence {
@@ -63,7 +63,11 @@ public void onSetup(Factory.LocalMachines localMachines) {
@Override
public void onTearDown(Factory.LocalMachines localMachines) {
System.out.println("dropping database " + uri + "/" + db);
new MongoClient(new MongoClientURI(uri)).dropDatabase(db);
try {
new MongoClient(new MongoClientURI(uri)).dropDatabase(db);
} catch (UnknownHostException e) {
throw new IllegalStateException("got unknown host exception while contacting mongo db on localhost", e);
}
}
}
}
View
@@ -22,8 +22,8 @@
<dependency org="com.fasterxml.jackson.core" name="jackson-annotations" rev="2.8.10" conf="default" />
<dependency org="com.fasterxml.jackson.core" name="jackson-databind" rev="2.8.10" conf="default" />
<dependency org="com.fasterxml.jackson.datatype" name="jackson-datatype-joda" rev="2.8.10" conf="default" />
<dependency org="de.undercouch" name="bson4jackson" rev="2.7.0" conf="default" />
<dependency org="org.mongodb" name="mongo-java-driver" rev="3.4.0" conf="default" />
<dependency org="de.undercouch" name="bson4jackson" rev="2.3.1" conf="default" />
<dependency org="org.mongodb" name="mongo-java-driver" rev="2.11.3" conf="default" />
<dependency org="org.jongo" name="jongo" rev="1.3.0" conf="default" />
<dependency org="org.slf4j" name="slf4j-api" rev="1.7.5" conf="default" />
<dependency org="junit" name="junit" rev="4.11" conf="test->default" />
@@ -27,8 +27,8 @@
"metrics.version": "3.1.0",
"javax.inject.version": "1",
"mongo-java-driver.version": "3.4.0",
"bson4jackson.version": "2.7.0",
"mongo-java-driver.version": "2.11.3",
"bson4jackson.version": "2.3.1",
"jongo.version": "1.3.0",
"servlet-api.version": "2.5",

0 comments on commit 44084b7

Please sign in to comment.