2 * ================================================================================
\r
4 * ================================================================================
\r
5 * Copyright (C) 2017 AT&T Intellectual Property
\r
6 * ================================================================================
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
18 * ================================================================================
\r
20 package org.openecomp.portalapp.portal.controller;
\r
22 import java.io.IOException;
\r
23 import java.io.InputStream;
\r
24 import java.util.Properties;
\r
27 * Trivial extension of Properties that populates itself from a known source.
\r
29 public class SharedContextTestProperties extends Properties {
\r
31 private static final long serialVersionUID = -4064100267979036550L;
\r
34 public static final String HOSTNAME = "hostname";
\r
35 public static final String PORT = "port";
\r
36 public static final String SECURE = "secure";
\r
37 public static final String APPNAME = "appname";
\r
38 public static final String RESTPATH = "restpath";
\r
39 public static final String UEBKEY = "uebkey";
\r
40 public static final String USERNAME = "username";
\r
41 public static final String PASSWORD = "password";
\r
44 * Expected on the classpath
\r
46 private static final String propertiesFileName = "shared-context-test.properties";
\r
49 * Constructor populates itself from properties file found in same package.
\r
53 public SharedContextTestProperties() throws IOException {
\r
54 InputStream inStream = getClass().getResourceAsStream(propertiesFileName);
\r
55 if (inStream == null)
\r
56 throw new IOException("Failed to find file on classpath: " + propertiesFileName);
\r
57 super.load(inStream);
\r
61 public int getProperty(final String name, final int defVal) throws NumberFormatException {
\r
62 String prop = getProperty(name);
\r
65 return Integer.parseInt(prop);
\r
68 public boolean getProperty(final String name, final boolean defVal) {
\r
69 String prop = getProperty(name);
\r
72 return Boolean.parseBoolean(prop);
\r
76 public static void main(String[] args) throws Exception {
\r
77 SharedContextTestProperties p = new SharedContextTestProperties();
\r
78 System.out.println("Property " + SharedContextTestProperties.HOSTNAME + " = "
\r
79 + p.getProperty(SharedContextTestProperties.HOSTNAME));
\r