Package javax.servlet

Examples of javax.servlet.ServletInputStream


      when(mockHttpServletRequest.getMethod()).thenReturn(HttpMethods.POST);
      when(mockHttpServletRequest.getPathInfo()).thenReturn(requestPathInfo);
      when(mockStubbedDataManager.findStubResponseFor(Mockito.any(StubRequest.class))).thenReturn(mockStubResponse);
      when(mockStubResponse.getStubResponseType()).thenReturn(StubResponseTypes.NOTFOUND);
      final InputStream inputStream = new ByteArrayInputStream(postData.getBytes());
      Mockito.when(mockHttpServletRequest.getInputStream()).thenReturn(new ServletInputStream() {
         @Override
         public int read() throws IOException {
            return inputStream.read();
         }
      });
View Full Code Here


      when(mockStubbedDataManager.findStubResponseFor(Mockito.any(StubRequest.class))).thenReturn(mockStubResponse);
      when(mockStubResponse.getStubResponseType()).thenReturn(StubResponseTypes.OK_200);
      when(mockStubResponse.getStatus()).thenReturn("200");

      final InputStream inputStream = new ByteArrayInputStream("".getBytes());
      Mockito.when(mockHttpServletRequest.getInputStream()).thenReturn(new ServletInputStream() {
         @Override
         public int read() throws IOException {
            return inputStream.read();
         }
      });
View Full Code Here

      when(mockStubResponse.getStubResponseType()).thenReturn(StubResponseTypes.OK_200);
      when(mockStubResponse.getResponseBodyAsBytes()).thenReturn(null);
      when(mockStubbedDataManager.findStubResponseFor(Mockito.any(StubRequest.class))).thenReturn(mockStubResponse);

      final InputStream inputStream = new ByteArrayInputStream(postData.getBytes());
      Mockito.when(mockHttpServletRequest.getInputStream()).thenReturn(new ServletInputStream() {
         @Override
         public int read() throws IOException {
            return inputStream.read();
         }
      });
View Full Code Here

            base_request.setHandled( true );

            File file = new File( resourceBase, URLDecoder.decode( request.getPathInfo() ) );
            file.getParentFile().mkdirs();
            FileOutputStream out = new FileOutputStream( file );
            ServletInputStream in = request.getInputStream();
            try
            {
                IOUtil.copy( in, out );
            }
            finally
            {
                in.close();
                out.close();
            }
            System.out.println( "put file " + request.getPathInfo() );
            putCallNumber++;
            DeployedResource deployedResource = new DeployedResource();
View Full Code Here

     */
    protected void uploadWar(HttpServletRequest request, File war)
        throws IOException {

        war.delete();
        ServletInputStream istream = null;
        BufferedOutputStream ostream = null;
        try {
            istream = request.getInputStream();
            ostream =
                new BufferedOutputStream(new FileOutputStream(war), 1024);
            byte buffer[] = new byte[1024];
            while (true) {
                int n = istream.read(buffer);
                if (n < 0) {
                    break;
                }
                ostream.write(buffer, 0, n);
            }
            ostream.flush();
            ostream.close();
            ostream = null;
            istream.close();
            istream = null;
        } catch (IOException e) {
            war.delete();
            throw e;
        } finally {
            if (ostream != null) {
                try {
                    ostream.close();
                } catch (Throwable t) {
                    ;
                }
                ostream = null;
            }
            if (istream != null) {
                try {
                    istream.close();
                } catch (Throwable t) {
                    ;
                }
                istream = null;
            }
View Full Code Here

      byte[] byteBuffer = new byte[bufferSize];
      ByteArrayOutputStream byteOutputStream = new ByteArrayOutputStream();

      int pointer = 0;
      int contentLength = request.getContentLength();
      ServletInputStream inputStream = request.getInputStream();
      int amtRead = inputStream.read(byteBuffer);

      while (amtRead > 0)
      {
         byteOutputStream.write(byteBuffer, pointer, amtRead);
         //pointer+=amtRead;
         if (amtRead < bufferSize && byteOutputStream.size() >= contentLength)
         {
            //done reading, so process
            break;
         }
         amtRead = inputStream.read(byteBuffer);
      }
      byteOutputStream.flush();
      byte[] totalByteArray = byteOutputStream.toByteArray();

      byte[] out = servletInvoker.processRequest(request, totalByteArray, response);
View Full Code Here

public class ServletRequest implements HttpServletRequest
{
    private ServletInputStream input;

    public ServletRequest(final InputStream stream) {
        this.input = new ServletInputStream() {
            public int read() throws IOException {
                return stream.read();
            }
        };
    }
View Full Code Here

      try
      {
         Object invocationResponse = null;

         ServletInputStream inputStream = request.getInputStream();
         UnMarshaller unmarshaller = MarshalFactory.getUnMarshaller(HTTPUnMarshaller.DATATYPE, getSerializationType());
         Object obj = null;
         if (unmarshaller instanceof VersionedUnMarshaller)
            obj = ((VersionedUnMarshaller)unmarshaller).read(inputStream, metadata, getVersion());
         else
            obj = unmarshaller.read(inputStream, metadata);
         inputStream.close();

         InvocationRequest invocationRequest = null;

         if(obj instanceof InvocationRequest)
         {
View Full Code Here

      try
      {
         Object responseObject = null;

         ServletInputStream inputStream = request.getInputStream();
         UnMarshaller unmarshaller = getUnMarshaller();
         Object obj = null;
         if (unmarshaller instanceof VersionedUnMarshaller)
            obj = ((VersionedUnMarshaller)unmarshaller).read(new ByteArrayInputStream(requestByte), metadata, getVersion());
         else
            obj = unmarshaller.read(new ByteArrayInputStream(requestByte), metadata);
         inputStream.close();

         boolean isError = false;
         InvocationRequest invocationRequest = null;

         if(obj instanceof InvocationRequest)
View Full Code Here

        }
    }

    private Properties getProperties(HttpServletRequest request) throws IOException {
        Properties props = new Properties();
        ServletInputStream xmlStream = request == null ? null : request.getInputStream();
        if (xmlStream != null) {
            if (xmlStream.markSupported()) {
                xmlStream.mark(XML_DEBUG_LEN); // mark up to debug len
            }
            props.load(xmlStream);
        }
        return props;
    }
View Full Code Here

TOP

Related Classes of javax.servlet.ServletInputStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.