This project has retired. For details please refer to its Attic page.
InstallTest xref
View Javadoc
1   /*
2    * Copyright 2015 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.apache.juddi.config;
17  
18  import org.apache.commons.configuration.Configuration;
19  import org.apache.commons.configuration.MapConfiguration;
20  import org.junit.*;
21  import org.uddi.repl_v3.ReplicationConfiguration;
22  
23  import javax.xml.bind.JAXB;
24  import java.io.InputStream;
25  import java.io.StringWriter;
26  import java.util.Properties;
27  import org.apache.juddi.v3.client.cryptor.XmlUtils;
28  
29  /**
30   *
31   * @author alex
32   */
33  public class InstallTest {
34          
35          public InstallTest() {
36          }
37          
38          @BeforeClass
39          public static void setUpClass() {
40          }
41          
42          @AfterClass
43          public static void tearDownClass() {
44          }
45          
46          @Before
47          public void setUp() {
48          }
49          
50          @After
51          public void tearDown() {
52          }
53  
54          /**
55           * Test of applyReplicationTokenChanges method, of class Install.
56           */
57          @Test
58          public void testApplyReplicationTokenChanges() throws Exception {
59                  System.out.println("applyReplicationTokenChanges");
60                  InputStream fis = getClass().getClassLoader().getResourceAsStream("juddi_install_data/root_replicationConfiguration.xml");
61                  
62                  ReplicationConfiguration replicationCfg = (ReplicationConfiguration) XmlUtils.unmarshal(fis, ReplicationConfiguration.class);
63                  Properties props = new Properties();
64                  props.put(Property.JUDDI_NODE_ID, "uddi:a_custom_node");
65                  props.put(Property.JUDDI_BASE_URL, "http://juddi.apache.org");
66                  props.put(Property.JUDDI_BASE_URL_SECURE, "https://juddi.apache.org");
67                  
68                  Configuration config = new MapConfiguration(props);
69                  String thisnode = "uddi:a_custom_node";
70                  
71                  ReplicationConfiguration result = Install.applyReplicationTokenChanges(replicationCfg, config, thisnode);
72                  StringWriter sw = new StringWriter();
73                  JAXB.marshal(result, sw);
74                  Assert.assertFalse(sw.toString().contains("${juddi.nodeId}"));
75                  Assert.assertFalse(sw.toString().contains("${juddi.server.baseurlsecure}"));
76                  Assert.assertFalse(sw.toString().contains("${juddi.server.baseurl}"));
77                  
78          }
79          
80  }