This project has retired. For details please refer to its
Attic page.
ApplicationConfigurationTest xref
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 package org.apache.juddi.config;
16
17 import java.net.MalformedURLException;
18 import java.net.URI;
19 import java.net.URISyntaxException;
20
21 import org.apache.commons.configuration.ConfigurationException;
22 import org.junit.Assert;
23 import org.junit.Test;
24
25
26
27
28 public class ApplicationConfigurationTest
29 {
30 @Test
31 public void readPropertyFromFile() throws ConfigurationException
32 {
33 try {
34 long refreshDelay = AppConfig.getConfiguration().getLong(Property.JUDDI_CONFIGURATION_RELOAD_DELAY);
35 System.out.println("refreshDelay=" + refreshDelay);
36 Assert.assertEquals(2000l, refreshDelay);
37 } catch (Exception e) {
38 e.printStackTrace();
39 Assert.fail();
40 }
41 }
42
43 @Test
44 public void readNonExistingProperty() throws ConfigurationException
45 {
46 long defaultValue = 3000l;
47 try {
48 long nonexisting = AppConfig.getConfiguration().getLong("nonexisting.property",defaultValue);
49 System.out.println("nonexisting=" + nonexisting);
50 Assert.assertEquals(3000l, nonexisting);
51 } catch (Exception e) {
52 e.printStackTrace();
53 Assert.fail();
54 }
55 }
56
57 @Test
58 public void testURLFormats() throws MalformedURLException, URISyntaxException {
59
60 URI file = new URI("file:/tmp/");
61 String path = file.getSchemeSpecificPart();
62 Assert.assertEquals("/tmp/", path);
63
64 URI fileInJar = new URI("jar:file:/tmp/my.jar!/");
65 String path1 = fileInJar.getSchemeSpecificPart();
66 Assert.assertEquals("file:/tmp/my.jar!/", path1);
67
68 URI fileInZip = new URI("zip:D:/bea/tmp/_WL_user/JuddiEAR/nk4cwv/war/WEB-INF/lib/juddi-core-3.0.1.jar!");
69 String path2 = fileInZip.getSchemeSpecificPart();
70 Assert.assertEquals("D:/bea/tmp/_WL_user/JuddiEAR/nk4cwv/war/WEB-INF/lib/juddi-core-3.0.1.jar!", path2);
71
72 URI fileInVfszip = new URI("vfsfile:/tmp/SOA%20Platform/jbossesb-registry.sar/juddi_custom_install_data/root_Publisher.xml");
73 String path3 = fileInVfszip.getSchemeSpecificPart();
74 Assert.assertEquals("/tmp/SOA Platform/jbossesb-registry.sar/juddi_custom_install_data/root_Publisher.xml", path3);
75
76 }
77
78 }