2 * ============LICENSE_START====================================================
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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====================================================
22 package org.onap.aaf.misc.env.jaxb;
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;
29 import java.io.InputStream;
30 import java.io.OutputStream;
31 import java.io.StringReader;
32 import java.io.StringWriter;
34 import javax.xml.bind.JAXBException;
35 import javax.xml.namespace.QName;
36 import javax.xml.validation.Schema;
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;
49 public class JU_JAXBDF {
63 TimeTaken tt,ttObjectify;
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();
77 public void testNewInstance() {
78 JAXBDF<?> bdfObj = null;
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
96 public void testNewInstanceNoException() {
97 JAXBDF<?> bdfObj = null;
99 bdfObj = new JAXBDF( null, new Class[] {this.getClass()});
100 Object retVal = bdfObj.newInstance();
101 assertTrue(retVal instanceof JU_JAXBDF);
102 } catch (APIException e) {
109 public void testPrettyNoException() {
110 JAXBDF<?> bdfObj = null;
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) {
121 public void testFragment() {
122 JAXBDF<?> bdfObj = null;
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) {
139 public void testNewData() {
140 JAXBDF<?> bdfObj = null;
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) {
151 public void testNewDataENV() {
152 JAXBDF<?> bdfObj = null;
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) {
163 public void testNewDataType() {
164 JAXBDF<JAXBumar> bdfObj = null;
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) {
171 } catch (JAXBException e) {
172 // TODO Auto-generated catch block
178 public void testNewDataStream() {
179 JAXBDF<?> bdfObj = null;
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) {
191 } catch (JAXBException e) {
192 // TODO Auto-generated catch block
198 public void testNewDataStreamException() {
199 JAXBDF<?> bdfObj = null;
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"));
217 public void testNewDataFromString() {
218 JAXBDF<?> bdfObj = null;
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) {
229 public void testStringify() {
230 JAXBDF<JAXBmar> bdfObj = null;
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) {
243 } catch (JAXBException e) {
244 // TODO Auto-generated catch block
250 public void testStringifyException() {
251 JAXBDF<JAXBmar> bdfObj = null;
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"));
270 public void testStringifyWriter() {
271 JAXBDF<JAXBmar> bdfObj = null;
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) {
283 } catch (JAXBException e) {
284 // TODO Auto-generated catch block
290 public void testStringifyWriterException() {
291 JAXBDF<JAXBmar> bdfObj = null;
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"));
310 public void testStringifyOS() {
311 JAXBDF<JAXBmar> bdfObj = null;
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) {
323 } catch (JAXBException e) {
324 // TODO Auto-generated catch block
330 public void testStringifyOsException() {
331 JAXBDF<JAXBmar> bdfObj = null;
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"));
350 public void testStringifyOptions() {
351 JAXBDF<JAXBmar> bdfObj = null;
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) {
363 } catch (JAXBException e) {
364 // TODO Auto-generated catch block
370 public void testStringifyOSOptions() {
371 JAXBDF<JAXBmar> bdfObj = null;
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) {
383 } catch (JAXBException e) {
384 // TODO Auto-generated catch block
390 public void testStringifyOsOptionsException() {
391 JAXBDF<JAXBmar> bdfObj = null;
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"));
409 public void testStringifySWOptions() {
410 JAXBDF<JAXBmar> bdfObj = null;
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) {
422 } catch (JAXBException e) {
423 // TODO Auto-generated catch block
429 public void testStringifySWOptionsException() {
430 JAXBDF<JAXBmar> bdfObj = null;
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"));
449 public void testObjectifyEnv() {
450 JAXBDF<JAXBumar> bdfObj = null;
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));
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"));
469 public void testObjectifyEnvException() {
470 JAXBDF<JAXBumar> bdfObj = null;
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);
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"));
491 public void testObjectifyRdr() {
492 JAXBDF<JAXBumar> bdfObj = null;
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));
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"));
511 public void testObjectifyRdrException() {
512 JAXBDF<JAXBumar> bdfObj = null;
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);
523 bdfObj.objectify(sr);
524 } catch (APIException e) {
525 assertTrue(e.getMessage().contains("test"));
526 } catch (JAXBException e) {
527 assertTrue(e.getMessage().contains("test"));
533 public void testObjectifyEnvIS() {
534 JAXBDF<JAXBumar> bdfObj = null;
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));
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"));
553 public void testObjectifyEnvISException() {
554 JAXBDF<JAXBumar> bdfObj = null;
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);
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"));
575 public void testObjectifyIs() {
576 JAXBDF<JAXBumar> bdfObj = null;
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));
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"));
595 public void testObjectifyIsException() {
596 JAXBDF<JAXBumar> bdfObj = null;
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);
607 bdfObj.objectify(sr);
608 } catch (APIException e) {
609 assertTrue(e.getMessage().contains("test"));
610 } catch (JAXBException e) {
611 assertTrue(e.getMessage().contains("test"));
617 public void testObjectifyEnvStr() {
618 JAXBDF<JAXBumar> bdfObj = null;
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");
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"));
637 public void testObjectifyEnvStrException() {
638 JAXBDF<JAXBumar> bdfObj = null;
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");
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"));
659 public void testObjectifyStr() {
660 JAXBDF<JAXBumar> bdfObj = null;
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");
670 bdfObj.objectify( "test");
671 } catch (APIException e) {
672 assertTrue(e.getMessage().contains("test"));
673 } catch (JAXBException e) {
674 assertTrue(e.getMessage().contains("test"));
679 public void testObjectifyStrException() {
680 JAXBDF<JAXBumar> bdfObj = null;
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");
691 bdfObj.objectify("test");
692 } catch (APIException e) {
693 assertTrue(e.getMessage().contains("test"));
694 } catch (JAXBException e) {
695 assertTrue(e.getMessage().contains("test"));
701 public void testTypeClass() {
702 JAXBDF<JAXBumar> bdfObj = null;
704 EnvJAXB envJaxb = Mockito.mock(EnvJAXB.class);
705 bdfObj = new JAXBDF<JAXBumar>( envJaxb, new Class[] {this.getClass()});
707 Object obj = bdfObj.getTypeClass();
708 assertFalse(obj instanceof JU_JAXBDF);
709 } catch (APIException e) {
710 assertTrue(e.getMessage().contains("test"));