aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPamela Dragosh <pdragosh@research.att.com>2018-06-20 17:26:17 +0000
committerGerrit Code Review <gerrit@onap.org>2018-06-20 17:26:17 +0000
commitb5a47dcb16af9e90e46d08d0b5faedb3302bca8b (patch)
tree33236fe4bd7b1b7398d760be467eafdad090cb98
parentcea49f658fe6eb93c6d9d8fd1049f2fcb77b1ac4 (diff)
parent35d4e5606dbbe055f29afb5e837c000863d5a15f (diff)
Merge "Remove references to SpecPropertyConfiguration"
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java4
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java1
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java38
-rw-r--r--feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/SpecProperties.java117
-rw-r--r--feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java14
-rw-r--r--feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest2.java14
-rw-r--r--feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java30
-rw-r--r--feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/SpecPropertiesTest.java224
8 files changed, 58 insertions, 384 deletions
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
index d42b8de1..bf35bcf5 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingFeature.java
@@ -25,6 +25,7 @@ import java.util.Properties;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CountDownLatch;
+import org.onap.policy.common.utils.properties.SpecProperties;
import org.onap.policy.common.utils.properties.exception.PropertyException;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.event.comm.TopicEndpoint;
@@ -128,6 +129,9 @@ public class PoolingFeature implements PolicyEngineFeatureAPI, PolicyControllerF
logger.info("initializing " + PoolingProperties.FEATURE_NAME);
featProps = factory.getProperties(PoolingProperties.FEATURE_NAME);
+ // remove any generic pooling topic - always use controller-specific property
+ featProps.remove(PoolingProperties.POOLING_TOPIC);
+
factory.initTopicSources(featProps);
factory.initTopicSinks(featProps);
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
index 33f45085..86cec4c3 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingManagerImpl.java
@@ -29,6 +29,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
+import org.onap.policy.common.utils.properties.SpecProperties;
import org.onap.policy.drools.controller.DroolsController;
import org.onap.policy.drools.event.comm.Topic.CommInfrastructure;
import org.onap.policy.drools.event.comm.TopicListener;
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
index ad118727..1482366f 100644
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
+++ b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/PoolingProperties.java
@@ -21,13 +21,14 @@
package org.onap.policy.drools.pooling;
import java.util.Properties;
-import org.onap.policy.common.utils.properties.SpecPropertyConfiguration;
+import org.onap.policy.common.utils.properties.PropertyConfiguration;
+import org.onap.policy.common.utils.properties.SpecProperties;
import org.onap.policy.common.utils.properties.exception.PropertyException;
/**
* Properties used by the pooling feature, specific to a controller.
*/
-public class PoolingProperties extends SpecPropertyConfiguration {
+public class PoolingProperties extends PropertyConfiguration {
/**
* The feature name, used to retrieve properties.
@@ -39,29 +40,16 @@ public class PoolingProperties extends SpecPropertyConfiguration {
*/
public static final String PREFIX = "pooling.";
- /*
- * These properties are not used by a SpecPropertyConfiguration, thus
- * they do not use any of the "{xxx}" forms.
- */
public static final String FEATURE_ENABLED = PREFIX + "enabled";
-
- /*
- * These properties REQUIRE a controller name, thus they use the "{$}" form.
- */
- public static final String POOLING_TOPIC = PREFIX + "{$}.topic";
-
- /*
- * These properties allow the controller name to be left out, thus they use
- * the "{prefix?suffix}" form.
- */
- public static final String OFFLINE_LIMIT = PREFIX + "{?.}offline.queue.limit";
- public static final String OFFLINE_AGE_MS = PREFIX + "{?.}offline.queue.age.milliseconds";
- public static final String OFFLINE_PUB_WAIT_MS = PREFIX + "{?.}offline.publish.wait.milliseconds";
- public static final String START_HEARTBEAT_MS = PREFIX + "{?.}start.heartbeat.milliseconds";
- public static final String REACTIVATE_MS = PREFIX + "{?.}reactivate.milliseconds";
- public static final String IDENTIFICATION_MS = PREFIX + "{?.}identification.milliseconds";
- public static final String ACTIVE_HEARTBEAT_MS = PREFIX + "{?.}active.heartbeat.milliseconds";
- public static final String INTER_HEARTBEAT_MS = PREFIX + "{?.}inter.heartbeat.milliseconds";
+ public static final String POOLING_TOPIC = PREFIX + "topic";
+ public static final String OFFLINE_LIMIT = PREFIX + "offline.queue.limit";
+ public static final String OFFLINE_AGE_MS = PREFIX + "offline.queue.age.milliseconds";
+ public static final String OFFLINE_PUB_WAIT_MS = PREFIX + "offline.publish.wait.milliseconds";
+ public static final String START_HEARTBEAT_MS = PREFIX + "start.heartbeat.milliseconds";
+ public static final String REACTIVATE_MS = PREFIX + "reactivate.milliseconds";
+ public static final String IDENTIFICATION_MS = PREFIX + "identification.milliseconds";
+ public static final String ACTIVE_HEARTBEAT_MS = PREFIX + "active.heartbeat.milliseconds";
+ public static final String INTER_HEARTBEAT_MS = PREFIX + "inter.heartbeat.milliseconds";
/**
* Type of item that the extractors will be extracting.
@@ -147,7 +135,7 @@ public class PoolingProperties extends SpecPropertyConfiguration {
*
*/
public PoolingProperties(String controllerName, Properties props) throws PropertyException {
- super(controllerName, props);
+ super(new SpecProperties(PREFIX, controllerName, props));
source = props;
}
diff --git a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/SpecProperties.java b/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/SpecProperties.java
deleted file mode 100644
index c831f706..00000000
--- a/feature-pooling-dmaap/src/main/java/org/onap/policy/drools/pooling/SpecProperties.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.pooling;
-
-import java.util.Properties;
-
-/**
- * Properties with an optional specialization (e.g., session name, controller name).
- */
-public class SpecProperties extends Properties {
- private static final long serialVersionUID = 1L;
-
- /**
- * The property prefix, ending with ".".
- */
- private final String prefix;
-
- /**
- * The specialized property prefix, ending with ".".
- */
- private final String specPrefix;
-
- /**
- *
- * @param prefix the property name prefix that appears before any specialization, may
- * be ""
- * @param specialization the property name specialization (e.g., session name)
- */
- public SpecProperties(String prefix, String specialization) {
- this.prefix = withTrailingDot(prefix);
- this.specPrefix = withTrailingDot(this.prefix + specialization);
- }
-
- /**
- *
- * @param prefix the property name prefix that appears before any specialization, may
- * be ""
- * @param specialization the property name specialization (e.g., session name)
- * @param props the default properties
- */
- public SpecProperties(String prefix, String specialization, Properties props) {
- super(props);
-
- this.prefix = withTrailingDot(prefix);
- this.specPrefix = withTrailingDot(this.prefix + specialization);
- }
-
- /**
- * Adds a trailing "." to a String, if it doesn't already have one.
- *
- * @param text text to which the "." should be added
- * @return the text, with a trailing "."
- */
- private static String withTrailingDot(String text) {
- return text.isEmpty() || text.endsWith(".") ? text : text + ".";
- }
-
- /**
- * Gets the property whose value has the given key, looking first for the specialized
- * property name, and then for the generalized property name.
- *
- * @param key property name, without the specialization
- * @return the value from the property set, or {@code null} if the property set does
- * not contain the value
- */
- @Override
- public String getProperty(String key) {
- if (!key.startsWith(prefix)) {
- return super.getProperty(key);
- }
-
- String suffix = key.substring(prefix.length());
-
- String val = super.getProperty(specPrefix + suffix);
- if (val != null) {
- return val;
- }
-
- return super.getProperty(key);
- }
-
- protected String getPrefix() {
- return prefix;
- }
-
- protected String getSpecPrefix() {
- return specPrefix;
- }
-
- @Override
- public final int hashCode() {
- throw new UnsupportedOperationException("SpecProperties cannot be hashed");
- }
-
- @Override
- public final boolean equals(Object obj) {
- throw new UnsupportedOperationException("cannot compare SpecProperties");
- }
-}
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
index d453e746..8683103c 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest.java
@@ -26,7 +26,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.onap.policy.common.utils.properties.SpecPropertyConfiguration.specialize;
+import static org.onap.policy.drools.pooling.PoolingProperties.PREFIX;
import java.io.IOException;
import java.util.Arrays;
import java.util.Deque;
@@ -994,6 +994,18 @@ public class FeatureTest {
public PolicyController getController(DroolsController droolsController) {
return context.getController(droolsController);
}
+
+ /**
+ * Embeds a specializer within a property name, after the prefix.
+ *
+ * @param propnm property name into which it should be embedded
+ * @param spec specializer to be embedded
+ * @return the property name, with the specializer embedded within it
+ */
+ private String specialize(String propnm, String spec) {
+ String suffix = propnm.substring(PREFIX.length());
+ return PREFIX + spec + "." + suffix;
+ }
}
/**
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest2.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest2.java
index 6884bec8..298af064 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest2.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/FeatureTest2.java
@@ -26,7 +26,7 @@ import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
-import static org.onap.policy.common.utils.properties.SpecPropertyConfiguration.specialize;
+import static org.onap.policy.drools.pooling.PoolingProperties.PREFIX;
import java.io.IOException;
import java.util.Deque;
import java.util.IdentityHashMap;
@@ -674,6 +674,18 @@ public class FeatureTest2 {
public PolicyController getController(DroolsController droolsController) {
return context.getController(droolsController);
}
+
+ /**
+ * Embeds a specializer within a property name, after the prefix.
+ *
+ * @param propnm property name into which it should be embedded
+ * @param spec specializer to be embedded
+ * @return the property name, with the specializer embedded within it
+ */
+ private String specialize(String propnm, String spec) {
+ String suffix = propnm.substring(PREFIX.length());
+ return PREFIX + spec + "." + suffix;
+ }
}
/**
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java
index 459c770a..eac8bfb1 100644
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java
+++ b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/PoolingPropertiesTest.java
@@ -21,9 +21,6 @@
package org.onap.policy.drools.pooling;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.onap.policy.common.utils.properties.SpecPropertyConfiguration.generalize;
-import static org.onap.policy.common.utils.properties.SpecPropertyConfiguration.specialize;
import static org.onap.policy.drools.pooling.PoolingProperties.ACTIVE_HEARTBEAT_MS;
import static org.onap.policy.drools.pooling.PoolingProperties.FEATURE_ENABLED;
import static org.onap.policy.drools.pooling.PoolingProperties.IDENTIFICATION_MS;
@@ -32,6 +29,7 @@ import static org.onap.policy.drools.pooling.PoolingProperties.OFFLINE_AGE_MS;
import static org.onap.policy.drools.pooling.PoolingProperties.OFFLINE_LIMIT;
import static org.onap.policy.drools.pooling.PoolingProperties.OFFLINE_PUB_WAIT_MS;
import static org.onap.policy.drools.pooling.PoolingProperties.POOLING_TOPIC;
+import static org.onap.policy.drools.pooling.PoolingProperties.PREFIX;
import static org.onap.policy.drools.pooling.PoolingProperties.REACTIVATE_MS;
import static org.onap.policy.drools.pooling.PoolingProperties.START_HEARTBEAT_MS;
import java.util.Properties;
@@ -82,12 +80,6 @@ public class PoolingPropertiesTest {
assertEquals(STD_POOLING_TOPIC, pooling.getPoolingTopic());
}
- @Test(expected = IllegalArgumentException.class)
- public void testGetPoolingTopic_Generalize() {
- // shouldn't be able to generalize the topic
- generalize(POOLING_TOPIC);
- }
-
@Test
public void testGetOfflineLimit() throws PropertyException {
doTest(OFFLINE_LIMIT, STD_OFFLINE_LIMIT, 1000, xxx -> pooling.getOfflineLimit());
@@ -147,16 +139,10 @@ public class PoolingPropertiesTest {
assertEquals("special " + propnm, specValue, func.apply(null));
/*
- * Ensure the property supports generalization - this will throw an exception if
- * it does not.
- */
- assertFalse(propnm.equals(generalize(propnm)));
-
- /*
* Without the property - should use the default value.
*/
plain.remove(specialize(propnm, CONTROLLER));
- plain.remove(generalize(propnm));
+ plain.remove(propnm);
pooling = new PoolingProperties(CONTROLLER, plain);
assertEquals("default " + propnm, dfltValue, func.apply(null));
}
@@ -183,4 +169,16 @@ public class PoolingPropertiesTest {
return props;
}
+
+ /**
+ * Embeds a specializer within a property name, after the prefix.
+ *
+ * @param propnm property name into which it should be embedded
+ * @param spec specializer to be embedded
+ * @return the property name, with the specializer embedded within it
+ */
+ private String specialize(String propnm, String spec) {
+ String suffix = propnm.substring(PREFIX.length());
+ return PREFIX + spec + "." + suffix;
+ }
}
diff --git a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/SpecPropertiesTest.java b/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/SpecPropertiesTest.java
deleted file mode 100644
index d09650db..00000000
--- a/feature-pooling-dmaap/src/test/java/org/onap/policy/drools/pooling/SpecPropertiesTest.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * ============LICENSE_START=======================================================
- * ONAP
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-package org.onap.policy.drools.pooling;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
-import java.util.Properties;
-import org.junit.Before;
-import org.junit.Test;
-
-public class SpecPropertiesTest {
-
- /**
- * Property prefix of interest.
- */
- private static final String MY_PREFIX = "my.prefix";
-
- /**
- * Specialization, which follows the prefix.
- */
- private static final String MY_SPEC = "my.spec";
-
- /**
- * Generalized prefix (i.e., without the spec).
- */
- private static final String PREFIX_GEN = MY_PREFIX + ".";
-
- /**
- * Specialized prefix (i.e., with the spec).
- */
- private static final String PREFIX_SPEC = PREFIX_GEN + MY_SPEC + ".";
-
- /**
- * Suffix to add to property names to generate names of properties that are not
- * populated.
- */
- private static final String SUFFIX = ".suffix";
-
- /**
- * Property name without a prefix.
- */
- private static final String PROP_NO_PREFIX = "other";
-
- /**
- * Generalized property name (i.e., without the spec).
- */
- private static final String PROP_GEN = PREFIX_GEN + "generalized";
-
- // property names that include the spec
- private static final String PROP_SPEC = PREFIX_SPEC + "specialized";
- private static final String PROP_UNKNOWN = PREFIX_SPEC + "unknown";
-
- // property values
- private static final String VAL_NO_PREFIX = "no-prefix";
- private static final String VAL_GEN = "gen";
- private static final String VAL_SPEC = "spec";
-
- private static final String VAL_DEFAULT = "default value";
-
- private Properties supportingProps;
- private SpecProperties props;
-
- @Before
- public void setUp() {
- supportingProps = new Properties();
-
- supportingProps.setProperty(PROP_NO_PREFIX, VAL_NO_PREFIX);
- supportingProps.setProperty(PROP_GEN, VAL_GEN);
- supportingProps.setProperty(PROP_SPEC, VAL_SPEC);
-
- props = new SpecProperties(MY_PREFIX, MY_SPEC);
-
- props.putAll(supportingProps);
- }
-
- @Test
- public void testSpecPropertiesStringString() {
-
- // no supporting properties
- props = new SpecProperties(MY_PREFIX, MY_SPEC);
-
- assertEquals(PREFIX_GEN, props.getPrefix());
- assertEquals(PREFIX_SPEC, props.getSpecPrefix());
-
- // everything is null
- assertNull(props.getProperty(gen(PROP_NO_PREFIX)));
- assertNull(props.getProperty(gen(PROP_GEN)));
- assertNull(props.getProperty(gen(PROP_SPEC)));
- assertNull(props.getProperty(gen(PROP_UNKNOWN)));
- }
-
- @Test
- public void testSpecPropertiesStringStringProperties() {
-
- // use supportingProps as default properties
- props = new SpecProperties(MY_PREFIX, MY_SPEC, supportingProps);
-
- assertEquals(PREFIX_GEN, props.getPrefix());
- assertEquals(PREFIX_SPEC, props.getSpecPrefix());
-
- assertEquals(VAL_NO_PREFIX, props.getProperty(gen(PROP_NO_PREFIX)));
- assertEquals(VAL_GEN, props.getProperty(gen(PROP_GEN)));
- assertEquals(VAL_SPEC, props.getProperty(gen(PROP_SPEC)));
- assertNull(props.getProperty(gen(PROP_UNKNOWN)));
- }
-
- @Test
- public void testSpecPropertiesStringStringProperties_EmptyPrefix() {
- supportingProps = new Properties();
-
- supportingProps.setProperty(PROP_NO_PREFIX, VAL_NO_PREFIX);
- supportingProps.setProperty("a.value", VAL_GEN);
- supportingProps.setProperty("b.value", VAL_GEN);
- supportingProps.setProperty(MY_SPEC + ".b.value", VAL_SPEC);
-
- // no supporting properties
- props = new SpecProperties("", MY_SPEC, supportingProps);
-
- assertEquals(VAL_NO_PREFIX, props.getProperty(gen(PROP_NO_PREFIX)));
- assertEquals(VAL_GEN, props.getProperty(gen("a.value")));
- assertEquals(VAL_SPEC, props.getProperty(MY_SPEC + ".b.value"));
- assertNull(props.getProperty(gen(PROP_UNKNOWN)));
- }
-
- @Test
- public void testWithTrailingDot() {
- // neither has trailing dot
- assertEquals(PREFIX_GEN, props.getPrefix());
- assertEquals(PREFIX_SPEC, props.getSpecPrefix());
-
- // both have trailing dot
- props = new SpecProperties(PREFIX_GEN, MY_SPEC + ".");
- assertEquals(PREFIX_GEN, props.getPrefix());
- assertEquals(PREFIX_SPEC, props.getSpecPrefix());
-
- // first is empty
- props = new SpecProperties("", MY_SPEC);
- assertEquals("", props.getPrefix());
- assertEquals(MY_SPEC + ".", props.getSpecPrefix());
-
- // second is empty
- props = new SpecProperties(PREFIX_GEN, "");
- assertEquals(PREFIX_GEN, props.getPrefix());
- assertEquals(PREFIX_GEN, props.getSpecPrefix());
- }
-
- @Test
- public void testGetPropertyString() {
- // the key does contain the prefix
- assertEquals(VAL_NO_PREFIX, props.getProperty(gen(PROP_NO_PREFIX)));
- assertNull(props.getProperty(gen(PROP_NO_PREFIX + SUFFIX)));
-
- // specialized value exists
- assertEquals(VAL_GEN, props.getProperty(gen(PROP_GEN)));
- assertNull(props.getProperty(gen(PROP_GEN + SUFFIX)));
-
- // generalized value exists
- assertEquals(VAL_SPEC, props.getProperty(gen(PROP_SPEC)));
- assertNull(props.getProperty(gen(PROP_SPEC + SUFFIX)));
-
- // not found
- assertNull(props.getProperty(gen(PROP_UNKNOWN)));
- assertNull(props.getProperty(gen(PROP_UNKNOWN + SUFFIX)));
- }
-
- @Test
- public void testGetPropertyStringString() {
- // the key does contain the prefix
- assertEquals(VAL_NO_PREFIX, props.getProperty(gen(PROP_NO_PREFIX), VAL_DEFAULT));
- assertEquals(VAL_DEFAULT, props.getProperty(gen(PROP_NO_PREFIX + SUFFIX), VAL_DEFAULT));
-
- // specialized value exists
- assertEquals(VAL_GEN, props.getProperty(gen(PROP_GEN), VAL_DEFAULT));
- assertEquals(VAL_DEFAULT, props.getProperty(gen(PROP_GEN + SUFFIX), VAL_DEFAULT));
-
- // generalized value exists
- assertEquals(VAL_SPEC, props.getProperty(gen(PROP_SPEC), VAL_DEFAULT));
- assertEquals(VAL_DEFAULT, props.getProperty(gen(PROP_SPEC + SUFFIX), VAL_DEFAULT));
-
- // not found
- assertEquals(VAL_DEFAULT, props.getProperty(gen(PROP_UNKNOWN), VAL_DEFAULT));
- assertEquals(VAL_DEFAULT, props.getProperty(gen(PROP_UNKNOWN + SUFFIX), VAL_DEFAULT));
-
- // can return null
- assertNull(props.getProperty(gen(PROP_UNKNOWN), null));
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testHashCode() {
- props.hashCode();
- }
-
- @Test(expected = UnsupportedOperationException.class)
- public void testEquals() {
- props.equals(props);
- }
-
- private String gen(String propnm) {
- if (propnm.startsWith(PREFIX_SPEC)) {
- return PREFIX_GEN + propnm.substring(PREFIX_SPEC.length());
- }
-
- return propnm;
- }
-
-}