1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.springframework.ws.transport;
18
19 import java.io.IOException;
20 import java.io.InputStream;
21 import java.util.Arrays;
22 import java.util.Iterator;
23 import java.util.Properties;
24
25 import org.springframework.util.Assert;
26 import org.springframework.util.StringUtils;
27
28 public class MockTransportInputStream extends TransportInputStream {
29
30 private Properties headers;
31
32 private InputStream inputStream;
33
34 public MockTransportInputStream(InputStream inputStream, Properties headers) {
35 Assert.notNull(inputStream, "inputStream must not be null");
36 Assert.notNull(headers, "headers must not be null");
37 this.inputStream = inputStream;
38 this.headers = headers;
39 }
40
41 public MockTransportInputStream(InputStream inputStream) {
42 Assert.notNull(inputStream, "inputStream must not be null");
43 this.inputStream = inputStream;
44 headers = new Properties();
45 }
46
47 protected InputStream createInputStream() throws IOException {
48 return inputStream;
49 }
50
51 public Iterator getHeaderNames() throws IOException {
52 return headers.keySet().iterator();
53 }
54
55 public Iterator getHeaders(String name) throws IOException {
56 String[] values = StringUtils.delimitedListToStringArray(headers.getProperty(name), ", ");
57 return Arrays.asList(values).iterator();
58 }
59 }