Skip to content

Commit ef9a34b

Browse files
author
Otavio Santana
committed
Merge branch 'master' of github.com:JNOSQL/diana-driver
2 parents c6dd122 + 324688f commit ef9a34b

File tree

8 files changed

+108
-17
lines changed

8 files changed

+108
-17
lines changed

docker.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
docker run -e ARANGO_NO_AUTH=1 -d --name arangodb-instance -p 8529:8529 -d arangodb/arangodb
22
docker run -d --name couchbase-instance -p 8091-8094:8091-8094 -p 11210:11210 couchbase
33
docker run --name elasticsearch-instance -p 9300:9300 -p 9200:9200 -d elasticsearch
4-
docker run --name mongo-instance -p 27017:27017 -d mongo
54
docker run -d --name orientdb -p 2424:2424 -p 2480:2480 -e ORIENTDB_ROOT_PASSWORD=rootpwd orientdb
65
docker run --name redis-instance -p 6379:6379 -d redis
76
docker run --name riak-instance -d -p 8087:8087 -p 8098:8098 basho/riak-ts

mongodb-driver/pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@
6363
<artifactId>mongodb-driver-async</artifactId>
6464
<version>${monbodb.driver}</version>
6565
</dependency>
66+
<dependency>
67+
<groupId>de.flapdoodle.embed</groupId>
68+
<artifactId>de.flapdoodle.embed.mongo</artifactId>
69+
<version>2.0.1-SNAPSHOT</version>
70+
</dependency>
6671
</dependencies>
6772
<build>
6873
<plugins>
@@ -101,4 +106,10 @@
101106
</plugin>
102107
</plugins>
103108
</build>
109+
<repositories>
110+
<repository>
111+
<id>sonartype</id>
112+
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
113+
</repository>
114+
</repositories>
104115
</project>

mongodb-driver/src/test/java/org/jnosql/diana/mongodb/document/MongoDBDocumentCollectionManagerAsyncTest.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@
2626
import org.jnosql.diana.api.document.DocumentEntity;
2727
import org.jnosql.diana.api.document.DocumentQuery;
2828
import org.jnosql.diana.api.document.Documents;
29-
import org.junit.Before;
29+
import org.junit.AfterClass;
30+
import org.junit.BeforeClass;
3031
import org.junit.Test;
3132

