This project has retired. For details please refer to its
Attic page.
BaseTestCase xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ws.scout;
18
19 import java.net.PasswordAuthentication;
20 import java.util.HashSet;
21 import java.util.Map;
22 import java.util.Properties;
23 import java.util.Set;
24
25 import javax.xml.registry.BusinessLifeCycleManager;
26 import javax.xml.registry.BusinessQueryManager;
27 import javax.xml.registry.Connection;
28 import javax.xml.registry.ConnectionFactory;
29 import javax.xml.registry.JAXRException;
30
31 import org.apache.ws.scout.registry.RegistryImpl;
32
33
34
35
36
37
38
39 public class BaseTestCase
40 {
41 protected Connection connection;
42 protected Connection connection2;
43
44 protected BusinessLifeCycleManager blm;
45 protected BusinessQueryManager bqm;
46
47
48 protected String uddiversion = null;
49
50 protected String userid = System.getProperty("uddi.test.uid") == null ? "jdoe" : System.getProperty("uddi.test.uid");
51 protected String passwd = System.getProperty("uddi.test.pass") == null ? "password" : System.getProperty("uddi.test.pass");
52
53 protected String userid2 = System.getProperty("uddi.test.uid2") == null ? "jdoe2" : System.getProperty("uddi.test.uid2");
54 protected String passwd2 = System.getProperty("uddi.test.pass2") == null ? "password2" : System.getProperty("uddi.test.pass2");
55
56 protected int maxRows = 100;
57
58
59
60
61
62 public void setUp()
63 {
64 System.out.println("************************************************************");
65 try
66 {
67 String envUDDIVersion = System.getenv("uddi.version");
68 if (envUDDIVersion==null) envUDDIVersion = "2";
69 uddiversion = envUDDIVersion + ".0";
70 String propertiesFile = "/scoutv" + envUDDIVersion + ".properties";
71
72 System.out.println("Reading Scout Properties from: " + propertiesFile);
73
74 Properties scoutProperties = new Properties();
75 scoutProperties.load(getClass().getResourceAsStream(propertiesFile));
76
77 if (scoutProperties.getProperty("userid")!=null) {
78 userid = scoutProperties.getProperty("userid");
79 }
80 if (scoutProperties.getProperty("password")!=null) {
81 passwd = scoutProperties.getProperty("password");
82 }
83
84
85
86
87
88
89
90
91
92 ConnectionFactory factory = ConnectionFactory.newInstance();
93 factory.setProperties(scoutProperties);
94 connection = factory.createConnection();
95 connection2 = factory.createConnection();
96 } catch (Exception e)
97 {
98 e.printStackTrace();
99 }
100 }
101
102
103
104
105 public void tearDown()
106 {
107
108 try
109 {
110 if (connection != null)
111 connection.close();
112
113 } catch (Exception e)
114 {
115
116 }
117 }
118
119
120
121
122 public void login()
123 {
124 PasswordAuthentication passwdAuth = new PasswordAuthentication(userid,
125 passwd.toCharArray());
126 Set<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>();
127 creds.add(passwdAuth);
128
129 try
130 {
131 connection.setCredentials(creds);
132 } catch (JAXRException e)
133 {
134 e.printStackTrace();
135 }
136 }
137
138
139
140
141 public void loginSecondUser()
142 {
143 PasswordAuthentication passwdAuth = new PasswordAuthentication(userid2,
144 passwd2.toCharArray());
145 Set<PasswordAuthentication> creds = new HashSet<PasswordAuthentication>();
146 creds.add(passwdAuth);
147
148 try
149 {
150 connection2.setCredentials(creds);
151 } catch (JAXRException e)
152 {
153 e.printStackTrace();
154 }
155 }
156 }