summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Future.java81
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NS.java41
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Role.java9
-rw-r--r--auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/AbsCredBody.java6
-rw-r--r--auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/data/CertResp.java3
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java135
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java137
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBObjectifierTest.java218
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBStringifierTest.java186
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_StoreImplTest.java144
10 files changed, 626 insertions, 334 deletions
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Future.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Future.java
index ac4a1323..d9ee272d 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Future.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Future.java
@@ -3,6 +3,8 @@
* org.onap.aaf
* ===========================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2018 IBM.
* ===========================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,7 +52,45 @@ public class Future implements CacheChange.Data, Comparable<Future> {
public final FutureDAO.Data fdd;
public final String role; // derived
private static final CacheChange<Future> cache = new CacheChange<>();
-
+
+ public static Creator<Future> v2_0_17 = new Creator<Future>() {
+ @Override
+ public Future create(Row row) {
+ return new Future(row.getUUID(0),row.getString(1),row.getString(2),
+ row.getTimestamp(3),row.getTimestamp(4), null);
+ }
+
+ @Override
+ public String select() {
+ return "select id,memo,target,start,expires from authz.future";
+ }
+ };
+
+ public static Creator<Future> withConstruct = new Creator<Future>() {
+ @Override
+ public String select() {
+ return "select id,memo,target,start,expires,construct from authz.future";
+ }
+
+ @Override
+ public Future create(Row row) {
+ return new Future(row.getUUID(0),row.getString(1),row.getString(2),
+ row.getTimestamp(3),row.getTimestamp(4), row.getBytes(5));
+ }
+
+ };
+
+
+ public Future(UUID id, String memo, String target, Date start, Date expires, ByteBuffer construct) {
+ fdd = new FutureDAO.Data();
+ fdd.id = id;
+ fdd.memo = memo;
+ fdd.target = target;
+ fdd.start = start;
+ fdd.expires = expires;
+ fdd.construct = construct;
+ role = Approval.roleFromMemo(memo);
+ }
public final UUID id() {
return fdd.id;
@@ -72,18 +112,6 @@ public class Future implements CacheChange.Data, Comparable<Future> {
return fdd.expires;
}
-
- public Future(UUID id, String memo, String target, Date start, Date expires, ByteBuffer construct) {
- fdd = new FutureDAO.Data();
- fdd.id = id;
- fdd.memo = memo;
- fdd.target = target;
- fdd.start = start;
- fdd.expires = expires;
- fdd.construct = construct;
- role = Approval.roleFromMemo(memo);
- }
-
public static void load(Trans trans, Session session, Creator<Future> creator) {
trans.info().log( "query: " + creator.select() );
ResultSet results;
@@ -118,33 +146,6 @@ public class Future implements CacheChange.Data, Comparable<Future> {
trans.info().log("Found",count,"Futures");
}
}
-
- public static Creator<Future> v2_0_17 = new Creator<Future>() {
- @Override
- public Future create(Row row) {
- return new Future(row.getUUID(0),row.getString(1),row.getString(2),
- row.getTimestamp(3),row.getTimestamp(4), null);
- }
-
- @Override
- public String select() {
- return "select id,memo,target,start,expires from authz.future";
- }
- };
-
- public static Creator<Future> withConstruct = new Creator<Future>() {
- @Override
- public String select() {
- return "select id,memo,target,start,expires,construct from authz.future";
- }
-
- @Override
- public Future create(Row row) {
- return new Future(row.getUUID(0),row.getString(1),row.getString(2),
- row.getTimestamp(3),row.getTimestamp(4), row.getBytes(5));
- }
-
- };
public Result<Void> delayedDelete(AuthzTrans trans, FutureDAO fd, boolean dryRun, String text) {
Result<Void> rv;
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NS.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NS.java
index 3df72e12..cad1c124 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NS.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/NS.java
@@ -3,6 +3,8 @@
* org.onap.aaf
* ===========================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2018 IBM.
* ===========================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,11 +37,26 @@ import com.datastax.driver.core.Session;
import com.datastax.driver.core.SimpleStatement;
import com.datastax.driver.core.Statement;
-public class NS implements Comparable<NS> {
- public final static Map<String,NS> data = new TreeMap<>();
+public class NS implements Comparable<NS> {
+ public static final Map<String,NS> data = new TreeMap<>();
+
+ public final String name;
+ public final String description;
+ public final String parent;
+ public final int scope;
+ public final int type;
- public final String name, description, parent;
- public final int scope,type;
+ public static Creator<NS> v2_0_11 = new Creator<NS> () {
+ @Override
+ public NS create(Row row) {
+ return new NS(row.getString(0),row.getString(1), row.getString(2),row.getInt(3),row.getInt(4));
+ }
+
+ @Override
+ public String select() {
+ return "SELECT name, description, parent, type, scope FROM authz.ns ";
+ }
+ };
public NS(String name, String description, String parent, int type, int scope) {
this.name = name;
@@ -143,7 +160,9 @@ public class NS implements Comparable<NS> {
}
}
public static NSSplit deriveParent(String dotted) {
- if (dotted==null)return null;
+ if (dotted==null) {
+ return null;
+ }
for (int idx = dotted.lastIndexOf('.');idx>=0; idx=dotted.lastIndexOf('.',idx-1)) {
if (data.get(dotted.substring(0, idx))!=null) {
return new NSSplit(dotted,idx);
@@ -151,18 +170,6 @@ public class NS implements Comparable<NS> {
}
return null;
}
-
- public static Creator<NS> v2_0_11 = new Creator<NS> () {
- @Override
- public NS create(Row row) {
- return new NS(row.getString(0),row.getString(1), row.getString(2),row.getInt(3),row.getInt(4));
- }
-
- @Override
- public String select() {
- return "SELECT name, description, parent, type, scope FROM authz.ns ";
- }
- };
} \ No newline at end of file
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Role.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Role.java
index 4b4a2551..6d87dedc 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Role.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/helpers/Role.java
@@ -3,6 +3,8 @@
* org.onap.aaf
* ===========================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2018 IBM.
* ===========================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -44,8 +46,11 @@ public class Role implements Comparable<Role> {
public static final TreeMap<String,Role> byName = new TreeMap<>();
private static List<Role> deleteRoles = new ArrayList<>();
- public final String ns, name, description;
- private String full, encode;
+ public final String ns;
+ public final String name;
+ public final String description;
+ private String full;
+ private String encode;
public final Set<String> perms;
public Role(String full) {
diff --git a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/AbsCredBody.java b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/AbsCredBody.java
index c0d16b06..db45e206 100644
--- a/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/AbsCredBody.java
+++ b/auth/auth-batch/src/main/java/org/onap/aaf/auth/batch/reports/bodies/AbsCredBody.java
@@ -3,6 +3,8 @@
* org.onap.aaf
* ===========================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2018 IBM.
* ===========================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -25,13 +27,13 @@ import java.util.List;
public abstract class AbsCredBody extends NotifyBody {
- public AbsCredBody(final String name) throws IOException {
+ public AbsCredBody(final String name) {
super("cred",name);
}
@Override
public String user(List<String> row) {
- if(row.size()>0) {
+ if( (row != null) && !row.isEmpty()) {
return row.get(1);
}
return null;
diff --git a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/data/CertResp.java b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/data/CertResp.java
index 71ccf3c7..9017763a 100644
--- a/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/data/CertResp.java
+++ b/auth/auth-certman/src/main/java/org/onap/aaf/auth/cm/data/CertResp.java
@@ -3,6 +3,8 @@
* org.onap.aaf
* ===========================================================================
* Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ *
+ * Modifications Copyright (C) 2018 IBM.
* ===========================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +24,6 @@
package org.onap.aaf.auth.cm.data;
import java.io.IOException;
-import java.security.GeneralSecurityException;
import java.security.KeyPair;
import java.security.cert.X509Certificate;
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java
deleted file mode 100644
index ac0e859c..00000000
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JAXBObjectifier.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.env.jaxb;
-
-import java.io.InputStream;
-import java.io.Reader;
-
-import javax.xml.bind.JAXBException;
-import javax.xml.validation.Schema;
-
-import org.onap.aaf.misc.env.APIException;
-import org.onap.aaf.misc.env.Env;
-import org.onap.aaf.misc.env.TimeTaken;
-import org.onap.aaf.misc.env.old.IOObjectifier;
-
-/**
- * Allow Extended IO interface usage without muddying up the Stringifier Interface
- */
-public class JAXBObjectifier<T> implements IOObjectifier<T> {
- private JAXBumar jumar;
-
- public JAXBObjectifier(Schema schema, Class<?>... classes) throws APIException {
- try {
- jumar = new JAXBumar(schema, classes);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- public JAXBObjectifier(Class<?>... classes) throws APIException {
- try {
- jumar = new JAXBumar(classes);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- // package on purpose
- JAXBObjectifier(JAXBumar jumar) {
- this.jumar = jumar;
- }
-
- @SuppressWarnings("unchecked")
- // @Override
- public T objectify(Env env, String input) throws APIException {
- TimeTaken tt = env.start("JAXB Unmarshal", Env.XML);
- try {
- tt.size(input.length());
- return (T)jumar.unmarshal(env.debug(), input);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- @SuppressWarnings("unchecked")
- // @Override
- public T objectify(Env env, Reader rdr) throws APIException {
- //TODO create a Reader that Counts?
- TimeTaken tt = env.start("JAXB Unmarshal", Env.XML);
- try {
- return (T)jumar.unmarshal(env.debug(), rdr);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
-
- @SuppressWarnings("unchecked")
- // @Override
- public T objectify(Env env, InputStream is) throws APIException {
- //TODO create a Reader that Counts?
- TimeTaken tt = env.start("JAXB Unmarshal", Env.XML);
- try {
- return (T)jumar.unmarshal(env.debug(), is);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
-
- public void servicePrestart(Env env) throws APIException {
- }
-
- public void threadPrestart(Env env) throws APIException {
- }
-
- // // @Override
- public void refresh(Env env) throws APIException {
- }
-
- // // @Override
- public void threadDestroy(Env env) throws APIException {
- }
-
- // // @Override
- public void serviceDestroy(Env env) throws APIException {
- }
-
-
- @SuppressWarnings("unchecked")
- public T newInstance() throws APIException {
- try {
- return (T)jumar.newInstance();
- } catch (Exception e) {
- throw new APIException(e);
- }
- }
-
-}
-
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java
deleted file mode 100644
index 9b8a2c97..00000000
--- a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JAXBStringifier.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/**
- * ============LICENSE_START====================================================
- * org.onap.aaf
- * ===========================================================================
- * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
- * ===========================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END====================================================
- *
- */
-
-package org.onap.aaf.misc.env.jaxb;
-
-import java.io.OutputStream;
-import java.io.StringWriter;
-import java.io.Writer;
-
-import javax.xml.bind.JAXBException;
-import javax.xml.namespace.QName;
-
-import org.onap.aaf.misc.env.APIException;
-import org.onap.aaf.misc.env.Env;
-import org.onap.aaf.misc.env.TimeTaken;
-import org.onap.aaf.misc.env.old.IOStringifier;
-
-public class JAXBStringifier<T> implements IOStringifier<T> {
- private JAXBmar jmar;
-
- public JAXBStringifier(Class<?>... classes) throws APIException {
- try {
- jmar = new JAXBmar(classes);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- public JAXBStringifier(QName qname, Class<?>... classes)
- throws APIException {
- try {
- jmar = new JAXBmar(qname, classes);
- } catch (JAXBException e) {
- throw new APIException(e);
- }
- }
-
- // package on purpose
- JAXBStringifier(JAXBmar jmar) {
- this.jmar = jmar;
- }
-
- // // @Override
- public void stringify(Env env, T input, Writer writer, boolean ... options)
- throws APIException {
- TimeTaken tt = env.start("JAXB Marshal", Env.XML);
- try {
- jmar.marshal(env.debug(), input, writer, options);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- // @Override
- public void stringify(Env env, T input, OutputStream os, boolean ... options)
- throws APIException {
- // TODO create an OutputStream that Counts?
- TimeTaken tt = env.start("JAXB Marshal", Env.XML);
- try {
- jmar.marshal(env.debug(), input, os, options);
- } catch (JAXBException e) {
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- // @Override
- public String stringify(Env env, T input, boolean ... options) throws APIException {
- TimeTaken tt = env.start("JAXB Marshal", Env.XML);
- StringWriter sw = new StringWriter();
- try {
- jmar.marshal(env.debug(), input, sw, options);
- String rv = sw.toString();
- tt.size(rv.length());
- return rv;
- } catch (JAXBException e) {
- tt.size(0);
- throw new APIException(e);
- } finally {
- tt.done();
- }
- }
-
- // // @Override
- public void servicePrestart(Env env) throws APIException {
- }
-
- // // @Override
- public void threadPrestart(Env env) throws APIException {
- }
-
- // // @Override
- public void refresh(Env env) throws APIException {
- }
-
- // // @Override
- public void threadDestroy(Env env) throws APIException {
- }
-
- // // @Override
- public void serviceDestroy(Env env) throws APIException {
- }
-
- // @Override
- public JAXBStringifier<T> pretty(boolean pretty) {
- jmar.pretty(pretty);
- return this;
- }
-
- // @Override
- public JAXBStringifier<T> asFragment(boolean fragment) {
- jmar.asFragment(fragment);
- return this;
- }
-
-}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBObjectifierTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBObjectifierTest.java
new file mode 100644
index 00000000..46feebb1
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBObjectifierTest.java
@@ -0,0 +1,218 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.misc.env.jaxb;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.io.InputStream;
+import java.io.StringReader;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.validation.Schema;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.aaf.misc.env.APIException;
+import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.LogTarget;
+import org.onap.aaf.misc.env.TimeTaken;
+
+public class JU_JAXBObjectifierTest {
+
+ @Mock
+ JAXBumar jumar;
+
+ @Mock
+ Schema schema;
+
+ @Mock
+ Env env;
+
+ TimeTaken tt,ttObjectify;
+
+ LogTarget logT;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ tt=Mockito.mock(TimeTaken.class);
+ Mockito.doReturn(tt).when(env).start("JAXB Unmarshal", Env.XML);
+ Mockito.doNothing().when(tt).done();
+ logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ }
+
+ @Test
+ public void testObjectify() {
+ JAXBObjectifier<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBObjectifier( schema, new Class[] {this.getClass()});
+ bdfObj = new JAXBObjectifier(jumar);
+ Mockito.doReturn(this.getClass()).when(jumar).unmarshal(logT, "test");
+ bdfObj.objectify(env, "test");
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testObjectifyException() {
+ JAXBObjectifier<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBObjectifier(jumar);
+ Mockito.doThrow(new JAXBException("Test Exception")).when(jumar).unmarshal(logT, "test");
+ bdfObj.objectify(env, "test");
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testObjectifyRdr() {
+ JAXBObjectifier<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBObjectifier(new Class[] {this.getClass()});
+ bdfObj = new JAXBObjectifier(jumar);
+ Mockito.doReturn(this.getClass()).when(jumar).unmarshal(logT, Mockito.mock(StringReader.class));
+ bdfObj.objectify(env, Mockito.mock(StringReader.class));
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testObjectifyRdrException() {
+ JAXBObjectifier<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBObjectifier(jumar);
+ StringReader sr = Mockito.mock(StringReader.class);
+ Mockito.doThrow(new JAXBException("Test Exception")).when(jumar).unmarshal(logT, sr);
+ bdfObj.objectify(env, sr);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testObjectifyIs() {
+ JAXBObjectifier<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBObjectifier(jumar);
+ Mockito.doReturn(this.getClass()).when(jumar).unmarshal(logT, Mockito.mock(InputStream.class));
+ bdfObj.objectify(env, Mockito.mock(InputStream.class));
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testObjectifyIsException() {
+ JAXBObjectifier<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBObjectifier(jumar);
+ InputStream sr = Mockito.mock(InputStream.class);
+ Mockito.doThrow(new JAXBException("Test Exception")).when(jumar).unmarshal(logT, sr);
+ bdfObj.objectify(env, sr);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testEmptyMethods() {
+ JAXBObjectifier<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBObjectifier(jumar);
+ bdfObj.servicePrestart(env);
+ bdfObj.threadPrestart(env);
+ bdfObj.threadDestroy(env);
+ bdfObj.serviceDestroy(env);
+ bdfObj.refresh(env);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ }
+
+ }
+
+ @Test
+ public void testNewInstance() {
+ JAXBObjectifier<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBObjectifier(jumar);
+ Object retVal = bdfObj.newInstance();
+ Mockito.doThrow(new IllegalAccessException("Test Exception")).when(jumar).newInstance();
+
+ } catch (IllegalAccessException e) {
+ assertEquals("Test Exception", e.getLocalizedMessage());
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testNewInstanceException() {
+ JAXBObjectifier<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBObjectifier(jumar);
+ Mockito.doThrow(new IllegalAccessException("Test Exception")).when(jumar).newInstance();
+ Object retVal = bdfObj.newInstance();
+ } catch (IllegalAccessException e) {
+ assertEquals("Test Exception", e.getLocalizedMessage());
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (InstantiationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBStringifierTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBStringifierTest.java
new file mode 100644
index 00000000..7d310ae7
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBStringifierTest.java
@@ -0,0 +1,186 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.misc.env.jaxb;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.onap.aaf.misc.env.APIException;
+import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.LogTarget;
+import org.onap.aaf.misc.env.TimeTaken;
+
+public class JU_JAXBStringifierTest {
+
+ @Mock
+ JAXBmar jumar;
+
+ @Mock
+ QName qname;
+
+ @Mock
+ Env env;
+
+ TimeTaken tt,ttstringify;
+
+ LogTarget logT;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ tt=Mockito.mock(TimeTaken.class);
+ Mockito.doReturn(tt).when(env).start("JAXB Marshal", Env.XML);
+ Mockito.doNothing().when(tt).done();
+ logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ }
+
+ @Test
+ public void teststringify() {
+ JAXBStringifier<JAXBmar> bdfObj = null;
+ try {
+ bdfObj = new JAXBStringifier<JAXBmar>( qname, new Class[] {this.getClass()});
+ bdfObj = new JAXBStringifier<JAXBmar>(jumar);
+ Mockito.doReturn(this.getClass()).when(jumar).marshal(logT, jumar, Mockito.mock(StringWriter.class), true);
+ bdfObj.stringify(env, jumar, true);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void teststringifyWriter() {
+ JAXBStringifier<JAXBmar> bdfObj = null;
+ try {
+ bdfObj = new JAXBStringifier<JAXBmar>(new Class[] {this.getClass()});
+ bdfObj = new JAXBStringifier<JAXBmar>(jumar);
+ Mockito.doReturn(this.getClass()).when(jumar).marshal(logT, jumar, Mockito.mock(StringWriter.class), true);
+ bdfObj.stringify(env, jumar, Mockito.mock(StringWriter.class), true);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void teststringifyWriterException() {
+ JAXBStringifier<JAXBmar> bdfObj = null;
+ try {
+ bdfObj = new JAXBStringifier<JAXBmar>(jumar);
+ StringWriter sr = Mockito.mock(StringWriter.class);
+ Mockito.doThrow(new JAXBException("Test Exception")).when(jumar).marshal(logT, jumar, sr, true);
+ bdfObj.stringify(env, jumar, sr, true);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void teststringifyOs() {
+ JAXBStringifier<JAXBmar> bdfObj = null;
+ try {
+ bdfObj = new JAXBStringifier<JAXBmar>(jumar);
+ Mockito.doReturn(this.getClass()).when(jumar).marshal(logT, jumar, Mockito.mock(OutputStream.class), true);
+ bdfObj.stringify(env, jumar, Mockito.mock(OutputStream.class), true);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void teststringifyOsException() {
+ JAXBStringifier<JAXBmar> bdfObj = null;
+ try {
+ bdfObj = new JAXBStringifier<JAXBmar>(jumar);
+ OutputStream os = Mockito.mock(OutputStream.class);
+ Mockito.doThrow(new JAXBException("Test Exception")).when(jumar).marshal(logT, jumar, os, true);
+ bdfObj.stringify(env, jumar, os, true);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testEmptyMethods() {
+ JAXBStringifier<JAXBmar> bdfObj = null;
+ try {
+ bdfObj = new JAXBStringifier<JAXBmar>(jumar);
+ bdfObj.servicePrestart(env);
+ bdfObj.threadPrestart(env);
+ bdfObj.threadDestroy(env);
+ bdfObj.serviceDestroy(env);
+ bdfObj.refresh(env);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("Test Exception"));
+ }
+
+ }
+
+ @Test
+ public void testPretty() {
+ JAXBStringifier<JAXBmar> bdfObj = null;
+ bdfObj = new JAXBStringifier<JAXBmar>(jumar);
+ Mockito.doReturn(jumar).when(jumar).pretty(true);
+ Object retVal = bdfObj.pretty(true);
+ assertTrue(retVal instanceof JAXBStringifier);
+ }
+
+ @Test
+ public void testNewInstanceException() {
+ JAXBStringifier<JAXBmar> bdfObj = null;
+ bdfObj = new JAXBStringifier<JAXBmar>(jumar);
+ Mockito.doReturn(jumar).when(jumar).asFragment(true);
+ Object retVal = bdfObj.asFragment(true);
+ assertTrue(retVal instanceof JAXBStringifier);
+
+ }
+}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_StoreImplTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_StoreImplTest.java
new file mode 100644
index 00000000..db48345c
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_StoreImplTest.java
@@ -0,0 +1,144 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+package org.onap.aaf.misc.env;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.io.File;
+import java.util.List;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+public class JU_StoreImplTest {
+
+ @Mock
+ QName qname;
+
+ @Mock
+ Env env;
+
+ TimeTaken tt,ttstringify;
+
+ LogTarget logT;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ tt=Mockito.mock(TimeTaken.class);
+ Mockito.doReturn(tt).when(env).start("JAXB Marshal", Env.XML);
+ Mockito.doNothing().when(tt).done();
+ logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ }
+
+ @Test
+ public void testPropsFromArgs() {
+ StoreImpl bdfObj = new StoreImpl();
+ bdfObj = new StoreImpl("");
+ bdfObj.propsFromArgs(null, new String[] {"test"});
+ bdfObj.propsFromArgs("test", new String[] {"test","te=st","test=1"});
+
+ }
+
+ @Test
+ public void testMorePropsConstructor() {
+ Properties props = Mockito.mock(Properties.class);
+ new StoreImpl(null,props);
+ StoreImpl bdfObj = new StoreImpl("test",props);
+ }
+
+ @Test
+ public void testMorePropsFileNOtExists() {
+ Properties props = Mockito.mock(Properties.class);
+ Mockito.doReturn("test").when(props).getProperty("test");
+ StoreImpl bdfObj = new StoreImpl("test",props);
+ }
+
+ @Test
+ public void testMorePropsExists() {
+ Properties props = Mockito.mock(Properties.class);
+ Mockito.doReturn(System.getProperty("user.dir")+"/src/test/java/org/onap/aaf/misc/env/JU_StoreImplTest.java").when(props).getProperty("test");
+ StoreImpl bdfObj = new StoreImpl("test",props);
+ }
+
+ @Test
+ public void testNewTransState() {
+ StoreImpl bdfObj = new StoreImpl(null, new String[] {});
+ bdfObj.newTransState();
+ }
+
+ @Test
+ public void testSlot() {
+ StoreImpl bdfObj = new StoreImpl("test", new String[] {});
+ Slot slot = bdfObj.slot(null);
+ assertEquals(slot.toString(),"=0");
+ slot = bdfObj.slot("test");
+ assertEquals(slot.toString(),"test=1");
+ }
+
+ @Test
+ public void testExistingSlot() {
+ StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
+ Slot retVal = bdfObj.existingSlot("test");
+ assertNull(retVal);
+ }
+
+ @Test
+ public void testExistingSlotNames() {
+ StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
+ List<String> retVal = bdfObj.existingSlotNames();
+ assertTrue(retVal.size()==0);
+ }
+
+ @Test
+ public void testGet() {
+ StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
+ Object retVal = bdfObj.get(new StaticSlot(1,"test"),qname);
+ assertTrue(retVal instanceof QName);
+ }
+
+ @Test
+ public void testGetSlot() {
+ StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
+ Object retVal = bdfObj.get(new StaticSlot(1,"test"));
+ assertNull(retVal);
+ }
+
+ @Test
+ public void testExistingStaticSlotNames() {
+ StoreImpl bdfObj = new StoreImpl("test", new String[] {"test","test=1"});
+ List<String> retVal = bdfObj.existingStaticSlotNames();
+ assertTrue(retVal.size()==1);
+ }
+}