aboutsummaryrefslogtreecommitdiffstats
path: root/utils/src/test
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-06-18 15:53:30 -0400
committerJim Hahn <jrh3@att.com>2018-06-18 16:19:58 -0400
commitcd5750e1c75294febce97c9567829abdbc3c7030 (patch)
tree98b51f3eb2993dcae95578c4e800e966dc81ef60 /utils/src/test
parent5c04cdde760ff9f92235f29f8892977853bce864 (diff)
Use setXxx() methods for @Property fields
Fortify generates a security exception when PropertyConfiguration attempts to directly update private fields. PropertyConfiguration has been modified to invoke setXxx() methods, instead, to set the values for the fields. Add junit tests for new methods. Change-Id: Ic4420b6348724c5a384d3c2c8bf7b4c0c6350fa9 Issue-ID: POLICY-906 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'utils/src/test')
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/properties/PropertyConfigurationTest.java568
-rw-r--r--utils/src/test/java/org/onap/policy/common/utils/properties/SpecPropertyConfigurationTest.java80
2 files changed, 482 insertions, 166 deletions
diff --git a/utils/src/test/java/org/onap/policy/common/utils/properties/PropertyConfigurationTest.java b/utils/src/test/java/org/onap/policy/common/utils/properties/PropertyConfigurationTest.java
index cf823b5d..121ae384 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/properties/PropertyConfigurationTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/properties/PropertyConfigurationTest.java
@@ -68,15 +68,9 @@ public class PropertyConfigurationTest {
@Test
public void testPropertyConfiguration() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private String value;
- };
-
props.setProperty(THE_VALUE, STRING_VALUE);
- Config cfg = new Config();
+ PlainStringConfig cfg = new PlainStringConfig();
assertEquals(null, cfg.value);
cfg.setAllFields(props);
@@ -85,18 +79,8 @@ public class PropertyConfigurationTest {
@Test
public void testPropertyConfigurationProperties() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private String value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, STRING_VALUE);
- Config cfg = new Config(props);
+ PlainStringConfig cfg = new PlainStringConfig(props);
assertEquals(STRING_VALUE, cfg.value);
}
@@ -111,6 +95,11 @@ public class PropertyConfigurationTest {
@Property(name = "grandparent.value")
protected boolean grandparentValue;
+
+ @SuppressWarnings("unused")
+ public void setGrandparentValue(boolean grandparentValue) {
+ this.grandparentValue = grandparentValue;
+ }
};
/*
@@ -120,12 +109,22 @@ public class PropertyConfigurationTest {
@Property(name = "parent.value")
protected long parentValue;
+
+ @SuppressWarnings("unused")
+ public void setParentValue(long parentValue) {
+ this.parentValue = parentValue;
+ }
};
class Config extends ParentConfig {
@Property(name = THE_VALUE)
private String value;
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
@@ -158,6 +157,11 @@ public class PropertyConfigurationTest {
class Config extends PropertyConfiguration {
private String value;
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
@@ -171,18 +175,8 @@ public class PropertyConfigurationTest {
@Test
public void testSetValueFieldProperties_FieldSet() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private String value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, STRING_VALUE);
- Config cfg = new Config(props);
+ PlainStringConfig cfg = new PlainStringConfig(props);
assertEquals(STRING_VALUE, cfg.value);
}
@@ -196,6 +190,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
props.setProperty(THE_VALUE, STRING_VALUE);
@@ -215,14 +214,19 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(Exception value) {
+ this.value = value;
+ }
};
props.setProperty(THE_VALUE, STRING_VALUE);
new Config(props);
}
- @Test(expected = PropertyMissingException.class)
- public void testSetValueFieldPropertyProperties_NoProperty_NoDefault() throws PropertyException {
+ @Test(expected = PropertyAccessException.class)
+ public void testGetSetter_NoSetter() throws PropertyException {
class Config extends PropertyConfiguration {
@Property(name = THE_VALUE)
@@ -233,15 +237,18 @@ public class PropertyConfigurationTest {
}
};
+ props.setProperty(THE_VALUE, STRING_VALUE);
new Config(props);
}
- @Test(expected = PropertyInvalidException.class)
- public void testSetValueFieldPropertyProperties_InvalidValue() throws PropertyException {
- class Config extends PropertyConfiguration {
+ @Test(expected = PropertyMissingException.class)
+ public void testSetValueMethodFieldPropertiesProperty_NoProperty_NoDefault() throws PropertyException {
+ new PlainStringConfig(props);
+ }
- @Property(name = THE_VALUE)
- private int value;
+ @Test(expected = PropertyInvalidException.class)
+ public void testSetValueMethodFieldPropertiesProperty_InvalidValue() throws PropertyException {
+ class Config extends PlainPrimIntConfig {
public Config(Properties props) throws PropertyException {
super(props);
@@ -260,6 +267,24 @@ public class PropertyConfigurationTest {
new Config(props);
}
+ @Test(expected = PropertyAccessException.class)
+ public void testSetValueMethodFieldPropertiesProperty_MethodEx() throws PropertyException {
+ class Config extends PlainStringConfig {
+
+ public Config(Properties props) throws PropertyException {
+ super(props);
+ }
+
+ @Override
+ public void setValue(String value) {
+ throw new IllegalArgumentException("expected exception");
+ }
+ };
+
+ props.setProperty(THE_VALUE, STRING_VALUE);
+ new Config(props);
+ }
+
@Test
public void testGetValue() throws PropertyException {
// this class contains all of the supported field types
@@ -295,6 +320,96 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public String getStringValue() {
+ return stringValue;
+ }
+
+ @SuppressWarnings("unused")
+ public void setStringValue(String stringValue) {
+ this.stringValue = stringValue;
+ }
+
+ @SuppressWarnings("unused")
+ public Boolean getBoolTrueValue() {
+ return boolTrueValue;
+ }
+
+ @SuppressWarnings("unused")
+ public void setBoolTrueValue(Boolean boolTrueValue) {
+ this.boolTrueValue = boolTrueValue;
+ }
+
+ @SuppressWarnings("unused")
+ public Boolean getBoolFalseValue() {
+ return boolFalseValue;
+ }
+
+ @SuppressWarnings("unused")
+ public void setBoolFalseValue(Boolean boolFalseValue) {
+ this.boolFalseValue = boolFalseValue;
+ }
+
+ @SuppressWarnings("unused")
+ public boolean isPrimBoolTrueValue() {
+ return primBoolTrueValue;
+ }
+
+ @SuppressWarnings("unused")
+ public void setPrimBoolTrueValue(boolean primBoolTrueValue) {
+ this.primBoolTrueValue = primBoolTrueValue;
+ }
+
+ @SuppressWarnings("unused")
+ public boolean isPrimBoolFalseValue() {
+ return primBoolFalseValue;
+ }
+
+ @SuppressWarnings("unused")
+ public void setPrimBoolFalseValue(boolean primBoolFalseValue) {
+ this.primBoolFalseValue = primBoolFalseValue;
+ }
+
+ @SuppressWarnings("unused")
+ public Integer getIntValue() {
+ return intValue;
+ }
+
+ @SuppressWarnings("unused")
+ public void setIntValue(Integer intValue) {
+ this.intValue = intValue;
+ }
+
+ @SuppressWarnings("unused")
+ public int getPrimIntValue() {
+ return primIntValue;
+ }
+
+ @SuppressWarnings("unused")
+ public void setPrimIntValue(int primIntValue) {
+ this.primIntValue = primIntValue;
+ }
+
+ @SuppressWarnings("unused")
+ public Long getLongValue() {
+ return longValue;
+ }
+
+ @SuppressWarnings("unused")
+ public void setLongValue(Long longValue) {
+ this.longValue = longValue;
+ }
+
+ @SuppressWarnings("unused")
+ public long getPrimLongValue() {
+ return primLongValue;
+ }
+
+ @SuppressWarnings("unused")
+ public void setPrimLongValue(long primLongValue) {
+ this.primLongValue = primLongValue;
+ }
};
props.setProperty("string", "a string");
@@ -331,6 +446,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(Exception value) {
+ this.value = value;
+ }
};
props.setProperty(THE_VALUE, STRING_VALUE);
@@ -354,6 +474,21 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setPublicString(String publicString) {
+ this.publicString = publicString;
+ }
+
+ @SuppressWarnings("unused")
+ public void setPrivateString(String privateString) {
+ this.privateString = privateString;
+ }
+
+ @SuppressWarnings("unused")
+ public void setProtectedString(String protectedString) {
+ this.protectedString = protectedString;
+ }
};
props.setProperty("public", "a public string");
@@ -370,7 +505,7 @@ public class PropertyConfigurationTest {
@Test(expected = PropertyAccessException.class)
public void testCheckModifiable_Static() throws PropertyException {
props.setProperty(THE_VALUE, STRING_VALUE);
- new StaticConfig(props);
+ new StaticPropConfig(props);
}
@Test(expected = PropertyAccessException.class)
@@ -390,38 +525,24 @@ public class PropertyConfigurationTest {
new Config(props);
}
+ @Test(expected = PropertyAccessException.class)
+ public void testCheckSetter_Static() throws PropertyException {
+ props.setProperty(THE_VALUE, STRING_VALUE);
+ new StaticMethodConfig(props);
+ }
+
@Test
public void testGetStringValue() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private String value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, STRING_VALUE);
- Config cfg = new Config(props);
+ PlainStringConfig cfg = new PlainStringConfig(props);
assertEquals(STRING_VALUE, cfg.value);
}
@Test
public void testGetBooleanValue_NoDefault() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private Boolean value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, "true");
- Config cfg = new Config(props);
+ PlainBooleanConfig cfg = new PlainBooleanConfig(props);
assertEquals(true, cfg.value);
}
@@ -436,6 +557,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(Boolean value) {
+ this.value = value;
+ }
};
props.setProperty(THE_VALUE, "true");
@@ -452,6 +578,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(Boolean value) {
+ this.value = value;
+ }
};
// property not defined
@@ -479,6 +610,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(Boolean value) {
+ this.value = value;
+ }
};
// property not defined
@@ -506,6 +642,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(Integer value) {
+ this.value = value;
+ }
};
props.setProperty(THE_VALUE, "200");
@@ -524,6 +665,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(Integer value) {
+ this.value = value;
+ }
};
props.setProperty(THE_VALUE, "200");
@@ -540,6 +686,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(Integer value) {
+ this.value = value;
+ }
};
// property not defined
@@ -562,6 +713,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(Long value) {
+ this.value = value;
+ }
};
props.setProperty(THE_VALUE, "20000");
@@ -580,6 +736,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(Long value) {
+ this.value = value;
+ }
};
props.setProperty(THE_VALUE, "20000");
@@ -596,6 +757,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(Long value) {
+ this.value = value;
+ }
};
// property not defined
@@ -610,18 +776,8 @@ public class PropertyConfigurationTest {
@Test
public void testGetPropValue_Prop_NoDefault() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private String value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, STRING_VALUE);
- Config cfg = new Config(props);
+ PlainStringConfig cfg = new PlainStringConfig(props);
assertEquals(STRING_VALUE, cfg.value);
}
@@ -636,6 +792,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
props.setProperty(THE_VALUE, STRING_VALUE);
@@ -654,6 +815,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
props.setProperty(THE_VALUE, "");
@@ -672,6 +838,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
Config cfg = new Config(props);
@@ -689,6 +860,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
Config cfg = new Config(props);
@@ -706,6 +882,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
new Config(props);
@@ -721,6 +902,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
Config cfg = new Config(props);
@@ -730,10 +916,7 @@ public class PropertyConfigurationTest {
@Test
public void testGetRawPropertyValue() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private String value;
+ class Config extends PlainStringConfig {
public Config(Properties props) throws PropertyException {
super(props);
@@ -747,144 +930,64 @@ public class PropertyConfigurationTest {
Config cfg = new Config(props);
- assertEquals(STRING_VALUE, cfg.value);
+ assertEquals(STRING_VALUE, cfg.getValue());
}
@Test
public void testMakeBoolean_True() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private Boolean value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, "true");
- Config cfg = new Config(props);
+ PlainBooleanConfig cfg = new PlainBooleanConfig(props);
assertEquals(true, cfg.value);
}
@Test
public void testMakeBoolean_False() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private Boolean value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, "false");
- Config cfg = new Config(props);
+ PlainBooleanConfig cfg = new PlainBooleanConfig(props);
assertEquals(false, cfg.value);
}
@Test(expected = PropertyInvalidException.class)
public void testMakeBoolean_Invalid() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private Boolean value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, INVALID_VALUE);
- new Config(props);
+ new PlainBooleanConfig(props);
}
@Test
public void testMakeInteger_Valid() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private int value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, "300");
- Config cfg = new Config(props);
+ PlainPrimIntConfig cfg = new PlainPrimIntConfig(props);
assertEquals(300, cfg.value);
}
@Test(expected = PropertyInvalidException.class)
public void testMakeInteger_Invalid() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private int value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, INVALID_VALUE);
- new Config(props);
+ new PlainPrimIntConfig(props);
}
@Test(expected = PropertyInvalidException.class)
public void testMakeInteger_TooBig() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private int value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, String.valueOf(Integer.MAX_VALUE + 10L));
- new Config(props);
+ new PlainPrimIntConfig(props);
}
@Test
public void testMakeLong_Valid() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private long value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, "30000");
- Config cfg = new Config(props);
+ PlainPrimLongConfig cfg = new PlainPrimLongConfig(props);
assertEquals(30000L, cfg.value);
}
@Test(expected = PropertyInvalidException.class)
public void testMakeLong_Invalid() throws PropertyException {
- class Config extends PropertyConfiguration {
-
- @Property(name = THE_VALUE)
- private long value;
-
- public Config(Properties props) throws PropertyException {
- super(props);
- }
- };
-
props.setProperty(THE_VALUE, INVALID_VALUE);
- new Config(props);
+ new PlainPrimLongConfig(props);
}
@Test
@@ -897,6 +1000,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(long value) {
+ this.value = value;
+ }
};
Config cfg = new Config(props);
@@ -914,6 +1022,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(long value) {
+ this.value = value;
+ }
};
new Config(props);
@@ -929,6 +1042,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(long value) {
+ this.value = value;
+ }
};
new Config(props);
@@ -944,6 +1062,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
// missing property - should default to ""
@@ -971,6 +1094,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(long value) {
+ this.value = value;
+ }
};
new Config(props);
@@ -986,6 +1114,11 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
Config cfg = new Config(props);
@@ -1003,23 +1136,126 @@ public class PropertyConfigurationTest {
public Config(Properties props) throws PropertyException {
super(props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(long value) {
+ this.value = value;
+ }
};
new Config(props);
}
/**
- * A config whose annotated property is "static".
+ * Config with a String value having no qualifiers.
*/
- public static class StaticConfig extends PropertyConfiguration {
+ public class PlainStringConfig extends PropertyConfiguration {
+
+ @Property(name = THE_VALUE)
+ private String value;
+
+ public PlainStringConfig() {
+
+ }
+
+ public PlainStringConfig(Properties props) throws PropertyException {
+ super(props);
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value) {
+ this.value = value;
+ }
+ };
+
+ /**
+ * Config with a Boolean value having no qualifiers.
+ */
+ public class PlainBooleanConfig extends PropertyConfiguration {
+
+ @Property(name = THE_VALUE)
+ private Boolean value;
+
+ public PlainBooleanConfig(Properties props) throws PropertyException {
+ super(props);
+ }
+
+ public void setValue(Boolean value) {
+ this.value = value;
+ }
+ };
+
+ /**
+ * Config with an int value having no qualifiers.
+ */
+ public class PlainPrimIntConfig extends PropertyConfiguration {
+
+ @Property(name = THE_VALUE)
+ private int value;
+
+ public PlainPrimIntConfig(Properties props) throws PropertyException {
+ super(props);
+ }
+
+ public void setValue(int value) {
+ this.value = value;
+ }
+ };
+
+ /**
+ * Config with a long value having no qualifiers.
+ */
+ public class PlainPrimLongConfig extends PropertyConfiguration {
+
+ @Property(name = THE_VALUE)
+ private long value;
+
+ public PlainPrimLongConfig(Properties props) throws PropertyException {
+ super(props);
+ }
+
+ public void setValue(long value) {
+ this.value = value;
+ }
+ };
+
+ /**
+ * A config whose field is "static".
+ */
+ public static class StaticPropConfig extends PropertyConfiguration {
// "static" field cannot be set
@Property(name = THE_VALUE)
private static String value;
- public StaticConfig(Properties props) throws PropertyException {
+ public StaticPropConfig(Properties props) throws PropertyException {
super(props);
}
+
+ public static void setValue(String value) {
+ StaticPropConfig.value = value;
+ }
+ };
+
+ /**
+ * A config whose method is "static".
+ */
+ public static class StaticMethodConfig extends PropertyConfiguration {
+
+ // "static" field cannot be set
+ @Property(name = THE_VALUE)
+ private String value;
+
+ public StaticMethodConfig(Properties props) throws PropertyException {
+ super(props);
+ }
+
+ public static void setValue(String value) {
+
+ }
};
/**
diff --git a/utils/src/test/java/org/onap/policy/common/utils/properties/SpecPropertyConfigurationTest.java b/utils/src/test/java/org/onap/policy/common/utils/properties/SpecPropertyConfigurationTest.java
index 39c8f01a..b5431c25 100644
--- a/utils/src/test/java/org/onap/policy/common/utils/properties/SpecPropertyConfigurationTest.java
+++ b/utils/src/test/java/org/onap/policy/common/utils/properties/SpecPropertyConfigurationTest.java
@@ -110,6 +110,66 @@ public class SpecPropertyConfigurationTest {
public Config(String specialization, Properties props) throws PropertyException {
super(specialization, props);
}
+
+ @SuppressWarnings("unused")
+ public void setNoSpec(String noSpec) {
+ this.noSpec = noSpec;
+ }
+
+ @SuppressWarnings("unused")
+ public void setNoSpecBool(boolean noSpecBool) {
+ this.noSpecBool = noSpecBool;
+ }
+
+ @SuppressWarnings("unused")
+ public void setType1NoPrefix(String type1NoPrefix) {
+ this.type1NoPrefix = type1NoPrefix;
+ }
+
+ @SuppressWarnings("unused")
+ public void setType1NoSuffix(String type1NoSuffix) {
+ this.type1NoSuffix = type1NoSuffix;
+ }
+
+ @SuppressWarnings("unused")
+ public void setType1Both(String type1Both) {
+ this.type1Both = type1Both;
+ }
+
+ @SuppressWarnings("unused")
+ public void setType1Int(int type1Int) {
+ this.type1Int = type1Int;
+ }
+
+ @SuppressWarnings("unused")
+ public void setType2NoPrefix(String type2NoPrefix) {
+ this.type2NoPrefix = type2NoPrefix;
+ }
+
+ @SuppressWarnings("unused")
+ public void setType2NoSuffix(String type2NoSuffix) {
+ this.type2NoSuffix = type2NoSuffix;
+ }
+
+ @SuppressWarnings("unused")
+ public void setType2NoSpecPrefix(String type2NoSpecPrefix) {
+ this.type2NoSpecPrefix = type2NoSpecPrefix;
+ }
+
+ @SuppressWarnings("unused")
+ public void setType2NoSpecSuffix(String type2NoSpecSuffix) {
+ this.type2NoSpecSuffix = type2NoSpecSuffix;
+ }
+
+ @SuppressWarnings("unused")
+ public void setType2Both(String type2Both) {
+ this.type2Both = type2Both;
+ }
+
+ @SuppressWarnings("unused")
+ public void setType2Long(long type2Long) {
+ this.type2Long = type2Long;
+ }
};
props.setProperty("prefix.suffix", "no.spec");
@@ -151,6 +211,11 @@ public class SpecPropertyConfigurationTest {
public Config(String specialization, Properties props) throws PropertyException {
super(specialization, props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
props.setProperty("prefix.suffix", "no.spec");
@@ -174,6 +239,11 @@ public class SpecPropertyConfigurationTest {
public Config(String specialization, Properties props) throws PropertyException {
super(specialization, props);
}
+
+ @SuppressWarnings("unused")
+ public void setNotFound(String notFound) {
+ this.notFound = notFound;
+ }
};
new Config("not found", props);
@@ -196,6 +266,11 @@ public class SpecPropertyConfigurationTest {
public Config(String specialization) {
super(specialization);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(String value) {
+ this.value = value;
+ }
};
props.setProperty(specialize(propnm, SPEC), propval);
@@ -224,6 +299,11 @@ public class SpecPropertyConfigurationTest {
public Config(String specialization, Properties props) throws PropertyException {
super(specialization, props);
}
+
+ @SuppressWarnings("unused")
+ public void setValue(int value) {
+ this.value = value;
+ }
};
props.setProperty(specialize(propnm, SPEC), String.valueOf(propval));