Package javax.servlet

Examples of javax.servlet.ServletInputStream


                "No deploy.mode found in /api/admin/version");
    }

    public void testValidate() {
        TestContext context = newContext();
        ServletInputStream stream = context.getServletInputStream(getClass().
                getResourceAsStream(TestContext.SAMPLE_PROCESS_XML));

        ClientResponse clientResponse = context.service
                .path("api/entities/validate/process")
                .header("Cookie", context.getAuthenticationToken())
View Full Code Here


    public ServletInputStream getServletInputStream(String fileName) throws IOException {
        return getServletInputStream(new FileInputStream(fileName));
    }

    public ServletInputStream getServletInputStream(final InputStream stream) {
        return new ServletInputStream() {

            @Override
            public int read() throws IOException {
                return stream.read();
            }
View Full Code Here

    }

    public ClientResponse submitAndSchedule(String template, Map<String, String> overlay, EntityType entityType)
        throws Exception {
        String tmpFile = overlayParametersOverTemplate(template, overlay);
        ServletInputStream rawlogStream = getServletInputStream(tmpFile);

        return this.service.path("api/entities/submitAndSchedule/" + entityType.name().toLowerCase())
                .header("Cookie", getAuthenticationToken())
                .accept(MediaType.TEXT_XML)
                .type(MediaType.TEXT_XML)
View Full Code Here

        return submitFileToFalcon(entityType, tmpFile);
    }

    public ClientResponse submitFileToFalcon(EntityType entityType, String tmpFile) throws IOException {

        ServletInputStream rawlogStream = getServletInputStream(tmpFile);

        return this.service.path("api/entities/submit/" + entityType.name().toLowerCase())
                .header("Cookie", getAuthenticationToken())
                .accept(MediaType.TEXT_XML)
                .type(MediaType.TEXT_XML)
View Full Code Here

            EasyMock.expect(registry.getDestinations()).andReturn(destinations);
        }
    }

    private void setUpMessage() throws Exception {
        ServletInputStream sis = control.createMock(ServletInputStream.class);
        EasyMock.expect(request.getInputStream()).andReturn(sis);
        message.setContent(EasyMock.eq(InputStream.class), EasyMock.same(sis));
        EasyMock.expectLastCall();
        setUpProperty(AbstractHTTPDestination.HTTP_REQUEST, request);
        setUpProperty(AbstractHTTPDestination.HTTP_RESPONSE, response);
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

     */
    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

      @Override
      public ServletInputStream getInputStream() throws IOException {
        final ByteArrayInputStream bais = new ByteArrayInputStream(
            EXAMPLE_NEW_ORDER_NOTIFICATION.getBytes("utf-8"));
        return new ServletInputStream() {
          @Override
          public int read() {
            return bais.read();
          }
        };
View Full Code Here

    @Override
    public IoFuture<byte[]> readRequestData() {
        final ByteArrayOutputStream data = new ByteArrayOutputStream();
        try {
            final ServletInputStream in = request.getInputStream();
            byte[] buf = new byte[1024];
            int r;
            while ((r = in.read(buf)) != -1) {
                data.write(buf, 0, r);
            }
            return new FinishedIoFuture<byte[]>(data.toByteArray());
        } catch (IOException e) {
            final ConcreteIoFuture<byte[]> ioFuture = new ConcreteIoFuture<>();
View Full Code Here

      byte[] request = buildRequest();

      // Ok lets make an input stream to return
      final ByteArrayInputStream bais = new ByteArrayInputStream(request);

      return new ServletInputStream()
      {
        public int read()
        {
          return bais.read();
        }
      };
    }
    else
    {
      return new ServletInputStream()
      {
        public int read()
        {
          return -1;
        }
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.