View Javadoc
1   /*
2    * Copyright 2001-2009 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    *      http://www.apache.org/licenses/LICENSE-2.0
8    * 
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package org.apache.juddi.v2.tck;
16  
17  import java.io.File;
18  import java.io.FileInputStream;
19  import java.io.IOException;
20  import java.io.InputStream;
21  import java.util.Properties;
22  import org.apache.commons.logging.Log;
23  import org.apache.commons.logging.LogFactory;
24  import org.apache.juddi.v3.tck.Property;
25  
26  /**
27   * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
28   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
29   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
30   */
31  public class TckPublisher {
32  
33          private static Properties tckProperties = new Properties();
34          public final static String JOE_PUBLISHER_XML = "uddi_data_v2/joepublisher/publisher.xml";
35          //public final static String TMODEL_PUBLISHER_XML = "uddi_data_v2/tmodels/publisher.xml";
36          public final static String SAM_SYNDICATOR_XML = "uddi_data_v2/samsyndicator/publisher.xml";
37          public final static String MARY_PUBLISHER_XML = "uddi_data_v2/marypublisher/publisher.xml";
38  
39          private static Log logger = LogFactory.getLog(TckPublisher.class);
40  
41          static {
42                  String s = System.getProperty("tck.properties");
43                  InputStream inputSteam = null;
44                  try {
45                          File f = null;
46                          if (s != null && s.length() != 0) {
47                                  f = new File(s);
48                          }
49                          if (f == null || !f.exists()) {
50                                  f = new File("tck.properties");
51                          }
52                          if (f.exists()) {
53  
54                                  inputSteam = new FileInputStream(f);
55                                  logger.info("Loading tck.properties from " + f.getAbsolutePath());
56                          } else {
57                                  inputSteam = TckPublisher.class.getResourceAsStream("/tck.properties");
58                                  logger.info("Loading tck.properties as a classpath resource, probably within uddi-tck-base.jar");
59                          }
60                          tckProperties.load(inputSteam);
61                  } catch (IOException ioe) {
62                          ioe.printStackTrace();
63                  } finally {
64                          if (inputSteam != null) {
65                                  try {
66                                          inputSteam.close();
67                                  } catch (Exception ex) {
68                                  }
69                          }
70                  }
71          }
72          
73          /**
74           * is enabled for UDDI v2 tests
75           * @return 
76           */
77          public final static boolean isEnabled(){
78               return Boolean.parseBoolean(tckProperties.getProperty("uddiv2.enabled", "false"));
79          }
80  
81          public final static String getRootPublisherId() {
82                  return tckProperties.getProperty(Property.ROOT_PUBLISHER);
83          }
84  
85          public final static String getRootPassword() {
86                  return tckProperties.getProperty(Property.ROOT_PASSWORD);
87          }
88  
89          public final static String getUDDIPublisherId() {
90                  return tckProperties.getProperty(Property.UDDI_PUBLISHER);
91          }
92  
93          public final static String getUDDIPassword() {
94                  return tckProperties.getProperty(Property.UDDI_PASSWORD);
95          }
96  
97          public final static String getJoePublisherId() {
98                  return tckProperties.getProperty(Property.JOE_PUBLISHER);
99          }
100 
101         public final static String getJoePassword() {
102                 return tckProperties.getProperty(Property.JOE_PASSWORD);
103         }
104 
105         public final static String getTModelPublisherId() {
106                 return tckProperties.getProperty(Property.TMODEL_PUBLISHER);
107         }
108 
109         public final static String getTModelPassword() {
110                 return tckProperties.getProperty(Property.TMODEL_PASSWORD);
111         }
112 
113         public final static String getSamPublisherId() {
114                 return tckProperties.getProperty(Property.SAM_PUBLISHER);
115         }
116 
117         public final static String getSamPassword() {
118                 return tckProperties.getProperty(Property.SAM_PASSWORD);
119         }
120 
121         public final static String getMaryPublisherId() {
122                 return tckProperties.getProperty(Property.MARY_PUBLISHER);
123         }
124 
125         public final static String getMaryPassword() {
126                 return tckProperties.getProperty(Property.MARY_PASSWORD);
127         }
128 
129         public final static String getRiftSawPublisherId() {
130                 return tckProperties.getProperty(Property.RIFTSAW_PUBLISHER);
131         }
132 
133         public final static String getRiftSawPassword() {
134                 return tckProperties.getProperty(Property.RIFTSAW_PASSWORD);
135         }
136 
137         public static boolean isUDDIAuthMode() {
138                 String x = tckProperties.getProperty("auth_mode");
139                 if (x != null && x.equalsIgnoreCase("uddi")) {
140                         return true;
141                 }
142                 return false;
143         }
144 
145         public static boolean isReplicationEnabled() {
146                 String x = tckProperties.getProperty("replication.enabled");
147                 if (x != null && x.equalsIgnoreCase("true")) {
148                         return true;
149                 }
150                 return false;
151         }
152 
153         public static boolean isInquiryRestEnabled() {
154                 String x = tckProperties.getProperty("rest.enabled");
155                 if (x != null && x.equalsIgnoreCase("true")) {
156                         return true;
157                 }
158                 return false;
159         }
160 
161         public static boolean isValueSetAPIEnabled() {
162                 String x = tckProperties.getProperty("vsv.enabled");
163                 if (x != null && x.equalsIgnoreCase("true")) {
164                         return true;
165                 }
166                 return false;
167         }
168 
169         public static boolean isSubscriptionEnabled() {
170                 String x = tckProperties.getProperty("sub.enabled");
171                 if (x != null && x.equalsIgnoreCase("true")) {
172                         return true;
173                 }
174                 return false;
175         }
176 
177         public static boolean isCustodyTransferEnabled() {
178                 String x = tckProperties.getProperty("transfer.enabled");
179                 if (x != null && x.equalsIgnoreCase("true")) {
180                         return true;
181                 }
182                 return false;
183         }
184 
185         public static boolean isJUDDI() {
186                 String x = tckProperties.getProperty("isJuddi");
187                 if (x.equalsIgnoreCase("true")) {
188                         return true;
189                 }
190                 return false;
191         }
192 
193         @Deprecated
194         public static boolean isRMI() {
195                 return false;
196         }
197 
198         public static boolean isLoadTest() {
199                 String x = tckProperties.getProperty("loadtest.enable");
200                 if (x.equalsIgnoreCase("true")) {
201                         return true;
202                 }
203                 return false;
204         }
205 
206         public static boolean isBPEL() {
207                 String x = tckProperties.getProperty("bpel.enable");
208                 if (x.equalsIgnoreCase("true")) {
209                         return true;
210                 }
211                 return false;
212         }
213 
214         public static int getMaxLoadServices() {
215                 String x = tckProperties.getProperty("loadtest.maxbusinesses");
216                 if (x != null) {
217                         try {
218                                 return Integer.parseInt(x);
219                         } catch (Exception ex) {
220                                 ex.printStackTrace();
221                         }
222                 }
223 
224                 return 1100;
225         }
226 
227         public static Properties getProperties() {
228                 return tckProperties;
229         }
230 
231         /**
232          * time in seconds, default is 60
233          *
234          * @return the subscription timeout in seconds or the default is not defined
235          */
236         public static int getSubscriptionTimeout() {
237                 String x = tckProperties.getProperty("sub.timeout");
238                 if (x != null) {
239                         try {
240                                 return Integer.parseInt(x);
241                         } catch (Exception ex) {
242                                 ex.printStackTrace();
243                         }
244                 }
245 
246                 return 60;
247         }
248 }