Project

General

Profile

« Previous | Next » 

Revision 6565

load hazelcast test files from the classpath rather than from rob's personal directory.

View differences:

test/edu/ucsb/nceas/metacat/dataone/hazelcast/HzObjectPathMapTest.java
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");		
build.xml
271 271
		<property name="docdir" value="./docs" />
272 272
		<property name="cgidir" value="./cgi-bin" />
273 273
		<property name="testdir" value="./test" />
274
		<property name="testtorun" value="InlineDataAccessTest" />
274
		<property name="testtorun" value="HzObjectPathMapTest" />
275 275
		<property name="junittestsdir"
276 276
			value="./test/edu/ucsb/nceas/metacattest" />
277 277
		<property name="junitnettestsdir"
......
1070 1070
		</javac>
1071 1071

  
1072 1072
		<jar jarfile="${build.dir}/${name}-junittests.jar"
1073
			basedir="${build.tests}" includes="**/*.class" />
1073
			basedir="${build.tests}" >
1074
			<include name="**/*.class"/>
1075
			<include name="**/*.xml"/>
1076
		</jar>	
1074 1077
		
1075 1078
	</target>
1076 1079

  

Also available in: Unified diff