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 ******************************************************************************/
23 package org.onap.aaf.cadi.wsse.test;
25 import org.junit.Test;
26 import org.onap.aaf.cadi.wsse.WSSEParser;
28 public class JU_WSSEParser {
32 @SuppressWarnings("unused")
33 WSSEParser wp = new WSSEParser();
35 // TODO: test the rest of this class
36 // final BasicCred bc = new BasicCred() {
37 // private String user;
38 // private byte[] password;
40 // public void setUser(String user) { this.user = user; }
41 // public void setCred(byte[] passwd) { this.password = passwd; }
42 // public String getUser() { return user; }
43 // public byte[] getCred() { return password; }
46 // FileInputStream fis;
47 // fis = new FileInputStream("test/example.xml");
48 // BufferedServletInputStream is = new BufferedServletInputStream(fis);
52 // assertNull(wp.parse(bc, is));
55 // assertEquals(814,is.buffered());
57 // String password = new String(bc.getCred());
58 // System.out.println("CadiWrap credentials are: " + bc.getUser() + ", " + password);
59 // assertEquals("some_user", bc.getUser());
60 // assertEquals("some_password", password);
67 // fis = new FileInputStream("test/CBUSevent.xml");
68 // is = new BufferedServletInputStream(fis);
72 // assertNull(wp.parse(bc, is));
75 // assertEquals(667,is.buffered());
77 // String password = new String(bc.getCred());
78 // System.out.println("CadiWrap credentials are: " + bc.getUser() + ", " + password);
79 // assertEquals("none", bc.getUser());
80 // assertEquals("none", password);
87 // fis = new FileInputStream("test/example.xml");
91 // XMLStreamException ex = wp.parse(bc, fis);
93 // assertNull(bc.getUser());
94 // assertNull(bc.getCred());
97 // fis = new FileInputStream("test/exampleNoSecurity.xml");
101 // assertNull(wp.parse(bc, fis));
102 // assertNull(bc.getUser());
103 // assertNull(bc.getCred());
108 // fis = new FileInputStream("test/exampleBad1.xml");
112 // assertNull(wp.parse(bc, fis));
113 // assertNull(bc.getUser());
114 // assertNull(bc.getCred());
119 // XMLStreamException e = wp.parse(bc, new ByteArrayInputStream("Not XML".getBytes())); // empty
122 // e = wp.parse(bc, new ByteArrayInputStream("".getBytes())); // empty
126 // long start, count = 0L;
128 // File f = new File("test/CBUSevent.xml");
129 // fis = new FileInputStream(f);
130 // is = new BufferedServletInputStream(fis);
133 // while (is.read()>=0);
138 // for (int i=0;i<iter;++i) {
139 // start = System.nanoTime();
142 // assertNull(wp.parse(bc, is));
144 // count += System.nanoTime()-start;
147 // float ms = count/1000000f;
148 // System.out.println("Executed " + iter + " WSSE reads from Memory Stream in " + ms + "ms. " + ms/iter + "ms per trans");
150 // // SPECIFIC ISSUES
152 // fis = new FileInputStream("test/error2013_04_23.xml");
156 // assertNull(wp.parse(bc, fis));
157 // assertNull(bc.getUser());
158 // assertNull(bc.getCred());