217 sb.append(" SvcTagClient"); |
217 sb.append(" SvcTagClient"); |
218 return sb.toString(); |
218 return sb.toString(); |
219 } |
219 } |
220 |
220 |
221 private static Registry registry = null; |
221 private static Registry registry = null; |
|
222 private static File registryFile = null; |
222 /** |
223 /** |
223 * Returns the Registry processed by SvcTagClient that simulates |
224 * Returns the Registry processed by SvcTagClient that simulates |
224 * stclient. |
225 * stclient. |
225 */ |
226 */ |
226 static synchronized Registry getSvcTagClientRegistry() throws IOException { |
227 static synchronized Registry getSvcTagClientRegistry() throws IOException { |
|
228 String regDir = System.getProperty("test.classes"); |
|
229 File f = new File(regDir, "registry.xml"); |
227 if (registry != null) { |
230 if (registry != null) { |
|
231 if (!f.equals(registryFile) && f.length() != 0) { |
|
232 throw new AssertionError("Has to be empty registry.xml to run in samevm"); |
|
233 } |
228 return registry; |
234 return registry; |
229 } |
235 } |
230 |
236 |
231 // System.setProperty("servicetag.verbose", "true"); |
237 // System.setProperty("servicetag.verbose", "true"); |
232 // enable the helper class |
238 // enable the helper class |
233 System.setProperty("servicetag.sthelper.supported", "true"); |
239 System.setProperty("servicetag.sthelper.supported", "true"); |
234 |
240 registryFile = f; |
235 // clean up registry.xml |
|
236 String regDir = System.getProperty("test.classes"); |
|
237 File registryFile = new File(regDir, "registry.xml"); |
|
238 if (registryFile.exists()) { |
|
239 registryFile.delete(); |
|
240 } |
|
241 |
241 |
242 String stclientCmd = Util.getSvcClientCommand(registryFile.getCanonicalPath()); |
242 String stclientCmd = Util.getSvcClientCommand(registryFile.getCanonicalPath()); |
243 System.out.println("stclient cmd: " + stclientCmd); |
243 System.out.println("stclient cmd: " + stclientCmd); |
244 System.setProperty("servicetag.stclient.cmd", stclientCmd); |
244 System.setProperty("servicetag.stclient.cmd", stclientCmd); |
245 |
245 |
246 // get the Registry object after the system properties are set |
246 // get the Registry object after the system properties are set |
247 registry = Registry.getSystemRegistry(); |
247 registry = Registry.getSystemRegistry(); |
248 return registry; |
248 return registry; |
249 } |
249 } |
|
250 |
|
251 static void emptyRegistryFile() throws IOException { |
|
252 if (registryFile.exists()) { |
|
253 BufferedOutputStream out = new BufferedOutputStream( |
|
254 new FileOutputStream(registryFile)); |
|
255 try { |
|
256 RegistrationData data = new RegistrationData(); |
|
257 data.storeToXML(out); |
|
258 } finally { |
|
259 out.close(); |
|
260 } |
|
261 } |
|
262 } |
250 } |
263 } |