33+
import java.io.IOException;
3234
import java.util.HashMap;
3335
import java.util.List;
3436
import java.util.Map;
@@ -40,10 +42,12 @@
4042
public class MongoDBDocumentCollectionManagerAsyncTest {
4143

4244
public static final String COLLECTION_NAME = "person";
43-
private DocumentCollectionManager entityManager;
4445

45-
@Before
46-
public void setUp() {
46+
private static DocumentCollectionManager entityManager;
47+
48+
@BeforeClass
49+
public static void setUp() throws IOException {
50+
MongoDbHelper.startMongoDb();
4751
entityManager = get().get("database");
4852
}
4953

@@ -84,4 +88,8 @@ private DocumentEntity getEntity() {
8488
return entity;
8589
}
8690

91+
@AfterClass
92+
public static void end() {
93+
MongoDbHelper.stopMongoDb();
94+
}
8795
}

mongodb-driver/src/test/java/org/jnosql/diana/mongodb/document/MongoDBDocumentCollectionManagerFactoryTest.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,23 @@
2020

2121
package org.jnosql.diana.mongodb.document;
2222

23-
import org.junit.Before;
23+
import org.junit.AfterClass;
24+
import org.junit.BeforeClass;
2425
import org.junit.Test;
2526

27+
import java.io.IOException;
28+
2629
import static org.junit.Assert.assertNotNull;
2730

2831

2932
public class MongoDBDocumentCollectionManagerFactoryTest {
3033

31-
private MongoDBDocumentConfiguration configuration;
34+
private static MongoDBDocumentConfiguration configuration;
3235

33-
@Before
34-
public void setUp() {
36+
@BeforeClass
37+
public static void setUp() throws IOException {
3538
configuration = new MongoDBDocumentConfiguration();
36-
39+
MongoDbHelper.startMongoDb();
3740
}
3841

3942
@Test
@@ -47,4 +50,9 @@ public void shouldCreateEntityManagerAsync() {
4750
MongoDBDocumentCollectionManagerFactory mongoDBFactory = configuration.get();
4851
assertNotNull(mongoDBFactory.getAsync("database"));
4952
}
53+
54+
@AfterClass
55+
public static void end(){
56+
MongoDbHelper.stopMongoDb();
57+
}
5058
}

mongodb-driver/src/test/java/org/jnosql/diana/mongodb/document/MongoDBDocumentCollectionManagerTest.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828
import org.jnosql.diana.api.document.DocumentEntity;
2929
import org.jnosql.diana.api.document.DocumentQuery;
3030
import org.jnosql.diana.api.document.Documents;
31-
import org.junit.Before;
31+
import org.junit.AfterClass;
32+
import org.junit.BeforeClass;
3233
import org.junit.Test;
3334

35+
import java.io.IOException;
3436
import java.util.Arrays;
3537
import java.util.HashMap;
3638
import java.util.List;
@@ -48,10 +50,11 @@
4850
public class MongoDBDocumentCollectionManagerTest {
4951

5052
public static final String COLLECTION_NAME = "person";
51-
private DocumentCollectionManager entityManager;
53+
private static DocumentCollectionManager entityManager;
5254

53-
@Before
54-
public void setUp() {
55+
@BeforeClass
56+
public static void setUp() throws IOException {
57+
MongoDbHelper.startMongoDb();
5558
entityManager = get().get("database");
5659
}
5760

@@ -121,6 +124,10 @@ private DocumentEntity getEntity() {
121124
return entity;
122125
}
123126

127+
@AfterClass
128+
public static void end(){
129+
MongoDbHelper.stopMongoDb();
130+
}
124131

125132
public void init() {
126133
DocumentEntity oReilly = DocumentEntity.of("oReilly");

mongodb-driver/src/test/java/org/jnosql/diana/mongodb/document/MongoDBDocumentConfigurationTest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131

3232

3333
public class MongoDBDocumentConfigurationTest {
34-
35-
3634
@Test
3735
public void shouldCreateDocumentCollectionManagerFactoryByMap() {
3836
Map<String, String> map = new HashMap<>();
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright 2017 Eclipse Foundation
3+
* Licensed to the Apache Software Foundation (ASF) under one
4+
* or more contributor license agreements. See the NOTICE file
5+
* distributed with this work for additional information
6+
* regarding copyright ownership. The ASF licenses this file
7+
* to you under the Apache License, Version 2.0 (the
8+
* "License"); you may not use this file except in compliance
9+
* with the License. You may obtain a copy of the License at
10+
*
11+
* http://www.apache.org/licenses/LICENSE-2.0
12+
*
13+
* Unless required by applicable law or agreed to in writing,
14+
* software distributed under the License is distributed on an
15+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16+
* KIND, either express or implied. See the License for the
17+
* specific language governing permissions and limitations
18+
* under the License.
19+
*/
20+
21+
package org.jnosql.diana.mongodb.document;
22+
23+
import com.mongodb.MongoClient;
24+
import de.flapdoodle.embed.mongo.MongodExecutable;
25+
import de.flapdoodle.embed.mongo.MongodProcess;
26+
import de.flapdoodle.embed.mongo.MongodStarter;
27+
import de.flapdoodle.embed.mongo.config.MongodConfigBuilder;
28+
import de.flapdoodle.embed.mongo.config.Net;
29+
import de.flapdoodle.embed.mongo.distribution.Version;
30+
import de.flapdoodle.embed.process.runtime.Network;
31+
32+
import java.io.IOException;
33+
34+
35+
/**
36+
* Class helper to start a mongodb embedded
37+
* @author Ivan Junckes Filho
38+
*/
39+
public abstract class MongoDbHelper {
40+
41+
private static final MongodStarter starter = MongodStarter.getDefaultInstance();
42+
private static MongodExecutable _mongodExe;
43+
private static MongodProcess _mongod;
44+
private static MongoClient _mongo;
45+
46+
public static void startMongoDb() throws IOException {
47+
_mongodExe = starter.prepare(new MongodConfigBuilder()
48+
.version(Version.Main.PRODUCTION)
49+
.net(new Net("localhost", 27017, Network.localhostIsIPv6()))
50+
.build());
51+
_mongod = _mongodExe.start();
52+
_mongo = new MongoClient("localhost", 27017);
53+
}
54+
55+
public static void stopMongoDb(){
56+
_mongod.stop();
57+
_mongodExe.stop();
58+
}
59+
60+
}

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<parent>
2727
<groupId>org.jnosql</groupId>
2828
<artifactId>jnosql-parent</artifactId>
29-
<version>0.0.1-SNAPSHOT</version>
29+
<version>0.0.2-SNAPSHOT</version>
3030
</parent>
3131

3232
<groupId>org.jnosql.diana</groupId>

0 commit comments

Comments
 (0)