You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2015/07/11 10:55:11 UTC
svn commit: r1690360 - in /webservices/axiom/trunk:
aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/
testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/
testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerb...
Author: veithen
Date: Sat Jul 11 08:55:10 2015
New Revision: 1690360
URL: http://svn.apache.org/r1690360
Log:
Fix a regression in the setRole method.
Added:
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestSetRoleWithoutExistingNamespaceDecl.java (with props)
Modified:
webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
webservices/axiom/trunk/testing/axiom-truth/src/main/java/org/apache/axiom/truth/OMElementSubject.java
webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/HeaderBlockAttribute.java
Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj?rev=1690360&r1=1690359&r2=1690360&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/om/impl/common/AxiomElementSupport.aj Sat Jul 11 08:55:10 2015
@@ -375,9 +375,14 @@ public aspect AxiomElementSupport {
return attr == null ? null : attr.getAttributeValue();
}
- // TODO: complete the implementation (i.e. support value == null) and add the method to the OMElement API
+ // TODO: complete the implementation (i.e. support value == null and the no namespace case) and add the method to the OMElement API
public final void AxiomElement._setAttributeValue(QName qname, String value) {
- coreSetAttribute(Policies.ATTRIBUTE_MATCHER, qname.getNamespaceURI(), qname.getLocalPart(), qname.getPrefix(), value);
+ OMAttribute attr = getAttribute(qname);
+ if (attr != null) {
+ attr.setAttributeValue(value);
+ } else {
+ addAttribute(qname.getLocalPart(), value, new OMNamespaceImpl(qname.getNamespaceURI(), qname.getLocalPart()));
+ }
}
public final void AxiomElement.removeAttribute(OMAttribute attr) {
Modified: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1690360&r1=1690359&r2=1690360&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java (original)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java Sat Jul 11 08:55:10 2015
@@ -266,6 +266,7 @@ public class SOAPTestSuiteBuilder extend
addTest(new org.apache.axiom.ts.soap.headerblock.TestSetMustUnderstandWithInvalidValue(metaFactory, spec, invalidBooleanLiterals[i]));
}
addTest(new org.apache.axiom.ts.soap.headerblock.TestSetRole(metaFactory, spec));
+ addTest(new org.apache.axiom.ts.soap.headerblock.TestSetRoleWithoutExistingNamespaceDecl(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.headerblock.TestWrongParent1(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.headerblock.TestWrongParent2(metaFactory, spec));
addTest(new org.apache.axiom.ts.soap.headerblock.TestWrongParent3(metaFactory, spec));
Added: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestSetRoleWithoutExistingNamespaceDecl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestSetRoleWithoutExistingNamespaceDecl.java?rev=1690360&view=auto
==============================================================================
--- webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestSetRoleWithoutExistingNamespaceDecl.java (added)
+++ webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestSetRoleWithoutExistingNamespaceDecl.java Sat Jul 11 08:55:10 2015
@@ -0,0 +1,46 @@
+/*
+ * 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.soap.headerblock;
+
+import static org.apache.axiom.truth.AxiomTestVerb.ASSERT;
+
+import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMMetaFactory;
+import org.apache.axiom.soap.SOAPHeaderBlock;
+import org.apache.axiom.ts.soap.HeaderBlockAttribute;
+import org.apache.axiom.ts.soap.SOAPSpec;
+import org.apache.axiom.ts.soap.SOAPTestCase;
+
+/**
+ * Tests that {@link SOAPHeaderBlock#setRole(String)} adds a namespace declaration if necessary.
+ */
+public class TestSetRoleWithoutExistingNamespaceDecl extends SOAPTestCase {
+ public TestSetRoleWithoutExistingNamespaceDecl(OMMetaFactory metaFactory, SOAPSpec spec) {
+ super(metaFactory, spec);
+ }
+
+ @Override
+ protected void runTest() throws Throwable {
+ SOAPHeaderBlock headerBlock = soapFactory.createSOAPHeaderBlock("block", soapFactory.createOMNamespace("urn:test", "p"));
+ headerBlock.setRole("urn:testrole");
+ OMAttribute roleAttr = headerBlock.getAttribute(HeaderBlockAttribute.ROLE.getQName(spec));
+ ASSERT.that(roleAttr).isNotNull();
+ ASSERT.that(headerBlock).hasNamespaceDeclaration(roleAttr.getNamespace());
+ }
+}
Propchange: webservices/axiom/trunk/testing/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/headerblock/TestSetRoleWithoutExistingNamespaceDecl.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: webservices/axiom/trunk/testing/axiom-truth/src/main/java/org/apache/axiom/truth/OMElementSubject.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/axiom-truth/src/main/java/org/apache/axiom/truth/OMElementSubject.java?rev=1690360&r1=1690359&r2=1690360&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/axiom-truth/src/main/java/org/apache/axiom/truth/OMElementSubject.java (original)
+++ webservices/axiom/trunk/testing/axiom-truth/src/main/java/org/apache/axiom/truth/OMElementSubject.java Sat Jul 11 08:55:10 2015
@@ -18,7 +18,10 @@
*/
package org.apache.axiom.truth;
+import java.util.Iterator;
+
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMNamespace;
import com.google.common.truth.FailureStrategy;
@@ -32,4 +35,14 @@ public final class OMElementSubject exte
fail("has no namespace declarations");
}
}
+
+ public void hasNamespaceDeclaration(OMNamespace ns) {
+ for (Iterator it = getSubject().getAllDeclaredNamespaces(); it.hasNext(); ) {
+ if (it.next().equals(ns)) {
+ return;
+ }
+ }
+ fail("has namespace declaration for namespace URI \"" + ns.getNamespaceURI()
+ + "\" and prefix \"" + ns.getPrefix() + "\"");
+ }
}
Modified: webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/HeaderBlockAttribute.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/HeaderBlockAttribute.java?rev=1690360&r1=1690359&r2=1690360&view=diff
==============================================================================
--- webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/HeaderBlockAttribute.java (original)
+++ webservices/axiom/trunk/testing/soap-testsuite/src/main/java/org/apache/axiom/ts/soap/HeaderBlockAttribute.java Sat Jul 11 08:55:10 2015
@@ -18,6 +18,8 @@
*/
package org.apache.axiom.ts.soap;
+import javax.xml.namespace.QName;
+
import org.apache.axiom.testing.multiton.Multiton;
/**
@@ -78,6 +80,10 @@ public abstract class HeaderBlockAttribu
*/
public abstract String getName(SOAPSpec spec);
+ public final QName getQName(SOAPSpec spec) {
+ return new QName(spec.getEnvelopeNamespaceURI(), getName(spec));
+ }
+
/**
* Determine if the attribute is a boolean attribute.
*