3 |
3 |
import static org.hamcrest.CoreMatchers.is;
|
4 |
4 |
import static org.junit.Assert.assertThat;
|
5 |
5 |
|
6 |
|
import java.io.File;
|
|
6 |
import java.io.IOException;
|
7 |
7 |
import java.util.Map;
|
8 |
8 |
import java.util.concurrent.Callable;
|
9 |
9 |
|
10 |
10 |
import org.dataone.service.types.v1.Identifier;
|
11 |
11 |
import org.junit.After;
|
12 |
|
import org.junit.Before;
|
13 |
12 |
import org.junit.Rule;
|
14 |
13 |
import org.junit.Test;
|
15 |
14 |
import org.junit.rules.ErrorCollector;
|
16 |
15 |
|
|
16 |
import com.hazelcast.config.ClasspathXmlConfig;
|
|
17 |
import com.hazelcast.config.Config;
|
|
18 |
import com.hazelcast.config.UrlXmlConfig;
|
17 |
19 |
import com.hazelcast.core.Hazelcast;
|
18 |
20 |
import com.hazelcast.core.HazelcastInstance;
|
19 |
21 |
|
... | ... | |
21 |
23 |
|
22 |
24 |
|
23 |
25 |
public class HzObjectPathMapTest extends MCTestCase {
|
24 |
|
public final static String CONFIG_PATH = "/Users/rnahf/" +
|
25 |
|
// "projects/" +
|
26 |
|
"software/workspace" +
|
27 |
|
"nceas/metacat/test/edu/ucsb/nceas/metacat/dataone/hazelcast";
|
28 |
|
|
|
26 |
|
29 |
27 |
/**
|
30 |
28 |
* Need to use the error collector to handle JUnit assertions
|
31 |
29 |
* and keep going. This is because setting up multiple tests of
|
... | ... | |
81 |
79 |
|
82 |
80 |
|
83 |
81 |
@Test
|
84 |
|
public void testBehavior() {
|
|
82 |
public void testBehavior() throws IOException {
|
85 |
83 |
/**
|
86 |
84 |
* set up the two hazelcast instances (separate configurations)
|
87 |
85 |
* mapProvider is configured with the ObjectPathMap (MapLoader)
|
88 |
86 |
* mapUser is configured with a default config file (no MapLoader implementation)
|
89 |
87 |
*/
|
90 |
|
File configPath = new File(CONFIG_PATH + "hzObjectPathMap.provider.test.properties.xml");
|
91 |
|
checkTrue("config file should exist", configPath.canRead());
|
92 |
|
System.getProperties().setProperty("hazelcast.config", configPath.getAbsolutePath());
|
93 |
|
HazelcastInstance mapProvider = Hazelcast.newHazelcastInstance(null);
|
94 |
|
|
|
88 |
Config config1 = new ClasspathXmlConfig("edu/ucsb/nceas/metacat/dataone/hazelcast/hzObjectPathMap.provider.test.properties.xml");
|
|
89 |
HazelcastInstance mapProvider = Hazelcast.newHazelcastInstance(config1);
|
95 |
90 |
|
96 |
91 |
// setup and start the non-maploader member (d1_indexer)
|
97 |
|
configPath = new File(CONFIG_PATH + "hzObjectPathMap.user.test.properties.xml");
|
98 |
|
checkTrue("config file should exist", configPath.canRead());
|
99 |
|
System.getProperties().setProperty("hazelcast.config", configPath.getAbsolutePath());
|
100 |
|
HazelcastInstance mapUser = Hazelcast.newHazelcastInstance(null);
|
|
92 |
Config config2 = new UrlXmlConfig(this.getClass().getClassLoader().getResource("edu/ucsb/nceas/metacat/dataone/hazelcast/hzObjectPathMap.user.test.properties.xml"));
|
|
93 |
HazelcastInstance mapUser = Hazelcast.newHazelcastInstance(config2 );
|
|
94 |
|
101 |
95 |
|
102 |
96 |
// try to read from uninstantiated map
|
103 |
97 |
Map<Identifier,String> userMap = mapUser.getMap("hzObjectPath");
|
load hazelcast test files from the classpath rather than from rob's personal directory.