This project has retired. For details please refer to its Attic page.
TckPublisher xref
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.v3.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  
25  /**
26   * @author <a href="mailto:kstam@apache.org">Kurt T Stam</a>
27   * @author <a href="mailto:jfaath@apache.org">Jeff Faath</a>
28   * @author <a href="mailto:alexoree@apache.org">Alex O'Ree</a>
29   */
30  public class TckPublisher {
31  
32          private static Properties tckProperties = new Properties();
33          public final static String JOE_PUBLISHER_XML = "uddi_data/joepublisher/publisher.xml";
34          //public final static String TMODEL_PUBLISHER_XML = "uddi_data/tmodels/publisher.xml";
35          public final static String SAM_SYNDICATOR_XML = "uddi_data/samsyndicator/publisher.xml";
36          public final static String MARY_PUBLISHER_XML = "uddi_data/marypublisher/publisher.xml";
37  
38          private static Log logger = LogFactory.getLog(TckPublisher.class);
39  
40          static {
41                  String s = System.getProperty("tck.properties");
42                  InputStream inputSteam = null;
43                  try {
44                          File f = null;
45                          if (s != null && s.length() != 0) {
46                                  f = new File(s);
47                          }
48                          if (f == null || !f.exists()) {
49                                  f = new File("tck.properties");
50                          }
51                          if (f.exists()) {
52  
53                                  inputSteam = new FileInputStream(f);
54                                  logger.info("Loading tck.properties from " + f.getAbsolutePath());
55                          } else {
56                                  inputSteam = TckPublisher.class.getResourceAsStream("/tck.properties");
57                                  logger.info("Loading tck.properties as a classpath resource, probably within uddi-tck-base.jar");
58                          }
59                          tckProperties.load(inputSteam);
60                  } catch (IOException ioe) {
61                          logger.warn(ioe);
62                  } finally {
63                          if (inputSteam != null) {
64                                  try {
65                                          inputSteam.close();
66                                  } catch (Exception ex) {
67                                      logger.debug(ex);
68                                  }
69                          }
70                  }
71          }
72          
73          /**
74           * is enabled for UDDI v3 tests
75           * @return 
76           */
77          public final static boolean isEnabled(){
78               return Boolean.parseBoolean(tckProperties.getProperty("uddiv3.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                 return "uddi".equalsIgnoreCase(x);
140         }
141 
142         public static boolean isReplicationEnabled() {
143                 String x = tckProperties.getProperty("replication.enabled");
144                 return "true".equalsIgnoreCase(x);
145         }
146 
147         public static boolean isInquiryRestEnabled() {
148                 String x = tckProperties.getProperty("rest.enabled");
149                 return "true".equalsIgnoreCase(x);
150         }
151 
152         public static boolean isValueSetAPIEnabled() {
153                 String x = tckProperties.getProperty("vsv.enabled");
154                 return "true".equalsIgnoreCase(x);
155         }
156 
157         public static boolean isSubscriptionEnabled() {
158                 String x = tckProperties.getProperty("sub.enabled");
159                 return "true".equalsIgnoreCase(x);
160         }
161 
162         public static boolean isCustodyTransferEnabled() {
163                 String x = tckProperties.getProperty("transfer.enabled");
164                 return "true".equalsIgnoreCase(x);
165         }
166 
167         public static boolean isJUDDI() {
168                 String x = tckProperties.getProperty("isJuddi");
169                 return "true".equalsIgnoreCase(x);
170         }
171 
172         @Deprecated
173         public static boolean isRMI() {
174                 return false;
175         }
176 
177         public static boolean isLoadTest() {
178                 String x = tckProperties.getProperty("loadtest.enable");
179                 return "true".equalsIgnoreCase(x);
180         }
181 
182         public static boolean isBPEL() {
183                 String x = tckProperties.getProperty("bpel.enable");
184                 return "true".equalsIgnoreCase(x);
185         }
186 
187         public static int getMaxLoadServices() {
188                 String x = tckProperties.getProperty("loadtest.maxbusinesses");
189                 if (x != null) {
190                         try {
191                                 return Integer.parseInt(x);
192                         } catch (Exception ex) {
193                                 ex.printStackTrace();
194                         }
195                 }
196 
197                 return 1100;
198         }
199 
200         public static Properties getProperties() {
201                 return tckProperties;
202         }
203 
204         /**
205          * time in seconds, default is 60
206          *
207          * @return the subscription timeout in seconds or the default is not defined
208          */
209         public static int getSubscriptionTimeout() {
210                 String x = tckProperties.getProperty("sub.timeout");
211                 if (x != null) {
212                         try {
213                                 return Integer.parseInt(x);
214                         } catch (Exception ex) {
215                                 ex.printStackTrace();
216                         }
217                 }
218 
219                 return 60;
220         }
221 
222         public static boolean isSMTPEnabled() {
223                 String x = tckProperties.getProperty("smtp.notify.enabled");
224                 return "true".equalsIgnoreCase(x);
225         }
226 }