Project

General

Profile

« Previous | Next » 

Revision 49735

Fixed ENA Resolver

View differences:

ConfigurationResolverStoreTestConfig.java
1 1
package eu.dnetlib.resolver.store;
2 2

  
3
import java.io.IOException;
3 4
import java.net.UnknownHostException;
4 5

  
5 6
import com.mongodb.MongoClient;
6 7

  
8
import de.flapdoodle.embed.mongo.MongodExecutable;
9
import de.flapdoodle.embed.mongo.MongodStarter;
10
import de.flapdoodle.embed.mongo.config.IMongodConfig;
11
import de.flapdoodle.embed.mongo.config.MongoCmdOptionsBuilder;
12
import de.flapdoodle.embed.mongo.config.MongodConfigBuilder;
13
import de.flapdoodle.embed.mongo.config.Net;
14
import de.flapdoodle.embed.mongo.distribution.Version;
15
import de.flapdoodle.embed.process.runtime.Network;
16
import eu.dnetlib.dli.resolver.DLIResolvedObjectFactory;
7 17
import eu.dnetlib.pid.resolver.store.ResolverStore;
8 18
import org.springframework.context.annotation.Bean;
9 19
import org.springframework.context.annotation.Configuration;
......
12 22
public class ConfigurationResolverStoreTestConfig {
13 23

  
14 24
	@Bean
15
	public MongoClient client() throws UnknownHostException {
16
		final MongoClient mongo = new MongoClient("localhost", 27017);
17
		return mongo;
25
	public MongoClient mongoClient() throws IOException {
26
		MongodStarter starter = MongodStarter.getDefaultInstance();
27
		String bindIp = "localhost";
28
		int port = 54321;
29
		IMongodConfig mongodConfig = new MongodConfigBuilder()
30
				.version(Version.Main.PRODUCTION)
31
				.net(new Net(bindIp, port, Network.localhostIsIPv6()))
32
				.cmdOptions(new MongoCmdOptionsBuilder()
33
						.useNoJournal(false)
34
						.build())
35
				.build();
36
		MongodExecutable mongodExecutable = starter.prepare(mongodConfig);
37
		mongodExecutable.start();
38

  
39
		return new MongoClient(bindIp, port);
18 40
	}
19 41

  
20 42
	@Bean
21
	public ResolverStore resolverStore() throws UnknownHostException {
43
	public ResolverStore resolverStore() throws IOException {
22 44

  
23 45
		ResolverStore store = new ResolverStore();
24
		store.setMongoClient(client());
46
		store.setMongoClient(mongoClient());
25 47
		store.setDatabaseName("mdstore_test");
26 48
		store.setCollectionName("resolverStore");
27 49

  
28 50
		return store;
29 51
	}
30 52

  
53
	@Bean
54
	public DLIResolvedObjectFactory resolvedObjectFactory() {
55
		return new DLIResolvedObjectFactory();
56
	}
57

  
31 58
}

Also available in: Unified diff