summaryrefslogtreecommitdiffstats
path: root/misc/env/src/test/java/org
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2018-09-07 12:21:34 -0500
committerInstrumental <jonathan.gathman@att.com>2018-09-07 12:22:50 -0500
commit4b5a7d721d994a49057e9bfb403c7bff1b376660 (patch)
treea36d03227b63a3e60346d6c3ca87b061087dae85 /misc/env/src/test/java/org
parent824dc7b5fc0e1ccdf7f460479aff344727f0f01e (diff)
Mass removal of all Tabs (Style Warnings)
Issue-ID: AAF-473 Change-Id: Iaf0ef8120882937959bb0065f2f6ba74a021940f Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'misc/env/src/test/java/org')
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/JU_APIExceptionTest.java60
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/JU_BasicTransTest.java146
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/JU_LogTargetTest.java70
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_BasicEnvTest.java202
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_EnvFactoryTest.java64
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java30
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDataTest.java192
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_ChronoTest.java302
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_DoubleOutputStreamTest.java94
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_IndentPrintWriterTest.java108
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java52
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderOutputStreamTest.java202
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderWriterTest.java202
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java64
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java90
15 files changed, 939 insertions, 939 deletions
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_APIExceptionTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_APIExceptionTest.java
index b0c60878..c1d7f6b1 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_APIExceptionTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_APIExceptionTest.java
@@ -27,45 +27,45 @@ import org.junit.Test;
public class JU_APIExceptionTest {
- private static final String EXCEPTION_MESSAGE = "New API Exception for test";
+ private static final String EXCEPTION_MESSAGE = "New API Exception for test";
- @Before
- public void setUp() throws Exception {
- }
+ @Before
+ public void setUp() throws Exception {
+ }
- @Test
- public void testNewAPIExceptionWithMessage() {
- APIException exception = new APIException(EXCEPTION_MESSAGE);
+ @Test
+ public void testNewAPIExceptionWithMessage() {
+ APIException exception = new APIException(EXCEPTION_MESSAGE);
- assertEquals(exception.getMessage(), EXCEPTION_MESSAGE);
- }
+ assertEquals(exception.getMessage(), EXCEPTION_MESSAGE);
+ }
- @Test
- public void testNewAPIExceptionCreatedWithMessageAndThrowable() {
- Throwable throwable = new Throwable();
- APIException exception = new APIException(EXCEPTION_MESSAGE, throwable);
+ @Test
+ public void testNewAPIExceptionCreatedWithMessageAndThrowable() {
+ Throwable throwable = new Throwable();
+ APIException exception = new APIException(EXCEPTION_MESSAGE, throwable);
- assertEquals(exception.getMessage(), EXCEPTION_MESSAGE);
- assertEquals(exception.getCause(), throwable);
- }
+ assertEquals(exception.getMessage(), EXCEPTION_MESSAGE);
+ assertEquals(exception.getCause(), throwable);
+ }
- @Test
- public void testNewAPIExceptionCreatedWithThrowable() {
- Throwable throwable = new Throwable();
- APIException exception = new APIException(throwable);
+ @Test
+ public void testNewAPIExceptionCreatedWithThrowable() {
+ Throwable throwable = new Throwable();
+ APIException exception = new APIException(throwable);
- assertEquals(exception.getCause(), throwable);
- }
+ assertEquals(exception.getCause(), throwable);
+ }
- @Test
- public void testPayloadSetter() {
- Throwable throwable = new Throwable();
- Object payload = new Object();
+ @Test
+ public void testPayloadSetter() {
+ Throwable throwable = new Throwable();
+ Object payload = new Object();
- APIException exception = new APIException(throwable);
+ APIException exception = new APIException(throwable);
- exception.setPayload(payload);
+ exception.setPayload(payload);
- assertEquals(exception.getPayload(), payload);
- }
+ assertEquals(exception.getPayload(), payload);
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_BasicTransTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_BasicTransTest.java
index 6a090167..0525bd66 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_BasicTransTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_BasicTransTest.java
@@ -33,77 +33,77 @@ import org.onap.aaf.misc.env.impl.BasicTrans;
@RunWith(MockitoJUnitRunner.class)
public class JU_BasicTransTest {
- BasicTrans trans = null;
-
- @Mock
- private EnvJAXB env;
-
- @Mock
- private TimeTaken timeTaken;
-
- @Before
- public void setUp() throws Exception {
- trans = new BasicTrans(env);
- }
-
- @Test
- public void testSlot() {
- Slot slot = new Slot(1, "XML");
- when(env.slot("XML")).thenReturn(slot);
-
- Slot outputSlot = trans.slot("XML");
- Object[] state = new Object[2];
-
- slot.put(state, "JSON");
-
- assertEquals(slot.get(state), "JSON");
- assertEquals(slot.getKey(), outputSlot.getKey());
- assertEquals(slot.toString(), outputSlot.toString());
- }
-
- @Test
- public void testGetStaticSlot() {
- StaticSlot staticSlot = new StaticSlot(1, "XML");
- when(env.get(staticSlot)).thenReturn(staticSlot.toString());
-
- assertEquals(staticSlot.toString(), trans.get(staticSlot));
- }
-
- @Test
- public void testGetStaticSlotWithT() {
- StaticSlot staticSlot = new StaticSlot(1, "XML");
- when(env.get(staticSlot, "XML")).thenReturn(staticSlot.getKey());
-
- assertEquals(staticSlot.getKey(), trans.get(staticSlot, "XML"));
- }
-
- @Test
- public void testSetProperty() {
- String tag = "tag";
- String value = "value";
- String defltValue = "diffValue";
- when(env.setProperty(tag, value)).thenReturn(value);
- when(env.getProperty(tag)).thenReturn(value);
- when(env.getProperty(tag, defltValue)).thenReturn(defltValue);
-
- assertEquals(value, trans.setProperty(tag, value));
- assertEquals(value, trans.getProperty(tag));
- assertEquals(defltValue, trans.getProperty(tag, defltValue));
- }
-
- @Test
- public void testDecryptor() {
- when(env.decryptor()).thenReturn(Decryptor.NULL);
-
- assertEquals(Decryptor.NULL, trans.decryptor());
- assertEquals("tag", trans.decryptor().decrypt("tag"));
- }
-
- @Test
- public void testEncryptor() {
- when(env.encryptor()).thenReturn(Encryptor.NULL);
-
- assertEquals(Encryptor.NULL, trans.encryptor());
- assertEquals("tag", trans.encryptor().encrypt("tag"));
- }
+ BasicTrans trans = null;
+
+ @Mock
+ private EnvJAXB env;
+
+ @Mock
+ private TimeTaken timeTaken;
+
+ @Before
+ public void setUp() throws Exception {
+ trans = new BasicTrans(env);
+ }
+
+ @Test
+ public void testSlot() {
+ Slot slot = new Slot(1, "XML");
+ when(env.slot("XML")).thenReturn(slot);
+
+ Slot outputSlot = trans.slot("XML");
+ Object[] state = new Object[2];
+
+ slot.put(state, "JSON");
+
+ assertEquals(slot.get(state), "JSON");
+ assertEquals(slot.getKey(), outputSlot.getKey());
+ assertEquals(slot.toString(), outputSlot.toString());
+ }
+
+ @Test
+ public void testGetStaticSlot() {
+ StaticSlot staticSlot = new StaticSlot(1, "XML");
+ when(env.get(staticSlot)).thenReturn(staticSlot.toString());
+
+ assertEquals(staticSlot.toString(), trans.get(staticSlot));
+ }
+
+ @Test
+ public void testGetStaticSlotWithT() {
+ StaticSlot staticSlot = new StaticSlot(1, "XML");
+ when(env.get(staticSlot, "XML")).thenReturn(staticSlot.getKey());
+
+ assertEquals(staticSlot.getKey(), trans.get(staticSlot, "XML"));
+ }
+
+ @Test
+ public void testSetProperty() {
+ String tag = "tag";
+ String value = "value";
+ String defltValue = "diffValue";
+ when(env.setProperty(tag, value)).thenReturn(value);
+ when(env.getProperty(tag)).thenReturn(value);
+ when(env.getProperty(tag, defltValue)).thenReturn(defltValue);
+
+ assertEquals(value, trans.setProperty(tag, value));
+ assertEquals(value, trans.getProperty(tag));
+ assertEquals(defltValue, trans.getProperty(tag, defltValue));
+ }
+
+ @Test
+ public void testDecryptor() {
+ when(env.decryptor()).thenReturn(Decryptor.NULL);
+
+ assertEquals(Decryptor.NULL, trans.decryptor());
+ assertEquals("tag", trans.decryptor().decrypt("tag"));
+ }
+
+ @Test
+ public void testEncryptor() {
+ when(env.encryptor()).thenReturn(Encryptor.NULL);
+
+ assertEquals(Encryptor.NULL, trans.encryptor());
+ assertEquals("tag", trans.encryptor().encrypt("tag"));
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_LogTargetTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_LogTargetTest.java
index 474f646c..caaca1d1 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_LogTargetTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_LogTargetTest.java
@@ -34,54 +34,54 @@ import org.mockito.Mock;
public class JU_LogTargetTest {
- @Mock
- Throwable t;
+ @Mock
+ Throwable t;
- @Before
- public void setup() {
- t = mock(Throwable.class);
- }
+ @Before
+ public void setup() {
+ t = mock(Throwable.class);
+ }
- @Test
- public void testLogTargetNull() {
- LogTarget nullTarget = LogTarget.NULL;
+ @Test
+ public void testLogTargetNull() {
+ LogTarget nullTarget = LogTarget.NULL;
- // Expect methods doing nothing as no implemenation provided.
- nullTarget.log(new Throwable(), null, null);
- nullTarget.log("String", null);
- nullTarget.printf(null, null, null);
+ // Expect methods doing nothing as no implemenation provided.
+ nullTarget.log(new Throwable(), null, null);
+ nullTarget.log("String", null);
+ nullTarget.printf(null, null, null);
- assertFalse(nullTarget.isLoggable());
- }
+ assertFalse(nullTarget.isLoggable());
+ }
- @Test
- public void testLogTargetSysOut() {
- LogTarget outTarget = LogTarget.SYSOUT;
+ @Test
+ public void testLogTargetSysOut() {
+ LogTarget outTarget = LogTarget.SYSOUT;
- outTarget.printf("format", new Date());
- outTarget.log("null", null, null);
+ outTarget.printf("format", new Date());
+ outTarget.log("null", null, null);
- outTarget.log(t);
- outTarget.log(t, "First String Object");
+ outTarget.log(t);
+ outTarget.log(t, "First String Object");
- assertTrue(outTarget.isLoggable());
+ assertTrue(outTarget.isLoggable());
- verify(t, times(2)).printStackTrace(System.out);
- }
+ verify(t, times(2)).printStackTrace(System.out);
+ }
- @Test
- public void testLogTargetSysErr() {
- LogTarget errTarget = LogTarget.SYSERR;
+ @Test
+ public void testLogTargetSysErr() {
+ LogTarget errTarget = LogTarget.SYSERR;
- errTarget.printf("format", new Date());
- errTarget.log("null", "null");
+ errTarget.printf("format", new Date());
+ errTarget.log("null", "null");
- errTarget.log(t);
- errTarget.log(t, "First String Object");
+ errTarget.log(t);
+ errTarget.log(t, "First String Object");
- assertTrue(errTarget.isLoggable());
+ assertTrue(errTarget.isLoggable());
- verify(t, times(2)).printStackTrace(System.err);
- }
+ verify(t, times(2)).printStackTrace(System.err);
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_BasicEnvTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_BasicEnvTest.java
index 65dc7c50..b15972ef 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_BasicEnvTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_BasicEnvTest.java
@@ -40,141 +40,141 @@ import org.onap.aaf.misc.env.TimeTaken;
public class JU_BasicEnvTest {
- @Mock
- Decryptor decrypt;
+ @Mock
+ Decryptor decrypt;
- @Mock
- Encryptor encrypt;
+ @Mock
+ Encryptor encrypt;
- @Before
- public void setup() {
- decrypt = mock(Decryptor.class);
- encrypt = mock(Encryptor.class);
- }
+ @Before
+ public void setup() {
+ decrypt = mock(Decryptor.class);
+ encrypt = mock(Encryptor.class);
+ }
- @Test
- public void testLogTarget() {
- Properties prop = new Properties();
- BasicEnv env = new BasicEnv(prop);
+ @Test
+ public void testLogTarget() {
+ Properties prop = new Properties();
+ BasicEnv env = new BasicEnv(prop);
- assertEquals(env.fatal(), LogTarget.SYSERR);
- assertEquals(env.error(), LogTarget.SYSERR);
- assertEquals(env.audit(), LogTarget.SYSOUT);
- assertEquals(env.warn(), LogTarget.SYSERR);
- assertEquals(env.init(), LogTarget.SYSOUT);
- assertEquals(env.info(), LogTarget.SYSOUT);
- assertEquals(env.debug(), LogTarget.NULL);
- assertEquals(env.trace(), LogTarget.NULL);
+ assertEquals(env.fatal(), LogTarget.SYSERR);
+ assertEquals(env.error(), LogTarget.SYSERR);
+ assertEquals(env.audit(), LogTarget.SYSOUT);
+ assertEquals(env.warn(), LogTarget.SYSERR);
+ assertEquals(env.init(), LogTarget.SYSOUT);
+ assertEquals(env.info(), LogTarget.SYSOUT);
+ assertEquals(env.debug(), LogTarget.NULL);
+ assertEquals(env.trace(), LogTarget.NULL);
- env.debug(LogTarget.SYSOUT);
- assertEquals(env.debug(), LogTarget.SYSOUT);
+ env.debug(LogTarget.SYSOUT);
+ assertEquals(env.debug(), LogTarget.SYSOUT);
- assertNull(env.getProperty("key"));
- assertEquals("default", env.getProperty("key", "default"));
+ assertNull(env.getProperty("key"));
+ assertEquals("default", env.getProperty("key", "default"));
- env.setProperty("key", "value");
- assertEquals("value", env.getProperty("key", "default"));
+ env.setProperty("key", "value");
+ assertEquals("value", env.getProperty("key", "default"));
- Properties filteredProperties = env.getProperties("key");
- assertEquals(filteredProperties.size(), 1);
+ Properties filteredProperties = env.getProperties("key");
+ assertEquals(filteredProperties.size(), 1);
- env.setProperty("key", null);
- assertEquals("default", env.getProperty("key", "default"));
+ env.setProperty("key", null);
+ assertEquals("default", env.getProperty("key", "default"));
- filteredProperties = env.getProperties("key1");
- assertEquals(filteredProperties.size(), 0);
+ filteredProperties = env.getProperties("key1");
+ assertEquals(filteredProperties.size(), 0);
- filteredProperties = env.getProperties();
- assertEquals(filteredProperties.size(), 0);
+ filteredProperties = env.getProperties();
+ assertEquals(filteredProperties.size(), 0);
- }
+ }
- @Test
- public void testBasicEnv() {
- Applet applet = null;
+ @Test
+ public void testBasicEnv() {
+ Applet applet = null;
- BasicEnv env = new BasicEnv(applet, "tag1", "tag2");
+ BasicEnv env = new BasicEnv(applet, "tag1", "tag2");
- TimeTaken tt = env.start("Name", 2);
+ TimeTaken tt = env.start("Name", 2);
- long end = tt.end();
- StringBuilder sb = new StringBuilder();
+ long end = tt.end();
+ StringBuilder sb = new StringBuilder();
- assertEquals(tt.toString(), "Name " + (end - tt.start) / 1000000f + "ms ");
- tt.output(sb);
- assertEquals(sb.toString(), "XML Name " + (end - tt.start) / 1000000f + "ms");
+ assertEquals(tt.toString(), "Name " + (end - tt.start) / 1000000f + "ms ");
+ tt.output(sb);
+ assertEquals(sb.toString(), "XML Name " + (end - tt.start) / 1000000f + "ms");
- env.set(decrypt);
- assertEquals(env.decryptor(), decrypt);
- env.set(encrypt);
- assertEquals(env.encryptor(), encrypt);
- }
+ env.set(decrypt);
+ assertEquals(env.decryptor(), decrypt);
+ env.set(encrypt);
+ assertEquals(env.encryptor(), encrypt);
+ }
- @Test
- public void testBasicEnvDiffFlag() {
- Properties prop = new Properties();
+ @Test
+ public void testBasicEnvDiffFlag() {
+ Properties prop = new Properties();
- BasicEnv env = new BasicEnv("tag1", prop);
+ BasicEnv env = new BasicEnv("tag1", prop);
- TimeTaken tt = env.start("Name", 1);
+ TimeTaken tt = env.start("Name", 1);
- long end = tt.end();
- StringBuilder sb = new StringBuilder();
+ long end = tt.end();
+ StringBuilder sb = new StringBuilder();
- assertEquals(tt.toString(), "Name " + (end - tt.start) / 1000000f + "ms ");
- tt.output(sb);
- assertEquals(sb.toString(), "REMOTE Name " + (end - tt.start) / 1000000f + "ms");
+ assertEquals(tt.toString(), "Name " + (end - tt.start) / 1000000f + "ms ");
+ tt.output(sb);
+ assertEquals(sb.toString(), "REMOTE Name " + (end - tt.start) / 1000000f + "ms");
- tt = env.start("New Name", 4);
- tt.size(10);
- sb = new StringBuilder();
- tt.output(sb);
- assertEquals(tt.toString(), "New Name " + (end - tt.start) / 1000000f + "ms 10");
- assertEquals(sb.toString(), "JSON New Name " + (end - tt.start) / 1000000f + "ms size: 10");
+ tt = env.start("New Name", 4);
+ tt.size(10);
+ sb = new StringBuilder();
+ tt.output(sb);
+ assertEquals(tt.toString(), "New Name " + (end - tt.start) / 1000000f + "ms 10");
+ assertEquals(sb.toString(), "JSON New Name " + (end - tt.start) / 1000000f + "ms size: 10");
- env.staticSlot("tag", "prop");
+ env.staticSlot("tag", "prop");
- if (System.getProperties().keySet().iterator().hasNext()) {
- String key = (String) System.getProperties().keySet().iterator().next();
+ if (System.getProperties().keySet().iterator().hasNext()) {
+ String key = (String) System.getProperties().keySet().iterator().next();
- env.loadFromSystemPropsStartsWith(key);
- assertEquals(env.getProperty(key), System.getProperties().get(key));
- }
+ env.loadFromSystemPropsStartsWith(key);
+ assertEquals(env.getProperty(key), System.getProperties().get(key));
+ }
- BasicTrans trans = env.newTrans();
- assertEquals(trans.delegate, env);
+ BasicTrans trans = env.newTrans();
+ assertEquals(trans.delegate, env);
- }
+ }
- @Test
- public void testLoadProperties() throws IOException {
- Properties prop = new Properties();
+ @Test
+ public void testLoadProperties() throws IOException {
+ Properties prop = new Properties();
- BasicEnv env = new BasicEnv("tag1", prop);
+ BasicEnv env = new BasicEnv("tag1", prop);
- env.loadPropFiles("tag1", null);
- env.setProperty("tag1", "propfile.properties");
- env.loadPropFiles("tag1", null);
+ env.loadPropFiles("tag1", null);
+ env.setProperty("tag1", "propfile.properties");
+ env.loadPropFiles("tag1", null);
- assertEquals(env.getProperty("prop1"), "New Property");
+ assertEquals(env.getProperty("prop1"), "New Property");
- env.loadToSystemPropsStartsWith("prop1");
+ env.loadToSystemPropsStartsWith("prop1");
- assertTrue(System.getProperties().keySet().contains("prop1"));
- assertEquals(System.getProperties().get("prop1"), "New Property");
- }
+ assertTrue(System.getProperties().keySet().contains("prop1"));
+ assertEquals(System.getProperties().get("prop1"), "New Property");
+ }
- @After
- public void tearDown() throws IOException {
- /*
- * File file = new File("./log-Append" + ending + "_0.log"); if (file.exists())
- * { Files.delete(Paths.get(file.getAbsolutePath())); } file = new
- * File("./log-Append" + ending + "_1.log"); if (file.exists()) {
- * Files.delete(Paths.get(file.getAbsolutePath())); } file = new File("./Append"
- * + ending + "_0.log"); if (file.exists()) {
- * Files.delete(Paths.get(file.getAbsolutePath())); } file = new File("./Append"
- * + ending + "_1.log"); if (file.exists()) {
- * Files.delete(Paths.get(file.getAbsolutePath())); }
- */
- }
+ @After
+ public void tearDown() throws IOException {
+ /*
+ * File file = new File("./log-Append" + ending + "_0.log"); if (file.exists())
+ * { Files.delete(Paths.get(file.getAbsolutePath())); } file = new
+ * File("./log-Append" + ending + "_1.log"); if (file.exists()) {
+ * Files.delete(Paths.get(file.getAbsolutePath())); } file = new File("./Append"
+ * + ending + "_0.log"); if (file.exists()) {
+ * Files.delete(Paths.get(file.getAbsolutePath())); } file = new File("./Append"
+ * + ending + "_1.log"); if (file.exists()) {
+ * Files.delete(Paths.get(file.getAbsolutePath())); }
+ */
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_EnvFactoryTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_EnvFactoryTest.java
index f6c6912d..e5d0ed52 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_EnvFactoryTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_EnvFactoryTest.java
@@ -31,49 +31,49 @@ import org.onap.aaf.misc.env.TransJAXB;
public class JU_EnvFactoryTest {
- @Before
- public void setUp() throws Exception {
- }
+ @Before
+ public void setUp() throws Exception {
+ }
- @Test
- public void testSingleton() {
- BasicEnv singleton = EnvFactory.singleton();
+ @Test
+ public void testSingleton() {
+ BasicEnv singleton = EnvFactory.singleton();
- assertEquals(EnvFactory.singleton, singleton);
- }
+ assertEquals(EnvFactory.singleton, singleton);
+ }
- @Test
- public void testSetSingleton() {
- String[] str = { "argument1" };
- BasicEnv env = new BasicEnv("tag", str);
- EnvFactory.setSingleton(env);
+ @Test
+ public void testSetSingleton() {
+ String[] str = { "argument1" };
+ BasicEnv env = new BasicEnv("tag", str);
+ EnvFactory.setSingleton(env);
- assertEquals(EnvFactory.singleton(), env);
- }
+ assertEquals(EnvFactory.singleton(), env);
+ }
- @Test
- public void testNewTrans() {
- TransJAXB newTrans = EnvFactory.newTrans();
+ @Test
+ public void testNewTrans() {
+ TransJAXB newTrans = EnvFactory.newTrans();
- assertTrue(newTrans instanceof BasicTrans);
- }
+ assertTrue(newTrans instanceof BasicTrans);
+ }
- @Test
- public void testNewTransEnvJAXB() {
- EnvJAXB env = new BasicEnv("");
+ @Test
+ public void testNewTransEnvJAXB() {
+ EnvJAXB env = new BasicEnv("");
- TransJAXB trans = EnvFactory.newTrans(env);
+ TransJAXB trans = EnvFactory.newTrans(env);
- assertTrue(trans instanceof BasicTrans);
- }
+ assertTrue(trans instanceof BasicTrans);
+ }
- @Test
- public void testTransCreator() {
- TransCreate<TransJAXB> transCreator = EnvFactory.transCreator();
+ @Test
+ public void testTransCreator() {
+ TransCreate<TransJAXB> transCreator = EnvFactory.transCreator();
- TransJAXB newTrans = transCreator.newTrans();
+ TransJAXB newTrans = transCreator.newTrans();
- assertTrue(newTrans instanceof BasicTrans);
- }
+ assertTrue(newTrans instanceof BasicTrans);
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java
index e3f54929..914a01b0 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java
@@ -40,23 +40,23 @@ import org.powermock.modules.junit4.PowerMockRunner;
@PrepareForTest({ Log4JLogTarget.class, Logger.class })
public class JU_Log4JLogTargetTest {
- @Mock
- Logger log;
+ @Mock
+ Logger log;
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
- PowerMockito.mockStatic(Logger.class);
- when(Logger.getLogger("Info")).thenReturn(log);
- when(log.isEnabledFor(Level.DEBUG)).thenReturn(false);
- }
+ @Before
+ public void setup() {
+ MockitoAnnotations.initMocks(this);
+ PowerMockito.mockStatic(Logger.class);
+ when(Logger.getLogger("Info")).thenReturn(log);
+ when(log.isEnabledFor(Level.DEBUG)).thenReturn(false);
+ }
- @Test
- public void test() throws APIException {
- Log4JLogTarget target = new Log4JLogTarget(null, Level.INFO);
- Log4JLogTarget target1 = new Log4JLogTarget("Info", Level.DEBUG);
+ @Test
+ public void test() throws APIException {
+ Log4JLogTarget target = new Log4JLogTarget(null, Level.INFO);
+ Log4JLogTarget target1 = new Log4JLogTarget("Info", Level.DEBUG);
- assertFalse(target1.isLoggable());
+ assertFalse(target1.isLoggable());
- }
+ }
} \ No newline at end of file
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDataTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDataTest.java
index 80de9b7b..6780a6a8 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDataTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDataTest.java
@@ -43,138 +43,138 @@ import org.onap.aaf.misc.env.old.Stringifier;
public class JU_JAXBDataTest {
- @Mock
- private Objectifier<String> objfr;
+ @Mock
+ private Objectifier<String> objfr;
- private String object = "Text";
+ private String object = "Text";
- @Mock
- private Stringifier<String> strfr;
+ @Mock
+ private Stringifier<String> strfr;
- @Mock
- private IOStringifier<String> ioStrfr;
+ @Mock
+ private IOStringifier<String> ioStrfr;
- @Mock
- private JAXBDF<String> df;
+ @Mock
+ private JAXBDF<String> df;
- @Mock
- private Env env;
+ @Mock
+ private Env env;
- @Mock
- private Class<String> typeClass;
+ @Mock
+ private Class<String> typeClass;
- @Mock
- private OutputStream os;
+ @Mock
+ private OutputStream os;
- @Mock
- private Writer writer;
+ @Mock
+ private Writer writer;
- @Mock
- private EnvJAXB env1;
+ @Mock
+ private EnvJAXB env1;
- @Before
- public void setUp() throws Exception {
- writer = mock(Writer.class);
- os = mock(OutputStream.class);
- strfr = mock(Stringifier.class);
- ioStrfr = mock(IOStringifier.class);
- objfr = mock(Objectifier.class);
- env1 = mock(EnvJAXB.class);
- }
+ @Before
+ public void setUp() throws Exception {
+ writer = mock(Writer.class);
+ os = mock(OutputStream.class);
+ strfr = mock(Stringifier.class);
+ ioStrfr = mock(IOStringifier.class);
+ objfr = mock(Objectifier.class);
+ env1 = mock(EnvJAXB.class);
+ }
- @Test
- public void testJAXBDataEnv() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object, typeClass);
+ @Test
+ public void testJAXBDataEnv() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object, typeClass);
- when(objfr.objectify(env, object)).thenReturn("String1");
+ when(objfr.objectify(env, object)).thenReturn("String1");
- jaxb.to(os);
- jaxb.to(writer);
+ jaxb.to(os);
+ jaxb.to(writer);
- verify(writer).write(object);
- verify(os).write(object.getBytes());
+ verify(writer).write(object);
+ verify(os).write(object.getBytes());
- assertEquals(jaxb.asString(), object);
- assertEquals(jaxb.asString(null), object);
- assertEquals(jaxb.toString(), object);
- assertEquals(jaxb.getTypeClass(), typeClass);
- assertEquals(jaxb.out(null), jaxb);
- assertEquals(jaxb.in(null), jaxb);
- assertTrue(jaxb.getInputStream() instanceof ByteArrayInputStream);
- assertEquals(jaxb.asObject(), "String1");
- assertEquals(jaxb.asObject(env1), "String1");
- assertEquals(jaxb.toString(), object);
- }
+ assertEquals(jaxb.asString(), object);
+ assertEquals(jaxb.asString(null), object);
+ assertEquals(jaxb.toString(), object);
+ assertEquals(jaxb.getTypeClass(), typeClass);
+ assertEquals(jaxb.out(null), jaxb);
+ assertEquals(jaxb.in(null), jaxb);
+ assertTrue(jaxb.getInputStream() instanceof ByteArrayInputStream);
+ assertEquals(jaxb.asObject(), "String1");
+ assertEquals(jaxb.asObject(env1), "String1");
+ assertEquals(jaxb.toString(), object);
+ }
- @Test
- public void testJAXBDataEnvForObjectifier() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object, typeClass);
+ @Test
+ public void testJAXBDataEnvForObjectifier() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object, typeClass);
- when(objfr.objectify(env1, object)).thenReturn("String1");
+ when(objfr.objectify(env1, object)).thenReturn("String1");
- assertEquals(jaxb.asObject(env1), "String1");
- }
+ assertEquals(jaxb.asObject(env1), "String1");
+ }
- @Test
- public void testJAXBDataEnvWithObject() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
+ @Test
+ public void testJAXBDataEnvWithObject() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
- when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
+ when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
- jaxb.to(os);
+ jaxb.to(os);
- verify(os).write(object.getBytes());
+ verify(os).write(object.getBytes());
- assertEquals(jaxb.asString(), object);
- assertEquals(jaxb.asString(null), object);
- assertEquals(jaxb.toString(), object);
- }
+ assertEquals(jaxb.asString(), object);
+ assertEquals(jaxb.asString(null), object);
+ assertEquals(jaxb.toString(), object);
+ }
- @Test
- public void testJAXBDataEnvForWriter() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
+ @Test
+ public void testJAXBDataEnvForWriter() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
- when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
+ when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
- jaxb.to(writer);
+ jaxb.to(writer);
- verify(writer).write(object);
+ verify(writer).write(object);
- assertEquals(jaxb.asString(), object);
- assertEquals(jaxb.asString(null), object);
- assertEquals(jaxb.toString(), object);
- assertEquals(jaxb.asObject(), object);
- assertEquals(jaxb.asObject(null), object);
- }
+ assertEquals(jaxb.asString(), object);
+ assertEquals(jaxb.asString(null), object);
+ assertEquals(jaxb.toString(), object);
+ assertEquals(jaxb.asObject(), object);
+ assertEquals(jaxb.asObject(null), object);
+ }
- @Test
- public void testAsStringWithNullString() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
+ @Test
+ public void testAsStringWithNullString() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
- when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
+ when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
- assertEquals(jaxb.asString(), object);
- }
+ assertEquals(jaxb.asString(), object);
+ }
- @Test
- public void testAsStringWithNullStringWithEnv() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
+ @Test
+ public void testAsStringWithNullStringWithEnv() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
- when(strfr.stringify(env1, object)).thenReturn(object);
+ when(strfr.stringify(env1, object)).thenReturn(object);
- assertEquals(jaxb.asString(env1), object);
- }
+ assertEquals(jaxb.asString(env1), object);
+ }
- @Test
- public void testToWithIOStrifier() throws APIException, IOException {
- JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
+ @Test
+ public void testToWithIOStrifier() throws APIException, IOException {
+ JAXBData<String> jaxb = new JAXBData<String>(env, df, strfr, objfr, object);
- jaxb.option(0);
+ jaxb.option(0);
- when(strfr.stringify(env1, object)).thenReturn(object);
- when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
+ when(strfr.stringify(env1, object)).thenReturn(object);
+ when(strfr.stringify(env, object, new boolean[] { false, false })).thenReturn(object);
- assertTrue(jaxb.getInputStream() instanceof ByteArrayInputStream);
- assertEquals(jaxb.asString(env1), object);
- }
+ assertTrue(jaxb.getInputStream() instanceof ByteArrayInputStream);
+ assertEquals(jaxb.asString(env1), object);
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_ChronoTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_ChronoTest.java
index 05fd6fbf..c113c86e 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_ChronoTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_ChronoTest.java
@@ -36,204 +36,204 @@ import org.junit.Test;
public class JU_ChronoTest {
- @Before
- public void setUp() throws Exception {
- }
-
- @Test
- public void testFormatter8601() {
- Chrono.Formatter8601 formatter = new Chrono.Formatter8601();
+ @Before
+ public void setUp() throws Exception {
+ }
+
+ @Test
+ public void testFormatter8601() {
+ Chrono.Formatter8601 formatter = new Chrono.Formatter8601();
- LogRecord record = new LogRecord(Level.WARNING, "Log Record to test log formating");
+ LogRecord record = new LogRecord(Level.WARNING, "Log Record to test log formating");
- Date date = new Date(118, 02, 02);
- long time = date.getTime();
+ Date date = new Date(118, 02, 02);
+ long time = date.getTime();
- record.setMillis(time);
+ record.setMillis(time);
- String expectedString = Chrono.dateFmt.format(date) + " " + record.getThreadID() + " " + record.getLevel()
- + ": " + record.getMessage() + "\n";
- assertEquals(expectedString, formatter.format(record));
- }
+ String expectedString = Chrono.dateFmt.format(date) + " " + record.getThreadID() + " " + record.getLevel()
+ + ": " + record.getMessage() + "\n";
+ assertEquals(expectedString, formatter.format(record));
+ }
- @Test
- public void testTimeStampWithDate() {
- Date date = Calendar.getInstance().getTime();
- XMLGregorianCalendar timeStamp = Chrono.timeStamp(date);
+ @Test
+ public void testTimeStampWithDate() {
+ Date date = Calendar.getInstance().getTime();
+ XMLGregorianCalendar timeStamp = Chrono.timeStamp(date);
- GregorianCalendar gc = new GregorianCalendar();
- gc.setTime(date);
- XMLGregorianCalendar expectedCalendar = Chrono.xmlDatatypeFactory.newXMLGregorianCalendar(gc);
+ GregorianCalendar gc = new GregorianCalendar();
+ gc.setTime(date);
+ XMLGregorianCalendar expectedCalendar = Chrono.xmlDatatypeFactory.newXMLGregorianCalendar(gc);
- assertEquals(expectedCalendar, timeStamp);
- }
+ assertEquals(expectedCalendar, timeStamp);
+ }
- @Test
- public void testUTCStamp() {
- final Date date = Calendar.getInstance().getTime();
- String expectedUTCTime = Chrono.utcFmt.format(date);
+ @Test
+ public void testUTCStamp() {
+ final Date date = Calendar.getInstance().getTime();
+ String expectedUTCTime = Chrono.utcFmt.format(date);
- String stamp = Chrono.utcStamp(date);
+ String stamp = Chrono.utcStamp(date);
- assertEquals(stamp, expectedUTCTime);
+ assertEquals(stamp, expectedUTCTime);
- Date date1 = null;
- assertEquals("", Chrono.utcStamp(date1));
+ Date date1 = null;
+ assertEquals("", Chrono.utcStamp(date1));
- GregorianCalendar gc = null;
- assertEquals(Chrono.utcStamp(gc), "");
- gc = new GregorianCalendar();
- gc.setTime(date);
- assertEquals(Chrono.utcStamp(gc), expectedUTCTime);
+ GregorianCalendar gc = null;
+ assertEquals(Chrono.utcStamp(gc), "");
+ gc = new GregorianCalendar();
+ gc.setTime(date);
+ assertEquals(Chrono.utcStamp(gc), expectedUTCTime);
- XMLGregorianCalendar xgc = null;
- assertEquals(Chrono.utcStamp(xgc), "");
- xgc = Chrono.timeStamp(gc);
- assertEquals(Chrono.utcStamp(xgc), expectedUTCTime);
+ XMLGregorianCalendar xgc = null;
+ assertEquals(Chrono.utcStamp(xgc), "");
+ xgc = Chrono.timeStamp(gc);
+ assertEquals(Chrono.utcStamp(xgc), expectedUTCTime);
- }
+ }
- @Test
- public void testDateStamp() {
- final Date date = Calendar.getInstance().getTime();
- String expectedUTCTime = Chrono.dateFmt.format(date);
+ @Test
+ public void testDateStamp() {
+ final Date date = Calendar.getInstance().getTime();
+ String expectedUTCTime = Chrono.dateFmt.format(date);
- String stamp = Chrono.dateStamp(date);
+ String stamp = Chrono.dateStamp(date);
- assertEquals(stamp, expectedUTCTime);
+ assertEquals(stamp, expectedUTCTime);
- Date date1 = null;
- assertEquals("", Chrono.dateStamp(date1));
+ Date date1 = null;
+ assertEquals("", Chrono.dateStamp(date1));
- GregorianCalendar gc = null;
- assertEquals(Chrono.dateStamp(gc), "");
- gc = new GregorianCalendar();
- gc.setTime(date);
- assertEquals(Chrono.dateStamp(gc), expectedUTCTime);
+ GregorianCalendar gc = null;
+ assertEquals(Chrono.dateStamp(gc), "");
+ gc = new GregorianCalendar();
+ gc.setTime(date);
+ assertEquals(Chrono.dateStamp(gc), expectedUTCTime);
- XMLGregorianCalendar xgc = null;
- assertEquals(Chrono.dateStamp(xgc), "");
- xgc = Chrono.timeStamp(gc);
- assertEquals(Chrono.dateStamp(xgc), expectedUTCTime);
- }
+ XMLGregorianCalendar xgc = null;
+ assertEquals(Chrono.dateStamp(xgc), "");
+ xgc = Chrono.timeStamp(gc);
+ assertEquals(Chrono.dateStamp(xgc), expectedUTCTime);
+ }
- @Test
- public void testDateTime() {
- final Date date = Calendar.getInstance().getTime();
- date.setTime(1525023883297L);
+ @Test
+ public void testDateTime() {
+ final Date date = Calendar.getInstance().getTime();
+ date.setTime(1525023883297L);
- GregorianCalendar gc = null;
- assertEquals(Chrono.dateTime(gc), "");
- gc = new GregorianCalendar();
- gc.setTime(date);
+ GregorianCalendar gc = null;
+ assertEquals(Chrono.dateTime(gc), "");
+ gc = new GregorianCalendar();
+ gc.setTime(date);
- // String expectedDateTime = "2018-04-29T11:14:43.297" + sign + hourOffSet + ":"
- // + minOffSet;
+ // String expectedDateTime = "2018-04-29T11:14:43.297" + sign + hourOffSet + ":"
+ // + minOffSet;
- TimeZone tz = gc.getTimeZone();
- int tz1 = (tz.getRawOffset() + tz.getDSTSavings()) / 0x8CA0;
- int tz1abs = Math.abs(tz1);
- String expectedDateTime = String.format("%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d:%02d",
- gc.get(GregorianCalendar.YEAR), gc.get(GregorianCalendar.MONTH) + 1,
- gc.get(GregorianCalendar.DAY_OF_MONTH), gc.get(GregorianCalendar.HOUR),
- gc.get(GregorianCalendar.MINUTE), gc.get(GregorianCalendar.SECOND),
- gc.get(GregorianCalendar.MILLISECOND), tz1 == tz1abs ? '+' : '-', tz1abs / 100,
- ((tz1abs - (tz1abs / 100) * 100) * 6) / 10 // Get the "10s", then convert to mins (without losing int
- // place)
- );
+ TimeZone tz = gc.getTimeZone();
+ int tz1 = (tz.getRawOffset() + tz.getDSTSavings()) / 0x8CA0;
+ int tz1abs = Math.abs(tz1);
+ String expectedDateTime = String.format("%04d-%02d-%02dT%02d:%02d:%02d.%03d%c%02d:%02d",
+ gc.get(GregorianCalendar.YEAR), gc.get(GregorianCalendar.MONTH) + 1,
+ gc.get(GregorianCalendar.DAY_OF_MONTH), gc.get(GregorianCalendar.HOUR),
+ gc.get(GregorianCalendar.MINUTE), gc.get(GregorianCalendar.SECOND),
+ gc.get(GregorianCalendar.MILLISECOND), tz1 == tz1abs ? '+' : '-', tz1abs / 100,
+ ((tz1abs - (tz1abs / 100) * 100) * 6) / 10 // Get the "10s", then convert to mins (without losing int
+ // place)
+ );
- String stamp = Chrono.dateTime(date);
+ String stamp = Chrono.dateTime(date);
- assertEquals(stamp, expectedDateTime);
+ assertEquals(stamp, expectedDateTime);
- assertEquals(Chrono.dateTime(gc), expectedDateTime);
+ assertEquals(Chrono.dateTime(gc), expectedDateTime);
- XMLGregorianCalendar xgc = null;
- assertEquals(Chrono.dateTime(xgc), "");
- xgc = Chrono.timeStamp(gc);
- assertEquals(Chrono.dateTime(xgc), expectedDateTime);
- }
+ XMLGregorianCalendar xgc = null;
+ assertEquals(Chrono.dateTime(xgc), "");
+ xgc = Chrono.timeStamp(gc);
+ assertEquals(Chrono.dateTime(xgc), expectedDateTime);
+ }
- @Test
- public void testDateOnlyStamp() {
- final Date date = Calendar.getInstance().getTime();
- date.setTime(1525023883297L);
+ @Test
+ public void testDateOnlyStamp() {
+ final Date date = Calendar.getInstance().getTime();
+ date.setTime(1525023883297L);
- String expectedDateTime = Chrono.dateOnlyFmt.format(date);
+ String expectedDateTime = Chrono.dateOnlyFmt.format(date);
- String stamp = Chrono.dateOnlyStamp(date);
+ String stamp = Chrono.dateOnlyStamp(date);
- assertEquals(stamp, expectedDateTime);
+ assertEquals(stamp, expectedDateTime);
- Date date1 = null;
- assertEquals("", Chrono.dateOnlyStamp(date1));
+ Date date1 = null;
+ assertEquals("", Chrono.dateOnlyStamp(date1));
- GregorianCalendar gc = null;
- assertEquals(Chrono.dateOnlyStamp(gc), "");
- gc = new GregorianCalendar();
- gc.setTime(date);
- assertEquals(Chrono.dateOnlyStamp(gc), expectedDateTime);
+ GregorianCalendar gc = null;
+ assertEquals(Chrono.dateOnlyStamp(gc), "");
+ gc = new GregorianCalendar();
+ gc.setTime(date);
+ assertEquals(Chrono.dateOnlyStamp(gc), expectedDateTime);
- XMLGregorianCalendar xgc = null;
- assertEquals(Chrono.dateOnlyStamp(xgc), "");
- xgc = Chrono.timeStamp(gc);
- assertEquals(Chrono.dateOnlyStamp(xgc), expectedDateTime);
- }
+ XMLGregorianCalendar xgc = null;
+ assertEquals(Chrono.dateOnlyStamp(xgc), "");
+ xgc = Chrono.timeStamp(gc);
+ assertEquals(Chrono.dateOnlyStamp(xgc), expectedDateTime);
+ }
- @Test
- public void testNiceDateStamp() {
- final Date date = Calendar.getInstance().getTime();
- date.setTime(1525023883297L);
+ @Test
+ public void testNiceDateStamp() {
+ final Date date = Calendar.getInstance().getTime();
+ date.setTime(1525023883297L);
- String expectedDateTime = Chrono.niceDateFmt.format(date);
+ String expectedDateTime = Chrono.niceDateFmt.format(date);
- String stamp = Chrono.niceDateStamp(date);
+ String stamp = Chrono.niceDateStamp(date);
- assertEquals(stamp, expectedDateTime);
+ assertEquals(stamp, expectedDateTime);
- Date date1 = null;
- assertEquals("", Chrono.niceDateStamp(date1));
+ Date date1 = null;
+ assertEquals("", Chrono.niceDateStamp(date1));
- GregorianCalendar gc = null;
- assertEquals(Chrono.niceDateStamp(gc), "");
- gc = new GregorianCalendar();
- gc.setTime(date);
- assertEquals(Chrono.niceDateStamp(gc), expectedDateTime);
+ GregorianCalendar gc = null;
+ assertEquals(Chrono.niceDateStamp(gc), "");
+ gc = new GregorianCalendar();
+ gc.setTime(date);
+ assertEquals(Chrono.niceDateStamp(gc), expectedDateTime);
- XMLGregorianCalendar xgc = null;
- assertEquals(Chrono.niceDateStamp(xgc), "");
- xgc = Chrono.timeStamp(gc);
- assertEquals(Chrono.niceDateStamp(xgc), expectedDateTime);
- }
-
- @Test
- public void testMoment() {
- final Date date = Calendar.getInstance().getTime();
- date.setTime(1525023883297L);
+ XMLGregorianCalendar xgc = null;
+ assertEquals(Chrono.niceDateStamp(xgc), "");
+ xgc = Chrono.timeStamp(gc);
+ assertEquals(Chrono.niceDateStamp(xgc), expectedDateTime);
+ }
+
+ @Test
+ public void testMoment() {
+ final Date date = Calendar.getInstance().getTime();
+ date.setTime(1525023883297L);
- GregorianCalendar begin = new GregorianCalendar();
- begin.setTimeInMillis(date.getTime());
- begin.set(GregorianCalendar.HOUR, 0);
- begin.set(GregorianCalendar.AM_PM, GregorianCalendar.AM);
- begin.set(GregorianCalendar.MINUTE, 0);
- begin.set(GregorianCalendar.SECOND, 0);
- begin.set(GregorianCalendar.MILLISECOND, 0);
+ GregorianCalendar begin = new GregorianCalendar();
+ begin.setTimeInMillis(date.getTime());
+ begin.set(GregorianCalendar.HOUR, 0);
+ begin.set(GregorianCalendar.AM_PM, GregorianCalendar.AM);
+ begin.set(GregorianCalendar.MINUTE, 0);
+ begin.set(GregorianCalendar.SECOND, 0);
+ begin.set(GregorianCalendar.MILLISECOND, 0);
- long firstMoment = begin.getTimeInMillis();
+ long firstMoment = begin.getTimeInMillis();
- begin.set(GregorianCalendar.HOUR, 11);
- begin.set(GregorianCalendar.MINUTE, 59);
- begin.set(GregorianCalendar.SECOND, 59);
- begin.set(GregorianCalendar.MILLISECOND, 999);
- begin.set(GregorianCalendar.AM_PM, GregorianCalendar.PM);
+ begin.set(GregorianCalendar.HOUR, 11);
+ begin.set(GregorianCalendar.MINUTE, 59);
+ begin.set(GregorianCalendar.SECOND, 59);
+ begin.set(GregorianCalendar.MILLISECOND, 999);
+ begin.set(GregorianCalendar.AM_PM, GregorianCalendar.PM);
- long lastMoment = begin.getTimeInMillis();
+ long lastMoment = begin.getTimeInMillis();
- assertEquals(firstMoment, Chrono.firstMomentOfDay(date.getTime()));
- assertEquals(lastMoment, Chrono.lastMomentOfDay(date.getTime()));
+ assertEquals(firstMoment, Chrono.firstMomentOfDay(date.getTime()));
+ assertEquals(lastMoment, Chrono.lastMomentOfDay(date.getTime()));
- float timeInMillis = (lastMoment - firstMoment) / 1000000f;
- assertEquals(timeInMillis, Chrono.millisFromNanos(firstMoment, lastMoment), 0);
+ float timeInMillis = (lastMoment - firstMoment) / 1000000f;
+ assertEquals(timeInMillis, Chrono.millisFromNanos(firstMoment, lastMoment), 0);
- }
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_DoubleOutputStreamTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_DoubleOutputStreamTest.java
index 4b8c9dce..3e6f5355 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_DoubleOutputStreamTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_DoubleOutputStreamTest.java
@@ -34,71 +34,71 @@ import org.mockito.Mock;
public class JU_DoubleOutputStreamTest {
- @Mock
- private OutputStream stream1;
+ @Mock
+ private OutputStream stream1;
- @Mock
- private OutputStream stream2;
+ @Mock
+ private OutputStream stream2;
- private DoubleOutputStream doubleOutputStream;
+ private DoubleOutputStream doubleOutputStream;
- @Before
- public void setup() {
- stream1 = mock(OutputStream.class);
- stream2 = mock(OutputStream.class);
- }
+ @Before
+ public void setup() {
+ stream1 = mock(OutputStream.class);
+ stream2 = mock(OutputStream.class);
+ }
- @Test
- public void testWriteInt() throws IOException {
- doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
+ @Test
+ public void testWriteInt() throws IOException {
+ doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
- doubleOutputStream.write(123);
+ doubleOutputStream.write(123);
- verify(stream1, only()).write(123);
- verify(stream2, only()).write(123);
- }
+ verify(stream1, only()).write(123);
+ verify(stream2, only()).write(123);
+ }
- @Test
- public void testWriteByteArray() throws IOException {
- doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
+ @Test
+ public void testWriteByteArray() throws IOException {
+ doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
- byte[] bytes = { 1, 2, 3, 4 };
+ byte[] bytes = { 1, 2, 3, 4 };
- doubleOutputStream.write(bytes);
+ doubleOutputStream.write(bytes);
- verify(stream1, only()).write(bytes);
- verify(stream2, only()).write(bytes);
+ verify(stream1, only()).write(bytes);
+ verify(stream2, only()).write(bytes);
- }
+ }
- @Test
- public void testWriteByteArrayWithOffset() throws IOException {
- doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
+ @Test
+ public void testWriteByteArrayWithOffset() throws IOException {
+ doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
- byte[] bytes = { 1, 2, 3, 4 };
+ byte[] bytes = { 1, 2, 3, 4 };
- doubleOutputStream.write(bytes, 1, 3);
- verify(stream1, only()).write(bytes, 1, 3);
- verify(stream2, only()).write(bytes, 1, 3);
- }
+ doubleOutputStream.write(bytes, 1, 3);
+ verify(stream1, only()).write(bytes, 1, 3);
+ verify(stream2, only()).write(bytes, 1, 3);
+ }
- @Test
- public void testFlush() throws IOException {
- doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
+ @Test
+ public void testFlush() throws IOException {
+ doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, true);
- doubleOutputStream.flush();
+ doubleOutputStream.flush();
- verify(stream1, only()).flush();
- verify(stream2, only()).flush();
- }
+ verify(stream1, only()).flush();
+ verify(stream2, only()).flush();
+ }
- @Test
- public void testClose() throws IOException {
- doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, false);
+ @Test
+ public void testClose() throws IOException {
+ doubleOutputStream = new DoubleOutputStream(stream1, true, stream2, false);
- doubleOutputStream.close();
+ doubleOutputStream.close();
- verify(stream1, only()).close();
- verify(stream2, never()).close();
- }
+ verify(stream1, only()).close();
+ verify(stream2, never()).close();
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_IndentPrintWriterTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_IndentPrintWriterTest.java
index b54026f1..a307b3f8 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_IndentPrintWriterTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_IndentPrintWriterTest.java
@@ -35,79 +35,79 @@ import org.mockito.Mock;
public class JU_IndentPrintWriterTest {
- @Mock
- private OutputStream stream;
+ @Mock
+ private OutputStream stream;
- @Mock
- private Writer writer;
+ @Mock
+ private Writer writer;
- @Before
- public void setUp() throws Exception {
- stream = mock(OutputStream.class);
- writer = mock(Writer.class);
- }
+ @Before
+ public void setUp() throws Exception {
+ stream = mock(OutputStream.class);
+ writer = mock(Writer.class);
+ }
- @Test
- public void testWriteInt() throws IOException {
- IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
+ @Test
+ public void testWriteInt() throws IOException {
+ IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
- indentWriter.write(123);
+ indentWriter.write(123);
- verify(writer).write(123);
+ verify(writer).write(123);
- assertEquals(indentWriter.getIndent(), 0);
- }
+ assertEquals(indentWriter.getIndent(), 0);
+ }
- @Test
- public void testWriteIntWithNewLineCharacter() throws IOException {
- IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
+ @Test
+ public void testWriteIntWithNewLineCharacter() throws IOException {
+ IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
- indentWriter.setIndent(12);
+ indentWriter.setIndent(12);
- indentWriter.println();
+ indentWriter.println();
- indentWriter.write("123", 1, 2);
+ indentWriter.write("123", 1, 2);
- verify(writer).write('\n');
- verify(writer).write('2');
- verify(writer).write('3');
- assertEquals(indentWriter.getIndent(), 12);
- }
+ verify(writer).write('\n');
+ verify(writer).write('2');
+ verify(writer).write('3');
+ assertEquals(indentWriter.getIndent(), 12);
+ }
- @Test
- public void testWriteString() throws IOException {
- IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
+ @Test
+ public void testWriteString() throws IOException {
+ IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
- indentWriter.inc();
+ indentWriter.inc();
- indentWriter.write("123");
+ indentWriter.write("123");
- verify(writer).write('1');
- verify(writer).write('2');
- verify(writer).write('3');
- assertEquals(indentWriter.getIndent(), 1);
- }
+ verify(writer).write('1');
+ verify(writer).write('2');
+ verify(writer).write('3');
+ assertEquals(indentWriter.getIndent(), 1);
+ }
- @Test
- public void testSetIndent() throws IOException {
- IndentPrintWriter indentWriter = new IndentPrintWriter(stream);
+ @Test
+ public void testSetIndent() throws IOException {
+ IndentPrintWriter indentWriter = new IndentPrintWriter(stream);
- indentWriter.setIndent(12);
- indentWriter.dec();
+ indentWriter.setIndent(12);
+ indentWriter.dec();
- assertEquals(indentWriter.getIndent(), 11);
- }
+ assertEquals(indentWriter.getIndent(), 11);
+ }
- @Test
- public void testToCol() throws IOException {
- IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
+ @Test
+ public void testToCol() throws IOException {
+ IndentPrintWriter indentWriter = new IndentPrintWriter(writer);
- indentWriter.toCol(5);
- char[] chars = { 'a', 'b', 'c' };
- indentWriter.write(chars, 1, 2);
+ indentWriter.toCol(5);
+ char[] chars = { 'a', 'b', 'c' };
+ indentWriter.write(chars, 1, 2);
- verify(writer, times(5)).write(' ');
- verify(writer).write('c');
- verify(writer).write('b');
- }
+ verify(writer, times(5)).write(' ');
+ verify(writer).write('c');
+ verify(writer).write('b');
+ }
} \ No newline at end of file
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java
index ce2245bf..f5b4aaa4 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_SplitTest.java
@@ -27,30 +27,30 @@ import org.junit.Test;
public class JU_SplitTest {
- @Test
- public void testSplit() {
- String[] splits = Split.split('c', "character c to break string");
-
- assertEquals(splits.length, 4);
- assertEquals(splits[0], "");
- assertEquals(splits[1], "hara");
- assertEquals(splits[2], "ter ");
- assertEquals(splits[3], " to break string");
- }
-
- @Test
- public void testSplitTrim() {
- String[] splits = Split.splitTrim('c', "character c to break string", 5);
-
- assertEquals(splits.length, 5);
- assertEquals(splits[0], "");
- assertEquals(splits[1], "hara");
- assertEquals(splits[2], "ter");
- assertEquals(splits[3], "to break string");
- assertEquals(splits[4], null);
-
- splits = Split.splitTrim('c', " character ", 1);
- assertEquals(splits.length, 1);
- assertEquals(splits[0], "character");
- }
+ @Test
+ public void testSplit() {
+ String[] splits = Split.split('c', "character c to break string");
+
+ assertEquals(splits.length, 4);
+ assertEquals(splits[0], "");
+ assertEquals(splits[1], "hara");
+ assertEquals(splits[2], "ter ");
+ assertEquals(splits[3], " to break string");
+ }
+
+ @Test
+ public void testSplitTrim() {
+ String[] splits = Split.splitTrim('c', "character c to break string", 5);
+
+ assertEquals(splits.length, 5);
+ assertEquals(splits[0], "");
+ assertEquals(splits[1], "hara");
+ assertEquals(splits[2], "ter");
+ assertEquals(splits[3], "to break string");
+ assertEquals(splits[4], null);
+
+ splits = Split.splitTrim('c', " character ", 1);
+ assertEquals(splits.length, 1);
+ assertEquals(splits[0], "character");
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderOutputStreamTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderOutputStreamTest.java
index 377a2891..b55e2545 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderOutputStreamTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderOutputStreamTest.java
@@ -31,105 +31,105 @@ import org.junit.Test;
public class JU_StringBuilderOutputStreamTest {
- StringBuilderOutputStream streamBuilder;
-
- StringBuilder builder = new StringBuilder();
-
- @Before
- public void setUp() throws Exception {
- streamBuilder = new StringBuilderOutputStream(builder);
- }
-
- @Test
- public void testWriteIntAndReset() {
- streamBuilder.write(123);
-
- assertEquals("123", streamBuilder.toString());
- streamBuilder.reset();
- assertEquals("", streamBuilder.toString());
- }
-
- @Test
- public void testWriteByteArrayWithoutException() throws IOException {
- byte[] bytes = { 1, 2, 3, 4 };
- streamBuilder.write(bytes);
- assertEquals(4, streamBuilder.getBuffer().length());
-
- streamBuilder.write(bytes, 1, 2);
- assertEquals(6, streamBuilder.getBuffer().length());
-
- streamBuilder.write(bytes, 1, 0);
- assertEquals(6, streamBuilder.getBuffer().length());
-
- streamBuilder.append(bytes[0]);
- assertEquals(7, streamBuilder.getBuffer().length());
- }
-
- @Test
- public void testWriteByteArrayWithIndexOutOfBoundException() {
- byte[] bytes = { 1, 2, 3, 4 };
-
- try {
- streamBuilder.write(bytes, -1, 2);
- fail("This is supposed to throw IndexOutOfBounds Excetpion");
- } catch (IndexOutOfBoundsException e) {
- } catch (Exception e) {
- fail("This should throw only IndexOutOfBounds Exception");
- }
- assertEquals(0, streamBuilder.getBuffer().length());
-
- }
-
- @Test
- public void testDefaultConstructor() throws IOException {
- StringBuilderOutputStream stream = new StringBuilderOutputStream();
-
- assertNotNull(stream.getBuffer());
- stream.close();
- }
-
- @Test
- public void testConstructorWithPositiveDefaultCapacity() throws IOException {
- StringBuilderOutputStream stream = new StringBuilderOutputStream(10);
-
- assertNotNull(stream.getBuffer());
- assertEquals(10, stream.getBuffer().capacity());
- stream.close();
- }
-
- @Test
- public void testConstructorWithNegativeCapacityException() {
- try {
- StringBuilderOutputStream stream = new StringBuilderOutputStream(-1);
- fail("This should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- } catch (Exception e) {
- fail("This should throw only IllegalArgumentException");
- }
- }
-
- @Test
- public void testWriteString() {
- streamBuilder.write("1234");
-
- assertEquals("1234", streamBuilder.toString());
-
- streamBuilder.write("1234", 1, 2);
- assertEquals("12342", streamBuilder.toString());
- }
-
- @Test
- public void testAppendCharSequence() {
- streamBuilder.append("1234");
- assertEquals("1234", streamBuilder.toString());
-
- streamBuilder.append(null);
- assertEquals("1234null", streamBuilder.toString());
-
- streamBuilder.append("1234", 1, 2);
- assertEquals("1234null2", streamBuilder.toString());
-
- streamBuilder.append(null, 1, 2);
- assertEquals("1234null2u", streamBuilder.toString());
- }
+ StringBuilderOutputStream streamBuilder;
+
+ StringBuilder builder = new StringBuilder();
+
+ @Before
+ public void setUp() throws Exception {
+ streamBuilder = new StringBuilderOutputStream(builder);
+ }
+
+ @Test
+ public void testWriteIntAndReset() {
+ streamBuilder.write(123);
+
+ assertEquals("123", streamBuilder.toString());
+ streamBuilder.reset();
+ assertEquals("", streamBuilder.toString());
+ }
+
+ @Test
+ public void testWriteByteArrayWithoutException() throws IOException {
+ byte[] bytes = { 1, 2, 3, 4 };
+ streamBuilder.write(bytes);
+ assertEquals(4, streamBuilder.getBuffer().length());
+
+ streamBuilder.write(bytes, 1, 2);
+ assertEquals(6, streamBuilder.getBuffer().length());
+
+ streamBuilder.write(bytes, 1, 0);
+ assertEquals(6, streamBuilder.getBuffer().length());
+
+ streamBuilder.append(bytes[0]);
+ assertEquals(7, streamBuilder.getBuffer().length());
+ }
+
+ @Test
+ public void testWriteByteArrayWithIndexOutOfBoundException() {
+ byte[] bytes = { 1, 2, 3, 4 };
+
+ try {
+ streamBuilder.write(bytes, -1, 2);
+ fail("This is supposed to throw IndexOutOfBounds Excetpion");
+ } catch (IndexOutOfBoundsException e) {
+ } catch (Exception e) {
+ fail("This should throw only IndexOutOfBounds Exception");
+ }
+ assertEquals(0, streamBuilder.getBuffer().length());
+
+ }
+
+ @Test
+ public void testDefaultConstructor() throws IOException {
+ StringBuilderOutputStream stream = new StringBuilderOutputStream();
+
+ assertNotNull(stream.getBuffer());
+ stream.close();
+ }
+
+ @Test
+ public void testConstructorWithPositiveDefaultCapacity() throws IOException {
+ StringBuilderOutputStream stream = new StringBuilderOutputStream(10);
+
+ assertNotNull(stream.getBuffer());
+ assertEquals(10, stream.getBuffer().capacity());
+ stream.close();
+ }
+
+ @Test
+ public void testConstructorWithNegativeCapacityException() {
+ try {
+ StringBuilderOutputStream stream = new StringBuilderOutputStream(-1);
+ fail("This should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ } catch (Exception e) {
+ fail("This should throw only IllegalArgumentException");
+ }
+ }
+
+ @Test
+ public void testWriteString() {
+ streamBuilder.write("1234");
+
+ assertEquals("1234", streamBuilder.toString());
+
+ streamBuilder.write("1234", 1, 2);
+ assertEquals("12342", streamBuilder.toString());
+ }
+
+ @Test
+ public void testAppendCharSequence() {
+ streamBuilder.append("1234");
+ assertEquals("1234", streamBuilder.toString());
+
+ streamBuilder.append(null);
+ assertEquals("1234null", streamBuilder.toString());
+
+ streamBuilder.append("1234", 1, 2);
+ assertEquals("1234null2", streamBuilder.toString());
+
+ streamBuilder.append(null, 1, 2);
+ assertEquals("1234null2u", streamBuilder.toString());
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderWriterTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderWriterTest.java
index 6a06e866..9247d0c9 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderWriterTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/JU_StringBuilderWriterTest.java
@@ -31,105 +31,105 @@ import org.junit.Test;
public class JU_StringBuilderWriterTest {
- StringBuilderWriter streamWriter;
-
- StringBuilder builder = new StringBuilder();
-
- @Before
- public void setUp() throws Exception {
- streamWriter = new StringBuilderWriter(builder);
- }
-
- @Test
- public void testWriteIntAndReset() {
- streamWriter.write(1);
-
- assertEquals(1, streamWriter.getBuffer().length());
- streamWriter.reset();
- assertEquals("", streamWriter.toString());
- }
-
- @Test
- public void testWriteByteArrayWithoutException() throws IOException {
- char[] bytes = { 1, 2, 3, 4 };
- streamWriter.write(bytes);
- assertEquals(4, streamWriter.getBuffer().length());
-
- streamWriter.write(bytes, 1, 2);
- assertEquals(6, streamWriter.getBuffer().length());
-
- streamWriter.write(bytes, 1, 0);
- assertEquals(6, streamWriter.getBuffer().length());
-
- streamWriter.append(bytes[0]);
- assertEquals(7, streamWriter.getBuffer().length());
- }
-
- @Test
- public void testWriteByteArrayWithIndexOutOfBoundException() {
- char[] bytes = { 1, 2, 3, 4 };
-
- try {
- streamWriter.write(bytes, -1, 2);
- fail("This is supposed to throw IndexOutOfBounds Excetpion");
- } catch (IndexOutOfBoundsException e) {
- } catch (Exception e) {
- fail("This should throw only IndexOutOfBounds Exception");
- }
- assertEquals(0, streamWriter.getBuffer().length());
-
- }
-
- @Test
- public void testDefaultConstructor() throws IOException {
- StringBuilderWriter stream = new StringBuilderWriter();
-
- assertNotNull(stream.getBuffer());
- stream.close();
- }
-
- @Test
- public void testConstructorWithPositiveDefaultCapacity() throws IOException {
- StringBuilderWriter stream = new StringBuilderWriter(10);
-
- assertNotNull(stream.getBuffer());
- assertEquals(10, stream.getBuffer().capacity());
- stream.close();
- }
-
- @Test
- public void testConstructorWithNegativeCapacityException() {
- try {
- StringBuilderWriter stream = new StringBuilderWriter(-1);
- fail("This should throw IllegalArgumentException");
- } catch (IllegalArgumentException e) {
- } catch (Exception e) {
- fail("This should throw only IllegalArgumentException");
- }
- }
-
- @Test
- public void testWriteString() {
- streamWriter.write("1234");
-
- assertEquals("1234", streamWriter.toString());
-
- streamWriter.write("1234", 1, 2);
- assertEquals("123423", streamWriter.toString());
- }
-
- @Test
- public void testAppendCharSequence() {
- streamWriter.append("1234");
- assertEquals("1234", streamWriter.toString());
-
- streamWriter.append(null);
- assertEquals("1234null", streamWriter.toString());
-
- streamWriter.append("1234", 1, 2);
- assertEquals("1234null2", streamWriter.toString());
-
- streamWriter.append(null, 1, 2);
- assertEquals("1234null2u", streamWriter.toString());
- }
+ StringBuilderWriter streamWriter;
+
+ StringBuilder builder = new StringBuilder();
+
+ @Before
+ public void setUp() throws Exception {
+ streamWriter = new StringBuilderWriter(builder);
+ }
+
+ @Test
+ public void testWriteIntAndReset() {
+ streamWriter.write(1);
+
+ assertEquals(1, streamWriter.getBuffer().length());
+ streamWriter.reset();
+ assertEquals("", streamWriter.toString());
+ }
+
+ @Test
+ public void testWriteByteArrayWithoutException() throws IOException {
+ char[] bytes = { 1, 2, 3, 4 };
+ streamWriter.write(bytes);
+ assertEquals(4, streamWriter.getBuffer().length());
+
+ streamWriter.write(bytes, 1, 2);
+ assertEquals(6, streamWriter.getBuffer().length());
+
+ streamWriter.write(bytes, 1, 0);
+ assertEquals(6, streamWriter.getBuffer().length());
+
+ streamWriter.append(bytes[0]);
+ assertEquals(7, streamWriter.getBuffer().length());
+ }
+
+ @Test
+ public void testWriteByteArrayWithIndexOutOfBoundException() {
+ char[] bytes = { 1, 2, 3, 4 };
+
+ try {
+ streamWriter.write(bytes, -1, 2);
+ fail("This is supposed to throw IndexOutOfBounds Excetpion");
+ } catch (IndexOutOfBoundsException e) {
+ } catch (Exception e) {
+ fail("This should throw only IndexOutOfBounds Exception");
+ }
+ assertEquals(0, streamWriter.getBuffer().length());
+
+ }
+
+ @Test
+ public void testDefaultConstructor() throws IOException {
+ StringBuilderWriter stream = new StringBuilderWriter();
+
+ assertNotNull(stream.getBuffer());
+ stream.close();
+ }
+
+ @Test
+ public void testConstructorWithPositiveDefaultCapacity() throws IOException {
+ StringBuilderWriter stream = new StringBuilderWriter(10);
+
+ assertNotNull(stream.getBuffer());
+ assertEquals(10, stream.getBuffer().capacity());
+ stream.close();
+ }
+
+ @Test
+ public void testConstructorWithNegativeCapacityException() {
+ try {
+ StringBuilderWriter stream = new StringBuilderWriter(-1);
+ fail("This should throw IllegalArgumentException");
+ } catch (IllegalArgumentException e) {
+ } catch (Exception e) {
+ fail("This should throw only IllegalArgumentException");
+ }
+ }
+
+ @Test
+ public void testWriteString() {
+ streamWriter.write("1234");
+
+ assertEquals("1234", streamWriter.toString());
+
+ streamWriter.write("1234", 1, 2);
+ assertEquals("123423", streamWriter.toString());
+ }
+
+ @Test
+ public void testAppendCharSequence() {
+ streamWriter.append("1234");
+ assertEquals("1234", streamWriter.toString());
+
+ streamWriter.append(null);
+ assertEquals("1234null", streamWriter.toString());
+
+ streamWriter.append("1234", 1, 2);
+ assertEquals("1234null2", streamWriter.toString());
+
+ streamWriter.append(null, 1, 2);
+ assertEquals("1234null2u", streamWriter.toString());
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java
index 3976718f..0ce3a84e 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_IPValidator.java
@@ -29,39 +29,39 @@ import org.onap.aaf.misc.env.util.IPValidator;
public class JU_IPValidator {
- @Test
- public void test() {
- assertTrue(IPValidator.ipv4("10.10.10.10"));
- assertTrue(IPValidator.ipv4("127.0.0.0"));
- assertFalse(IPValidator.ipv4("10"));
- assertFalse(IPValidator.ipv4("10.10.10"));
- assertFalse(IPValidator.ipv4("10.10.10."));
- assertFalse(IPValidator.ipv4("10.10.10.10."));
- assertFalse(IPValidator.ipv4("10.10.10.10.10"));
- assertFalse(IPValidator.ipv4("something10.10.10.10"));
- assertTrue(IPValidator.ipv4("0.10.10.10"));
- assertTrue(IPValidator.ipv4("0.0.0.0"));
- assertTrue(IPValidator.ipv4("0.10.10.10"));
- assertFalse(IPValidator.ipv4("011.255.255.255"));
- assertFalse(IPValidator.ipv4("255.01.255.255"));
- assertFalse(IPValidator.ipv4("255.255.255.256"));
- assertFalse(IPValidator.ipv4("255.299.255.255"));
+ @Test
+ public void test() {
+ assertTrue(IPValidator.ipv4("10.10.10.10"));
+ assertTrue(IPValidator.ipv4("127.0.0.0"));
+ assertFalse(IPValidator.ipv4("10"));
+ assertFalse(IPValidator.ipv4("10.10.10"));
+ assertFalse(IPValidator.ipv4("10.10.10."));
+ assertFalse(IPValidator.ipv4("10.10.10.10."));
+ assertFalse(IPValidator.ipv4("10.10.10.10.10"));
+ assertFalse(IPValidator.ipv4("something10.10.10.10"));
+ assertTrue(IPValidator.ipv4("0.10.10.10"));
+ assertTrue(IPValidator.ipv4("0.0.0.0"));
+ assertTrue(IPValidator.ipv4("0.10.10.10"));
+ assertFalse(IPValidator.ipv4("011.255.255.255"));
+ assertFalse(IPValidator.ipv4("255.01.255.255"));
+ assertFalse(IPValidator.ipv4("255.255.255.256"));
+ assertFalse(IPValidator.ipv4("255.299.255.255"));
- assertTrue(IPValidator.ipv6("0000:0000:0000:0000:0000:0000:0000:0000"));
- assertTrue(IPValidator.ipv6("0:0:0:0:0:0:0:0"));
- assertTrue(IPValidator.ipv6("2001:08DB:0000:0000:0023:F422:FE3B:AC10"));
- assertTrue(IPValidator.ipv6("2001:8DB:0:0:23:F422:FE3B:AC10"));
- assertTrue(IPValidator.ipv6("2001:8DB::23:F422:FE3B:AC10"));
- assertTrue(IPValidator.ipv6("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
- assertTrue(IPValidator.ipv6("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"));
- assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10"));
- assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10"));
- // more than one Double Colons
- assertFalse(IPValidator.ipv6("0000:0000:0000::0000::0000"));
- assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10:FFFF"));
+ assertTrue(IPValidator.ipv6("0000:0000:0000:0000:0000:0000:0000:0000"));
+ assertTrue(IPValidator.ipv6("0:0:0:0:0:0:0:0"));
+ assertTrue(IPValidator.ipv6("2001:08DB:0000:0000:0023:F422:FE3B:AC10"));
+ assertTrue(IPValidator.ipv6("2001:8DB:0:0:23:F422:FE3B:AC10"));
+ assertTrue(IPValidator.ipv6("2001:8DB::23:F422:FE3B:AC10"));
+ assertTrue(IPValidator.ipv6("ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
+ assertTrue(IPValidator.ipv6("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF"));
+ assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10"));
+ assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10"));
+ // more than one Double Colons
+ assertFalse(IPValidator.ipv6("0000:0000:0000::0000::0000"));
+ assertFalse(IPValidator.ipv6("2001:8DB::23:G422:FE3B:AC10:FFFF"));
- assertTrue(IPValidator.ip("2001:08DB:0000:0000:0023:F422:FE3B:AC10"));
- assertTrue(IPValidator.ip("192.168.7.2"));
- }
+ assertTrue(IPValidator.ip("2001:08DB:0000:0000:0023:F422:FE3B:AC10"));
+ assertTrue(IPValidator.ip("192.168.7.2"));
+ }
}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java
index 11f03d52..32e4080b 100644
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/util/test/JU_PoolTest.java
@@ -30,57 +30,57 @@ import org.onap.aaf.misc.env.util.Pool;
public class JU_PoolTest {
- @Before
- public void setUp() throws Exception {
- }
+ @Before
+ public void setUp() throws Exception {
+ }
- @Test
- public void test() {
- Pool pool = new Pool<Integer>(new Pool.Creator<Integer>() {
+ @Test
+ public void test() {
+ Pool pool = new Pool<Integer>(new Pool.Creator<Integer>() {
- Integer content = 0;
+ Integer content = 0;
- @Override
- public Integer create() throws APIException {
- return content++;
- }
+ @Override
+ public Integer create() throws APIException {
+ return content++;
+ }
- @Override
- public void destroy(Integer t) {
+ @Override
+ public void destroy(Integer t) {
- }
+ }
- @Override
- public boolean isValid(Integer t) {
- return t == content;
- }
+ @Override
+ public boolean isValid(Integer t) {
+ return t == content;
+ }
- @Override
- public void reuse(Integer t) {
- content = t;
- }
- });
- Pool.Pooled<Integer> pooled = new Pool.Pooled<Integer>(new Integer(123), pool, LogTarget.SYSOUT);
- Pool.Pooled<Integer> pooled1 = new Pool.Pooled<Integer>(new Integer(123), null, LogTarget.SYSOUT);
- try {
- // pool.drain();
- assertEquals("Should return intial value", 0, pool.get().content);
- // pooled.toss();
- pool.prime(LogTarget.SYSOUT, 23);
- assertEquals("Should Return 23 as added at last prime", 23, pool.get(LogTarget.SYSOUT).content);
- pool.prime(LogTarget.SYSERR, 13);
- assertEquals("Should add another 13 from SysErr and remove 1", 35, pool.get(LogTarget.SYSERR).content);
- assertEquals("Create a new creator with create method", 1, pool.get().content);
- assertEquals("Create a new creator with create method", 2, pool.get().content);
- assertEquals("Should remove last from pool", 34, pool.get(LogTarget.SYSOUT).content);
+ @Override
+ public void reuse(Integer t) {
+ content = t;
+ }
+ });
+ Pool.Pooled<Integer> pooled = new Pool.Pooled<Integer>(new Integer(123), pool, LogTarget.SYSOUT);
+ Pool.Pooled<Integer> pooled1 = new Pool.Pooled<Integer>(new Integer(123), null, LogTarget.SYSOUT);
+ try {
+ // pool.drain();
+ assertEquals("Should return intial value", 0, pool.get().content);
+ // pooled.toss();
+ pool.prime(LogTarget.SYSOUT, 23);
+ assertEquals("Should Return 23 as added at last prime", 23, pool.get(LogTarget.SYSOUT).content);
+ pool.prime(LogTarget.SYSERR, 13);
+ assertEquals("Should add another 13 from SysErr and remove 1", 35, pool.get(LogTarget.SYSERR).content);
+ assertEquals("Create a new creator with create method", 1, pool.get().content);
+ assertEquals("Create a new creator with create method", 2, pool.get().content);
+ assertEquals("Should remove last from pool", 34, pool.get(LogTarget.SYSOUT).content);
- pool.drain();
- assertEquals("Should remove last from pool", 17, pool.get(LogTarget.SYSOUT).content);
- pool.setMaxRange(10);
- assertEquals(10, pool.getMaxRange());
- pooled.toss();
- pooled1.toss();
- } catch (APIException e) {
- }
- }
+ pool.drain();
+ assertEquals("Should remove last from pool", 17, pool.get(LogTarget.SYSOUT).content);
+ pool.setMaxRange(10);
+ assertEquals(10, pool.getMaxRange());
+ pooled.toss();
+ pooled1.toss();
+ } catch (APIException e) {
+ }
+ }
}