1 17 package org.apache.axis2.om.impl.llom.mtom; 18 19 import org.apache.axis2.attachments.MIMEHelper; 20 import org.apache.axis2.om.AbstractTestCase; 21 import org.apache.axis2.om.OMElement; 22 import org.apache.axis2.om.OMText; 23 import org.apache.axis2.om.OMXMLParserWrapper; 24 25 import javax.activation.DataHandler ; 26 import javax.xml.stream.XMLInputFactory; 27 import javax.xml.stream.XMLStreamReader; 28 import java.io.BufferedReader ; 29 import java.io.FileInputStream ; 30 import java.io.InputStream ; 31 import java.io.InputStreamReader ; 32 import java.util.Iterator ; 33 34 37 38 public class MTOMStAXSOAPModelBuilderTest extends AbstractTestCase { 39 MIMEHelper mimeHelper; 40 41 String inFileName; 42 43 OMXMLParserWrapper builder; 44 45 48 public MTOMStAXSOAPModelBuilderTest(String testName) { 49 super(testName); 50 } 51 52 String contentTypeString = "multipart/Related; type=\"application/xop+xml\"; boundary=\"----=_AxIs2_Def_boundary_=42214532\"; start=\"<SOAPPart>\""; 53 54 protected void setUp() throws Exception { 55 super.setUp(); 56 inFileName = "mtom/MTOMBuilderTestIn.txt"; 57 InputStream inStream = new FileInputStream ( 58 getTestResourceFile(inFileName)); 59 mimeHelper = new MIMEHelper(inStream, contentTypeString); 60 XMLStreamReader reader = XMLInputFactory.newInstance() 61 .createXMLStreamReader( 62 new BufferedReader (new InputStreamReader (mimeHelper 63 .getSOAPPartInputStream()))); 64 builder = new MTOMStAXSOAPModelBuilder(reader, mimeHelper); 65 66 } 67 68 public void testCreateOMElement() throws Exception { 69 OMElement root = (OMElement) builder.getDocumentElement(); 70 System.out.println(root.getLocalName() + " : " 71 + root.getNamespace().getName()); 72 OMElement body = (OMElement) root.getFirstChild(); 73 System.out.println(body.getLocalName() + " : " 74 + body.getNamespace().getName()); 75 76 OMElement data = (OMElement) body.getFirstChild(); 77 System.out.println(data.getLocalName() + " : " 78 + data.getNamespace().getName()); 79 Iterator childIt = data.getChildren(); 80 OMElement child = (OMElement) childIt.next(); 82 OMText blob = (OMText) child.getFirstChild(); 83 89 byte[] expectedObject = new byte[] { 13, 56, 65, 32, 12, 12, 7, -3, -2, 90 -1, 98 }; 91 DataHandler actualDH; 92 actualDH = blob.getDataHandler(); 93 98 } 100 101 public void testGetDataHandler() { 102 } 103 104 } | Popular Tags |