Remove Tabs, per Jococo
[aaf/authz.git] / misc / env / src / test / java / org / onap / aaf / misc / env / jaxb / JU_JAXBDF.java
1 /**
2  * ============LICENSE_START====================================================
3  * org.onap.aaf
4  * ===========================================================================
5  * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
6  * ===========================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  * 
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  * 
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END====================================================
19  *
20  */
21
22 package org.onap.aaf.misc.env.jaxb;
23
24 import static org.junit.Assert.assertEquals;
25 import static org.junit.Assert.assertFalse;
26 import static org.junit.Assert.assertTrue;
27 import static org.mockito.MockitoAnnotations.initMocks;
28
29 import java.io.InputStream;
30 import java.io.OutputStream;
31 import java.io.StringReader;
32 import java.io.StringWriter;
33
34 import javax.xml.bind.JAXBException;
35 import javax.xml.namespace.QName;
36 import javax.xml.validation.Schema;
37
38 import org.junit.Before;
39 import org.junit.Test;
40 import org.mockito.Mock;
41 import org.mockito.Mockito;
42 import org.onap.aaf.misc.env.APIException;
43 import org.onap.aaf.misc.env.Data;
44 import org.onap.aaf.misc.env.Env;
45 import org.onap.aaf.misc.env.EnvJAXB;
46 import org.onap.aaf.misc.env.LogTarget;
47 import org.onap.aaf.misc.env.TimeTaken;
48
49 public class JU_JAXBDF {
50
51     @Mock
52     EnvJAXB primaryEnv;
53     
54     @Mock
55     JAXBumar jumar;
56     
57     @Mock
58     JAXBmar jmar;
59     
60     @Mock
61     Env env;
62     
63     TimeTaken tt,ttObjectify;
64
65     @Before
66     public void setUp() {
67         initMocks(this);
68         tt=Mockito.mock(TimeTaken.class);
69         Mockito.doReturn(tt).when(env).start("JAXB Stringify", Env.XML);
70         Mockito.doNothing().when(tt).done();
71         ttObjectify=Mockito.mock(TimeTaken.class);
72         Mockito.doReturn(ttObjectify).when(env).start("JAXB Objectify", Env.XML);
73         Mockito.doNothing().when(ttObjectify).done();
74     }
75
76     @Test
77     public void testNewInstance() {
78         JAXBDF<?> bdfObj = null;
79         try {
80             bdfObj = new JAXBDF( null, new Class[] {this.getClass()});
81             bdfObj.jumar = Mockito.mock(JAXBumar.class);
82             Mockito.doThrow(new IllegalAccessException("Test Exception")).when(bdfObj.jumar).newInstance();
83             Object retVal = bdfObj.newInstance();
84         } catch (IllegalAccessException e) {
85             assertEquals("Test Exception", e.getLocalizedMessage());
86         } catch (APIException e) {
87             assertTrue(e.getMessage().contains("Test Exception"));
88         } catch (InstantiationException e) {
89             // TODO Auto-generated catch block
90             e.printStackTrace();
91         }
92         
93     }
94     
95     @Test
96     public void testNewInstanceNoException() {
97         JAXBDF<?> bdfObj = null;
98         try {
99             bdfObj = new JAXBDF( null, new Class[] {this.getClass()});
100             Object retVal = bdfObj.newInstance();
101             assertTrue(retVal instanceof JU_JAXBDF);
102         } catch (APIException e) {
103             e.printStackTrace();
104         } 
105         
106     }
107     
108     @Test
109     public void testPrettyNoException() {
110         JAXBDF<?> bdfObj = null;
111         try {
112             bdfObj = new JAXBDF( null, Mockito.mock(Schema.class), new Class[] {this.getClass()});
113             Object retVal = bdfObj.pretty(true);
114             assertTrue(retVal instanceof JAXBDF);
115         } catch (APIException e) {
116             e.printStackTrace();
117         } 
118     }
119
120     @Test
121     public void testFragment() {
122         JAXBDF<?> bdfObj = null;
123         try {
124             bdfObj = new JAXBDF( null, Mockito.mock(QName.class), new Class[] {this.getClass()});
125             Object retVal = bdfObj.asFragment(true);
126             assertTrue(retVal instanceof JAXBDF);
127             bdfObj.servicePrestart(null);
128             bdfObj.threadPrestart(null);
129             bdfObj.refresh(null);
130             bdfObj.threadDestroy(null);
131             bdfObj.serviceDestroy(null);
132         } catch (APIException e) {
133             e.printStackTrace();
134         } 
135         
136     }
137     
138     @Test
139     public void testNewData() {
140         JAXBDF<?> bdfObj = null;
141         try {
142             bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
143             Data<?> retVal = bdfObj.newData();
144             assertTrue(retVal instanceof JAXBData);
145         } catch (APIException e) {
146             e.printStackTrace();
147         } 
148     }
149     
150     @Test
151     public void testNewDataENV() {
152         JAXBDF<?> bdfObj = null;
153         try {
154             bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
155             Data<?> retVal = bdfObj.newData(Mockito.mock(Env.class));
156             assertTrue(retVal instanceof JAXBData);
157         } catch (APIException e) {
158             e.printStackTrace();
159         } 
160     }
161     
162     @Test
163     public void testNewDataType() {
164         JAXBDF<JAXBumar> bdfObj = null;
165         try {
166             bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
167             Data<?> retVal = bdfObj.newData(new JAXBumar(new Class[] {this.getClass()}));
168             assertTrue(retVal instanceof JAXBData);
169         } catch (APIException e) {
170             e.printStackTrace();
171         } catch (JAXBException e) {
172             // TODO Auto-generated catch block
173             e.printStackTrace();
174         } 
175     }
176     
177     @Test
178     public void testNewDataStream() {
179         JAXBDF<?> bdfObj = null;
180         try {
181             bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
182             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
183             LogTarget logT = Mockito.mock(LogTarget.class);
184             Mockito.doReturn(logT).when(env).debug();
185             InputStream is = Mockito.mock(InputStream.class);
186             Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, is);
187             Data<?> retVal = bdfObj.newDataFromStream(env, is);
188             assertTrue(retVal instanceof JAXBData);
189         } catch (APIException e) {
190             e.printStackTrace();
191         } catch (JAXBException e) {
192             // TODO Auto-generated catch block
193             e.printStackTrace();
194         } 
195     }
196     
197     @Test
198     public void testNewDataStreamException() {
199         JAXBDF<?> bdfObj = null;
200         try {
201             bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
202             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
203             LogTarget logT = Mockito.mock(LogTarget.class);
204             Mockito.doReturn(logT).when(env).debug();
205             InputStream is = Mockito.mock(InputStream.class);
206             Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, is);
207             Data<?> retVal = bdfObj.newDataFromStream(env, is);
208         } catch (APIException e) {
209             assertTrue(e.getMessage().contains("test"));
210         } catch (JAXBException e) {
211             // TODO Auto-generated catch block
212             assertTrue(e.getMessage().contains("test"));
213         } 
214     }
215     
216     @Test
217     public void testNewDataFromString() {
218         JAXBDF<?> bdfObj = null;
219         try {
220             bdfObj = new JAXBDF( null, Mockito.mock(Schema.class),Mockito.mock(QName.class), new Class[] {this.getClass()});
221             Data<?> retVal = bdfObj.newDataFromString("test");
222             assertTrue(retVal instanceof JAXBData);
223         } catch (APIException e) {
224             e.printStackTrace();
225         } 
226     }
227     
228     @Test
229     public void testStringify() {
230         JAXBDF<JAXBmar> bdfObj = null;
231         try {
232             JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
233             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
234             bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
235             bdfObj.jmar =  Mockito.mock(JAXBmar.class);
236             LogTarget logT = Mockito.mock(LogTarget.class);
237             Mockito.doReturn(logT).when(envJaxb).debug();
238             Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(StringWriter.class));
239             String retVal = bdfObj.stringify(typeObj);
240             assertEquals("", retVal);
241         } catch (APIException e) {
242             e.printStackTrace();
243         } catch (JAXBException e) {
244             // TODO Auto-generated catch block
245             e.printStackTrace();
246         } 
247     }
248     
249     @Test
250     public void testStringifyException() {
251         JAXBDF<JAXBmar> bdfObj = null;
252         try {
253             JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
254             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
255             LogTarget logT = Mockito.mock(LogTarget.class);
256             Mockito.doReturn(logT).when(envJaxb).debug();
257             bdfObj = new JAXBDF<JAXBmar>( envJaxb, new Class[] {this.getClass()});
258             bdfObj.jmar =  Mockito.mock(JAXBmar.class);
259             Mockito.doThrow(new JAXBException("test") ).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(StringWriter.class));
260             String retVal = bdfObj.stringify(typeObj);
261             System.out.println(retVal);
262         } catch (APIException e) {
263             assertTrue(e.getMessage().contains("test"));
264         } catch (JAXBException e) {
265             assertTrue(e.getMessage().contains("test"));
266         } 
267     }
268     
269     @Test
270     public void testStringifyWriter() {
271         JAXBDF<JAXBmar> bdfObj = null;
272         try {
273             JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
274             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
275             bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
276             bdfObj.jmar =  Mockito.mock(JAXBmar.class);
277             LogTarget logT = Mockito.mock(LogTarget.class);
278             Mockito.doReturn(logT).when(envJaxb).debug();
279             Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(StringWriter.class));
280             bdfObj.stringify(typeObj, Mockito.mock(StringWriter.class));
281         } catch (APIException e) {
282             e.printStackTrace();
283         } catch (JAXBException e) {
284             // TODO Auto-generated catch block
285             e.printStackTrace();
286         } 
287     }
288     
289     @Test
290     public void testStringifyWriterException() {
291         JAXBDF<JAXBmar> bdfObj = null;
292         try {
293             JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
294             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
295             bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
296             bdfObj.jmar =  Mockito.mock(JAXBmar.class);
297             LogTarget logT = Mockito.mock(LogTarget.class);
298             Mockito.doReturn(logT).when(envJaxb).debug();
299             StringWriter sw = Mockito.mock(StringWriter.class);
300             Mockito.doThrow(new JAXBException("test")).when(bdfObj.jmar).marshal(logT, typeObj, sw);
301             bdfObj.stringify(typeObj, sw);
302         } catch (APIException e) {
303             assertTrue(e.getMessage().contains("test"));
304         } catch (JAXBException e) {
305             assertTrue(e.getMessage().contains("test"));
306         } 
307     }
308     
309     @Test
310     public void testStringifyOS() {
311         JAXBDF<JAXBmar> bdfObj = null;
312         try {
313             JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
314             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
315             bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
316             bdfObj.jmar =  Mockito.mock(JAXBmar.class);
317             LogTarget logT = Mockito.mock(LogTarget.class);
318             Mockito.doReturn(logT).when(envJaxb).debug();
319             Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(OutputStream.class));
320             bdfObj.stringify(typeObj, Mockito.mock(OutputStream.class));
321         } catch (APIException e) {
322             e.printStackTrace();
323         } catch (JAXBException e) {
324             // TODO Auto-generated catch block
325             e.printStackTrace();
326         } 
327     }
328     
329     @Test
330     public void testStringifyOsException() {
331         JAXBDF<JAXBmar> bdfObj = null;
332         try {
333             JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
334             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
335             bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
336             bdfObj.jmar =  Mockito.mock(JAXBmar.class);
337             LogTarget logT = Mockito.mock(LogTarget.class);
338             Mockito.doReturn(logT).when(envJaxb).debug();
339             OutputStream sw = Mockito.mock(OutputStream.class);
340             Mockito.doThrow(new JAXBException("test")).when(bdfObj.jmar).marshal(logT, typeObj, sw);
341             bdfObj.stringify(typeObj, sw);
342         } catch (APIException e) {
343             assertTrue(e.getMessage().contains("test"));
344         } catch (JAXBException e) {
345             assertTrue(e.getMessage().contains("test"));
346         } 
347     }
348     
349     @Test
350     public void testStringifyOptions() {
351         JAXBDF<JAXBmar> bdfObj = null;
352         try {
353             JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
354             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
355             bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
356             bdfObj.jmar =  Mockito.mock(JAXBmar.class);
357             LogTarget logT = Mockito.mock(LogTarget.class);
358             Mockito.doReturn(logT).when(envJaxb).debug();
359             Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(OutputStream.class));
360             bdfObj.stringify(env, typeObj, true);
361         } catch (APIException e) {
362             e.printStackTrace();
363         } catch (JAXBException e) {
364             // TODO Auto-generated catch block
365             e.printStackTrace();
366         } 
367     }
368     
369     @Test
370     public void testStringifyOSOptions() {
371         JAXBDF<JAXBmar> bdfObj = null;
372         try {
373             JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
374             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
375             bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
376             bdfObj.jmar =  Mockito.mock(JAXBmar.class);
377             LogTarget logT = Mockito.mock(LogTarget.class);
378             Mockito.doReturn(logT).when(env).debug();
379             Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(OutputStream.class),true);
380             bdfObj.stringify(env, typeObj, Mockito.mock(OutputStream.class),true);
381         } catch (APIException e) {
382             e.printStackTrace();
383         } catch (JAXBException e) {
384             // TODO Auto-generated catch block
385             e.printStackTrace();
386         } 
387     }
388     
389     @Test
390     public void testStringifyOsOptionsException() {
391         JAXBDF<JAXBmar> bdfObj = null;
392         try {
393             JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
394             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
395             bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
396             bdfObj.jmar =  Mockito.mock(JAXBmar.class);
397             LogTarget logT = Mockito.mock(LogTarget.class);
398             Mockito.doReturn(logT).when(env).debug();
399             OutputStream sw = Mockito.mock(OutputStream.class);
400             Mockito.doThrow(new JAXBException("test")).when(bdfObj.jmar).marshal(logT, typeObj, sw,true);
401             bdfObj.stringify(env, typeObj, sw,true);
402         } catch (APIException e) {
403             assertTrue(e.getMessage().contains("test"));
404         } catch (JAXBException e) {
405             assertTrue(e.getMessage().contains("test"));
406         } 
407     }
408     @Test
409     public void testStringifySWOptions() {
410         JAXBDF<JAXBmar> bdfObj = null;
411         try {
412             JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
413             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
414             bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
415             bdfObj.jmar =  Mockito.mock(JAXBmar.class);
416             LogTarget logT = Mockito.mock(LogTarget.class);
417             Mockito.doReturn(logT).when(env).debug();
418             Mockito.doReturn(this.getClass()).when(bdfObj.jmar).marshal(logT, typeObj, Mockito.mock(StringWriter.class),true);
419             bdfObj.stringify(env, typeObj, Mockito.mock(StringWriter.class),true);
420         } catch (APIException e) {
421             e.printStackTrace();
422         } catch (JAXBException e) {
423             // TODO Auto-generated catch block
424             e.printStackTrace();
425         } 
426     }
427     
428     @Test
429     public void testStringifySWOptionsException() {
430         JAXBDF<JAXBmar> bdfObj = null;
431         try {
432             JAXBmar typeObj = new JAXBmar(new Class[] {this.getClass()});
433             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
434             bdfObj = new JAXBDF( envJaxb, new Class[] {this.getClass()});
435             bdfObj.jmar =  Mockito.mock(JAXBmar.class);
436             LogTarget logT = Mockito.mock(LogTarget.class);
437             Mockito.doReturn(logT).when(env).debug();
438             StringWriter sw = Mockito.mock(StringWriter.class);
439             Mockito.doThrow(new JAXBException("test")).when(bdfObj.jmar).marshal(logT, typeObj, sw,true);
440             bdfObj.stringify(env, typeObj, sw,true);
441         } catch (APIException e) {
442             assertTrue(e.getMessage().contains("test"));
443         } catch (JAXBException e) {
444             assertTrue(e.getMessage().contains("test"));
445         } 
446     }
447  
448     @Test
449     public void testObjectifyEnv() {
450         JAXBDF<JAXBumar> bdfObj = null;
451         try {
452             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
453             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
454             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
455             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
456             LogTarget logT = Mockito.mock(LogTarget.class);
457             Mockito.doReturn(logT).when(env).debug();
458             Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, Mockito.mock(StringReader.class));
459             
460             bdfObj.objectify(env, Mockito.mock(StringReader.class));
461         } catch (APIException e) {
462             assertTrue(e.getMessage().contains("test"));
463         } catch (JAXBException e) {
464             assertTrue(e.getMessage().contains("test"));
465         } 
466         
467     }
468     @Test
469     public void testObjectifyEnvException() {
470         JAXBDF<JAXBumar> bdfObj = null;
471         try {
472             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
473             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
474             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
475             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
476             LogTarget logT = Mockito.mock(LogTarget.class);
477             Mockito.doReturn(logT).when(env).debug();
478             StringReader sr = Mockito.mock(StringReader.class);
479             Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, sr);
480             
481             bdfObj.objectify(env, sr);
482         } catch (APIException e) {
483             assertTrue(e.getMessage().contains("test"));
484         } catch (JAXBException e) {
485             assertTrue(e.getMessage().contains("test"));
486         } 
487         
488     }
489     
490     @Test
491     public void testObjectifyRdr() {
492         JAXBDF<JAXBumar> bdfObj = null;
493         try {
494             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
495             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
496             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
497             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
498             LogTarget logT = Mockito.mock(LogTarget.class);
499             Mockito.doReturn(logT).when(env).debug();
500             Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, Mockito.mock(StringReader.class));
501             
502             bdfObj.objectify( Mockito.mock(StringReader.class));
503         } catch (APIException e) {
504             assertTrue(e.getMessage().contains("test"));
505         } catch (JAXBException e) {
506             assertTrue(e.getMessage().contains("test"));
507         } 
508         
509     }
510     @Test
511     public void testObjectifyRdrException() {
512         JAXBDF<JAXBumar> bdfObj = null;
513         try {
514             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
515             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
516             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
517             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
518             LogTarget logT = Mockito.mock(LogTarget.class);
519             Mockito.doReturn(logT).when(envJaxb).debug();
520             StringReader sr = Mockito.mock(StringReader.class);
521             Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, sr);
522             
523             bdfObj.objectify(sr);
524         } catch (APIException e) {
525             assertTrue(e.getMessage().contains("test"));
526         } catch (JAXBException e) {
527             assertTrue(e.getMessage().contains("test"));
528         } 
529         
530     }
531     
532     @Test
533     public void testObjectifyEnvIS() {
534         JAXBDF<JAXBumar> bdfObj = null;
535         try {
536             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
537             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
538             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
539             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
540             LogTarget logT = Mockito.mock(LogTarget.class);
541             Mockito.doReturn(logT).when(env).debug();
542             Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, Mockito.mock(InputStream.class));
543             
544             bdfObj.objectify(env, Mockito.mock(InputStream.class));
545         } catch (APIException e) {
546             assertTrue(e.getMessage().contains("test"));
547         } catch (JAXBException e) {
548             assertTrue(e.getMessage().contains("test"));
549         } 
550         
551     }
552     @Test
553     public void testObjectifyEnvISException() {
554         JAXBDF<JAXBumar> bdfObj = null;
555         try {
556             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
557             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
558             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
559             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
560             LogTarget logT = Mockito.mock(LogTarget.class);
561             Mockito.doReturn(logT).when(env).debug();
562             InputStream sr = Mockito.mock(InputStream.class);
563             Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, sr);
564             
565             bdfObj.objectify(env, sr);
566         } catch (APIException e) {
567             assertTrue(e.getMessage().contains("test"));
568         } catch (JAXBException e) {
569             assertTrue(e.getMessage().contains("test"));
570         } 
571         
572     }
573     
574     @Test
575     public void testObjectifyIs() {
576         JAXBDF<JAXBumar> bdfObj = null;
577         try {
578             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
579             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
580             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
581             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
582             LogTarget logT = Mockito.mock(LogTarget.class);
583             Mockito.doReturn(logT).when(env).debug();
584             Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, Mockito.mock(InputStream.class));
585             
586             bdfObj.objectify( Mockito.mock(InputStream.class));
587         } catch (APIException e) {
588             assertTrue(e.getMessage().contains("test"));
589         } catch (JAXBException e) {
590             assertTrue(e.getMessage().contains("test"));
591         } 
592         
593     }
594     @Test
595     public void testObjectifyIsException() {
596         JAXBDF<JAXBumar> bdfObj = null;
597         try {
598             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
599             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
600             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
601             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
602             LogTarget logT = Mockito.mock(LogTarget.class);
603             Mockito.doReturn(logT).when(envJaxb).debug();
604             InputStream sr = Mockito.mock(InputStream.class);
605             Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, sr);
606             
607             bdfObj.objectify(sr);
608         } catch (APIException e) {
609             assertTrue(e.getMessage().contains("test"));
610         } catch (JAXBException e) {
611             assertTrue(e.getMessage().contains("test"));
612         } 
613         
614     }
615     
616     @Test
617     public void testObjectifyEnvStr() {
618         JAXBDF<JAXBumar> bdfObj = null;
619         try {
620             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
621             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
622             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
623             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
624             LogTarget logT = Mockito.mock(LogTarget.class);
625             Mockito.doReturn(logT).when(env).debug();
626             Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, "test");
627             
628             bdfObj.objectify(env, "test");
629         } catch (APIException e) {
630             assertTrue(e.getMessage().contains("test"));
631         } catch (JAXBException e) {
632             assertTrue(e.getMessage().contains("test"));
633         } 
634         
635     }
636     @Test
637     public void testObjectifyEnvStrException() {
638         JAXBDF<JAXBumar> bdfObj = null;
639         try {
640             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
641             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
642             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
643             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
644             LogTarget logT = Mockito.mock(LogTarget.class);
645             Mockito.doReturn(logT).when(env).debug();
646             InputStream sr = Mockito.mock(InputStream.class);
647             Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, "test");
648             
649             bdfObj.objectify(env, "test");
650         } catch (APIException e) {
651             assertTrue(e.getMessage().contains("test"));
652         } catch (JAXBException e) {
653             assertTrue(e.getMessage().contains("test"));
654         } 
655         
656     }
657     
658     @Test
659     public void testObjectifyStr() {
660         JAXBDF<JAXBumar> bdfObj = null;
661         try {
662             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
663             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
664             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
665             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
666             LogTarget logT = Mockito.mock(LogTarget.class);
667             Mockito.doReturn(logT).when(env).debug();
668             Mockito.doReturn(this.getClass()).when(bdfObj.jumar).unmarshal(logT, "test");
669             
670             bdfObj.objectify( "test");
671         } catch (APIException e) {
672             assertTrue(e.getMessage().contains("test"));
673         } catch (JAXBException e) {
674             assertTrue(e.getMessage().contains("test"));
675         } 
676         
677     }
678     @Test
679     public void testObjectifyStrException() {
680         JAXBDF<JAXBumar> bdfObj = null;
681         try {
682             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
683             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
684             JAXBumar typeObj = new JAXBumar(new Class[] {this.getClass()});
685             bdfObj.jumar =  Mockito.mock(JAXBumar.class);
686             LogTarget logT = Mockito.mock(LogTarget.class);
687             Mockito.doReturn(logT).when(envJaxb).debug();
688             InputStream sr = Mockito.mock(InputStream.class);
689             Mockito.doThrow(new JAXBException("test")).when(bdfObj.jumar).unmarshal(logT, "test");
690             
691             bdfObj.objectify("test");
692         } catch (APIException e) {
693             assertTrue(e.getMessage().contains("test"));
694         } catch (JAXBException e) {
695             assertTrue(e.getMessage().contains("test"));
696         } 
697         
698     }
699     
700     @Test
701     public void testTypeClass() {
702         JAXBDF<JAXBumar> bdfObj = null;
703         try {
704             EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
705             bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
706             
707             Object obj = bdfObj.getTypeClass();
708             assertFalse(obj instanceof JU_JAXBDF);
709         } catch (APIException e) {
710             assertTrue(e.getMessage().contains("test"));
711         } 
712         
713     }
714 }