Package org.apache.axiom.attachments

Examples of org.apache.axiom.attachments.ByteArrayDataSource


        Base64Binary base64Binary = new Base64Binary();
        testExtension.setTestExtension(base64Binary);

        String testString = "test base 64 eleemnt";
        DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(testString.getBytes()));
        base64Binary.setBase64Binary(dataHandler);

        ContentType_type0 contentType_type0 = new ContentType_type0();
        contentType_type0.setContentType_type0("test string");
        base64Binary.setContentType(contentType_type0);
View Full Code Here


        Base64Binary base64Binary = new Base64Binary();
        testBase64Binary.setTestBase64Binary(base64Binary);

        String testString = "new test string";

        DataHandler dataHandler = new DataHandler(new ByteArrayDataSource(testString.getBytes()));
        base64Binary.setBase64Binary(dataHandler);
        ContentType_type0 contentType_type0 = new ContentType_type0();
        contentType_type0.setContentType_type0("test content type");
        base64Binary.setContentType(contentType_type0);
View Full Code Here

     */
    public void testretByteArray() throws java.lang.Exception {


        byte[] input = new byte[]{(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF};
        DataHandler ret = stub.retByteArray(new DataHandler(new ByteArrayDataSource(input)));
        byte[] bytes = IOUtils.getStreamAsByteArray(ret.getInputStream());
        assertTrue(Arrays.equals(bytes, input));
    }
View Full Code Here

        return new HexBinary(s);
    }

    public static javax.activation.DataHandler convertToBase64Binary(String s) {
        // reusing the byteArrayDataSource from the Axiom classes
        ByteArrayDataSource byteArrayDataSource = new ByteArrayDataSource(
                Base64.decode(s)
        );
        return new DataHandler(byteArrayDataSource);
    }
View Full Code Here

    public void testretByteArray() throws java.lang.Exception {


        byte[] input = new byte[]{(byte) 0xDE, (byte) 0xAD, (byte) 0xBE, (byte) 0xEF};
        ComplexDataTypesDocLitBareStub.RetByteArray req = new ComplexDataTypesDocLitBareStub.RetByteArray();
        req.setInByteArray(new DataHandler(new ByteArrayDataSource(input)));
        DataHandler ret = stub.retByteArray(req).get_return();
        byte[] bytes = IOUtils.getStreamAsByteArray(ret.getInputStream());
        assertTrue(Arrays.equals(bytes, input));
    }
View Full Code Here

                Base64.encode(textTobeSent.getBytes()) +
                "</ns2:QualifiedElement></ns1:testElementText>";
        try {
            ArrayList properties = new ArrayList();
            properties.add(new QName("http://testQElementText.org", "QualifiedElement", "ns2"));
            properties.add(new DataHandler(new ByteArrayDataSource(textTobeSent.getBytes())));

            XMLStreamReader pullParser = new ADBXMLStreamReaderImpl(
                    new QName("http://testElementText.org", "testElementText", "ns1"),
                    properties.toArray(),
                    null);
View Full Code Here

public class TextFileDataSourceTest extends TestCase {

    public void testWithXMLChars() throws Exception {
        String testString = "Test string with ampersand (&)";
        OMDataSource dataSource
            = new TextFileDataSource(new ByteArrayDataSource(testString.getBytes("UTF-8")));
        OMFactory omFactory = OMAbstractFactory.getOMFactory();
        OMSourcedElementImpl element
            = new OMSourcedElementImpl(BaseConstants.DEFAULT_TEXT_WRAPPER, omFactory, dataSource);
        assertEquals(testString, element.getText());
    }
View Full Code Here

import javax.activation.DataHandler;

public class DataHandlerUtils {

    public static Object getDataHandlerFromText(String value, String mimeType) {
        ByteArrayDataSource dataSource;
        byte[] data = Base64.decode(value);
        if (mimeType != null) {
            dataSource = new ByteArrayDataSource(data, mimeType);
        } else {
            // Assumes type as application/octet-stream
            dataSource = new ByteArrayDataSource(data);
        }
        return new DataHandler(dataSource);
    }
View Full Code Here

        OMAttribute cType1 = new OMAttributeImpl("contentType", mime,
                                                 "text/plain", fac);
        text.addAttribute(cType1);
        byte[] byteArray = new byte[] { 13, 56, 65, 32, 12, 12, 7, -3, -2, -1,
                98 };
        dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
        OMTextImpl textData = new OMTextImpl(dataHandler, false, fac);

        envelope.addChild(body);
        body.addChild(data);
        data.addChild(text);
View Full Code Here

        boundary = omOutput.getMimeBoundary();
        omOutput.setSOAP11(false);

        String contentType = omOutput.getContentType();
        DataHandler dataHandler;
        dataHandler = new DataHandler(new ByteArrayDataSource(byteArray));
        OMText textData = factory.createOMText(dataHandler, true);
        assertNotNull(textData.getContentID());

        DataHandler dataHandler2 = new DataHandler(
                "Apache Software Foundation", "text/plain");
View Full Code Here

TOP

Related Classes of org.apache.axiom.attachments.ByteArrayDataSource

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.