Search in sources :

Example 11 with NullOutputStream

use of org.apache.commons.io.output.NullOutputStream in project webservices-axiom by apache.

the class OMOutputTest method testComplete.

public void testComplete() throws Exception {
    OMOutputFormat mtomOutputFormat = new OMOutputFormat();
    mtomOutputFormat.setDoOptimize(true);
    OMOutputFormat baseOutputFormat = new OMOutputFormat();
    baseOutputFormat.setDoOptimize(false);
    envelope.serializeAndConsume(new NullOutputStream(), baseOutputFormat);
    envelope.serializeAndConsume(new NullOutputStream(), mtomOutputFormat);
}
Also used : OMOutputFormat(org.apache.axiom.om.OMOutputFormat) NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Example 12 with NullOutputStream

use of org.apache.commons.io.output.NullOutputStream in project webservices-axiom by apache.

the class AttachmentsTest method testReadOnceOnBufferedPart.

/**
     * Tests that after consuming the input stream returned by {@link DataHandlerExt#readOnce()} for
     * an attachment that has been buffered on disk, the temporary file for that attachment is
     * deleted.
     * 
     * @throws Exception
     */
public void testReadOnceOnBufferedPart() throws Exception {
    InputStream in = getTestResource("mtom/msg-soap-wls81.txt");
    MyLifecycleManager manager = new MyLifecycleManager();
    Attachments attachments = new Attachments(manager, in, "multipart/related;type=\"text/xml\";boundary=\"----=_Part_0_3437046.1188904239130\";start=__WLS__1188904239161__SOAP__", true, getAttachmentsDir(), "1024");
    // Read the attachment once to make sure it is buffered
    DataHandler dh = attachments.getDataHandler("__WLS__1188904239162__SOAP__");
    InputStream content = dh.getInputStream();
    IOUtils.copy(content, new NullOutputStream());
    content.close();
    assertEquals(1, manager.getFileCount());
    // Now consume the content of the attachment
    content = ((DataHandlerExt) dh).readOnce();
    IOUtils.copy(content, new NullOutputStream());
    content.close();
    // The temporary file should have been deleted
    assertEquals(0, manager.getFileCount());
    in.close();
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) PipedInputStream(java.io.PipedInputStream) ExceptionInputStream(org.apache.axiom.testutils.io.ExceptionInputStream) InputStream(java.io.InputStream) DataHandler(javax.activation.DataHandler) NullOutputStream(org.apache.commons.io.output.NullOutputStream)

Example 13 with NullOutputStream

use of org.apache.commons.io.output.NullOutputStream in project webservices-axiom by apache.

the class SerializerTest method testUnmappableCharacterInProcessingInstruction.

@Test(expected = StreamException.class)
public void testUnmappableCharacterInProcessingInstruction() throws Exception {
    Serializer handler = new Serializer(new NullOutputStream(), "ascii");
    handler.startFragment();
    handler.startProcessingInstruction("test");
    handler.processCharacterData("c'est la fête!", false);
    handler.endProcessingInstruction();
    handler.completed();
}
Also used : NullOutputStream(org.apache.commons.io.output.NullOutputStream) Test(org.junit.Test)

Example 14 with NullOutputStream

use of org.apache.commons.io.output.NullOutputStream in project webservices-axiom by apache.

the class SerializerTest method testUnmappableCharacterInCDATASection.

@Test(expected = StreamException.class)
public void testUnmappableCharacterInCDATASection() throws Exception {
    Serializer handler = new Serializer(new NullOutputStream(), "ascii");
    handler.startFragment();
    handler.startCDATASection();
    handler.processCharacterData("c'est la fête!", false);
    handler.endCDATASection();
    handler.completed();
}
Also used : NullOutputStream(org.apache.commons.io.output.NullOutputStream) Test(org.junit.Test)

Example 15 with NullOutputStream

use of org.apache.commons.io.output.NullOutputStream in project webservices-axiom by apache.

the class SerializerTest method testUnmappableCharacterInName.

@Test(expected = StreamException.class)
public void testUnmappableCharacterInName() throws Exception {
    Serializer handler = new Serializer(new NullOutputStream(), "iso-8859-15");
    handler.startFragment();
    handler.startElement("", "Ͱ", "");
    handler.attributesCompleted();
    handler.endElement();
    handler.completed();
}
Also used : NullOutputStream(org.apache.commons.io.output.NullOutputStream) Test(org.junit.Test)

Aggregations

NullOutputStream (org.apache.commons.io.output.NullOutputStream)30 InputStream (java.io.InputStream)7 Test (org.junit.Test)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 OutputStream (java.io.OutputStream)5 DigestOutputStream (java.security.DigestOutputStream)5 MessageDigest (java.security.MessageDigest)5 FileInputStream (java.io.FileInputStream)3 PrintStream (java.io.PrintStream)3 DataHandler (javax.activation.DataHandler)3 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 FileReader (java.io.FileReader)2 IOException (java.io.IOException)2 PipedInputStream (java.io.PipedInputStream)2 ArrayList (java.util.ArrayList)2 Node (javax.jcr.Node)2 XMLStreamWriter (javax.xml.stream.XMLStreamWriter)2 OMFactory (org.apache.axiom.om.OMFactory)2 ExceptionInputStream (org.apache.axiom.testutils.io.ExceptionInputStream)2