summaryrefslogtreecommitdiffstats
path: root/misc/env/src
diff options
context:
space:
mode:
authorSai Gandham <sg481n@att.com>2018-12-30 23:17:59 -0600
committerSai Gandham <sg481n@att.com>2018-12-30 23:18:15 -0600
commit850788c053064409ad07b2b313396c674b57ac4b (patch)
tree98fab74319b35d8b661ee2171de01924f61e81f7 /misc/env/src
parent52c89c9940544c1b2db1dd1e0ce9b22e2fcdca42 (diff)
Add more junits in auth cass & misc env
Issue-ID: AAF-111 Change-Id: Iac8ff0043b89b00f2f6f9f45ccfa6253552d445d Signed-off-by: Sai Gandham <sg481n@att.com>
Diffstat (limited to 'misc/env/src')
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/Api.java373
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/JU_BaseDataFactory.java82
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/JU_JavaUtilLogTarget.java85
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/JU_NullLifeCycle.java43
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_Log4JLogTargetTest.java80
-rw-r--r--misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDF.java714
6 files changed, 1360 insertions, 17 deletions
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/Api.java b/misc/env/src/test/java/org/onap/aaf/misc/env/Api.java
new file mode 100644
index 00000000..688e11b8
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/Api.java
@@ -0,0 +1,373 @@
+/**
+ * ============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====================================================
+ *
+ */
+//
+// This file was generated by the JavaTM Architecture for XML Binding(JAXB) Reference Implementation, v2.2.5-2
+// See <a href="http://java.sun.com/xml/jaxb">http://java.sun.com/xml/jaxb</a>
+// Any modifications to this file will be lost upon recompilation of the source schema.
+// Generated on: 2018.12.09 at 10:14:23 PM IST
+//
+
+
+package org.onap.aaf.misc.env;
+
+import java.util.ArrayList;
+import java.util.List;
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+
+/**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="route" maxOccurs="unbounded" minOccurs="0">
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="meth" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="path" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="param" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="desc" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="comments" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="contentType" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="expected" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ * &lt;element name="explicitErr" type="{http://www.w3.org/2001/XMLSchema}int" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * &lt;/element>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+@XmlAccessorType(XmlAccessType.FIELD)
+@XmlType(name = "", propOrder = {
+ "route"
+})
+@XmlRootElement(name = "api")
+public class Api {
+
+ protected List<Api.Route> route;
+
+ /**
+ * Gets the value of the route property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the route property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getRoute().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Api.Route }
+ *
+ *
+ */
+ public List<Api.Route> getRoute() {
+ if (route == null) {
+ route = new ArrayList<Api.Route>();
+ }
+ return this.route;
+ }
+
+
+ /**
+ * <p>Java class for anonymous complex type.
+ *
+ * <p>The following schema fragment specifies the expected content contained within this class.
+ *
+ * <pre>
+ * &lt;complexType>
+ * &lt;complexContent>
+ * &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ * &lt;sequence>
+ * &lt;element name="meth" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="path" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="param" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="desc" type="{http://www.w3.org/2001/XMLSchema}string"/>
+ * &lt;element name="comments" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="contentType" type="{http://www.w3.org/2001/XMLSchema}string" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;element name="expected" type="{http://www.w3.org/2001/XMLSchema}int"/>
+ * &lt;element name="explicitErr" type="{http://www.w3.org/2001/XMLSchema}int" maxOccurs="unbounded" minOccurs="0"/>
+ * &lt;/sequence>
+ * &lt;/restriction>
+ * &lt;/complexContent>
+ * &lt;/complexType>
+ * </pre>
+ *
+ *
+ */
+ @XmlAccessorType(XmlAccessType.FIELD)
+ @XmlType(name = "", propOrder = {
+ "meth",
+ "path",
+ "param",
+ "desc",
+ "comments",
+ "contentType",
+ "expected",
+ "explicitErr"
+ })
+ public static class Route {
+
+ @XmlElement(required = true)
+ protected String meth;
+ @XmlElement(required = true)
+ protected String path;
+ protected List<String> param;
+ @XmlElement(required = true)
+ protected String desc;
+ protected List<String> comments;
+ protected List<String> contentType;
+ protected int expected;
+ @XmlElement(type = Integer.class)
+ protected List<Integer> explicitErr;
+
+ /**
+ * Gets the value of the meth property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getMeth() {
+ return meth;
+ }
+
+ /**
+ * Sets the value of the meth property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setMeth(String value) {
+ this.meth = value;
+ }
+
+ /**
+ * Gets the value of the path property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getPath() {
+ return path;
+ }
+
+ /**
+ * Sets the value of the path property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setPath(String value) {
+ this.path = value;
+ }
+
+ /**
+ * Gets the value of the param property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the param property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getParam().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getParam() {
+ if (param == null) {
+ param = new ArrayList<String>();
+ }
+ return this.param;
+ }
+
+ /**
+ * Gets the value of the desc property.
+ *
+ * @return
+ * possible object is
+ * {@link String }
+ *
+ */
+ public String getDesc() {
+ return desc;
+ }
+
+ /**
+ * Sets the value of the desc property.
+ *
+ * @param value
+ * allowed object is
+ * {@link String }
+ *
+ */
+ public void setDesc(String value) {
+ this.desc = value;
+ }
+
+ /**
+ * Gets the value of the comments property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the comments property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getComments().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getComments() {
+ if (comments == null) {
+ comments = new ArrayList<String>();
+ }
+ return this.comments;
+ }
+
+ /**
+ * Gets the value of the contentType property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the contentType property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getContentType().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link String }
+ *
+ *
+ */
+ public List<String> getContentType() {
+ if (contentType == null) {
+ contentType = new ArrayList<String>();
+ }
+ return this.contentType;
+ }
+
+ /**
+ * Gets the value of the expected property.
+ *
+ */
+ public int getExpected() {
+ return expected;
+ }
+
+ /**
+ * Sets the value of the expected property.
+ *
+ */
+ public void setExpected(int value) {
+ this.expected = value;
+ }
+
+ /**
+ * Gets the value of the explicitErr property.
+ *
+ * <p>
+ * This accessor method returns a reference to the live list,
+ * not a snapshot. Therefore any modification you make to the
+ * returned list will be present inside the JAXB object.
+ * This is why there is not a <CODE>set</CODE> method for the explicitErr property.
+ *
+ * <p>
+ * For example, to add a new item, do as follows:
+ * <pre>
+ * getExplicitErr().add(newItem);
+ * </pre>
+ *
+ *
+ * <p>
+ * Objects of the following type(s) are allowed in the list
+ * {@link Integer }
+ *
+ *
+ */
+ public List<Integer> getExplicitErr() {
+ if (explicitErr == null) {
+ explicitErr = new ArrayList<Integer>();
+ }
+ return this.explicitErr;
+ }
+
+ }
+
+}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_BaseDataFactory.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_BaseDataFactory.java
new file mode 100644
index 00000000..0c21bda3
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_BaseDataFactory.java
@@ -0,0 +1,82 @@
+/**
+ * ============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.assertTrue;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.aaf.misc.env.impl.EnvFactory;
+
+public class JU_BaseDataFactory {
+
+ @Before
+ public void setUp() throws Exception {
+ initMocks(this);
+ }
+
+ @Test
+ public void testGenSchemaException() {
+ Store env = Mockito.mock(Store.class);
+ Mockito.doReturn("testdir").when(env).get(null, EnvFactory.DEFAULT_SCHEMA_DIR);
+ try {
+ BaseDataFactory.genSchema(env, new String[] {});
+ } catch (APIException e) {
+ assertTrue(e.getLocalizedMessage().contains("does not exist. You can set this with"));
+ }
+ }
+
+ @Test
+ public void testGenSchemaXsdException() {
+ Store env = Mockito.mock(Store.class);
+ Mockito.doReturn(System.getProperty("user.dir")).when(env).get(null, EnvFactory.DEFAULT_SCHEMA_DIR);
+ String[] schemaFIles = new String[] {"../auth-client/src/main/xsd/aaf_2_0.xsd"};
+ try {
+ BaseDataFactory.genSchema(env, schemaFIles);
+ } catch (APIException e) {
+ assertTrue(e.getLocalizedMessage().contains("for schema validation"));
+ }
+ }
+
+ @Test
+ public void testGenSchemaNoException() {
+ Store env = Mockito.mock(Store.class);
+ Mockito.doReturn(System.getProperty("user.dir")).when(env).get(null, EnvFactory.DEFAULT_SCHEMA_DIR);
+ String[] schemaFIles = new String[] {"../../auth-client/src/main/xsd/aaf_2_0.xsd"};
+ try {
+ BaseDataFactory.genSchema(env, schemaFIles);
+ } catch (APIException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testGetQName() {
+ String[] schemaFIles = new String[] {"../../auth-client/src/main/xsd/aaf_2_0.xsd"};
+ try {
+ BaseDataFactory.getQName(Api.class);
+ } catch (APIException e) {
+ assertTrue(e.getLocalizedMessage().contains("package-info does not have an XmlSchema annotation"));
+ }
+ }
+}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_JavaUtilLogTarget.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_JavaUtilLogTarget.java
new file mode 100644
index 00000000..2617559d
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_JavaUtilLogTarget.java
@@ -0,0 +1,85 @@
+/**
+ * ============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.impl;
+
+import static org.junit.Assert.assertFalse;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+
+public class JU_JavaUtilLogTarget {
+
+ @Mock
+ Level level;
+
+ @Mock
+ Logger log;
+
+ @Before
+ public void setup() {
+ initMocks(this);
+ }
+
+ @Test
+ public void testLoggable() {
+ JavaUtilLogTarget logObj = new JavaUtilLogTarget( log, level);
+ boolean retVal = logObj.isLoggable();
+
+ assertFalse(retVal);
+ }
+
+ @Test
+ public void testLog() {
+ JavaUtilLogTarget logObj = new JavaUtilLogTarget( log, level);
+ Mockito.doReturn(false).when(log).isLoggable(level);
+ logObj.log(new Object[] {"test","test2",""});
+ Mockito.doReturn(true).when(log).isLoggable(level);
+ logObj.log(new Object[] {"test","test2",""});
+
+ }
+
+ @Test
+ public void testLogThrowable() {
+ JavaUtilLogTarget logObj = new JavaUtilLogTarget( log, level);
+
+ Mockito.doReturn(true).when(log).isLoggable(level);
+ logObj.log(new Throwable("test exception"), new Object[] {"test","test2",""});
+ logObj.log(new Throwable(), new Object[] {"test","test2",""});
+ }
+
+ @Test
+ public void testPrintf() {
+ JavaUtilLogTarget logObj = new JavaUtilLogTarget( log, level);
+
+ Mockito.doReturn(true).when(log).isLoggable(level);
+ logObj.printf("test", new Object[] {"test","test2",""});
+
+ Mockito.doReturn(false).when(log).isLoggable(level);
+ logObj.printf("test", new Object[] {"test","test2",""});
+ }
+}
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/JU_NullLifeCycle.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_NullLifeCycle.java
new file mode 100644
index 00000000..e685dfe6
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_NullLifeCycle.java
@@ -0,0 +1,43 @@
+/**
+ * ============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.impl;
+
+import org.junit.Test;
+import org.onap.aaf.misc.env.APIException;
+
+public class JU_NullLifeCycle {
+
+ @Test
+ public void testServicePrestart() {
+ NullLifeCycle lifeCycleObj = new NullLifeCycle();
+ try {
+ lifeCycleObj.servicePrestart(null);
+ lifeCycleObj.serviceDestroy(null);
+ lifeCycleObj.threadDestroy(null);
+ lifeCycleObj.threadPrestart(null);
+ lifeCycleObj.refresh(null);
+ }catch(APIException a) {
+
+ }
+ }
+
+} \ No newline at end of file
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 9feaf3ef..2067e2ab 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
@@ -21,42 +21,88 @@
package org.onap.aaf.misc.env.impl;
-import static org.junit.Assert.assertFalse;
-import static org.powermock.api.mockito.PowerMockito.when;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.MockitoAnnotations.initMocks;
import org.apache.log4j.Level;
import org.apache.log4j.Logger;
import org.junit.Before;
import org.junit.Test;
-import org.junit.runner.RunWith;
import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
+import org.mockito.Mockito;
import org.onap.aaf.misc.env.APIException;
-import org.powermock.api.mockito.PowerMockito;
-import org.powermock.core.classloader.annotations.PrepareForTest;
-import org.powermock.modules.junit4.PowerMockRunner;
-@RunWith(PowerMockRunner.class)
-@PrepareForTest({ Log4JLogTarget.class, Logger.class })
public class JU_Log4JLogTargetTest {
+ @Mock
+ Level level;
+
@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);
+ initMocks(this);
}
@Test
- public void test() throws APIException {
- Log4JLogTarget target = new Log4JLogTarget(null, Level.INFO);
- Log4JLogTarget target1 = new Log4JLogTarget("Info", Level.DEBUG);
+ public void testLoggable() {
+ Log4JLogTarget logObj = null;
+ try {
+ logObj = new Log4JLogTarget( "testLogger", Level.DEBUG);
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ boolean retVal = logObj.isLoggable();
+ assertTrue(retVal);
+ }
+
+ @Test
+ public void testLog() {
+ Log4JLogTarget logObj = null;
+ try {
+ logObj = new Log4JLogTarget( null, Level.DEBUG);
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ logObj.log(new Object[] {"test"});
+ }
+
+ @Test
+ public void testLogThrowable() {
+ Log4JLogTarget logObj = null;
+ try {
+ logObj = new Log4JLogTarget( null, Level.DEBUG);
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ logObj.log(new Throwable("test exception"), new Object[] {"test","test2","",null});
+ }
+
+ @Test
+ public void testPrintf() {
+ Log4JLogTarget logObj = null;
+ try {
+ logObj = new Log4JLogTarget( "", level);
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ logObj.printf("test", new Object[] {"test","test2",""});
- assertFalse(target1.isLoggable());
+ }
+
+ @Test
+ public void testSetEnv() {
+ try {
+ Log4JLogTarget.setLog4JEnv("test", Mockito.mock(BasicEnv.class));
+ } catch (APIException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
} \ No newline at end of file
diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDF.java b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDF.java
new file mode 100644
index 00000000..62c49032
--- /dev/null
+++ b/misc/env/src/test/java/org/onap/aaf/misc/env/jaxb/JU_JAXBDF.java
@@ -0,0 +1,714 @@
+/**
+ * ============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.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.MockitoAnnotations.initMocks;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.StringReader;
+import java.io.StringWriter;
+
+import javax.xml.bind.JAXBException;
+import javax.xml.namespace.QName;
+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.Data;
+import org.onap.aaf.misc.env.Env;
+import org.onap.aaf.misc.env.EnvJAXB;
+import org.onap.aaf.misc.env.LogTarget;
+import org.onap.aaf.misc.env.TimeTaken;
+
+public class JU_JAXBDF {
+
+ @Mock
+ EnvJAXB primaryEnv;
+
+ @Mock
+ JAXBumar jumar;
+
+ @Mock
+ JAXBmar jmar;
+
+ @Mock
+ Env env;
+
+ TimeTaken tt,ttObjectify;
+
+ @Before
+ public void setUp() {
+ initMocks(this);
+ tt=Mockito.mock(TimeTaken.class);
+ Mockito.doReturn(tt).when(env).start("JAXB Stringify", Env.XML);
+ Mockito.doNothing().when(tt).done();
+ ttObjectify=Mockito.mock(TimeTaken.class);
+ Mockito.doReturn(ttObjectify).when(env).start("JAXB Objectify", Env.XML);
+ Mockito.doNothing().when(ttObjectify).done();
+ }
+
+ @Test
+ public void testNewInstance() {
+ JAXBDF<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBDF( null, new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ Mockito.doThrow(new IllegalAccessException("Test Exception")).when(bdfObj.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();
+ }
+
+ }
+
+ @Test
+ public void testNewInstanceNoException() {
+ JAXBDF<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBDF( null, new Class[] {this.getClass()});
+ Object retVal = bdfObj.newInstance();
+ assertTrue(retVal instanceof JU_JAXBDF);
+ } catch (APIException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testPrettyNoException() {
+ JAXBDF<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBDF( null, Mockito.mock(Schema.class), new Class[] {this.getClass()});
+ Object retVal = bdfObj.pretty(true);
+ assertTrue(retVal instanceof JAXBDF);
+ } catch (APIException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testFragment() {
+ JAXBDF<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBDF( null, Mockito.mock(QName.class), new Class[] {this.getClass()});
+ Object retVal = bdfObj.asFragment(true);
+ assertTrue(retVal instanceof JAXBDF);
+ bdfObj.servicePrestart(null);
+ bdfObj.threadPrestart(null);
+ bdfObj.refresh(null);
+ bdfObj.threadDestroy(null);
+ bdfObj.serviceDestroy(null);
+ } catch (APIException e) {
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testNewData() {
+ JAXBDF<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
+ Data<?> retVal = bdfObj.newData();
+ assertTrue(retVal instanceof JAXBData);
+ } catch (APIException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testNewDataENV() {
+ JAXBDF<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
+ Data<?> retVal = bdfObj.newData(Mockito.mock(Env.class));
+ assertTrue(retVal instanceof JAXBData);
+ } catch (APIException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testNewDataType() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
+ Data<?> retVal = bdfObj.newData(new JAXBumar(new Class[] {this.getClass()}));
+ assertTrue(retVal instanceof JAXBData);
+ } catch (APIException e) {
+ e.printStackTrace();
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testNewDataStream() {
+ JAXBDF<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ InputStream is = Mockito.mock(InputStream.class);
+ Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, is);
+ Data<?> retVal = bdfObj.newDataFromStream(env, is);
+ assertTrue(retVal instanceof JAXBData);
+ } catch (APIException e) {
+ e.printStackTrace();
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testNewDataStreamException() {
+ JAXBDF<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ InputStream is = Mockito.mock(InputStream.class);
+ Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, is);
+ Data<?> retVal = bdfObj.newDataFromStream(env, is);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ assertTrue(e.getMessage().contains("test"));
+ }
+ }
+
+ @Test
+ public void testNewDataFromString() {
+ JAXBDF<?> bdfObj = null;
+ try {
+ bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
+ Data<?> retVal = bdfObj.newDataFromString("test");
+ assertTrue(retVal instanceof JAXBData);
+ } catch (APIException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testStringify() {
+ JAXBDF<JAXBmar> bdfObj = null;
+ try {
+ JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
+ bdfObj.jmar = Mockito.mock(JAXBmar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(envJaxb).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(StringWriter.class));
+ String retVal = bdfObj.stringify(typeObj);
+ assertEquals("", retVal);
+ } catch (APIException e) {
+ e.printStackTrace();
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testStringifyException() {
+ JAXBDF<JAXBmar> bdfObj = null;
+ try {
+ JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(envJaxb).debug();
+ bdfObj = new JAXBDF<JAXBmar>( envJaxb, new Class[] {this.getClass()});
+ bdfObj.jmar = Mockito.mock(JAXBmar.class);
+ Mockito.doThrow(new JAXBException("test") ).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(StringWriter.class));
+ String retVal = bdfObj.stringify(typeObj);
+ System.out.println(retVal);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+ }
+
+ @Test
+ public void testStringifyWriter() {
+ JAXBDF<JAXBmar> bdfObj = null;
+ try {
+ JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
+ bdfObj.jmar = Mockito.mock(JAXBmar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(envJaxb).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(StringWriter.class));
+ bdfObj.stringify(typeObj, Mockito.mock(StringWriter.class));
+ } catch (APIException e) {
+ e.printStackTrace();
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testStringifyWriterException() {
+ JAXBDF<JAXBmar> bdfObj = null;
+ try {
+ JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
+ bdfObj.jmar = Mockito.mock(JAXBmar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(envJaxb).debug();
+ StringWriter sw = Mockito.mock(StringWriter.class);
+ Mockito.doThrow(new JAXBException("test")).when(bdfObj.jmar).marshal(logT, typeObj, sw);
+ bdfObj.stringify(typeObj, sw);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+ }
+
+ @Test
+ public void testStringifyOS() {
+ JAXBDF<JAXBmar> bdfObj = null;
+ try {
+ JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
+ bdfObj.jmar = Mockito.mock(JAXBmar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(envJaxb).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(OutputStream.class));
+ bdfObj.stringify(typeObj, Mockito.mock(OutputStream.class));
+ } catch (APIException e) {
+ e.printStackTrace();
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testStringifyOsException() {
+ JAXBDF<JAXBmar> bdfObj = null;
+ try {
+ JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
+ bdfObj.jmar = Mockito.mock(JAXBmar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(envJaxb).debug();
+ OutputStream sw = Mockito.mock(OutputStream.class);
+ Mockito.doThrow(new JAXBException("test")).when(bdfObj.jmar).marshal(logT, typeObj, sw);
+ bdfObj.stringify(typeObj, sw);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+ }
+
+ @Test
+ public void testStringifyOptions() {
+ JAXBDF<JAXBmar> bdfObj = null;
+ try {
+ JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
+ bdfObj.jmar = Mockito.mock(JAXBmar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(envJaxb).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(OutputStream.class));
+ bdfObj.stringify(env, typeObj, true);
+ } catch (APIException e) {
+ e.printStackTrace();
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testStringifyOSOptions() {
+ JAXBDF<JAXBmar> bdfObj = null;
+ try {
+ JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
+ bdfObj.jmar = Mockito.mock(JAXBmar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(OutputStream.class),true);
+ bdfObj.stringify(env, typeObj, Mockito.mock(OutputStream.class),true);
+ } catch (APIException e) {
+ e.printStackTrace();
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testStringifyOsOptionsException() {
+ JAXBDF<JAXBmar> bdfObj = null;
+ try {
+ JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
+ bdfObj.jmar = Mockito.mock(JAXBmar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ OutputStream sw = Mockito.mock(OutputStream.class);
+ Mockito.doThrow(new JAXBException("test")).when(bdfObj.jmar).marshal(logT, typeObj, sw,true);
+ bdfObj.stringify(env, typeObj, sw,true);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+ }
+ @Test
+ public void testStringifySWOptions() {
+ JAXBDF<JAXBmar> bdfObj = null;
+ try {
+ JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
+ bdfObj.jmar = Mockito.mock(JAXBmar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(StringWriter.class),true);
+ bdfObj.stringify(env, typeObj, Mockito.mock(StringWriter.class),true);
+ } catch (APIException e) {
+ e.printStackTrace();
+ } catch (JAXBException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testStringifySWOptionsException() {
+ JAXBDF<JAXBmar> bdfObj = null;
+ try {
+ JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
+ bdfObj.jmar = Mockito.mock(JAXBmar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ StringWriter sw = Mockito.mock(StringWriter.class);
+ Mockito.doThrow(new JAXBException("test")).when(bdfObj.jmar).marshal(logT, typeObj, sw,true);
+ bdfObj.stringify(env, typeObj, sw,true);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+ }
+
+ @Test
+ public void testObjectifyEnv() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, Mockito.mock(StringReader.class));
+
+ bdfObj.objectify(env, Mockito.mock(StringReader.class));
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+ @Test
+ public void testObjectifyEnvException() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ StringReader sr = Mockito.mock(StringReader.class);
+ Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, sr);
+
+ bdfObj.objectify(env, sr);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+
+ @Test
+ public void testObjectifyRdr() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, Mockito.mock(StringReader.class));
+
+ bdfObj.objectify( Mockito.mock(StringReader.class));
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+ @Test
+ public void testObjectifyRdrException() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(envJaxb).debug();
+ StringReader sr = Mockito.mock(StringReader.class);
+ Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, sr);
+
+ bdfObj.objectify(sr);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+
+ @Test
+ public void testObjectifyEnvIS() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, Mockito.mock(InputStream.class));
+
+ bdfObj.objectify(env, Mockito.mock(InputStream.class));
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+ @Test
+ public void testObjectifyEnvISException() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ InputStream sr = Mockito.mock(InputStream.class);
+ Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, sr);
+
+ bdfObj.objectify(env, sr);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+
+ @Test
+ public void testObjectifyIs() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, Mockito.mock(InputStream.class));
+
+ bdfObj.objectify( Mockito.mock(InputStream.class));
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+ @Test
+ public void testObjectifyIsException() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(envJaxb).debug();
+ InputStream sr = Mockito.mock(InputStream.class);
+ Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, sr);
+
+ bdfObj.objectify(sr);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+
+ @Test
+ public void testObjectifyEnvStr() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, "test");
+
+ bdfObj.objectify(env, "test");
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+ @Test
+ public void testObjectifyEnvStrException() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ InputStream sr = Mockito.mock(InputStream.class);
+ Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, "test");
+
+ bdfObj.objectify(env, "test");
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+
+ @Test
+ public void testObjectifyStr() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(env).debug();
+ Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, "test");
+
+ bdfObj.objectify( "test");
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+ @Test
+ public void testObjectifyStrException() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+ JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
+ bdfObj.jumar = Mockito.mock(JAXBumar.class);
+ LogTarget logT = Mockito.mock(LogTarget.class);
+ Mockito.doReturn(logT).when(envJaxb).debug();
+ InputStream sr = Mockito.mock(InputStream.class);
+ Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, "test");
+
+ bdfObj.objectify("test");
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ } catch (JAXBException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+
+ @Test
+ public void testTypeClass() {
+ JAXBDF<JAXBumar> bdfObj = null;
+ try {
+ EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
+ bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
+
+ Object obj = bdfObj.getTypeClass();
+ assertFalse(obj instanceof JU_JAXBDF);
+ } catch (APIException e) {
+ assertTrue(e.getMessage().contains("test"));
+ }
+
+ }
+}