1 package org.openecomp.portalapp.portal.controller;
3 import java.io.IOException;
4 import java.io.InputStream;
5 import java.util.Properties;
8 * Trivial extension of Properties that populates itself from a known source.
10 public class SharedContextTestProperties extends Properties {
12 private static final long serialVersionUID = -4064100267979036550L;
15 public static final String HOSTNAME = "hostname";
16 public static final String PORT = "port";
17 public static final String SECURE = "secure";
18 public static final String APPNAME = "appname";
19 public static final String RESTPATH = "restpath";
20 public static final String UEBKEY = "uebkey";
21 public static final String USERNAME = "username";
22 public static final String PASSWORD = "password";
25 * Expected on the classpath
27 private static final String propertiesFileName = "shared-context-test.properties";
30 * Constructor populates itself from properties file found in same package.
34 public SharedContextTestProperties() throws IOException {
35 InputStream inStream = getClass().getResourceAsStream(propertiesFileName);
37 throw new IOException("Failed to find file on classpath: " + propertiesFileName);
42 public int getProperty(final String name, final int defVal) throws NumberFormatException {
43 String prop = getProperty(name);
46 return Integer.parseInt(prop);
49 public boolean getProperty(final String name, final boolean defVal) {
50 String prop = getProperty(name);
53 return Boolean.parseBoolean(prop);
57 public static void main(String[] args) throws Exception {
58 SharedContextTestProperties p = new SharedContextTestProperties();
59 System.out.println("Property " + SharedContextTestProperties.HOSTNAME + " = "
60 + p.getProperty(SharedContextTestProperties.HOSTNAME));