use of org.apache.commons.io.output.NullOutputStream in project webservices-axiom by apache.
the class AttachmentsTest method testPurgeDataSource.
public void testPurgeDataSource() 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__");
assertTrue(dh instanceof DataHandlerExt);
InputStream content = dh.getInputStream();
IOUtils.copy(content, new NullOutputStream());
content.close();
assertEquals(1, manager.getFileCount());
((DataHandlerExt) dh).purgeDataSource();
assertEquals(0, manager.getFileCount());
in.close();
}
use of org.apache.commons.io.output.NullOutputStream in project webservices-axiom by apache.
the class TestBase64StreamingWithSerialize method runTest.
@Override
protected void runTest() throws Throwable {
OMFactory factory = metaFactory.getOMFactory();
OMElement elem = factory.createOMElement("test", null);
// Create a data source that would eat up all memory when loaded. If the test
// doesn't fail with an OutOfMemoryError, we know that the OMText implementation
// supports streaming.
DataSource ds = new TestDataSource('A', Runtime.getRuntime().maxMemory());
OMText text = factory.createOMText(new DataHandler(ds), false);
elem.addChild(text);
elem.serialize(new NullOutputStream());
}
use of org.apache.commons.io.output.NullOutputStream in project webservices-axiom by apache.
the class AxiomTestCase method assertConsumed.
protected void assertConsumed(OMContainer container) {
assertFalse("Expected the node to be incomplete", container.isComplete());
boolean isConsumed;
try {
container.serialize(new NullOutputStream());
isConsumed = false;
} catch (Exception ex) {
isConsumed = true;
}
assertTrue(isConsumed);
}
use of org.apache.commons.io.output.NullOutputStream in project benchmarx by eMoflon.
the class MediniQVTFamiliesToPersonsConfig method launch.
/**
* launch the transformation in the QVT execution engine
*
* @param direction : the desired execution direction
*/
public void launch(String direction) {
PrintStream ps = System.out;
PrintStream ps_err = System.err;
// Load the QVT relations
try {
System.setOut(new PrintStream(new NullOutputStream()));
System.setErr(new PrintStream(new NullOutputStream()));
qvtRuleSet = new FileReader(basePath + RULESET);
this.transform(qvtRuleSet, transformation, direction);
} catch (FileNotFoundException fileNotFoundException) {
fileNotFoundException.printStackTrace();
return;
} catch (Throwable throwable) {
throwable.printStackTrace();
} finally {
System.setOut(ps);
System.setErr(ps_err);
}
}
use of org.apache.commons.io.output.NullOutputStream in project benchmarx by eMoflon.
the class MediniQVTFamiliesToPersons method launch.
/**
* launch the transformation in the QVT execution engine
*
* @param direction : the desired execution direction
*/
public void launch(String direction) {
PrintStream ps = System.out;
PrintStream ps_err = System.err;
// Load the QVT relations
try {
System.setOut(new PrintStream(new NullOutputStream()));
System.setErr(new PrintStream(new NullOutputStream()));
qvtRuleSet = new FileReader(basePath + RULESET);
this.transform(qvtRuleSet, transformation, direction);
} catch (FileNotFoundException fileNotFoundException) {
fileNotFoundException.printStackTrace();
return;
} catch (Throwable throwable) {
throwable.printStackTrace();
System.out.println(throwable.getMessage());
} finally {
System.setOut(ps);
System.setErr(ps_err);
}
}
Aggregations