List of usage examples for javax.servlet ServletInputStream ServletInputStream
protected ServletInputStream()
From source file:org.deegree.securityproxy.filter.RequestBodyWrapperTest.java
private ServletInputStream createServletStream() { final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(TEST_CONTENT.getBytes()); return new ServletInputStream() { @Override/*from w w w . j a v a2 s . com*/ public int read() throws IOException { return byteArrayInputStream.read(); } }; }
From source file:org.deegree.securityproxy.request.HttpServletRequestBodyWrapper.java
@Override public ServletInputStream getInputStream() throws IOException { return new ServletInputStream() { @Override/*from w w w. ja va 2 s . c o m*/ public int read() throws IOException { return wrappedInputStream.read(); } }; }
From source file:org.directwebremoting.util.FakeHttpServletRequest.java
public ServletInputStream getInputStream() throws IOException { return new ServletInputStream() { private final ByteArrayInputStream proxy = new ByteArrayInputStream(content); /* (non-Javadoc) * @see java.io.InputStream#read() *//*www. j av a 2 s . c o m*/ @Override public int read() throws IOException { return proxy.read(); } /* (non-Javadoc) * @see java.io.InputStream#available() */ @Override public int available() throws IOException { return proxy.available(); } /* (non-Javadoc) * @see java.io.InputStream#mark(int) */ @Override public synchronized void mark(int readlimit) { proxy.mark(readlimit); } /* (non-Javadoc) * @see java.io.InputStream#markSupported() */ @Override public boolean markSupported() { return proxy.markSupported(); } /* (non-Javadoc) * @see java.io.InputStream#read(byte[], int, int) */ @Override public int read(byte[] b, int off, int len) throws IOException { return proxy.read(b, off, len); } /* (non-Javadoc) * @see java.io.InputStream#close() */ @Override public void close() throws IOException { proxy.close(); } /* (non-Javadoc) * @see java.io.InputStream#read(byte[]) */ @Override public int read(byte[] b) throws IOException { return proxy.read(b); } /* (non-Javadoc) * @see java.io.InputStream#reset() */ @Override public synchronized void reset() throws IOException { proxy.reset(); } /* (non-Javadoc) * @see java.io.InputStream#skip(long) */ @Override public long skip(long n) throws IOException { return proxy.skip(n); } }; }
From source file:org.ebayopensource.turmeric.runtime.tests.common.jetty.DebugHttpServletRequest.java
@Override public ServletInputStream getInputStream() throws IOException { LOG.info("getInputStream()"); if (bodyInputStream != null) { return bodyInputStream; }//from w w w .j ava 2 s . c o m if (bodyAsReader) { throw new IOException("Body content already opened as BufferedReader via .getReader()"); } bodyAsInputStream = true; bodyInputStream = new ServletInputStream() { private InputStream in = new ByteArrayInputStream(requestBody); @Override public int read() throws IOException { return in.read(); } }; return bodyInputStream; }
From source file:org.iqvis.nvolv3.request.filter.RequestWrapper.java
@Override public ServletInputStream getInputStream() throws IOException { return new ServletInputStream() { private TeeInputStream tee = new TeeInputStream(RequestWrapper.super.getInputStream(), bos); @Override//from w w w .j a v a 2s.c o m public int read() throws IOException { return tee.read(); } @Override public boolean isFinished() { // TODO Auto-generated method stub return false; } @Override public boolean isReady() { // TODO Auto-generated method stub return false; } @Override public void setReadListener(ReadListener arg0) { // TODO Auto-generated method stub } }; }
From source file:org.kohsuke.stapler.RequestImplTest.java
@Test public void test_mutipart_formdata() throws IOException, ServletException { final Stapler stapler = new Stapler(); final byte[] buf = generateMultipartData(); final ByteArrayInputStream is = new ByteArrayInputStream(buf); final MockRequest mockRequest = new MockRequest() { @Override/* w ww .j av a 2 s .co m*/ public String getContentType() { return "multipart/form-data; boundary=mpboundary"; } @Override public String getCharacterEncoding() { return "UTF-8"; } @Override public int getContentLength() { return buf.length; } @Override public Enumeration getParameterNames() { return Collections.enumeration(Arrays.asList("p1")); } @Override public ServletInputStream getInputStream() throws IOException { return new ServletInputStream() { @Override public int read() throws IOException { return is.read(); } @Override public int read(byte[] b) throws IOException { return is.read(b); } @Override public int read(byte[] b, int off, int len) throws IOException { return is.read(b, off, len); } }; } }; RequestImpl request = new RequestImpl(stapler, mockRequest, Collections.<AncestorImpl>emptyList(), null); // Check that we can get the Form Fields. See https://github.com/stapler/stapler/issues/52 Assert.assertEquals("text1_val", request.getParameter("text1")); Assert.assertEquals("text2_val", request.getParameter("text2")); // Check that we can get the file FileItem fileItem = request.getFileItem("pomFile"); Assert.assertNotNull(fileItem); // Check getParameterValues Assert.assertEquals("text1_val", request.getParameterValues("text1")[0]); // Check getParameterNames Assert.assertTrue(Collections.list(request.getParameterNames()).contains("p1")); Assert.assertTrue(Collections.list(request.getParameterNames()).contains("text1")); // Check getParameterMap Assert.assertTrue(request.getParameterMap().containsKey("text1")); }
From source file:org.mule.transport.http.servlet.MuleHttpServletRequest.java
public ServletInputStream getInputStream() throws IOException { return new ServletInputStream() { @Override/*from w ww . j av a 2 s.c om*/ public int read() throws IOException { return 0; } }; }
From source file:org.opencastproject.ingest.endpoint.IngestRestServiceTest.java
private ServletInputStream setupAddZippedMediaPackageServletInputStream() { ServletInputStream servletInputStream = new ServletInputStream() { @Override// w ww . ja v a2 s . c om public int read() throws IOException { return 0; } }; return servletInputStream; }
From source file:org.ovirt.vdsmfake.servlet.CustomHttpServletRequestWrapper.java
@Override public ServletInputStream getInputStream() throws IOException { final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(inputStreamData); ServletInputStream inputStream = new ServletInputStream() { @Override/* w w w .ja v a2 s . com*/ public int read() throws IOException { return byteArrayInputStream.read(); } }; return inputStream; }
From source file:org.seasar.cubby.controller.impl.MultipartRequestParserImplMultipartRequestTest.java
@Before @SuppressWarnings("unchecked") public void setupRequest() throws Exception { request = createMock(HttpServletRequest.class); expect(request.getCharacterEncoding()).andStubReturn("UTF-8"); expect(request.getAttribute(String.class.cast(anyObject()))).andStubAnswer(new IAnswer<Object>() { public Object answer() throws Throwable { return attributes.get(getCurrentArguments()[0]); }/* w w w .j a v a2 s. c om*/ }); request.setAttribute(String.class.cast(anyObject()), anyObject()); expectLastCall().andStubAnswer(new IAnswer<Object>() { public Object answer() throws Throwable { attributes.put(String.class.cast(getCurrentArguments()[0]), getCurrentArguments()[1]); return null; } }); expect(request.getAttributeNames()).andStubAnswer(new IAnswer<Enumeration>() { public Enumeration answer() throws Throwable { return attributes.keys(); } }); expect(request.getParameterMap()).andStubReturn(attributes); expect(request.getContentType()).andStubAnswer(new IAnswer<String>() { public String answer() throws Throwable { return entity.getContentType(); } }); expect(request.getContentLength()).andStubAnswer(new IAnswer<Integer>() { public Integer answer() throws Throwable { return (int) entity.getContentLength(); } }); expect(request.getInputStream()).andStubReturn(new ServletInputStream() { @Override public int read() throws IOException { return input.read(); } }); replay(request); final FileUpload fileUpload = new ServletFileUpload(); fileUpload.setFileItemFactory(new DiskFileItemFactory()); final RequestContext requestContext = new ServletRequestContext(request); BinderPlugin binderPlugin = new BinderPlugin(); binderPlugin.bind(ContainerProvider.class).toInstance(new MockContainerProvider(new Container() { public <T> T lookup(final Class<T> type) { if (FileUpload.class.equals(type)) { return type.cast(fileUpload); } if (RequestContext.class.equals(type)) { return type.cast(requestContext); } return null; } })); pluginRegistry.register(binderPlugin); }