1 | package geniusweb.simplerunner;
|
---|
2 |
|
---|
3 | import static org.junit.Assert.assertNotNull;
|
---|
4 |
|
---|
5 | import java.io.IOException;
|
---|
6 | import java.net.URISyntaxException;
|
---|
7 |
|
---|
8 | import org.junit.Before;
|
---|
9 | import org.junit.Test;
|
---|
10 |
|
---|
11 | import geniusweb.actions.Action;
|
---|
12 | import geniusweb.connection.ConnectionEnd;
|
---|
13 | import geniusweb.inform.Inform;
|
---|
14 | import geniusweb.references.PartyRef;
|
---|
15 |
|
---|
16 | public class ClassPathConnectionFactoryTest {
|
---|
17 | private ClassPathConnectionFactory factory;
|
---|
18 |
|
---|
19 | @Before
|
---|
20 | public void before() {
|
---|
21 | factory = new ClassPathConnectionFactory();
|
---|
22 |
|
---|
23 | }
|
---|
24 |
|
---|
25 | @Test(expected = IllegalArgumentException.class)
|
---|
26 | public void testWrongURI() throws IOException, URISyntaxException {
|
---|
27 | factory.connect(new PartyRef("http://blabla"));
|
---|
28 | }
|
---|
29 |
|
---|
30 | @Test(expected = IllegalArgumentException.class)
|
---|
31 | public void testNullPath() throws IOException, URISyntaxException {
|
---|
32 | // bad because classpath should not start with //
|
---|
33 | factory.connect(new PartyRef("http://some.class.path"));
|
---|
34 | }
|
---|
35 |
|
---|
36 | @Test(expected = IllegalArgumentException.class)
|
---|
37 | public void testUnknownParty() throws IOException, URISyntaxException {
|
---|
38 | factory.connect(new PartyRef("classpath:blabla.bla"));
|
---|
39 | }
|
---|
40 |
|
---|
41 | @Test
|
---|
42 | public void testRandomParty() throws IOException, URISyntaxException {
|
---|
43 | ConnectionEnd<Action, Inform> party = factory.connect(new PartyRef(
|
---|
44 | "classpath:geniusweb.exampleparties.randomparty.RandomParty"));
|
---|
45 | assertNotNull(party);
|
---|
46 | }
|
---|
47 |
|
---|
48 | }
|
---|