diff options
author | Instrumental <jonathan.gathman@att.com> | 2019-08-07 13:40:39 -0500 |
---|---|---|
committer | Instrumental <jonathan.gathman@att.com> | 2019-08-07 13:40:42 -0500 |
commit | 3d1706fcbe7f95830ff6fd23cf679ee55c6d0595 (patch) | |
tree | ff97f10380a44d9f81d536c066782af10f728687 /misc | |
parent | 321dce367d74092a0ba09930c3aa526abdbd5da8 (diff) |
Remove Tabs, per Jococo
Issue-ID: AAF-932
Change-Id: I3ab0ebcc082048d2d1424a58a90ea479fb005ee6
Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'misc')
21 files changed, 2148 insertions, 2148 deletions
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java b/misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java index 84eb5ee6..a98d7100 100644 --- a/misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/LogTarget.java @@ -69,18 +69,18 @@ public interface LogTarget { public static final LogTarget SYSERR = new StreamLogTarget(System.err,false);
public static class StreamLogTarget implements LogTarget {
- private final PrintStream out;
- private final boolean closeMe;
-
- public StreamLogTarget(PrintStream ps) {
- this(ps,true);
- }
-
- /* Do NOT close SYSTEM ERR or OUT*/
- protected StreamLogTarget(PrintStream ps, boolean shouldClose) {
- out = ps;
- closeMe = shouldClose;
- }
+ private final PrintStream out;
+ private final boolean closeMe;
+
+ public StreamLogTarget(PrintStream ps) {
+ this(ps,true);
+ }
+
+ /* Do NOT close SYSTEM ERR or OUT*/
+ protected StreamLogTarget(PrintStream ps, boolean shouldClose) {
+ out = ps;
+ closeMe = shouldClose;
+ }
public void log(Object ... msgs) {
out.print(Chrono.dateFmt.format(new Date()));
out.print(": ");
@@ -117,9 +117,9 @@ public interface LogTarget { }
public void close() {
- if(closeMe) {
- out.close();
- }
+ if(closeMe) {
+ out.close();
+ }
}
}
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java b/misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java index 58c588f6..2491e16c 100644 --- a/misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/TimeTaken.java @@ -78,7 +78,7 @@ public abstract class TimeTaken { }
- /**
+ /**
* For sizable contents, set the size. Implementations can simply write a no-op if they don't wish to
* store the size.
*
diff --git a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java index 5ba74369..9edd3bf4 100644 --- a/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java +++ b/misc/env/src/main/java/org/onap/aaf/misc/env/impl/AbsTrans.java @@ -131,11 +131,11 @@ public abstract class AbsTrans<ENV extends Env> implements TransStore { //long end = (first.flag&SUB)==SUB?first.end():trail.get(last).end();
long end = 0L;
for(int i=last;end==0L && i>=0;--i) {
- end= trail.get(i).end();
+ end= trail.get(i).end();
}
metric.total = (end - first.start) / 1000000f;
} else {
- metric.total=0L;
+ metric.total=0L;
}
if (sb==null) {
@@ -170,14 +170,14 @@ public abstract class AbsTrans<ENV extends Env> implements TransStore { sb.append(" ");
}
if((tt.flag & CHECKPOINT)==CHECKPOINT) {
- // Checkpoint
- sb.append(" ");
+ // Checkpoint
+ sb.append(" ");
} else {
- float ms=tt.millis();
+ float ms=tt.millis();
// Add time values to Metric
for (int i=0;i<flags.length;++i) {
if ((tt.flag & flags[i]) == flags[i]) {
- metric.buckets[i]+=ms;
+ metric.buckets[i]+=ms;
}
}
}
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 index 0c21bda3..15049dcd 100644 --- 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 @@ -30,53 +30,53 @@ 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")); - } - } + @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 index d76d8828..a3063f73 100644 --- 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 @@ -43,44 +43,44 @@ public class JU_JavaUtilLogTarget { @Before public void setup() { - initMocks(this); + initMocks(this); } @Test public void testLoggable() { - JavaUtilLogTarget logObj = new JavaUtilLogTarget( log, level); - boolean retVal = logObj.isLoggable(); - + 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",""}); - + 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",""}); + 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",""}); + 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",""}); + 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_LogTargetTest.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_LogTargetTest.java index 2388964f..c679d11e 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 @@ -65,9 +65,9 @@ public class JU_LogTargetTest { 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
@@ -80,9 +80,9 @@ public class JU_LogTargetTest { 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/JU_NullLifeCycle.java b/misc/env/src/test/java/org/onap/aaf/misc/env/JU_NullLifeCycle.java index d8e843b4..ed75f4cb 100644 --- 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 @@ -28,16 +28,16 @@ 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) { - - } + 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_AbsTrans.java b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTrans.java index 93821606..e1e7d0e9 100644 --- a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTrans.java +++ b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTrans.java @@ -39,253 +39,253 @@ import org.onap.aaf.misc.env.TimeTaken; public class JU_AbsTrans { - @Mock - Env delegate; - - @Mock - BasicEnv delegate1; - - @Mock - LogTarget lt; - - @Before - public void setUp() { - initMocks(this); - } - - class AbsTransImpl extends AbsTrans{ + @Mock + Env delegate; + + @Mock + BasicEnv delegate1; + + @Mock + LogTarget lt; + + @Before + public void setUp() { + initMocks(this); + } + + class AbsTransImpl extends AbsTrans{ - public AbsTransImpl(Env delegate) { - super(delegate); - // TODO Auto-generated constructor stub - } - - public AbsTransImpl(BasicEnv delegate) { - super(delegate); - // TODO Auto-generated constructor stub - } + public AbsTransImpl(Env delegate) { + super(delegate); + // TODO Auto-generated constructor stub + } + + public AbsTransImpl(BasicEnv delegate) { + super(delegate); + // TODO Auto-generated constructor stub + } - @Override - public Slot slot(String name) { - // TODO Auto-generated method stub - return new Slot(-1, "test"); - } + @Override + public Slot slot(String name) { + // TODO Auto-generated method stub + return new Slot(-1, "test"); + } - @Override - public <T> T get(StaticSlot slot, T dflt) { - // TODO Auto-generated method stub - return null; - } + @Override + public <T> T get(StaticSlot slot, T dflt) { + // TODO Auto-generated method stub + return null; + } - @Override - public String setProperty(String tag, String value) { - // TODO Auto-generated method stub - return null; - } + @Override + public String setProperty(String tag, String value) { + // TODO Auto-generated method stub + return null; + } - @Override - public String getProperty(String tag) { - // TODO Auto-generated method stub - return null; - } + @Override + public String getProperty(String tag) { + // TODO Auto-generated method stub + return null; + } - @Override - public String getProperty(String tag, String deflt) { - // TODO Auto-generated method stub - return null; - } + @Override + public String getProperty(String tag, String deflt) { + // TODO Auto-generated method stub + return null; + } - @Override - public Decryptor decryptor() { - // TODO Auto-generated method stub - return null; - } + @Override + public Decryptor decryptor() { + // TODO Auto-generated method stub + return null; + } - @Override - public Encryptor encryptor() { - // TODO Auto-generated method stub - return null; - } + @Override + public Encryptor encryptor() { + // TODO Auto-generated method stub + return null; + } - @Override - protected TimeTaken newTimeTaken(String name, int flag, Object ... values) { - // TODO Auto-generated method stub - return new TimeTaken("nameTest", Env.XML) { - - @Override - public void output(StringBuilder sb) { - // TODO Auto-generated method stub - - } - }; - } - - } - - @Test - public void testFatal() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).fatal(); - LogTarget lt = absTransObj.fatal(); - assertTrue(lt instanceof LogTarget); - } - - @Test - public void testError() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).error(); - LogTarget lt = absTransObj.error(); - assertTrue(lt instanceof LogTarget); - } - - @Test - public void testAudit() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).audit(); - LogTarget lt = absTransObj.audit(); - assertTrue(lt instanceof LogTarget); - } + @Override + protected TimeTaken newTimeTaken(String name, int flag, Object ... values) { + // TODO Auto-generated method stub + return new TimeTaken("nameTest", Env.XML) { + + @Override + public void output(StringBuilder sb) { + // TODO Auto-generated method stub + + } + }; + } + + } + + @Test + public void testFatal() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).fatal(); + LogTarget lt = absTransObj.fatal(); + assertTrue(lt instanceof LogTarget); + } + + @Test + public void testError() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).error(); + LogTarget lt = absTransObj.error(); + assertTrue(lt instanceof LogTarget); + } + + @Test + public void testAudit() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).audit(); + LogTarget lt = absTransObj.audit(); + assertTrue(lt instanceof LogTarget); + } - @Test - public void testInit() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).init(); - LogTarget lt = absTransObj.init(); - assertTrue(lt instanceof LogTarget); - } - - @Test - public void testWarn() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).warn(); - LogTarget lt = absTransObj.warn(); - assertTrue(lt instanceof LogTarget); - } - - @Test - public void testInfo() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).info(); - LogTarget lt = absTransObj.info(); - assertTrue(lt instanceof LogTarget); - } - - @Test - public void testDebug() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).debug(); - LogTarget lt = absTransObj.debug(); - assertTrue(lt instanceof LogTarget); - } - - @Test - public void testTrace() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).trace(); - LogTarget lt = absTransObj.trace(); - assertTrue(lt instanceof LogTarget); - } - - @Test - public void testStart() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - TimeTaken lt = absTransObj.start("test",1); - assertEquals("nameTest", lt.name); - } - - @Test - public void testCheckpint() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - absTransObj.checkpoint("test"); - assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); - } - - @Test - public void testCheckpintAddFlag() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - absTransObj.checkpoint("test",1); - assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); - } - - @Test - public void testAuditTrailWithEmptyTrail() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).info(); - Mockito.doReturn(true).when(lt).isLoggable(); - absTransObj.auditTrail(1, new StringBuilder(), 1); - //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); - } - - @Test - public void testAuditTrail() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).info(); - Mockito.doReturn(true).when(lt).isLoggable(); - TimeTaken tt=absTransObj.newTimeTaken("test", 1); - absTransObj.trail.add(tt); - absTransObj.trail.add(tt); - absTransObj.trail.add(tt); - absTransObj.auditTrail(1, new StringBuilder(), 2); - //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); - } - - @Test - public void testAuditTrailLoggableFalse() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).info(); - Mockito.doReturn(false).when(lt).isLoggable(); - TimeTaken tt=absTransObj.newTimeTaken("test", 1); - absTransObj.trail.add(tt); - absTransObj.trail.add(tt); - absTransObj.trail.add(tt); - absTransObj.auditTrail(1, new StringBuilder(), 1); - //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); - } - - @Test - public void testAuditTrailNullSB() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).info(); - Mockito.doReturn(true).when(lt).isLoggable(); - TimeTaken tt=absTransObj.newTimeTaken("test", 1); - absTransObj.trail.add(tt); - absTransObj.trail.add(tt); - absTransObj.trail.add(tt); - absTransObj.auditTrail(1, null, 1); - //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); - } - - @Test - public void testAuditTrailEmpptyFlag() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate); - Mockito.doReturn(lt).when(delegate).info(); - Mockito.doReturn(true).when(lt).isLoggable(); - TimeTaken tt=absTransObj.newTimeTaken("test", 1); - absTransObj.trail.add(tt); - absTransObj.trail.add(tt); - absTransObj.trail.add(tt); - absTransObj.auditTrail(1, null, new int[] {}); - //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); - } - - @Test - public void testPut() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate1); - try { - absTransObj.put(absTransObj.slot("test"), "test"); - } catch(Exception e){ - assertTrue(e instanceof NullPointerException); - } - } - - @Test - public void testGet() { - AbsTransImpl absTransObj = new AbsTransImpl(delegate1); - try { - absTransObj.get(absTransObj.slot("test"), "test"); - } catch(Exception e){ - e.printStackTrace(); - assertTrue(e instanceof NullPointerException); - } - } + @Test + public void testInit() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).init(); + LogTarget lt = absTransObj.init(); + assertTrue(lt instanceof LogTarget); + } + + @Test + public void testWarn() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).warn(); + LogTarget lt = absTransObj.warn(); + assertTrue(lt instanceof LogTarget); + } + + @Test + public void testInfo() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).info(); + LogTarget lt = absTransObj.info(); + assertTrue(lt instanceof LogTarget); + } + + @Test + public void testDebug() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).debug(); + LogTarget lt = absTransObj.debug(); + assertTrue(lt instanceof LogTarget); + } + + @Test + public void testTrace() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).trace(); + LogTarget lt = absTransObj.trace(); + assertTrue(lt instanceof LogTarget); + } + + @Test + public void testStart() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + TimeTaken lt = absTransObj.start("test",1); + assertEquals("nameTest", lt.name); + } + + @Test + public void testCheckpint() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + absTransObj.checkpoint("test"); + assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); + } + + @Test + public void testCheckpintAddFlag() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + absTransObj.checkpoint("test",1); + assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); + } + + @Test + public void testAuditTrailWithEmptyTrail() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).info(); + Mockito.doReturn(true).when(lt).isLoggable(); + absTransObj.auditTrail(1, new StringBuilder(), 1); + //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); + } + + @Test + public void testAuditTrail() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).info(); + Mockito.doReturn(true).when(lt).isLoggable(); + TimeTaken tt=absTransObj.newTimeTaken("test", 1); + absTransObj.trail.add(tt); + absTransObj.trail.add(tt); + absTransObj.trail.add(tt); + absTransObj.auditTrail(1, new StringBuilder(), 2); + //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); + } + + @Test + public void testAuditTrailLoggableFalse() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).info(); + Mockito.doReturn(false).when(lt).isLoggable(); + TimeTaken tt=absTransObj.newTimeTaken("test", 1); + absTransObj.trail.add(tt); + absTransObj.trail.add(tt); + absTransObj.trail.add(tt); + absTransObj.auditTrail(1, new StringBuilder(), 1); + //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); + } + + @Test + public void testAuditTrailNullSB() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).info(); + Mockito.doReturn(true).when(lt).isLoggable(); + TimeTaken tt=absTransObj.newTimeTaken("test", 1); + absTransObj.trail.add(tt); + absTransObj.trail.add(tt); + absTransObj.trail.add(tt); + absTransObj.auditTrail(1, null, 1); + //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); + } + + @Test + public void testAuditTrailEmpptyFlag() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate); + Mockito.doReturn(lt).when(delegate).info(); + Mockito.doReturn(true).when(lt).isLoggable(); + TimeTaken tt=absTransObj.newTimeTaken("test", 1); + absTransObj.trail.add(tt); + absTransObj.trail.add(tt); + absTransObj.trail.add(tt); + absTransObj.auditTrail(1, null, new int[] {}); + //assertEquals("nameTest", ((TimeTaken)absTransObj.trail.get(0)).name); + } + + @Test + public void testPut() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate1); + try { + absTransObj.put(absTransObj.slot("test"), "test"); + } catch(Exception e){ + assertTrue(e instanceof NullPointerException); + } + } + + @Test + public void testGet() { + AbsTransImpl absTransObj = new AbsTransImpl(delegate1); + try { + absTransObj.get(absTransObj.slot("test"), "test"); + } catch(Exception e){ + e.printStackTrace(); + assertTrue(e instanceof NullPointerException); + } + } }
\ No newline at end of file diff --git a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTransJaxb.java b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTransJaxb.java index 22d979fe..f8b32451 100644 --- a/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTransJaxb.java +++ b/misc/env/src/test/java/org/onap/aaf/misc/env/impl/JU_AbsTransJaxb.java @@ -42,136 +42,136 @@ import org.onap.aaf.misc.env.TimeTaken; public class JU_AbsTransJaxb { - @Mock - EnvJAXB delegate; - - @Mock - LogTarget lt; - - @Before - public void setUp() { - initMocks(this); - } - - class AbsTransJAXBImpl extends AbsTransJAXB{ - - public AbsTransJAXBImpl(EnvJAXB env) { - super(env); - // TODO Auto-generated constructor stub - } - - @Override - public String setProperty(String tag, String value) { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getProperty(String tag) { - // TODO Auto-generated method stub - return null; - } - - @Override - public String getProperty(String tag, String deflt) { - // TODO Auto-generated method stub - return null; - } - - @Override - public Decryptor decryptor() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Encryptor encryptor() { - // TODO Auto-generated method stub - return null; - } - - @Override - public Slot slot(String name) { - // TODO Auto-generated method stub - return null; - } - - @Override - public <T> T get(StaticSlot slot, T dflt) { - // TODO Auto-generated method stub - return null; - } - - @Override - protected TimeTaken newTimeTaken(String name, int flag, Object ... values) { - // TODO Auto-generated method stub - return null; - } - - - } - - - @Test - public void testNewDataFactory() { - AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate); - DataFactory<Object> lt = null; - - try { - Mockito.doReturn(lt).when(delegate).newDataFactory(new Class[] {AbsTransJAXB.class}); - lt = absTransObj.newDataFactory(new Class[] {AbsTransJAXB.class}); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - //assertTrue(lt instanceof LogTarget); - } - - @Test - public void testNewDataFactorySchema() { - AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate); - DataFactory<Object> lt = null; - Schema schema = Mockito.mock(Schema.class); - try { - Mockito.doReturn(lt).when(delegate).newDataFactory(schema, new Class[] {AbsTransJAXB.class}); - lt = absTransObj.newDataFactory(schema, new Class[] {AbsTransJAXB.class}); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - //assertTrue(lt instanceof LogTarget); - } - - @Test - public void testNewDataFactoryQname() { - AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate); - DataFactory<Object> lt = null; - QName schema = Mockito.mock(QName.class); - try { - Mockito.doReturn(lt).when(delegate).newDataFactory(schema, new Class[] {AbsTransJAXB.class}); - lt = absTransObj.newDataFactory(schema, new Class[] {AbsTransJAXB.class}); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - //assertTrue(lt instanceof LogTarget); - } - - @Test - public void testNewDataFactorySchemaQname() { - AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate); - DataFactory<Object> lt = null; - QName qname = Mockito.mock(QName.class); - Schema schema = Mockito.mock(Schema.class); - try { - Mockito.doReturn(lt).when(delegate).newDataFactory(schema, qname,new Class[] {AbsTransJAXB.class}); - lt = absTransObj.newDataFactory(schema, qname,new Class[] {AbsTransJAXB.class}); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - //assertTrue(lt instanceof LogTarget); - } - - + @Mock + EnvJAXB delegate; + + @Mock + LogTarget lt; + + @Before + public void setUp() { + initMocks(this); + } + + class AbsTransJAXBImpl extends AbsTransJAXB{ + + public AbsTransJAXBImpl(EnvJAXB env) { + super(env); + // TODO Auto-generated constructor stub + } + + @Override + public String setProperty(String tag, String value) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getProperty(String tag) { + // TODO Auto-generated method stub + return null; + } + + @Override + public String getProperty(String tag, String deflt) { + // TODO Auto-generated method stub + return null; + } + + @Override + public Decryptor decryptor() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Encryptor encryptor() { + // TODO Auto-generated method stub + return null; + } + + @Override + public Slot slot(String name) { + // TODO Auto-generated method stub + return null; + } + + @Override + public <T> T get(StaticSlot slot, T dflt) { + // TODO Auto-generated method stub + return null; + } + + @Override + protected TimeTaken newTimeTaken(String name, int flag, Object ... values) { + // TODO Auto-generated method stub + return null; + } + + + } + + + @Test + public void testNewDataFactory() { + AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate); + DataFactory<Object> lt = null; + + try { + Mockito.doReturn(lt).when(delegate).newDataFactory(new Class[] {AbsTransJAXB.class}); + lt = absTransObj.newDataFactory(new Class[] {AbsTransJAXB.class}); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //assertTrue(lt instanceof LogTarget); + } + + @Test + public void testNewDataFactorySchema() { + AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate); + DataFactory<Object> lt = null; + Schema schema = Mockito.mock(Schema.class); + try { + Mockito.doReturn(lt).when(delegate).newDataFactory(schema, new Class[] {AbsTransJAXB.class}); + lt = absTransObj.newDataFactory(schema, new Class[] {AbsTransJAXB.class}); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //assertTrue(lt instanceof LogTarget); + } + + @Test + public void testNewDataFactoryQname() { + AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate); + DataFactory<Object> lt = null; + QName schema = Mockito.mock(QName.class); + try { + Mockito.doReturn(lt).when(delegate).newDataFactory(schema, new Class[] {AbsTransJAXB.class}); + lt = absTransObj.newDataFactory(schema, new Class[] {AbsTransJAXB.class}); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //assertTrue(lt instanceof LogTarget); + } + + @Test + public void testNewDataFactorySchemaQname() { + AbsTransJAXB absTransObj = new AbsTransJAXBImpl(delegate); + DataFactory<Object> lt = null; + QName qname = Mockito.mock(QName.class); + Schema schema = Mockito.mock(Schema.class); + try { + Mockito.doReturn(lt).when(delegate).newDataFactory(schema, qname,new Class[] {AbsTransJAXB.class}); + lt = absTransObj.newDataFactory(schema, qname,new Class[] {AbsTransJAXB.class}); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + //assertTrue(lt instanceof LogTarget); + } + + }
\ 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 6900d9ed..fe72d01e 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 @@ -34,75 +34,75 @@ import org.onap.aaf.misc.env.APIException; public class JU_Log4JLogTargetTest {
- @Mock
- Level level;
-
+ @Mock
+ Level level;
+
@Mock
Logger log;
@Before
public void setup() {
- initMocks(this);
+ initMocks(this);
}
@Test
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();
+ 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"});
+ 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});
+ 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",""});
+ 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",""});
}
@Test
public void testSetEnv() {
- try {
- Log4JLogTarget.setLog4JEnv("test", Mockito.mock(BasicEnv.class));
- } catch (APIException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ 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 index 62c49032..7952740b 100644 --- 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 @@ -64,651 +64,651 @@ public class JU_JAXBDF { @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(); + 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(); - } - + 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(); - } - + 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(); - } + 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(); - } - + 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(); - } + 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(); - } + 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(); - } + 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(); - } + 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")); - } + 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(); - } + 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(); - } + 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")); - } + 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(); - } + 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")); - } + 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(); - } + 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")); - } + 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(); - } + 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(); - } + 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")); - } + 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(); - } + 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")); - } + 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")); - } - + 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")); - } - + 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")); - } - + 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")); - } - + 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")); - } - + 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")); - } - + 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")); - } - + 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")); - } - + 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")); - } - + 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")); - } - + 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")); - } - + 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")); - } - + 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")); - } - + 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")); + } + } } 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 index 46feebb1..9330f18b 100644 --- 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 @@ -41,178 +41,178 @@ 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(); - } + @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 + @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(); - } - + 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 + + @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(); - } - + 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 + + @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(); - } - + 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 + + @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(); - } - + 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 + + @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(); - } - + 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 + + @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(); - } - + 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 + + @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")); - } - + 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 + + @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(); - } + 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 + + @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(); - } - + 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 index 7d310ae7..84415fdb 100644 --- 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 @@ -42,145 +42,145 @@ 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(); - } + @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 + @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(); - } - + 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 + + @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(); - } - + 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 + + @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(); - } - + 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 + + @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(); - } - + 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 + + @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(); - } - + 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 + + @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")); - } - + 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 + + @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); + 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 + + @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); - + 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 index 39d43066..22c209c2 100644 --- 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 @@ -45,104 +45,104 @@ import org.onap.aaf.misc.env.TimeTaken; @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(); - } + + @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 + @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"}); - + StoreImpl bdfObj = new StoreImpl(); + bdfObj = new StoreImpl(""); + bdfObj.propsFromArgs(null, new String[] {"test"}); + bdfObj.propsFromArgs("test", new String[] {"test","te=st","test=1"}); + } - - @Test + + @Test public void testMorePropsConstructor() { - Properties props = Mockito.mock(Properties.class); - new StoreImpl(null,props); - StoreImpl bdfObj = new StoreImpl("test",props); + Properties props = Mockito.mock(Properties.class); + new StoreImpl(null,props); + StoreImpl bdfObj = new StoreImpl("test",props); } - - @Test + + @Test public void testMorePropsFileNOtExists() { - Properties props = Mockito.mock(Properties.class); - Mockito.doReturn("test").when(props).getProperty("test"); - StoreImpl bdfObj = new StoreImpl("test",props); + Properties props = Mockito.mock(Properties.class); + Mockito.doReturn("test").when(props).getProperty("test"); + StoreImpl bdfObj = new StoreImpl("test",props); } - - @Test + + @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); + 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 + + @Test public void testNewTransState() { - StoreImpl bdfObj = new StoreImpl(null, new String[] {}); - bdfObj.newTransState(); - } - - @Test + 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); - } + 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); + } } diff --git a/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java b/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java index 85aae6f0..35d5038c 100644 --- a/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java +++ b/misc/log4j/src/main/java/org/onap/aaf/misc/env/log4j/LogFileNamer.java @@ -56,24 +56,24 @@ public class LogFileNamer { * @throws IOException
*/
public String setAppender(String appender) throws IOException {
- File f = new File(String.format(FIRST_FILE_FORMAT_STR, dir, root, appender));
- File lock = new File(f.getAbsoluteFile()+".lock");
- if(f.exists()) {
- if(lock.exists()) {
- int i = 0;
- while ((f = new File(String.format(FILE_FORMAT_STR, dir, root, appender, i))).exists() &&
- (lock = new File(f.getAbsoluteFile()+".lock")).exists()) {
- ++i;
- }
- }
- }
+ File f = new File(String.format(FIRST_FILE_FORMAT_STR, dir, root, appender));
+ File lock = new File(f.getAbsoluteFile()+".lock");
+ if(f.exists()) {
+ if(lock.exists()) {
+ int i = 0;
+ while ((f = new File(String.format(FILE_FORMAT_STR, dir, root, appender, i))).exists() &&
+ (lock = new File(f.getAbsoluteFile()+".lock")).exists()) {
+ ++i;
+ }
+ }
+ }
try {
- lock.createNewFile();
- lock.deleteOnExit();
- f.createNewFile();
+ lock.createNewFile();
+ lock.deleteOnExit();
+ f.createNewFile();
} catch (IOException e) {
- throw new IOException("Cannot create file '" + f.getCanonicalPath() + '\'', e);
+ throw new IOException("Cannot create file '" + f.getCanonicalPath() + '\'', e);
}
System.setProperty("LOG4J_FILENAME_" + appender, f.getCanonicalPath());
return appender;
diff --git a/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java b/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java index 8657e1d6..1aaeb7fb 100644 --- a/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java +++ b/misc/log4j/src/test/java/org/onap/aaf/misc/env/log4j/JU_LogFileNamerTest.java @@ -38,55 +38,55 @@ public class JU_LogFileNamerTest { } private void cleanup(String name) { -// System.out.println("XXXX" + dir.getAbsolutePath()); - for(File f : dir.listFiles(new FilenameFilter() { - @Override - public boolean accept(File dir, String name) { - return name.contains(name) && name.endsWith(".log"); - } - })) { -// System.out.println("Deleting " + f.getAbsolutePath()); - f.delete(); - }; +// System.out.println("XXXX" + dir.getAbsolutePath()); + for(File f : dir.listFiles(new FilenameFilter() { + @Override + public boolean accept(File dir, String name) { + return name.contains(name) && name.endsWith(".log"); + } + })) { +// System.out.println("Deleting " + f.getAbsolutePath()); + f.delete(); + }; } @Test public void test() throws IOException { - String name = "Append"; - try { - LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), "log"); - assertEquals(logFileNamer, logFileNamer.noPID()); - - logFileNamer.setAppender(name); - assertEquals(System.getProperty("LOG4J_FILENAME_Append"), - dir.getCanonicalFile() + File.separator + "log-" + name + ".log"); - - logFileNamer.setAppender(name); - assertEquals(System.getProperty("LOG4J_FILENAME_Append"), - dir.getCanonicalFile() + File.separator + "log-" + name + ".0.log"); - } finally { - cleanup("log-" + name); - } + String name = "Append"; + try { + LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), "log"); + assertEquals(logFileNamer, logFileNamer.noPID()); + + logFileNamer.setAppender(name); + assertEquals(System.getProperty("LOG4J_FILENAME_Append"), + dir.getCanonicalFile() + File.separator + "log-" + name + ".log"); + + logFileNamer.setAppender(name); + assertEquals(System.getProperty("LOG4J_FILENAME_Append"), + dir.getCanonicalFile() + File.separator + "log-" + name + ".0.log"); + } finally { + cleanup("log-" + name); + } } @Test public void testBlankRoot() throws IOException { - String name = "Different"; - try { - LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), ""); - assertEquals(logFileNamer, logFileNamer.noPID()); - - logFileNamer.setAppender(name); - assertEquals(System.getProperty("LOG4J_FILENAME_Different"), - dir.getCanonicalPath() + File.separator + name + ".log"); - - logFileNamer.setAppender(name); - assertEquals(System.getProperty("LOG4J_FILENAME_Different"), - dir.getCanonicalPath() + File.separator + name + ".0.log"); - } finally { - cleanup(name); - } + String name = "Different"; + try { + LogFileNamer logFileNamer = new LogFileNamer(dir.getCanonicalPath(), ""); + assertEquals(logFileNamer, logFileNamer.noPID()); + + logFileNamer.setAppender(name); + assertEquals(System.getProperty("LOG4J_FILENAME_Different"), + dir.getCanonicalPath() + File.separator + name + ".log"); + + logFileNamer.setAppender(name); + assertEquals(System.getProperty("LOG4J_FILENAME_Different"), + dir.getCanonicalPath() + File.separator + name + ".0.log"); + } finally { + cleanup(name); + } } } diff --git a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java index bb590e1c..36ebde68 100644 --- a/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java +++ b/misc/rosetta/src/main/java/org/onap/aaf/misc/rosetta/env/RosettaData.java @@ -60,7 +60,7 @@ public class RosettaData<T> implements Data<T>{ //Added for junits void setSaved(Saved saved) { - this.saved = saved; + this.saved = saved; } // // @Override diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/JU_ParseException.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/JU_ParseException.java index 1eb55916..1a31b0fb 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/JU_ParseException.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/JU_ParseException.java @@ -26,24 +26,24 @@ import org.junit.Test; public class JU_ParseException { - @Test - public void test() { - ParseException pe = new ParseException(); - } - @Test - public void test1() { - ParseException pe = new ParseException("exception"); - } - @Test - public void test2() { - ParseException pe = new ParseException(new NullPointerException("exception")); - } - @Test - public void test3() { - ParseException pe = new ParseException("exception",new NullPointerException("exception")); - } + @Test + public void test() { + ParseException pe = new ParseException(); + } + @Test + public void test1() { + ParseException pe = new ParseException("exception"); + } + @Test + public void test2() { + ParseException pe = new ParseException(new NullPointerException("exception")); + } + @Test + public void test3() { + ParseException pe = new ParseException("exception",new NullPointerException("exception")); + } - - + + } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java index cbf7e2dc..9ab3b258 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaData.java @@ -56,608 +56,608 @@ import org.onap.aaf.misc.rosetta.Saved; public class JU_RosettaData { - @Mock - Env env; - - @Mock - RosettaDF df; - - @Mock - JAXBmar bmar; - - @Mock - Saved saved; - - @Before - public void setUp() { - initMocks(this); - } - - @Test - public void testLoad() { - RosettaData rosettaObj = new RosettaData(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - StringReader sr= Mockito.mock(StringReader.class); - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - Mockito.doNothing().when(saved).extract(sr,(Writer)null,inxml); - - rosettaObj = rosettaObj.load(sr); - } catch (APIException | IOException | ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testLoadException() { - RosettaData rosettaObj = new RosettaData(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - rosettaObj = rosettaObj.load(Mockito.mock(StringReader.class)); - } catch (APIException e) { - assertTrue(e.getMessage().contains("NullPointerException")); - } - } - - @Test - public void testLoadIs() { - RosettaData rosettaObj = new RosettaData(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - InputStream sr= Mockito.mock(InputStream.class); - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - Mockito.doNothing().when(saved).extract(new InputStreamReader(sr),(Writer)null,inxml); - - rosettaObj = rosettaObj.load(sr); - } catch (APIException | IOException | ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testLoadIsException() { - RosettaData rosettaObj = new RosettaData(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - rosettaObj = rosettaObj.load(Mockito.mock(InputStream.class)); - } catch (APIException e) { - assertTrue(e.getMessage().contains("NullPointerException")); - } - } - - @Test - public void testLoadStr() { - RosettaData rosettaObj = new RosettaData(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - - rosettaObj = rosettaObj.load("test"); - } catch (APIException | IOException | ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - @Test - public void testLoadStrJson() { - RosettaData rosettaObj = new RosettaData(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.JSON); - rosettaObj.setSaved(saved); - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - - rosettaObj = rosettaObj.load("test"); - } catch (APIException | IOException | ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - @Test - public void testLoadStrException() { - RosettaData rosettaObj = new RosettaData(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - rosettaObj = rosettaObj.load("test"); - } catch (APIException e) { - assertTrue(e.getMessage().contains("NullPointerException")); - } - } - - @Test - public void testLoadT() { - RosettaData rosettaObj = new RosettaData(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); - df.jaxMar = Mockito.mock(JAXBmar.class); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - - rosettaObj = rosettaObj.load(bmar); - df.marshal = null; - rosettaObj = rosettaObj.load(bmar); - } catch (APIException | IOException | ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testLoadTMarshalNull() { - RosettaData rosettaObj = new RosettaData(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); - df.jaxMar = Mockito.mock(JAXBmar.class); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - df.marshal = Mockito.mock(Marshal.class);; - rosettaObj = rosettaObj.load(bmar); - } catch (APIException | IOException | ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testLoadTException() { - RosettaData rosettaObj = new RosettaData(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - rosettaObj = rosettaObj.load(bmar); - } catch (APIException e) { - assertTrue(e.getMessage().contains("NullPointerException")); - } - } - - @Test - public void testGetEvents() { - RosettaData rosettaObj = new RosettaData(env, df); - Saved saved = rosettaObj.getEvents(); - assertEquals("Rosetta Saved", saved.logName()); - } - - @Test - public void testAsObject() { - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - try { - Out outxml = Mockito.mock(OutXML.class); - Mockito.doReturn(outxml).when(df).getOut(Data.TYPE.XML); - Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); - Mockito.doReturn("test").when(outxml).logName(); - df.jaxMar = Mockito.mock(JAXBmar.class); - df.jaxUmar = Mockito.mock(JAXBumar.class); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",0); - LogTarget lt = Mockito.mock(LogTarget.class); - Mockito.doReturn( lt).when(env).debug(); - Mockito.doNothing().when(saved).extract(null,new StringWriter(),saved); - Mockito.doReturn(bmar).when(df.jaxUmar).unmarshal(lt,""); - - bmar = rosettaObj.asObject(); - - } catch (APIException | IOException | ParseException | JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testAsObjectException() { - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - try { - Out outxml = Mockito.mock(OutXML.class); - Mockito.doReturn(outxml).when(df).getOut(Data.TYPE.XML); - Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); - Mockito.doReturn("test").when(outxml).logName(); - df.jaxMar = Mockito.mock(JAXBmar.class); - df.jaxUmar = Mockito.mock(JAXBumar.class); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",0); - LogTarget lt = Mockito.mock(LogTarget.class); - Mockito.doReturn( lt).when(env).debug(); - Mockito.doThrow(new IOException("test Exception")).when(saved).extract(null,new StringWriter(),saved); - Mockito.doThrow(new JAXBException("test Exception")).when(df.jaxUmar).unmarshal(lt,""); - - bmar = rosettaObj.asObject(); - - } catch (APIException | IOException | ParseException | JAXBException e) { - assertTrue(e.getMessage().contains("test Exception")); - } - } + @Mock + Env env; + + @Mock + RosettaDF df; + + @Mock + JAXBmar bmar; + + @Mock + Saved saved; + + @Before + public void setUp() { + initMocks(this); + } + + @Test + public void testLoad() { + RosettaData rosettaObj = new RosettaData(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + StringReader sr= Mockito.mock(StringReader.class); + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + Mockito.doNothing().when(saved).extract(sr,(Writer)null,inxml); + + rosettaObj = rosettaObj.load(sr); + } catch (APIException | IOException | ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testLoadException() { + RosettaData rosettaObj = new RosettaData(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + rosettaObj = rosettaObj.load(Mockito.mock(StringReader.class)); + } catch (APIException e) { + assertTrue(e.getMessage().contains("NullPointerException")); + } + } + + @Test + public void testLoadIs() { + RosettaData rosettaObj = new RosettaData(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + InputStream sr= Mockito.mock(InputStream.class); + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + Mockito.doNothing().when(saved).extract(new InputStreamReader(sr),(Writer)null,inxml); + + rosettaObj = rosettaObj.load(sr); + } catch (APIException | IOException | ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testLoadIsException() { + RosettaData rosettaObj = new RosettaData(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + rosettaObj = rosettaObj.load(Mockito.mock(InputStream.class)); + } catch (APIException e) { + assertTrue(e.getMessage().contains("NullPointerException")); + } + } + + @Test + public void testLoadStr() { + RosettaData rosettaObj = new RosettaData(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); + + rosettaObj = rosettaObj.load("test"); + } catch (APIException | IOException | ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + @Test + public void testLoadStrJson() { + RosettaData rosettaObj = new RosettaData(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.JSON); + rosettaObj.setSaved(saved); + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); + + rosettaObj = rosettaObj.load("test"); + } catch (APIException | IOException | ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + @Test + public void testLoadStrException() { + RosettaData rosettaObj = new RosettaData(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + rosettaObj = rosettaObj.load("test"); + } catch (APIException e) { + assertTrue(e.getMessage().contains("NullPointerException")); + } + } + + @Test + public void testLoadT() { + RosettaData rosettaObj = new RosettaData(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); + df.jaxMar = Mockito.mock(JAXBmar.class); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); + + rosettaObj = rosettaObj.load(bmar); + df.marshal = null; + rosettaObj = rosettaObj.load(bmar); + } catch (APIException | IOException | ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testLoadTMarshalNull() { + RosettaData rosettaObj = new RosettaData(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); + df.jaxMar = Mockito.mock(JAXBmar.class); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); + df.marshal = Mockito.mock(Marshal.class);; + rosettaObj = rosettaObj.load(bmar); + } catch (APIException | IOException | ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testLoadTException() { + RosettaData rosettaObj = new RosettaData(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + rosettaObj = rosettaObj.load(bmar); + } catch (APIException e) { + assertTrue(e.getMessage().contains("NullPointerException")); + } + } + + @Test + public void testGetEvents() { + RosettaData rosettaObj = new RosettaData(env, df); + Saved saved = rosettaObj.getEvents(); + assertEquals("Rosetta Saved", saved.logName()); + } + + @Test + public void testAsObject() { + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + try { + Out outxml = Mockito.mock(OutXML.class); + Mockito.doReturn(outxml).when(df).getOut(Data.TYPE.XML); + Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); + Mockito.doReturn("test").when(outxml).logName(); + df.jaxMar = Mockito.mock(JAXBmar.class); + df.jaxUmar = Mockito.mock(JAXBumar.class); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",0); + LogTarget lt = Mockito.mock(LogTarget.class); + Mockito.doReturn( lt).when(env).debug(); + Mockito.doNothing().when(saved).extract(null,new StringWriter(),saved); + Mockito.doReturn(bmar).when(df.jaxUmar).unmarshal(lt,""); + + bmar = rosettaObj.asObject(); + + } catch (APIException | IOException | ParseException | JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testAsObjectException() { + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + try { + Out outxml = Mockito.mock(OutXML.class); + Mockito.doReturn(outxml).when(df).getOut(Data.TYPE.XML); + Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); + Mockito.doReturn("test").when(outxml).logName(); + df.jaxMar = Mockito.mock(JAXBmar.class); + df.jaxUmar = Mockito.mock(JAXBumar.class); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",0); + LogTarget lt = Mockito.mock(LogTarget.class); + Mockito.doReturn( lt).when(env).debug(); + Mockito.doThrow(new IOException("test Exception")).when(saved).extract(null,new StringWriter(),saved); + Mockito.doThrow(new JAXBException("test Exception")).when(df.jaxUmar).unmarshal(lt,""); + + bmar = rosettaObj.asObject(); + + } catch (APIException | IOException | ParseException | JAXBException e) { + assertTrue(e.getMessage().contains("test Exception")); + } + } - @Test - public void testAsString() { - TYPE type = TYPE.XML; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - try { - Out outxml = Mockito.mock(OutXML.class); - - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); - - String retVal = rosettaObj.asString(); - assertTrue("".equals(retVal)); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testAsStringJson() { - TYPE type = TYPE.JSON; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.JSON); - rosettaObj.setSaved(saved); - try { - Out outxml = Mockito.mock(OutXML.class); - - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4); - - String retVal = rosettaObj.asString(); - assertTrue("".equals(retVal)); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - @Test - public void testToXml() { - TYPE type = TYPE.XML; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - - rosettaObj = rosettaObj.load("test"); - } catch (APIException | IOException | ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - try { - Out outxml = Mockito.mock(OutXML.class); - - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); - RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(OutputStream.class)); - - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testToJson() { - TYPE type = TYPE.JSON; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.JSON); - rosettaObj.setSaved(saved); - - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - - rosettaObj = rosettaObj.load("test"); - } catch (APIException | IOException | ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - try { - Out outxml = Mockito.mock(OutXML.class); - - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4); - RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(OutputStream.class)); - - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testTo() { - TYPE type = TYPE.XML; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - - try { - Out outxml = Mockito.mock(OutXML.class); - - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); - RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(OutputStream.class)); - - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testToWriterXml() { - TYPE type = TYPE.XML; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - - rosettaObj = rosettaObj.load("test"); - } catch (APIException | IOException | ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - try { - Out outxml = Mockito.mock(OutXML.class); - - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); - RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(StringWriter.class)); - - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testToWriterJson() { - TYPE type = TYPE.JSON; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.JSON); - rosettaObj.setSaved(saved); - - try { - InXML inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); - Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); - - rosettaObj = rosettaObj.load("test"); - } catch (APIException | IOException | ParseException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - try { - Out outxml = Mockito.mock(OutXML.class); - - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4); - RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(StringWriter.class)); - - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testToWriter() { - TYPE type = TYPE.XML; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - rosettaObj = rosettaObj.in(Data.TYPE.XML); - rosettaObj.setSaved(saved); - - try { - Out outxml = Mockito.mock(OutXML.class); - - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); - RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(StringWriter.class)); - - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testGetTypeClass() { - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - rosettaObj.getTypeClass(); - } - - @Test - public void testDirect() { - TYPE type = TYPE.XML; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - try { - Out outxml = Mockito.mock(OutXML.class); - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); - rosettaObj.direct(Mockito.mock(InputStream.class), Mockito.mock(OutputStream.class)); - } catch (APIException | IOException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testDirectException() { - TYPE type = TYPE.XML; - Mockito.doReturn(type).when(df).getOutType(); - Mockito.doReturn(type).when(df).getInType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - InXML inxml = null; - - inxml = Mockito.mock(InXML.class); - Mockito.doReturn(inxml).when(df).getIn(type); - - - StringReader is = Mockito.mock(StringReader.class); - StringWriter os= Mockito.mock(StringWriter.class); - try { - Out outxml = Mockito.mock(OutXML.class); - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); - Mockito.doThrow( new IOException("testException")).when(outxml).extract(is, os, inxml, true); - - rosettaObj.direct(is,os, true); - } catch (APIException | IOException | ParseException e) { - // TODO Auto-generated catch block - assertTrue(e.getMessage().contains("testException")); - } - } - - @Test - public void testDirectT() { - TYPE type = TYPE.XML; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - try { - Out outxml = Mockito.mock(OutXML.class); - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); + @Test + public void testAsString() { + TYPE type = TYPE.XML; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + try { + Out outxml = Mockito.mock(OutXML.class); + + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); + + String retVal = rosettaObj.asString(); + assertTrue("".equals(retVal)); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testAsStringJson() { + TYPE type = TYPE.JSON; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.JSON); + rosettaObj.setSaved(saved); + try { + Out outxml = Mockito.mock(OutXML.class); + + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4); + + String retVal = rosettaObj.asString(); + assertTrue("".equals(retVal)); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + @Test + public void testToXml() { + TYPE type = TYPE.XML; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); + + rosettaObj = rosettaObj.load("test"); + } catch (APIException | IOException | ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + Out outxml = Mockito.mock(OutXML.class); + + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); + RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(OutputStream.class)); + + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testToJson() { + TYPE type = TYPE.JSON; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.JSON); + rosettaObj.setSaved(saved); + + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); + + rosettaObj = rosettaObj.load("test"); + } catch (APIException | IOException | ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + Out outxml = Mockito.mock(OutXML.class); + + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4); + RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(OutputStream.class)); + + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testTo() { + TYPE type = TYPE.XML; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + + try { + Out outxml = Mockito.mock(OutXML.class); + + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); + RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(OutputStream.class)); + + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testToWriterXml() { + TYPE type = TYPE.XML; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.XML); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); + + rosettaObj = rosettaObj.load("test"); + } catch (APIException | IOException | ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + Out outxml = Mockito.mock(OutXML.class); + + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); + RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(StringWriter.class)); + + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testToWriterJson() { + TYPE type = TYPE.JSON; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.JSON); + rosettaObj.setSaved(saved); + + try { + InXML inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(Data.TYPE.JSON); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(inxml).start(env); + Mockito.doNothing().when(saved).extract(new StringReader("test"),(Writer)null,inxml); + + rosettaObj = rosettaObj.load("test"); + } catch (APIException | IOException | ParseException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + try { + Out outxml = Mockito.mock(OutXML.class); + + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4); + RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(StringWriter.class)); + + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testToWriter() { + TYPE type = TYPE.XML; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + rosettaObj = rosettaObj.in(Data.TYPE.XML); + rosettaObj.setSaved(saved); + + try { + Out outxml = Mockito.mock(OutXML.class); + + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); + RosettaData<JAXBmar> retVal = rosettaObj.to(Mockito.mock(StringWriter.class)); + + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testGetTypeClass() { + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + rosettaObj.getTypeClass(); + } + + @Test + public void testDirect() { + TYPE type = TYPE.XML; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + try { + Out outxml = Mockito.mock(OutXML.class); + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); + rosettaObj.direct(Mockito.mock(InputStream.class), Mockito.mock(OutputStream.class)); + } catch (APIException | IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testDirectException() { + TYPE type = TYPE.XML; + Mockito.doReturn(type).when(df).getOutType(); + Mockito.doReturn(type).when(df).getInType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + InXML inxml = null; + + inxml = Mockito.mock(InXML.class); + Mockito.doReturn(inxml).when(df).getIn(type); + + + StringReader is = Mockito.mock(StringReader.class); + StringWriter os= Mockito.mock(StringWriter.class); + try { + Out outxml = Mockito.mock(OutXML.class); + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); + Mockito.doThrow( new IOException("testException")).when(outxml).extract(is, os, inxml, true); + + rosettaObj.direct(is,os, true); + } catch (APIException | IOException | ParseException e) { + // TODO Auto-generated catch block + assertTrue(e.getMessage().contains("testException")); + } + } + + @Test + public void testDirectT() { + TYPE type = TYPE.XML; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + try { + Out outxml = Mockito.mock(OutXML.class); + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); - df.jaxMar = Mockito.mock(JAXBmar.class); - LogTarget lt = Mockito.mock(LogTarget.class); - Mockito.doReturn( lt).when(env).debug(); - Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true); - - rosettaObj.direct(bmar, Mockito.mock(StringWriter.class), true); - df.marshal =Mockito.mock(Marshal.class);; - rosettaObj.direct(bmar, Mockito.mock(StringWriter.class), true); - } catch (APIException | IOException | JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testDirectTOS() { - TYPE type = TYPE.XML; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - try { - Out outxml = Mockito.mock(OutXML.class); - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); + df.jaxMar = Mockito.mock(JAXBmar.class); + LogTarget lt = Mockito.mock(LogTarget.class); + Mockito.doReturn( lt).when(env).debug(); + Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true); + + rosettaObj.direct(bmar, Mockito.mock(StringWriter.class), true); + df.marshal =Mockito.mock(Marshal.class);; + rosettaObj.direct(bmar, Mockito.mock(StringWriter.class), true); + } catch (APIException | IOException | JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testDirectTOS() { + TYPE type = TYPE.XML; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + try { + Out outxml = Mockito.mock(OutXML.class); + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.XML).when(df).logType(Data.TYPE.XML); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",2); - df.jaxMar = Mockito.mock(JAXBmar.class); - LogTarget lt = Mockito.mock(LogTarget.class); - Mockito.doReturn( lt).when(env).debug(); - Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true); - - rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true); - df.marshal =Mockito.mock(Marshal.class);; - rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true); - } catch (APIException | IOException | JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testDirectTOSJson() { - TYPE type = TYPE.JSON; - Mockito.doReturn(type).when(df).getOutType(); - RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); - try { - Out outxml = Mockito.mock(OutXML.class); - Mockito.doReturn(outxml).when(df).getOut(type); - Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON); - Mockito.doReturn("test").when(outxml).logName(); - Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4); + df.jaxMar = Mockito.mock(JAXBmar.class); + LogTarget lt = Mockito.mock(LogTarget.class); + Mockito.doReturn( lt).when(env).debug(); + Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true); + + rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true); + df.marshal =Mockito.mock(Marshal.class);; + rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true); + } catch (APIException | IOException | JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testDirectTOSJson() { + TYPE type = TYPE.JSON; + Mockito.doReturn(type).when(df).getOutType(); + RosettaData<JAXBmar> rosettaObj = new RosettaData<JAXBmar>(env, df); + try { + Out outxml = Mockito.mock(OutXML.class); + Mockito.doReturn(outxml).when(df).getOut(type); + Mockito.doReturn(Env.JSON).when(df).logType(Data.TYPE.JSON); + Mockito.doReturn("test").when(outxml).logName(); + Mockito.doReturn( Mockito.mock(TimeTaken.class)).when(env).start("test",4); - df.jaxMar = Mockito.mock(JAXBmar.class); - LogTarget lt = Mockito.mock(LogTarget.class); - Mockito.doReturn( lt).when(env).debug(); - Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true); - - rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true); - } catch (APIException | IOException | JAXBException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - + df.jaxMar = Mockito.mock(JAXBmar.class); + LogTarget lt = Mockito.mock(LogTarget.class); + Mockito.doReturn( lt).when(env).debug(); + Mockito.doReturn(bmar).when(df.jaxMar).marshal(lt,bmar, new StringWriter(),true); + + rosettaObj.direct(bmar, Mockito.mock(OutputStream.class), true); + } catch (APIException | IOException | JAXBException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java index b5889b45..c8771519 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/env/JU_RosettaEnv.java @@ -41,58 +41,58 @@ import org.onap.aaf.misc.rosetta.Saved; public class JU_RosettaEnv { - @Before - public void setUp() { - initMocks(this); - } - - @Test - public void testNewDataFactoryClass() { - RosettaEnv rosettaObj = new RosettaEnv(); - try { - Object retVal = rosettaObj.newDataFactory(Api.class); - assertTrue(retVal instanceof RosettaDF); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testNewDataFactorySchema() { - RosettaEnv rosettaObj = new RosettaEnv(Mockito.mock(Applet.class),"test"); - try { - Object retVal = rosettaObj.newDataFactory(Mockito.mock(Schema.class),Api.class); - assertTrue(retVal instanceof RosettaDF); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testNewDataFactoryQname() { - RosettaEnv rosettaObj = new RosettaEnv(new String[] {"test"}); - rosettaObj = new RosettaEnv(Mockito.mock(Properties.class)); - try { - Object retVal = rosettaObj.newDataFactory(Mockito.mock(QName.class),Api.class); - assertTrue(retVal instanceof RosettaDF); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - - @Test - public void testNewDataFactoryQnameSchema() { - RosettaEnv rosettaObj = new RosettaEnv("test", new String[] {"test"}); - rosettaObj = new RosettaEnv("test", Mockito.mock(Properties.class)); - try { - Object retVal = rosettaObj.newDataFactory(Mockito.mock(Schema.class),Mockito.mock(QName.class),Api.class); - assertTrue(retVal instanceof RosettaDF); - } catch (APIException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } + @Before + public void setUp() { + initMocks(this); + } + + @Test + public void testNewDataFactoryClass() { + RosettaEnv rosettaObj = new RosettaEnv(); + try { + Object retVal = rosettaObj.newDataFactory(Api.class); + assertTrue(retVal instanceof RosettaDF); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testNewDataFactorySchema() { + RosettaEnv rosettaObj = new RosettaEnv(Mockito.mock(Applet.class),"test"); + try { + Object retVal = rosettaObj.newDataFactory(Mockito.mock(Schema.class),Api.class); + assertTrue(retVal instanceof RosettaDF); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testNewDataFactoryQname() { + RosettaEnv rosettaObj = new RosettaEnv(new String[] {"test"}); + rosettaObj = new RosettaEnv(Mockito.mock(Properties.class)); + try { + Object retVal = rosettaObj.newDataFactory(Mockito.mock(QName.class),Api.class); + assertTrue(retVal instanceof RosettaDF); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + @Test + public void testNewDataFactoryQnameSchema() { + RosettaEnv rosettaObj = new RosettaEnv("test", new String[] {"test"}); + rosettaObj = new RosettaEnv("test", Mockito.mock(Properties.class)); + try { + Object retVal = rosettaObj.newDataFactory(Mockito.mock(Schema.class),Mockito.mock(QName.class),Api.class); + assertTrue(retVal instanceof RosettaDF); + } catch (APIException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } } diff --git a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java index c28e83d5..5b7875f7 100644 --- a/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java +++ b/misc/rosetta/src/test/java/org/onap/aaf/misc/rosetta/marshal/JU_FieldBlob.java @@ -26,24 +26,24 @@ import org.onap.aaf.misc.env.jaxb.JAXBumar; public class JU_FieldBlob { - class FieldBlobImpl extends FieldBlob{ + class FieldBlobImpl extends FieldBlob{ - public FieldBlobImpl(String name) { - super(name); - // TODO Auto-generated constructor stub - } + public FieldBlobImpl(String name) { + super(name); + // TODO Auto-generated constructor stub + } - @Override - protected byte[] data(Object t) { - // TODO Auto-generated method stub - return null; - } - - } - @Test - public void testData() { - FieldBlob<JAXBumar> obj = new FieldBlobImpl("test"); - obj.data(Mockito.mock(JAXBumar.class), new StringBuilder()); - } + @Override + protected byte[] data(Object t) { + // TODO Auto-generated method stub + return null; + } + + } + @Test + public void testData() { + FieldBlob<JAXBumar> obj = new FieldBlobImpl("test"); + obj.data(Mockito.mock(JAXBumar.class), new StringBuilder()); + } } |