1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.openehealth.ipf.commons.ihe.ws.utils;
17
18 import org.junit.Assert;
19
20 import javax.activation.DataSource;
21 import java.io.InputStream;
22 import java.io.IOException;
23 import java.io.OutputStream;
24
25
26
27
28
29 public class LargeDataSource implements DataSource {
30
31
32 public static final int STREAM_SIZE = 70000;
33
34 @Override
35 public InputStream getInputStream() throws IOException {
36 return new InputStream() {
37 private int idx;
38
39 @Override
40 public int read() throws IOException {
41 if (idx >= STREAM_SIZE) {
42 return -1;
43 }
44 ++idx;
45 return 65;
46 }
47
48 @Override
49 public void close() throws IOException {
50 Assert.assertEquals(STREAM_SIZE, idx);
51 super.close();
52 }
53 };
54 }
55
56 @Override
57 public OutputStream getOutputStream() throws IOException {
58 throw new UnsupportedOperationException();
59 }
60
61 @Override
62 public String getContentType() {
63 return "test/plain";
64 }
65
66 @Override
67 public String getName() {
68 return "dummy";
69 }
70 }