1 | package gov.va.med.edp.vistalink.locator;
|
---|
2 |
|
---|
3 | import junit.framework.TestCase;
|
---|
4 | import org.springframework.dao.DataAccessResourceFailureException;
|
---|
5 |
|
---|
6 | import javax.resource.cci.ConnectionFactory;
|
---|
7 | import java.util.HashSet;
|
---|
8 | import java.util.Set;
|
---|
9 |
|
---|
10 | public class VistaLinkConnectorConfigConnectionFactoryLocatorTest extends TestCase {
|
---|
11 |
|
---|
12 | public void testNoConnectorForRequestedStationNumber() throws Exception {
|
---|
13 | VistaLinkConnectorConfigConnectionFactoryLocator locator = new VistaLinkConnectorConfigConnectionFactoryLocator();
|
---|
14 |
|
---|
15 | try {
|
---|
16 | locator.getConnectionFactory("982");
|
---|
17 | } catch (DataAccessResourceFailureException e) {
|
---|
18 | assertTrue(true);
|
---|
19 | }
|
---|
20 | }
|
---|
21 |
|
---|
22 | public void testGetConnectionFactory() throws Exception {
|
---|
23 | Set/*<VistaLinkConnectorConfig>*/ connectors = new HashSet/*<VistaLinkConnectorConfig>*/();
|
---|
24 | connectors.add(new VistaLinkConnectorConfig("982", "FOO FACILITY NUMERO UNO", "vhaislfoo2.vha.med.va.gov", 8014, "10BAR", "BAR10"));
|
---|
25 |
|
---|
26 | VistaLinkConnectorConfigConnectionFactoryLocator locator = new VistaLinkConnectorConfigConnectionFactoryLocator();
|
---|
27 | locator.setConnectors(connectors);
|
---|
28 |
|
---|
29 | ConnectionFactory cf = locator.getConnectionFactory("982");
|
---|
30 |
|
---|
31 | assertNotNull(cf);
|
---|
32 | }
|
---|
33 |
|
---|
34 | public void testGetConnectionFactoryForDifferentConnectorSets() throws Exception {
|
---|
35 | Set/*<VistaLinkConnectorConfig>*/ connectors1 = new HashSet/*<VistaLinkConnectorConfig>*/();
|
---|
36 | connectors1.add(new VistaLinkConnectorConfig("982", "FOO FACILITY NUMERO UNO", "vhaislfoo2.vha.med.va.gov", 8014, "10BAR", "BAR10"));
|
---|
37 |
|
---|
38 | VistaLinkConnectorConfigConnectionFactoryLocator locator = new VistaLinkConnectorConfigConnectionFactoryLocator();
|
---|
39 | locator.setConnectors(connectors1);
|
---|
40 |
|
---|
41 | ConnectionFactory cf = locator.getConnectionFactory("982");
|
---|
42 | assertNotNull(cf);
|
---|
43 | try {
|
---|
44 | locator.getConnectionFactory("983");
|
---|
45 | } catch (DataAccessResourceFailureException e) {
|
---|
46 | assertTrue(true);
|
---|
47 | }
|
---|
48 |
|
---|
49 | Set/*<VistaLinkConnectorConfig>*/ connectors2 = new HashSet/*<VistaLinkConnectorConfig>*/();
|
---|
50 | connectors2.add(new VistaLinkConnectorConfig("983", "BAR FACILITY NUMERO UNO", "vhaislbar2.vha.med.va.gov", 8015, "10FOO", "FOO10"));
|
---|
51 | locator.setConnectors(connectors2);
|
---|
52 |
|
---|
53 | cf = locator.getConnectionFactory("983");
|
---|
54 | assertNotNull(cf);
|
---|
55 | try {
|
---|
56 | locator.getConnectionFactory("982");
|
---|
57 | } catch (DataAccessResourceFailureException e) {
|
---|
58 | assertTrue(true);
|
---|
59 | }
|
---|
60 |
|
---|
61 | }
|
---|
62 | }
|
---|