1
2
3
4
5
6
7
8 package it.imolinfo.jbi4ejb.test.deploy;
9
10 import it.imolinfo.jbi4ejb.jbi.component.Jbi4EjbRuntime;
11 import it.imolinfo.jbi4ejb.jbi.component.Jbi4EjbSUManager;
12 import it.imolinfo.jbi4ejb.jbi.endpoint.Jbi4EjbEndpoint;
13 import it.imolinfo.jbi4ejb.test.TestUtils;
14
15 import java.io.File;
16 import java.util.List;
17
18 import javax.jbi.management.DeploymentException;
19 import javax.xml.namespace.QName;
20
21 import junit.framework.TestCase;
22
23
24
25
26
27
28
29 public class WSDLDeployTest extends TestCase {
30
31
32
33 public static final String SUS_TEST_DIR = "src/test/etc/test-sus";
34
35
36 public static final String WORKING_PATH = "target/test-deploy";
37
38 public WSDLDeployTest() {}
39
40 public WSDLDeployTest(String name) {
41 super(name);
42 }
43
44 public void setUp() {
45
46 File dirTemp = new File(WORKING_PATH);
47 dirTemp.mkdir();
48 }
49
50
51
52
53 public void testSuComplexDeployTest() {
54 String serviceUnitName = "su-complex";
55 String suWorkingPath = WORKING_PATH + File.separator + serviceUnitName;
56 try {
57 Jbi4EjbSUManager suManager = getTestSUManager(serviceUnitName, suWorkingPath);
58
59 try {
60 suManager.deploy(serviceUnitName, suWorkingPath);
61 suManager.init(serviceUnitName, suWorkingPath);
62 } catch (DeploymentException e) {
63 fail(e.getMessage());
64 }
65
66 List<Jbi4EjbEndpoint> endpoints = suManager.getDeployedEndpoints();
67 assertEquals(1, endpoints.size());
68 assertEquals(endpoints.get(0).getServiceName(), new QName("http://complex.test14.imolinfo.it","TestComplexSessionRemote"));
69 assertEquals(endpoints.get(0).getEndpointName(), "TestComplexSessionRemotePort");
70
71 } catch (Exception ex) {
72 ex.printStackTrace();
73 fail(ex.getMessage());
74 }
75
76
77 }
78
79
80
81
82 public void testSuSimpleDeployTest() {
83 String serviceUnitName = "su-simple";
84 String suWorkingPath = WORKING_PATH + File.separator + serviceUnitName;
85 try {
86 Jbi4EjbSUManager suManager = getTestSUManager(serviceUnitName, suWorkingPath);
87
88 try {
89 suManager.deploy(serviceUnitName, suWorkingPath);
90 suManager.init(serviceUnitName, suWorkingPath);
91 } catch (DeploymentException e) {
92 fail(e.getMessage());
93 }
94
95 List<Jbi4EjbEndpoint> endpoints = suManager.getDeployedEndpoints();
96 assertEquals(1, endpoints.size());
97 assertEquals(endpoints.get(0).getServiceName(), new QName("http://test14.imolinfo.it","TestSessionRemote"));
98 assertEquals(endpoints.get(0).getEndpointName(), "TestSessionRemotePort");
99
100 } catch (Exception ex) {
101 ex.printStackTrace();
102 fail(ex.getMessage());
103 }
104
105 }
106
107
108
109
110
111
112 private Jbi4EjbSUManager getTestSUManager(String suName, String suWorkingPath) throws Exception {
113 File susTestDirFile = new File(SUS_TEST_DIR + File.separator + suName);
114 File suDeployFile = new File(suWorkingPath);
115 System.out.println("Copying files from: " + susTestDirFile.getAbsolutePath() + " to :" + suDeployFile.getAbsolutePath());
116 TestUtils.copyDirectory(susTestDirFile, suDeployFile);
117 Jbi4EjbRuntime ejbComponent = new Jbi4EjbRuntime();
118 Jbi4EjbSUManager suManager = new Jbi4EjbSUManager(ejbComponent);
119 return suManager;
120 }
121
122
123
124
125 public void tearDown() {
126 System.out.println("Removing the directory:" + WORKING_PATH);
127 File dir = new File(WORKING_PATH);
128 TestUtils.deleteDir(dir);
129 }
130
131
132 }
133