5d765c5ae09be0d297c45b7bebf1a205972a2ebd
[aaf/authz.git] / cadi / core / src / test / java / org / onap / aaf / cadi / test / wsse / JU_XReader.java
1 /*******************************************************************************
2  * ============LICENSE_START====================================================
3  * * org.onap.aaf
4  * * ===========================================================================
5  * * Copyright © 2017 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.cadi.test.wsse;
23
24 import java.io.FileInputStream;
25
26 import javax.xml.stream.events.XMLEvent;
27
28 import org.junit.Test;
29 import org.onap.aaf.cadi.wsse.XEvent;
30 import org.onap.aaf.cadi.wsse.XReader;
31
32 public class JU_XReader {
33         //TODO: Gabe [JUnit] Class not found error
34         @Test
35         public void test() throws Exception {
36                 FileInputStream fis = new FileInputStream("test/CBUSevent.xml");
37                 try {
38                         XReader xr = new XReader(fis);
39                         while(xr.hasNext()) {
40                                 XEvent xe = xr.nextEvent();
41                                 switch(xe.getEventType()) {
42                                         case XMLEvent.START_DOCUMENT:
43                                                 System.out.println("Start Document");
44                                                 break;
45                                         case XMLEvent.START_ELEMENT:
46                                                 System.out.println("Start Event: " + xe.asStartElement().getName());
47                                                 break;
48                                         case XMLEvent.END_ELEMENT:
49                                                 System.out.println("End Event: " + xe.asEndElement().getName());
50                                                 break;
51                                         case XMLEvent.CHARACTERS:
52                                                 System.out.println("Characters: " + xe.asCharacters().getData());
53                                                 break;
54                                         case XMLEvent.COMMENT:
55                                                 System.out.println("Comment: " + ((XEvent.Comment)xe).value);
56                                                 break;
57                                 }
58                         }
59                 } finally {
60                         fis.close();
61                 }
62                 
63         }
64
65 }