1 /*******************************************************************************
2 * ============LICENSE_START====================================================
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
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====================================================
21 ******************************************************************************/
22 package org.onap.aaf.cadi.wsse.test;
24 import org.junit.Test;
25 import org.onap.aaf.cadi.wsse.WSSEParser;
27 public class JU_WSSEParser {
31 @SuppressWarnings("unused")
32 WSSEParser wp = new WSSEParser();
34 // TODO: test the rest of this class
35 // final BasicCred bc = new BasicCred() {
36 // private String user;
37 // private byte[] password;
39 // public void setUser(String user) { this.user = user; }
40 // public void setCred(byte[] passwd) { this.password = passwd; }
41 // public String getUser() { return user; }
42 // public byte[] getCred() { return password; }
45 // FileInputStream fis;
46 // fis = new FileInputStream("test/example.xml");
47 // BufferedServletInputStream is = new BufferedServletInputStream(fis);
51 // assertNull(wp.parse(bc, is));
54 // assertEquals(814,is.buffered());
56 // String password = new String(bc.getCred());
57 // System.out.println("CadiWrap credentials are: " + bc.getUser() + ", " + password);
58 // assertEquals("some_user", bc.getUser());
59 // assertEquals("some_password", password);
66 // fis = new FileInputStream("test/CBUSevent.xml");
67 // is = new BufferedServletInputStream(fis);
71 // assertNull(wp.parse(bc, is));
74 // assertEquals(667,is.buffered());
76 // String password = new String(bc.getCred());
77 // System.out.println("CadiWrap credentials are: " + bc.getUser() + ", " + password);
78 // assertEquals("none", bc.getUser());
79 // assertEquals("none", password);
86 // fis = new FileInputStream("test/example.xml");
90 // XMLStreamException ex = wp.parse(bc, fis);
92 // assertNull(bc.getUser());
93 // assertNull(bc.getCred());
96 // fis = new FileInputStream("test/exampleNoSecurity.xml");
100 // assertNull(wp.parse(bc, fis));
101 // assertNull(bc.getUser());
102 // assertNull(bc.getCred());
107 // fis = new FileInputStream("test/exampleBad1.xml");
111 // assertNull(wp.parse(bc, fis));
112 // assertNull(bc.getUser());
113 // assertNull(bc.getCred());
118 // XMLStreamException e = wp.parse(bc, new ByteArrayInputStream("Not XML".getBytes())); // empty
121 // e = wp.parse(bc, new ByteArrayInputStream("".getBytes())); // empty
125 // long start, count = 0L;
127 // File f = new File("test/CBUSevent.xml");
128 // fis = new FileInputStream(f);
129 // is = new BufferedServletInputStream(fis);
132 // while(is.read()>=0);
137 // for(int i=0;i<iter;++i) {
138 // start = System.nanoTime();
141 // assertNull(wp.parse(bc, is));
143 // count += System.nanoTime()-start;
146 // float ms = count/1000000f;
147 // System.out.println("Executed " + iter + " WSSE reads from Memory Stream in " + ms + "ms. " + ms/iter + "ms per trans");
149 // // SPECIFIC ISSUES
151 // fis = new FileInputStream("test/error2013_04_23.xml");
155 // assertNull(wp.parse(bc, fis));
156 // assertNull(bc.getUser());
157 // assertNull(bc.getCred());