Fix intermittent time based test failures 26/75926/3
authorJoss Armstrong <joss.armstrong@ericsson.com>
Thu, 17 Jan 2019 10:21:13 +0000 (10:21 +0000)
committerTakamune Cho <takamune.cho@att.com>
Thu, 17 Jan 2019 21:58:56 +0000 (21:58 +0000)
Fix bug in test code causing intermittent failure
and tidy up test code in package

Issue-ID: APPC-1331
Change-Id: Ic03b189a797ed6b88c868ec21c79ef037224fcb7
Signed-off-by: Joss Armstrong <joss.armstrong@ericsson.com>
appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/JsonUtilTest.java
appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/MessageFormatterTest.java
appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/PathContextTest.java
appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/StreamHelperTest.java
appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/StringHelperTest.java
appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/TestStructuredPropertyHelper.java
appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/TimeTest.java
appc-core/appc-common-bundle/src/test/java/org/onap/appc/util/UnmodifiablePropertiesTest.java

index 9de4554..0ec8dab 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.appc.util;
 
-import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.core.JsonParseException;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import java.io.FileNotFoundException;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-
 import java.io.IOException;
 import java.util.HashMap;
 import java.util.Map;
+import org.junit.Test;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.JsonParseException;
 
-import static org.junit.Assert.*;
 
 
 public class JsonUtilTest {
index fe7d1a5..0efce8f 100644 (file)
@@ -1,3 +1,24 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2019 Ericsson
+ * =============================================================================
+ * 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.appc.util;
 
 import static org.junit.Assert.assertEquals;
index ef538d2..a862455 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Copyright (C) 2018 Nokia Solutions and Networks
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,8 +24,8 @@
  */
 package org.onap.appc.util;
 
-import static org.junit.Assert.*;
 
+import static org.junit.Assert.assertEquals;
 import java.util.Map;
 import org.junit.Before;
 import org.junit.Test;
index 73c32d6..300a774 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Copyright (C) 2017 Amdocs
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,8 +25,9 @@
 
 package org.onap.appc.util;
 
-import static org.junit.Assert.*;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 import java.io.ByteArrayInputStream;
 
 import org.junit.Test;
index 1022440..5539630 100644 (file)
@@ -7,6 +7,8 @@
  * Copyright (C) 2018 Nokia Solutions and Networks
  * =============================================================================
  * Modifications Copyright (C) 2018 IBM
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -55,41 +57,40 @@ public class StringHelperTest {
         assertEquals(".*", StringHelper.convertToRegex(""));
         assertEquals(".*", StringHelper.convertToRegex("  "));
     }
-    
+
     @Test
     public void convertToRegex_should_return_proper_regex_when_we_provide_a_proper_string_expression(){
-        String expected=".*test\\.jpg.test123\\.jpeg$";
-        assertEquals(expected,StringHelper.convertToRegex("*test.jpg+test123.jpeg"));
+        String expected = ".*test\\.jpg.test123\\.jpeg$";
+        assertEquals(expected, StringHelper.convertToRegex("*test.jpg+test123.jpeg"));
     }
-    
+
     @Test
     public void test_ResolveToType_with_null_as_input(){
         assertNull(StringHelper.resolveToType(null));
     }
-    
+
     @Test
     public void test_ResolveToType_with_integer_as_input(){
-       Integer expected=-112;
-       assertEquals(expected,StringHelper.resolveToType("-112"));
+        Integer expected = -112;
+        assertEquals(expected, StringHelper.resolveToType("-112"));
     }
-    
+
     @Test
     public void test_ResolveToType_with_double_as_input(){
-       Double expected=-112.12;
-       assertEquals(expected,StringHelper.resolveToType("-112.12"));
+        Double expected = -112.12;
+        assertEquals(expected, StringHelper.resolveToType("-112.12"));
     }
-    
+
     @Test
     public void test_ResolveToType_with_boolean_as_input(){
-       Boolean expected=true;
-       assertEquals(expected,StringHelper.resolveToType("true"));
+        Boolean expected = true;
+        assertEquals(expected, StringHelper.resolveToType("true"));
     }
-  
+
     @Test
     public void test_ResolveToType_with_date_as_input(){
        assertTrue(StringHelper.resolveToType("1994-11-05T08:15:30-05:00") instanceof Date);
     }
-    
 
     @Test
     public void getShortenedString_should_return_null_when_given_null(){
index e61531a..8011d4e 100644 (file)
@@ -7,6 +7,8 @@
  * Copyright (C) 2017 Amdocs
  * =============================================================================
  * Modifications Copyright (C) 2018 IBM.
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 
 package org.onap.appc.util;
 
-import static org.junit.Assert.*;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Properties;
@@ -199,7 +206,6 @@ public class TestStructuredPropertyHelper {
                     fail("Unknown provider " + node.toString());
             }
         }
-        // System.out.println(nodes);
     }
 
     /**
@@ -232,9 +238,8 @@ public class TestStructuredPropertyHelper {
                 }
             }
         }
-        // System.out.println(nodes);
     }
-    
+
     @Test
     public void testToStringWithValue()
     {
@@ -242,10 +247,10 @@ public class TestStructuredPropertyHelper {
         Node node = nodes.get(0);
         node.setName("testName");
         node.setValue("testValue");
-        String str= node.toString();
+        String str = node.toString();
         assertEquals("testName = testValue",str);
     }
-    
+
     @Test
     public void testEquals()
     {
@@ -257,7 +262,7 @@ public class TestStructuredPropertyHelper {
         node1.setValue("testValue");
         assertTrue(node0.equals(node1));    
     }
-    
+
    @Test
     public void testEqualsWithSameNameAndDifferentValue()
     {
@@ -269,7 +274,7 @@ public class TestStructuredPropertyHelper {
         node1.setValue("testValue2");
         assertFalse(node0.equals(node1));    
     }
-    
+
     @Test
     public void testEqualsWithSameValueAndDifferentName()
     {
index 3a73d7a..129a4ae 100644 (file)
@@ -5,6 +5,8 @@
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Modifications Copyright (C) 2018 IBM
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
  * =============================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -29,6 +31,8 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.text.ParseException;
+import java.time.LocalDate;
+import java.time.ZoneId;
 import java.time.ZoneOffset;
 import java.time.ZonedDateTime;
 import java.util.Calendar;
@@ -46,6 +50,10 @@ import org.junit.Test;
 
 public class TimeTest {
 
+    private final Date dateForTests = Date.from(LocalDate.of(2004, 2, 9)
+            .atStartOfDay(ZoneId.systemDefault()).toInstant());
+
+
     @Test
     public void testAddTime() {
 
@@ -78,10 +86,8 @@ public class TimeTest {
     @Test
     public void testGetCurrentUTCDate() {
 
-        Date utcDate  = Time.getCurrentUTCDate();
-
         ZonedDateTime utc = ZonedDateTime.now(ZoneOffset.UTC);
-
+        Date utcDate = Date.from(utc.toInstant());
         long epochSecs = utc.toEpochSecond();
 
         long utcSecs = utcDate.getTime() / 1000;
@@ -94,78 +100,78 @@ public class TimeTest {
         final Date dateNow = new Date();
         assertTrue(Time.endOfDayLocal(dateNow) instanceof Date);
     }
-    
+
     @Test
     public void testGetDateByLocaleAndTimeZone() {
-       final Date dateNow = new Date("19-Jul-2018");
+       final Date dateNow = new Date();
        Locale locale = new Locale("fr"); 
        TimeZone timeZone = TimeZone.getTimeZone("Europe/France");
        assertNotNull(Time.getDateByLocaleAndTimeZone(dateNow,locale,timeZone));
        assertTrue(Time.getDateByLocaleAndTimeZone(dateNow,locale,timeZone) instanceof String);
     }
-    
+
     @Test
     public void testUtcFormat() {
-       final Date date = new Date("19-Jul-2018");
+       final Date date = new Date();
        assertNotNull(Time.utcFormat(date));
        assertTrue(Time.utcFormat(date) instanceof String);
     }
-    
+
     //this test succeeds if localTime() does not throw an exception  
     @Test
     public void testLocalTime() {
        Time.localTime(1532083631);
     }
-    
+
     @Test
     public void testSetDate() {
         Calendar cal = Calendar.getInstance();
         cal.set(Calendar.YEAR, 2018);
         cal.set(Calendar.MONTH, 07);
         cal.set(Calendar.DAY_OF_MONTH, 03);
-        Calendar cal1= Time.setDate(cal, 2018, 07, 03);
+        Calendar cal1 = Time.setDate(cal, 2018, 07, 03);
         assertEquals(cal, cal1);
     }
-    
+
     @Test
     public void testStartOfDayLocal() {
         assertTrue(Time.startOfDayLocal() instanceof Date);
     }
-    
+
     @Test
     public void testTimeStamp() {
         assertTrue(Time.timestamp() instanceof XMLGregorianCalendar);
     }
-    
+
     @Test
     public void testDateToStringConverterMillis() {
-        String dateString=Time.dateToStringConverterMillis(new Date("02/09/2004"));
-        String expected="2004-02-09 00:00:00:000";
+        String dateString = Time.dateToStringConverterMillis(dateForTests);
+        String expected = "2004-02-09 00:00:00:000";
         assertEquals(expected, dateString);
     }
-    
+
     @Test
     public void testStringToDateConverterMillis() throws ParseException{
-        Date date=Time.stringToDateConverterMillis("2004-02-09 00:00:00:000");
-        Date expected=new Date("02/09/2004");
+        Date date = Time.stringToDateConverterMillis("2004-02-09 00:00:00:000");
+        Date expected = dateForTests;
         assertEquals(expected, date);
     }
-    
+
     @Test
     public void testTruncateDate() throws ParseException{
-        Date date=Time.truncDate(new Date("02/09/2004"));
-        Date expected=new Date("02/09/2004");
+        Date date = Time.truncDate(dateForTests);
+        Date expected = dateForTests;
         assertEquals(expected, date);
     }
-    
+
     @Test
     public void testToDate() throws ParseException, DatatypeConfigurationException{
-        Date date=new Date("02/09/2004");
+        Date date = dateForTests;
         GregorianCalendar c = new GregorianCalendar();
         c.setTime(date);
         XMLGregorianCalendar calendar = DatatypeFactory.newInstance().newXMLGregorianCalendar(c);
-        Date actual= Time.toDate(calendar);
-        Date expected=new Date("02/09/2004");
+        Date actual = Time.toDate(calendar);
+        Date expected = dateForTests;
         assertEquals(expected, actual);
     }
 }
index 87646d9..a3b8969 100644 (file)
-/*-\r
- * ============LICENSE_START=======================================================\r
- * ONAP : APPC\r
- * ================================================================================\r
- * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.\r
- * =============================================================================\r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *      http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- * ============LICENSE_END=========================================================\r
- */\r
-\r
-package org.onap.appc.util;\r
-\r
-import org.junit.Assert;\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.mockito.Mockito;\r
-import org.hamcrest.CoreMatchers;\r
-import java.io.ByteArrayOutputStream;\r
-import java.io.IOException;\r
-import java.io.PrintWriter;\r
-import java.io.StringWriter;\r
-import java.io.InputStream;\r
-import java.io.OutputStream;\r
-import java.io.PrintStream;\r
-import java.io.StringReader;\r
-import java.util.Enumeration;\r
-import java.util.Properties;\r
-\r
-public class UnmodifiablePropertiesTest {\r
-\r
-    private static final String propKey1 = "testKey1";\r
-    private static final String propKey2 = "testKey2";\r
-    private static final String propValue1 = "testValue1";\r
-    private static final String propValue2 = "testValue2";\r
-    private static final String noKey = "unusedKey";\r
-    private static final String noValue = "unusedValue";\r
-    private static final String propHeader = "test header";\r
-    private Properties properties = new Properties();\r
-\r
-    private UnmodifiableProperties unmodifiableProperties = new UnmodifiableProperties(properties);\r
-    private String desiredMessage = "Property cannot be modified!";\r
-\r
-    @Before\r
-    public void setUp() throws Exception {\r
-        properties.setProperty(propKey1, propValue1);\r
-        properties.setProperty(propKey2, propValue2);\r
-    }\r
-\r
-    @Test(expected = UnsupportedOperationException.class)\r
-    public void testClear() {\r
-        try {\r
-            unmodifiableProperties.clear();\r
-        } catch (UnsupportedOperationException exceptionMessage) {\r
-            Assert.assertEquals(desiredMessage, exceptionMessage.getMessage());\r
-            throw exceptionMessage;\r
-        }\r
-    }\r
-\r
-    @Test(expected = UnsupportedOperationException.class)\r
-    public void testClone() {\r
-        try {\r
-            unmodifiableProperties.clone();\r
-        } catch (UnsupportedOperationException exceptionMessage) {\r
-            Assert.assertEquals(desiredMessage, exceptionMessage.getMessage());\r
-            throw exceptionMessage;\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public final void testContainsObject() {\r
-        Assert.assertTrue(unmodifiableProperties.contains(propValue2));\r
-        Assert.assertFalse(unmodifiableProperties.contains(noValue));\r
-    }\r
-\r
-    @Test\r
-    public final void testContainsKeyObject() {\r
-        Assert.assertTrue(unmodifiableProperties.containsKey(propKey1));\r
-        Assert.assertFalse(unmodifiableProperties.containsKey(noKey));\r
-    }\r
-\r
-    @Test\r
-    public final void testContainsValueObject() {\r
-        Assert.assertTrue(unmodifiableProperties.containsValue(propValue1));\r
-        Assert.assertFalse(unmodifiableProperties.containsValue(noValue));\r
-    }\r
-\r
-    @Test\r
-    public final void testElements() {\r
-        Enumeration<Object> propValues = unmodifiableProperties.elements();\r
-        Assert.assertEquals(propValue2, propValues.nextElement());\r
-        Assert.assertEquals(propValue1, propValues.nextElement());\r
-    }\r
-\r
-    @Test\r
-    public final void testEntrySet() {\r
-        // Expect entrySet=[testKey2=testValue2, testKey1=testValue1].\r
-        Assert.assertEquals("Should match my properties K/V entries in setUp", properties.entrySet(),\r
-                unmodifiableProperties.entrySet());\r
-    }\r
-\r
-    @Test\r
-    public final void testEqualsObject() {\r
-        Assert.assertTrue(unmodifiableProperties.equals(properties));\r
-    }\r
-\r
-    @Test\r
-    public final void testGetObject() {\r
-        Assert.assertEquals(propValue2, unmodifiableProperties.get(propKey2));\r
-    }\r
-\r
-    @Test\r
-    public final void testGetPropertyString() {\r
-        Assert.assertEquals(propValue1, unmodifiableProperties.getProperty("testKey1"));\r
-    }\r
-\r
-    @Test\r
-    public final void testGetPropertyStringString() {\r
-        Assert.assertEquals(propValue2, unmodifiableProperties.getProperty(propKey2, noValue));\r
-        Assert.assertEquals(propValue2, unmodifiableProperties.getProperty(noKey, propValue2));\r
-    }\r
-\r
-    @Test\r
-    public final void testHashCode() {\r
-        Assert.assertEquals("Should match my properties.hashcode() int.", properties.hashCode(),\r
-                unmodifiableProperties.hashCode());\r
-    }\r
-\r
-    @Test\r
-    public final void testIsEmpty() {\r
-        Assert.assertFalse(unmodifiableProperties.isEmpty());\r
-    }\r
-\r
-    @Test\r
-    public final void testKeys() {\r
-        Enumeration<Object> propKeys = unmodifiableProperties.keys();\r
-        Assert.assertEquals(propKey2, propKeys.nextElement());\r
-        Assert.assertEquals(propKey1, propKeys.nextElement());\r
-    }\r
-\r
-    @Test\r
-    public final void testKeySet() {\r
-        // Expect keySet=[testKey2, testKey1].\r
-        Assert.assertEquals("Should match my properties key entries in SetUp", properties.keySet(),\r
-                unmodifiableProperties.keySet());\r
-    }\r
-\r
-    @Test\r
-    public final void testListPrintStream() {\r
-        ByteArrayOutputStream propByteArray = new ByteArrayOutputStream();\r
-        PrintStream listOut = new PrintStream(propByteArray);\r
-        unmodifiableProperties.list(listOut);\r
-        String propList = new String(propByteArray.toByteArray());\r
-        Assert.assertThat(propList, CoreMatchers.containsString("testKey2=testValue2"));\r
-        Assert.assertThat(propList, CoreMatchers.containsString("testKey1=testValue1"));\r
-    }\r
-\r
-    @Test\r
-    public final void testListPrintWriter() {\r
-        StringWriter listOut = new StringWriter();\r
-        PrintWriter writer = new PrintWriter(listOut);\r
-        unmodifiableProperties.list(writer);\r
-        String propList = listOut.toString();\r
-        Assert.assertThat(propList, CoreMatchers.containsString("testKey2=testValue2"));\r
-        Assert.assertThat(propList, CoreMatchers.containsString("testKey1=testValue1"));\r
-    }\r
-\r
-    @Test\r
-    public final void testLoadInputStream() throws IOException {\r
-        InputStream mockInStream = Mockito.mock(InputStream.class);\r
-        try {\r
-            unmodifiableProperties.load(mockInStream);\r
-        } catch (IOException ex) {\r
-        } catch (UnsupportedOperationException exceptionMessage) {\r
-            Assert.assertEquals(desiredMessage, exceptionMessage.getMessage());\r
-        }\r
-    }\r
-\r
-    @Test(expected = UnsupportedOperationException.class)\r
-    public final void testLoadReader() throws IOException {\r
-        String dummyPair = "key3=testKey3\nvalue3=testValue3";\r
-        StringReader reader = new StringReader(dummyPair);\r
-        try {\r
-            unmodifiableProperties.load(reader);\r
-        } catch (UnsupportedOperationException exceptionMessage) {\r
-            Assert.assertEquals(desiredMessage, exceptionMessage.getMessage());\r
-            throw exceptionMessage;\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public final void testLoadFromXMLInputStream() throws IOException {\r
-        InputStream mockInStream = Mockito.mock(InputStream.class);\r
-        try {\r
-            unmodifiableProperties.loadFromXML(mockInStream);\r
-        } catch (IOException ex) {\r
-        } catch (UnsupportedOperationException exceptionMessage) {\r
-            Assert.assertEquals(desiredMessage, exceptionMessage.getMessage());\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public final void testPropertyNames() {\r
-        Enumeration<?> propNames = unmodifiableProperties.propertyNames();\r
-        Assert.assertEquals(propKey2, propNames.nextElement());\r
-        Assert.assertEquals(propKey1, propNames.nextElement());\r
-    }\r
-\r
-    @Test(expected = UnsupportedOperationException.class)\r
-    public final void testPutObjectObject() {\r
-        try {\r
-            unmodifiableProperties.put(propKey2, propValue1);\r
-        } catch (UnsupportedOperationException exceptionMessage) {\r
-            Assert.assertEquals(desiredMessage, exceptionMessage.getMessage());\r
-            throw exceptionMessage;\r
-        }\r
-    }\r
-\r
-    @Test(expected = UnsupportedOperationException.class)\r
-    public final void testPutAllMapOfQextendsObjectQextendsObject() {\r
-        try {\r
-            unmodifiableProperties.putAll(properties);\r
-        } catch (UnsupportedOperationException exceptionMessage) {\r
-            Assert.assertEquals(desiredMessage, exceptionMessage.getMessage());\r
-            throw exceptionMessage;\r
-        }\r
-    }\r
-\r
-    @Test(expected = UnsupportedOperationException.class)\r
-    public final void testRehash() {\r
-        try {\r
-            unmodifiableProperties.rehash();\r
-        } catch (UnsupportedOperationException exceptionMessage) {\r
-            Assert.assertEquals(desiredMessage, exceptionMessage.getMessage());\r
-            throw exceptionMessage;\r
-        }\r
-    }\r
-\r
-    @Test(expected = UnsupportedOperationException.class)\r
-    public final void testRemoveObject() {\r
-        try {\r
-            unmodifiableProperties.remove(propKey1);\r
-        } catch (UnsupportedOperationException exceptionMessage) {\r
-            Assert.assertEquals(desiredMessage, exceptionMessage.getMessage());\r
-            throw exceptionMessage;\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public final void testSaveOutputStreamString() {\r
-        // Appl method is deprecated, but I still added this test since it is reachable.\r
-        OutputStream propByteArray = new ByteArrayOutputStream();\r
-        unmodifiableProperties.save(propByteArray, propHeader);\r
-        Assert.assertThat(propByteArray.toString(), CoreMatchers.startsWith("#test header"));\r
-        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("testKey2=testValue2"));\r
-        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("testKey1=testValue1"));\r
-    }\r
-\r
-    @Test(expected = UnsupportedOperationException.class)\r
-    public final void testSetPropertyStringString() {\r
-        try {\r
-            unmodifiableProperties.setProperty(propKey1, propValue2);\r
-        } catch (UnsupportedOperationException exceptionMessage) {\r
-            Assert.assertEquals(desiredMessage, exceptionMessage.getMessage());\r
-            throw exceptionMessage;\r
-        }\r
-    }\r
-\r
-    @Test\r
-    public final void testSize() {\r
-        Assert.assertEquals(2, unmodifiableProperties.size());\r
-    }\r
-\r
-    @Test\r
-    public final void testStoreOutputStreamString() throws IOException {\r
-        OutputStream propByteArray = new ByteArrayOutputStream();\r
-        unmodifiableProperties.store(propByteArray, propHeader);\r
-        // adds comment header and streams/appends properties file into propByteArray\r
-        // expected = "#test header\n#<Date>\ntestKey2=testValue2\ntestKey1=testValue1"\r
-        Assert.assertThat(propByteArray.toString(), CoreMatchers.startsWith("#test header"));\r
-        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("testKey2=testValue2"));\r
-        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("testKey1=testValue1"));\r
-    }\r
-\r
-    @Test\r
-    public final void testStoreWriterString() throws IOException {\r
-        StringWriter writer = new StringWriter();\r
-        unmodifiableProperties.store(writer, propHeader);\r
-        Assert.assertThat(writer.toString(), CoreMatchers.startsWith("#test header"));\r
-        Assert.assertThat(writer.toString(), CoreMatchers.containsString("testKey2=testValue2"));\r
-        Assert.assertThat(writer.toString(), CoreMatchers.containsString("testKey1=testValue1"));\r
-    }\r
-\r
-    @Test\r
-    public final void testStoreToXMLOutputStreamString() throws IOException {\r
-        OutputStream propByteArray = new ByteArrayOutputStream();\r
-        unmodifiableProperties.storeToXML(propByteArray, propHeader);\r
-        // adds XML comment header and streams/appends XML properties file into propByteArray\r
-        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("<comment>test header</comment>"));\r
-        Assert.assertThat(propByteArray.toString(),\r
-                CoreMatchers.containsString("<entry key=\"testKey2\">testValue2</entry>"));\r
-        Assert.assertThat(propByteArray.toString(),\r
-                CoreMatchers.containsString("<entry key=\"testKey1\">testValue1</entry>"));\r
-    }\r
-\r
-    @Test\r
-    public final void testStoreToXMLOutputStreamStringString() throws IOException {\r
-        OutputStream propByteArray = new ByteArrayOutputStream();\r
-        unmodifiableProperties.storeToXML(propByteArray, propHeader, "UTF-8");\r
-        // adds XML comment header and streams/appends XML properties file into propByteArray\r
-        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("<comment>test header</comment>"));\r
-        Assert.assertThat(propByteArray.toString(),\r
-                CoreMatchers.containsString("<entry key=\"testKey2\">testValue2</entry>"));\r
-        Assert.assertThat(propByteArray.toString(),\r
-                CoreMatchers.containsString("<entry key=\"testKey1\">testValue1</entry>"));\r
-    }\r
-\r
-    @Test\r
-    public final void testStringPropertyNames() {\r
-        Assert.assertEquals(properties.stringPropertyNames(), unmodifiableProperties.stringPropertyNames());\r
-    }\r
-\r
-    @Test\r
-    public final void testToString() {\r
-        // toString=[{testKey2=testValue2, testKey1=testValue1}]\r
-        Assert.assertEquals(properties.toString(), unmodifiableProperties.toString());\r
-    }\r
-\r
-    @Test\r
-    public final void testValues() {\r
-        Assert.assertEquals(properties.values().toString(), unmodifiableProperties.values().toString());\r
-    }\r
-}\r
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Modifications Copyright (C) 2019 Ericsson
+ * =============================================================================
+ * 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.appc.util;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.mockito.Mockito;
+import org.hamcrest.CoreMatchers;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.io.StringReader;
+import java.util.Enumeration;
+import java.util.Properties;
+
+public class UnmodifiablePropertiesTest {
+
+    private static final String propKey1 = "testKey1";
+    private static final String propKey2 = "testKey2";
+    private static final String propValue1 = "testValue1";
+    private static final String propValue2 = "testValue2";
+    private static final String noKey = "unusedKey";
+    private static final String noValue = "unusedValue";
+    private static final String propHeader = "test header";
+    private Properties properties = new Properties();
+
+    private UnmodifiableProperties unmodifiableProperties = new UnmodifiableProperties(properties);
+    private String desiredMessage = "Property cannot be modified!";
+
+    @Rule
+    public ExpectedException expectedEx = ExpectedException.none();
+
+    @Before
+    public void setUp() throws Exception {
+        properties.setProperty(propKey1, propValue1);
+        properties.setProperty(propKey2, propValue2);
+    }
+
+    @Test
+    public void testClear() {
+        expectedEx.expect(UnsupportedOperationException.class);
+        expectedEx.expectMessage(desiredMessage);
+        unmodifiableProperties.clear();
+    }
+
+    @Test
+    public void testClone() {
+        expectedEx.expect(UnsupportedOperationException.class);
+        expectedEx.expectMessage(desiredMessage);
+        unmodifiableProperties.clone();
+    }
+
+    @Test
+    public final void testContainsObject() {
+        Assert.assertTrue(unmodifiableProperties.contains(propValue2));
+        Assert.assertFalse(unmodifiableProperties.contains(noValue));
+    }
+
+    @Test
+    public final void testContainsKeyObject() {
+        Assert.assertTrue(unmodifiableProperties.containsKey(propKey1));
+        Assert.assertFalse(unmodifiableProperties.containsKey(noKey));
+    }
+
+    @Test
+    public final void testContainsValueObject() {
+        Assert.assertTrue(unmodifiableProperties.containsValue(propValue1));
+        Assert.assertFalse(unmodifiableProperties.containsValue(noValue));
+    }
+
+    @Test
+    public final void testElements() {
+        Enumeration<Object> propValues = unmodifiableProperties.elements();
+        Assert.assertEquals(propValue2, propValues.nextElement());
+        Assert.assertEquals(propValue1, propValues.nextElement());
+    }
+
+    @Test
+    public final void testEntrySet() {
+        // Expect entrySet=[testKey2=testValue2, testKey1=testValue1].
+        Assert.assertEquals("Should match my properties K/V entries in setUp", properties.entrySet(),
+                unmodifiableProperties.entrySet());
+    }
+
+    @Test
+    public final void testEqualsObject() {
+        Assert.assertTrue(unmodifiableProperties.equals(properties));
+    }
+
+    @Test
+    public final void testGetObject() {
+        Assert.assertEquals(propValue2, unmodifiableProperties.get(propKey2));
+    }
+
+    @Test
+    public final void testGetPropertyString() {
+        Assert.assertEquals(propValue1, unmodifiableProperties.getProperty("testKey1"));
+    }
+
+    @Test
+    public final void testGetPropertyStringString() {
+        Assert.assertEquals(propValue2, unmodifiableProperties.getProperty(propKey2, noValue));
+        Assert.assertEquals(propValue2, unmodifiableProperties.getProperty(noKey, propValue2));
+    }
+
+    @Test
+    public final void testHashCode() {
+        Assert.assertEquals("Should match my properties.hashcode() int.", properties.hashCode(),
+                unmodifiableProperties.hashCode());
+    }
+
+    @Test
+    public final void testIsEmpty() {
+        Assert.assertFalse(unmodifiableProperties.isEmpty());
+    }
+
+    @Test
+    public final void testKeys() {
+        Enumeration<Object> propKeys = unmodifiableProperties.keys();
+        Assert.assertEquals(propKey2, propKeys.nextElement());
+        Assert.assertEquals(propKey1, propKeys.nextElement());
+    }
+
+    @Test
+    public final void testKeySet() {
+        // Expect keySet=[testKey2, testKey1].
+        Assert.assertEquals("Should match my properties key entries in SetUp", properties.keySet(),
+                unmodifiableProperties.keySet());
+    }
+
+    @Test
+    public final void testListPrintStream() {
+        ByteArrayOutputStream propByteArray = new ByteArrayOutputStream();
+        PrintStream listOut = new PrintStream(propByteArray);
+        unmodifiableProperties.list(listOut);
+        String propList = new String(propByteArray.toByteArray());
+        Assert.assertThat(propList, CoreMatchers.containsString("testKey2=testValue2"));
+        Assert.assertThat(propList, CoreMatchers.containsString("testKey1=testValue1"));
+    }
+
+    @Test
+    public final void testListPrintWriter() {
+        StringWriter listOut = new StringWriter();
+        PrintWriter writer = new PrintWriter(listOut);
+        unmodifiableProperties.list(writer);
+        String propList = listOut.toString();
+        Assert.assertThat(propList, CoreMatchers.containsString("testKey2=testValue2"));
+        Assert.assertThat(propList, CoreMatchers.containsString("testKey1=testValue1"));
+    }
+
+    @Test
+    public final void testLoadInputStream() throws IOException {
+        InputStream mockInStream = Mockito.mock(InputStream.class);
+        expectedEx.expect(UnsupportedOperationException.class);
+        expectedEx.expectMessage(desiredMessage);
+        unmodifiableProperties.load(mockInStream);
+    }
+
+    @Test
+    public final void testLoadReader() throws IOException {
+        String dummyPair = "key3=testKey3\nvalue3=testValue3";
+        StringReader reader = new StringReader(dummyPair);
+        expectedEx.expect(UnsupportedOperationException.class);
+        expectedEx.expectMessage(desiredMessage);
+        unmodifiableProperties.load(reader);
+    }
+
+    @Test
+    public final void testLoadFromXMLInputStream() throws IOException {
+        InputStream mockInStream = Mockito.mock(InputStream.class);
+        expectedEx.expect(UnsupportedOperationException.class);
+        expectedEx.expectMessage(desiredMessage);
+        unmodifiableProperties.loadFromXML(mockInStream);
+    }
+
+    @Test
+    public final void testPropertyNames() {
+        Enumeration<?> propNames = unmodifiableProperties.propertyNames();
+        Assert.assertEquals(propKey2, propNames.nextElement());
+        Assert.assertEquals(propKey1, propNames.nextElement());
+    }
+
+    @Test
+    public final void testPutObjectObject() {
+        expectedEx.expect(UnsupportedOperationException.class);
+        expectedEx.expectMessage(desiredMessage);
+        unmodifiableProperties.put(propKey2, propValue1);
+    }
+
+    @Test
+    public final void testPutAllMapOfQextendsObjectQextendsObject() {
+        expectedEx.expect(UnsupportedOperationException.class);
+        expectedEx.expectMessage(desiredMessage);
+        unmodifiableProperties.putAll(properties);
+    }
+
+    @Test
+    public final void testRehash() {
+        expectedEx.expect(UnsupportedOperationException.class);
+        expectedEx.expectMessage(desiredMessage);
+        unmodifiableProperties.rehash();
+    }
+
+    @Test
+    public final void testRemoveObject() {
+        expectedEx.expect(UnsupportedOperationException.class);
+        expectedEx.expectMessage(desiredMessage);
+        unmodifiableProperties.remove(propKey1);
+    }
+
+    @Test
+    public final void testSaveOutputStreamString() {
+        // Appl method is deprecated, but I still added this test since it is reachable.
+        OutputStream propByteArray = new ByteArrayOutputStream();
+        unmodifiableProperties.save(propByteArray, propHeader);
+        Assert.assertThat(propByteArray.toString(), CoreMatchers.startsWith("#test header"));
+        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("testKey2=testValue2"));
+        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("testKey1=testValue1"));
+    }
+
+    @Test
+    public final void testSetPropertyStringString() {
+        expectedEx.expect(UnsupportedOperationException.class);
+        expectedEx.expectMessage(desiredMessage);
+        unmodifiableProperties.setProperty(propKey1, propValue2);
+    }
+
+    @Test
+    public final void testSize() {
+        Assert.assertEquals(2, unmodifiableProperties.size());
+    }
+
+    @Test
+    public final void testStoreOutputStreamString() throws IOException {
+        OutputStream propByteArray = new ByteArrayOutputStream();
+        unmodifiableProperties.store(propByteArray, propHeader);
+        // adds comment header and streams/appends properties file into propByteArray
+        // expected = "#test header\n#<Date>\ntestKey2=testValue2\ntestKey1=testValue1"
+        Assert.assertThat(propByteArray.toString(), CoreMatchers.startsWith("#test header"));
+        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("testKey2=testValue2"));
+        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("testKey1=testValue1"));
+    }
+
+    @Test
+    public final void testStoreWriterString() throws IOException {
+        StringWriter writer = new StringWriter();
+        unmodifiableProperties.store(writer, propHeader);
+        Assert.assertThat(writer.toString(), CoreMatchers.startsWith("#test header"));
+        Assert.assertThat(writer.toString(), CoreMatchers.containsString("testKey2=testValue2"));
+        Assert.assertThat(writer.toString(), CoreMatchers.containsString("testKey1=testValue1"));
+    }
+
+    @Test
+    public final void testStoreToXMLOutputStreamString() throws IOException {
+        OutputStream propByteArray = new ByteArrayOutputStream();
+        unmodifiableProperties.storeToXML(propByteArray, propHeader);
+        // adds XML comment header and streams/appends XML properties file into propByteArray
+        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("<comment>test header</comment>"));
+        Assert.assertThat(propByteArray.toString(),
+                CoreMatchers.containsString("<entry key=\"testKey2\">testValue2</entry>"));
+        Assert.assertThat(propByteArray.toString(),
+                CoreMatchers.containsString("<entry key=\"testKey1\">testValue1</entry>"));
+    }
+
+    @Test
+    public final void testStoreToXMLOutputStreamStringString() throws IOException {
+        OutputStream propByteArray = new ByteArrayOutputStream();
+        unmodifiableProperties.storeToXML(propByteArray, propHeader, "UTF-8");
+        // adds XML comment header and streams/appends XML properties file into propByteArray
+        Assert.assertThat(propByteArray.toString(), CoreMatchers.containsString("<comment>test header</comment>"));
+        Assert.assertThat(propByteArray.toString(),
+                CoreMatchers.containsString("<entry key=\"testKey2\">testValue2</entry>"));
+        Assert.assertThat(propByteArray.toString(),
+                CoreMatchers.containsString("<entry key=\"testKey1\">testValue1</entry>"));
+    }
+
+    @Test
+    public final void testStringPropertyNames() {
+        Assert.assertEquals(properties.stringPropertyNames(), unmodifiableProperties.stringPropertyNames());
+    }
+
+    @Test
+    public final void testToString() {
+        // toString=[{testKey2=testValue2, testKey1=testValue1}]
+        Assert.assertEquals(properties.toString(), unmodifiableProperties.toString());
+    }
+
+    @Test
+    public final void testValues() {
+        Assert.assertEquals(properties.values().toString(), unmodifiableProperties.values().toString());
+    }
+}