Permalink
Browse files

[breaking] deps - upgraded mongo java driver to 3.4.0 and bson4jackso…

…n to 2.7.0 to follow jongo 1.3.0 upgrade
  • Loading branch information...
fcamblor committed Sep 13, 2017
1 parent 38447ac commit 1c07f87e91c10320f1a8b2bbbfefa45ebb6614fb
@@ -82,8 +82,8 @@
<el.api.version>2.2</el.api.version>
<!-- Mongo modules -->
<mongo-java-driver.version>2.11.3</mongo-java-driver.version>
<bson4jackson.version>2.3.1</bson4jackson.version>
<mongo-java-driver.version>3.4.0</mongo-java-driver.version>
<bson4jackson.version>2.7.0</bson4jackson.version>
<jongo.version>1.3.0</jongo.version>
<de.flapdoodle.embed.version>1.42</de.flapdoodle.embed.version>
@@ -38,83 +38,75 @@
}
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 {
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();
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();
}
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;
}
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;
}
};
}
});
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);
}
}
};
} 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());
}
};
}
public static interface CollectionSequence {
@@ -63,11 +63,7 @@ public void onSetup(Factory.LocalMachines localMachines) {
@Override
public void onTearDown(Factory.LocalMachines localMachines) {
System.out.println("dropping database " + uri + "/" + 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);
}
new MongoClient(new MongoClientURI(uri)).dropDatabase(db);
}
}
}
@@ -26,8 +26,8 @@
"metrics.version": "3.1.0",
"javax.inject.version": "1",
"mongo-java-driver.version": "2.11.3",
"bson4jackson.version": "2.3.1",
"mongo-java-driver.version": "3.4.0",
"bson4jackson.version": "2.7.0",
"jongo.version": "1.3.0",
"servlet-api.version": "2.5",

0 comments on commit 1c07f87

Please sign in to comment.