1
2
3
4
5
6
7
8
9
10
11
12
13 package com.eviware.soapui.impl.wsdl.submit.transports.http;
14
15 import java.io.ByteArrayInputStream;
16 import java.io.IOException;
17 import java.io.InputStream;
18 import java.io.OutputStream;
19
20 import javax.activation.DataSource;
21 import javax.servlet.http.HttpServletRequest;
22
23 import com.eviware.soapui.support.Tools;
24
25 public class MockRequestDataSource implements DataSource
26 {
27 private byte[] data;
28 private String contentType;
29 private String name;
30
31 public MockRequestDataSource(HttpServletRequest request)
32 {
33 try
34 {
35 data = Tools.readAll( request.getInputStream(), 0 ).toByteArray();
36 contentType = request.getContentType();
37 name = "Request for " + request.getPathInfo();
38 }
39 catch (Exception e)
40 {
41 e.printStackTrace();
42 }
43 }
44
45 public String getContentType()
46 {
47 return contentType;
48 }
49
50 public InputStream getInputStream() throws IOException
51 {
52 return new ByteArrayInputStream( data );
53 }
54
55 public String getName()
56 {
57 return name;
58 }
59
60 public OutputStream getOutputStream() throws IOException
61 {
62 return null;
63 }
64 }