Package java.io

Examples of java.io.ByteArrayOutputStream.reset()


    public void testSerializeToBytes() throws Exception {
        OMSourcedElement element = createSourcedElement("test", UTF8);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        element.serialize(baos);
        byte[] actual = baos.toByteArray();
        baos.reset();
        // We validate the result by creating an equivalent OMElement
        // and calling serialize on it. The two results must be identical.
        element.cloneOMElement().serialize(baos);
        byte[] expected = baos.toByteArray();
        assertTrue(Arrays.equals(expected, actual));
View Full Code Here


                    }
                }
                if (log.isDebugEnabled()){
                    log.debug("Client Request Line: " + line.toString());
                }
                line.reset();
            } else if (!inHeaders) {
                readLength++;
            }
        }
        // Keep the raw post data
View Full Code Here

  @Test
  public void testDBObject() throws Exception {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    for (DBObject dbo : getObjectsToSerialize()) {
      baos.reset();
      ObjectOutputStream oos = new ObjectOutputStream(baos);
      oos.writeObject(dbo);

      ObjectInputStream oin = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
      DBObject dbo2 = (DBObject) oin.readObject();
View Full Code Here

            else if (statement.startsWith("assume "))
            {
                assertTrue(result.contains("successfully."));
            }

            outStream.reset(); // reset stream so we have only output from next statement all the time
            errStream.reset(); // no errors to the end user.
        }
    }

    @Test
View Full Code Here


        assertLogContains(output.toString(), "//wsa:Action", base + "addNumbersRequest");
        assertLogContains(input.toString(), "//wsa:Action", base + "addNumbersResponse");

        output.reset();
        input.reset();
       
        ((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
            "http://localhost:" + PORT + "/jaxws/add-providernows");
        assertEquals(3, port.addNumbers(1, 2));
View Full Code Here

       
        assertLogContains(output.toString(), "//wsa:Action", base + "addNumbersRequest");
        assertLogContains(input.toString(), "//wsa:Action", base + "addNumbersResponse");
       

        output.reset();
        input.reset();
       
        disp = service.createDispatch(AddNumbersService.AddNumbersPort,
                                      Source.class, Mode.PAYLOAD);
View Full Code Here

            assertResult(result);
        } else if (scenario == Scenario.SER_SER) {
            root.serialize(baos);
            String result = baos.toString("UTF-8");
            assertResult(result);
            baos.reset();
            root.serialize(baos);
            result = baos.toString("UTF-8");
            assertResult(result);
        } else if (scenario == Scenario.SAC) {
            root.serializeAndConsume(baos);
View Full Code Here

            assertResult(result);
        } else if (scenario == Scenario.SER_SAC) {
            root.serialize(baos);
            String result = baos.toString("UTF-8");
            assertResult(result);
            baos.reset();
            root.serializeAndConsume(baos);
            result = baos.toString("UTF-8");
            assertResult(result);
        } else if (scenario == Scenario.SAC_SAC) {
            root.serializeAndConsume(baos);
View Full Code Here

            assertResult(result);
        } else if (scenario == Scenario.SAC_SAC) {
            root.serializeAndConsume(baos);
            String result = baos.toString("UTF-8");
            assertResult(result);
            baos.reset();
            root.serializeAndConsume(baos);
            // This second serializeAndConsume is expected to throw an exception.
        }
       
        return peds.numReads();
View Full Code Here

            error = StringUtils.stringifyException(e);
          }
          UserGroupInformation.setCurrentUGI(previous);
          CurCall.set(null);

          buf.reset();
          DataOutputStream out = new DataOutputStream(buf);
          out.writeInt(call.id);                // write call id
          out.writeBoolean(error != null);      // write error flag

          if (error == null) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.