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