Author: veithen
Date: Fri Feb 7 15:20:24 2014
New Revision: 1565685
URL: http://svn.apache.org/r1565685
Log:
Fixed an issue with the clone implementation for DOOM's OMText.
Added:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/DummyMimePartProvider.java
(with props)
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/TestCloneBinary.java
(with props)
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/text/
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/text/TestCloneNodeBinary.java
(with props)
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
Modified:
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java?rev=1565685&r1=1565684&r2=1565685&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
(original)
+++
webservices/axiom/trunk/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/TextImpl.java
Fri Feb 7 15:20:24 2014
@@ -82,6 +82,6 @@ public class TextImpl extends TextNodeIm
}
LeafNode createClone() {
- return new TextImpl(textValue, factory);
+ return new TextImpl(this, factory);
}
}
Modified:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java?rev=1565685&r1=1565684&r2=1565685&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
(original)
+++
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/OMTestSuiteBuilder.java
Fri Feb 7 15:20:24 2014
@@ -577,6 +577,8 @@ public class OMTestSuiteBuilder extends
addTest(new org.apache.axiom.ts.om.pi.TestDigest(metaFactory));
addTest(new
org.apache.axiom.ts.om.text.TestBase64StreamingWithGetSAXSource(metaFactory));
addTest(new
org.apache.axiom.ts.om.text.TestBase64StreamingWithSerialize(metaFactory));
+ addTest(new org.apache.axiom.ts.om.text.TestCloneBinary(metaFactory,
false));
+ addTest(new org.apache.axiom.ts.om.text.TestCloneBinary(metaFactory,
true));
addTest(new org.apache.axiom.ts.om.text.TestDigest(metaFactory));
addTest(new org.apache.axiom.ts.om.text.TestGetNamespace(metaFactory));
addTest(new
org.apache.axiom.ts.om.text.TestGetNamespaceNoNamespace(metaFactory));
Added:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/DummyMimePartProvider.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/DummyMimePartProvider.java?rev=1565685&view=auto
==============================================================================
---
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/DummyMimePartProvider.java
(added)
+++
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/DummyMimePartProvider.java
Fri Feb 7 15:20:24 2014
@@ -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.text;
+
+import java.io.IOException;
+
+import javax.activation.DataHandler;
+
+import org.apache.axiom.util.stax.xop.MimePartProvider;
+
+final class DummyMimePartProvider implements MimePartProvider {
+ private final String contentID;
+ private final DataHandler dataHandler;
+ private boolean loaded;
+
+ DummyMimePartProvider(String contentID, DataHandler dataHandler) {
+ this.contentID = contentID;
+ this.dataHandler = dataHandler;
+ }
+
+ boolean isLoaded() {
+ return loaded;
+ }
+
+ public boolean isLoaded(String contentID) {
+ return loaded;
+ }
+
+ public DataHandler getDataHandler(String contentID) throws IOException {
+ if (!contentID.equals(this.contentID)) {
+ throw new IllegalArgumentException("Unknown content ID");
+ } else {
+ loaded = true;
+ return dataHandler;
+ }
+ }
+}
Propchange:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/DummyMimePartProvider.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/TestCloneBinary.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/TestCloneBinary.java?rev=1565685&view=auto
==============================================================================
---
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/TestCloneBinary.java
(added)
+++
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/TestCloneBinary.java
Fri Feb 7 15:20:24 2014
@@ -0,0 +1,57 @@
+/*
+ * 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.text;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import javax.activation.DataHandler;
+
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.util.StAXParserConfiguration;
+import org.apache.axiom.testutils.activation.RandomDataSource;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.xml.sax.InputSource;
+
+public class TestCloneBinary extends AxiomTestCase {
+ private boolean fetch;
+
+ public TestCloneBinary(OMMetaFactory metaFactory, boolean fetch) {
+ super(metaFactory);
+ this.fetch = fetch;
+ addTestParameter("fetch", fetch);
+ }
+
+ protected void runTest() throws Throwable {
+ DataHandler dh = new DataHandler(new RandomDataSource(600613L, 4096));
+ InputStream rootPart = new ByteArrayInputStream("<root><xop:Include
xmlns:xop='http://www.w3.org/2004/08/xop/include'
href='cid:[email protected]'/></root>".getBytes("utf-8"));
+ DummyMimePartProvider mimePartProvider = new
DummyMimePartProvider("[email protected]", dh);
+ OMElement root =
metaFactory.createOMBuilder(StAXParserConfiguration.DEFAULT,
metaFactory.getOMFactory(), new InputSource(rootPart),
mimePartProvider).getDocumentElement();
+ OMText text = (OMText)root.getFirstOMChild();
+ OMCloneOptions options = new OMCloneOptions();
+ options.setFetchDataHandlers(fetch);
+ OMText clone = (OMText)text.clone(options);
+ assertTrue(clone.isBinary());
+ assertEquals(fetch, mimePartProvider.isLoaded());
+ assertSame(dh, clone.getDataHandler());
+ }
+}
Propchange:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/om/text/TestCloneBinary.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java?rev=1565685&r1=1565684&r2=1565685&view=diff
==============================================================================
---
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
(original)
+++
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/OMDOMTestSuiteBuilder.java
Fri Feb 7 15:20:24 2014
@@ -57,5 +57,6 @@ public class OMDOMTestSuiteBuilder exten
addTest(new
org.apache.axiom.ts.omdom.factory.TestCreateOMTextCDATASectionWithParent(metaFactory));
addTest(new
org.apache.axiom.ts.omdom.node.TestInsertSiblingAfterFromForeignDocument(metaFactory));
addTest(new
org.apache.axiom.ts.omdom.node.TestInsertSiblingBeforeFromForeignDocument(metaFactory));
+ addTest(new
org.apache.axiom.ts.omdom.text.TestCloneNodeBinary(metaFactory));
}
}
Added:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/text/TestCloneNodeBinary.java
URL:
http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/text/TestCloneNodeBinary.java?rev=1565685&view=auto
==============================================================================
---
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/text/TestCloneNodeBinary.java
(added)
+++
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/text/TestCloneNodeBinary.java
Fri Feb 7 15:20:24 2014
@@ -0,0 +1,43 @@
+/*
+ * 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.omdom.text;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.testutils.activation.RandomDataSource;
+import org.apache.axiom.ts.AxiomTestCase;
+import org.w3c.dom.Text;
+
+public class TestCloneNodeBinary extends AxiomTestCase {
+ public TestCloneNodeBinary(OMMetaFactory metaFactory) {
+ super(metaFactory);
+ }
+
+ protected void runTest() throws Throwable {
+ OMFactory factory = metaFactory.getOMFactory();
+ DataSource ds = new RandomDataSource(666L, 1000);
+ Text text = (Text)factory.createOMText(new DataHandler(ds), false);
+ String base64 = text.getData();
+ assertTrue(base64.length() > 0);
+ assertEquals(base64, ((Text)text.cloneNode(true)).getData());
+ }
+}
Propchange:
webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/omdom/text/TestCloneNodeBinary.java
------------------------------------------------------------------------------
svn:eol-style = native