Skip to content
Browse files

AXIOM-376: Trigger exceptions for conflicts detected during namespace…

… repairing.

git-svn-id: https://svn.apache.org/repos/asf/webservices/axiom/trunk@1748504 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent 3d0261b commit 29b67714ccf3970e46792f274d6a4191c6764030 @veithen veithen committed Jun 15, 2016
View
27 .../src/main/java/org/apache/axiom/core/stream/ConflictingNamespaceDeclarationException.java
@@ -0,0 +1,27 @@
+/*
+ * 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.core.stream;
+
+public class ConflictingNamespaceDeclarationException extends StreamException {
+ private static final long serialVersionUID = 1L;
+
+ public ConflictingNamespaceDeclarationException(String message) {
+ super(message);
+ }
+}
View
3 ...e-aspects/src/main/java/org/apache/axiom/core/stream/NamespaceRepairingFilterHandler.java
@@ -105,8 +105,7 @@ public void processNamespaceDeclaration(String prefix, String namespaceURI) thro
if (namespaceStack[i*2+1].equals(namespaceURI)) {
return;
} else {
- // TODO: this causes a failure in the FOM tests
-// throw new OMException("The same prefix cannot be bound to two different namespaces");
+ throw new ConflictingNamespaceDeclarationException("The same prefix cannot be bound to two different namespaces");
}
}
}
View
34 ...core-aspects/src/test/java/org/apache/axiom/core/stream/NamespaceRepairingFilterTest.java
@@ -0,0 +1,34 @@
+/*
+ * 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.core.stream;
+
+import org.junit.Test;
+
+public class NamespaceRepairingFilterTest {
+ @Test(expected=ConflictingNamespaceDeclarationException.class)
+ public void testNamespaceDeclarationConflictingWithElementName() throws StreamException {
+ XmlHandler handler = new NamespaceRepairingFilter(null, false).createFilterHandler(NullXmlHandler.INSTANCE);
+ handler.startFragment();
+ handler.startElement("urn:ns1", "test", "p");
+ handler.processNamespaceDeclaration("p", "urn:ns2");
+ handler.attributesCompleted();
+ handler.endElement();
+ handler.completed();
+ }
+}

0 comments on commit 29b6771

Please sign in to comment.
Something went wrong with that request. Please try again.