ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1849052 - in /webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts: jaxb/beans/DocumentBean2.java om/OMTestSuiteBuilder.java om/element/TestUnmarshalWithDataHandlerToByteArray.java
Date Sun, 16 Dec 2018 23:36:50 GMT
Author: veithen
Date: Sun Dec 16 23:36:50 2018
New Revision: 1849052

URL: http://svn.apache.org/viewvc?rev=1849052&view=rev
Log:
Test JAXB unmarshalling to byte[].

Added:
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/jaxb/beans/DocumentBean2.java
  (with props)
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestUnmarshalWithDataHandlerToByteArray.java
  (with props)
Modified:
    webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java

Added: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/jaxb/beans/DocumentBean2.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/jaxb/beans/DocumentBean2.java?rev=1849052&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/jaxb/beans/DocumentBean2.java
(added)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/jaxb/beans/DocumentBean2.java
Sun Dec 16 23:36:50 2018
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.jaxb.beans;
+
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlType;
+
+@XmlRootElement(name="document2")
+@XmlType(propOrder={ "id", "content" })
+public class DocumentBean2 {
+    private String id;
+    private byte[] content;
+    
+    public String getId() {
+        return id;
+    }
+    
+    public void setId(String id) {
+        this.id = id;
+    }
+    
+    public byte[] getContent() {
+        return content;
+    }
+    
+    public void setContent(byte[] content) {
+        this.content = content;
+    }
+}

Propchange: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/jaxb/beans/DocumentBean2.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1849052&r1=1849051&r2=1849052&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
(original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
Sun Dec 16 23:36:50 2018
@@ -443,6 +443,7 @@ public class OMTestSuiteBuilder extends
         addTest(new org.apache.axiom.ts.om.element.TestSetTextQNameWithoutNamespace(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestUndeclarePrefix(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestUnmarshalWithDataHandler(metaFactory));
+        addTest(new org.apache.axiom.ts.om.element.TestUnmarshalWithDataHandlerToByteArray(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestUnmarshalWithDeclaredType(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestWriteTextTo(metaFactory));
         addTest(new org.apache.axiom.ts.om.element.TestWriteTextToWithNonTextNodes(metaFactory));

Added: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestUnmarshalWithDataHandlerToByteArray.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestUnmarshalWithDataHandlerToByteArray.java?rev=1849052&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestUnmarshalWithDataHandlerToByteArray.java
(added)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestUnmarshalWithDataHandlerToByteArray.java
Sun Dec 16 23:36:50 2018
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.ts.om.element;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import javax.activation.DataHandler;
+import javax.xml.bind.JAXBContext;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.util.jaxb.JAXBUtils;
+import org.apache.axiom.testutils.activation.TextDataSource;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.apache.axiom.ts.jaxb.beans.DocumentBean2;
+
+public class TestUnmarshalWithDataHandlerToByteArray extends AxiomTestCase {
+    public TestUnmarshalWithDataHandlerToByteArray(OMMetaFactory metaFactory) {
+        super(metaFactory);
+    }
+
+    @Override
+    protected void runTest() throws Throwable {
+        OMFactory factory = metaFactory.getOMFactory();
+        OMNamespace ns = factory.createOMNamespace("http://ws.apache.org/axiom/test/jaxb",
"p");
+        OMElement element = factory.createOMElement("document2", ns);
+        factory.createOMElement("id", ns, element).setText("12345");
+        OMElement content = factory.createOMElement("content", ns, element);
+        content.addChild(factory.createOMText(new DataHandler(new TextDataSource("test content",
"utf-8", "plain")), true));
+        JAXBContext context = JAXBContext.newInstance(DocumentBean2.class);
+        DocumentBean2 bean = (DocumentBean2)JAXBUtils.unmarshal(element, context, null, true);
+        assertThat(bean.getId()).isEqualTo("12345");
+        assertThat(bean.getContent()).isEqualTo("test content".getBytes("utf-8"));
+    }
+}

Propchange: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/element/TestUnmarshalWithDataHandlerToByteArray.java
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message