[java-opensaml] branch main updated: IDP-2069 - Null handling task
Scott Cantor
cantor.2 at osu.edu
Wed Mar 15 15:03:56 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=7882908dd1a5c0d4bcf80a65d8080c5b6b410ce8
The following commit(s) were added to refs/heads/main by this push:
new 7882908dd IDP-2069 - Null handling task
7882908dd is described below
commit 7882908dd1a5c0d4bcf80a65d8080c5b6b410ce8
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Mar 15 11:03:53 2023 -0400
IDP-2069 - Null handling task
https://shibboleth.atlassian.net/browse/IDP-2069
Clean opensaml-core-impl.
---
.../org/opensaml/core/xml/schema/XSBoolean.java | 3 +-
.../opensaml/core/metrics/impl/HTTPReporter.java | 5 +-
.../metrics/impl/MetricRegistryInitializer.java | 3 +-
.../SegmentingIntermediateDirectoryStrategy.java | 6 +-
.../opensaml/core/xml/schema/impl/XSAnyImpl.java | 1 +
.../core/xml/schema/impl/XSBooleanMarshaller.java | 12 +++-
.../core/xml/schema/impl/XSDateTimeMarshaller.java | 12 +++-
.../xml/schema/impl/XSDateTimeUnmarshaller.java | 4 +-
.../core/xml/schema/impl/XSIntegerImpl.java | 12 ++--
.../core/xml/schema/impl/XSIntegerMarshaller.java | 12 ++--
.../xml/schema/impl/XSIntegerUnmarshaller.java | 4 +-
.../opensaml/core/xml/schema/impl/XSQNameImpl.java | 15 +++--
.../core/xml/schema/impl/XSQNameMarshaller.java | 13 +++-
.../core/xml/schema/impl/XSQNameUnmarshaller.java | 9 ++-
.../core/xml/schema/impl/XSStringImpl.java | 12 ++--
.../core/xml/schema/impl/XSStringMarshaller.java | 4 +-
.../core/xml/schema/impl/XSStringUnmarshaller.java | 4 +-
.../opensaml/core/xml/schema/impl/XSURIImpl.java | 6 +-
.../core/xml/schema/impl/XSURIMarshaller.java | 4 +-
.../core/xml/schema/impl/XSURIUnmarshaller.java | 4 +-
.../core/xml/config/tests/ConfigurationTest.java | 66 +++++++++----------
.../config/tests/InitializationServiceTest.java | 5 ++
.../tests/XMLObjectProviderInitializerTest.java | 2 +-
.../impl/FilesystemLoadSaveManagerTest.java | 6 +-
.../core/xml/schema/impl/XSBase64BinaryTest.java | 4 +-
.../core/xml/schema/impl/XSBooleanTest.java | 12 ++--
.../core/xml/schema/impl/XSDateTimeTest.java | 8 +--
.../core/xml/schema/impl/XSIntegerTest.java | 4 +-
.../opensaml/core/xml/schema/impl/XSQNameTest.java | 4 +-
.../core/xml/schema/impl/XSStringTest.java | 4 +-
.../opensaml/core/xml/schema/impl/XSURITest.java | 4 +-
.../opensaml/core/xml/tests/ElementProxyTest.java | 15 ++++-
.../opensaml/core/xml/tests/IDAttributeTest.java | 57 ++++++++--------
.../opensaml/core/xml/tests/MarshallingTest.java | 75 +++++++++++-----------
.../core/xml/tests/NamespaceManagerTest.java | 1 +
.../core/xml/tests/UnmarshallingSecurityTest.java | 13 ++--
.../opensaml/core/xml/tests/UnmarshallingTest.java | 6 +-
.../core/xml/tests/XMLObjectXSIAttribsTest.java | 65 ++++++++++---------
.../tests/IndexedXMLObjectChildrenListTest.java | 44 +++++++------
.../xml/util/tests/XMLObjectChildrenListTest.java | 1 +
.../core/xml/util/tests/XMLObjectSourceTest.java | 7 --
.../core/xml/util/tests/XMLObjectSupportTest.java | 69 +++++++++++---------
.../opensaml/core/xml/mock/SimpleXMLObject.java | 46 +++++++------
43 files changed, 377 insertions(+), 286 deletions(-)
diff --git a/opensaml-core-api/src/main/java/org/opensaml/core/xml/schema/XSBoolean.java b/opensaml-core-api/src/main/java/org/opensaml/core/xml/schema/XSBoolean.java
index aaec0114f..f9c93ee69 100644
--- a/opensaml-core-api/src/main/java/org/opensaml/core/xml/schema/XSBoolean.java
+++ b/opensaml-core-api/src/main/java/org/opensaml/core/xml/schema/XSBoolean.java
@@ -29,7 +29,7 @@ import net.shibboleth.shared.xml.XMLConstants;
/**
* XSBoolean is the <code>xs:boolean</code> schema type.
*/
-public abstract interface XSBoolean extends XMLObject {
+public interface XSBoolean extends XMLObject {
/** Local name of the XSI type. */
@Nonnull @NotEmpty static final String TYPE_LOCAL_NAME = "boolean";
@@ -50,5 +50,4 @@ public abstract interface XSBoolean extends XMLObject {
* @param value The {@link XSBooleanValue} value
*/
void setValue(@Nullable final XSBooleanValue value);
-
}
\ No newline at end of file
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/HTTPReporter.java b/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/HTTPReporter.java
index fe64f5938..d7d105524 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/HTTPReporter.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/HTTPReporter.java
@@ -39,7 +39,6 @@ import org.apache.hc.core5.http.HttpStatus;
import org.opensaml.security.httpclient.HttpClientSecurityParameters;
import org.opensaml.security.httpclient.HttpClientSecuritySupport;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.codahale.metrics.Counter;
import com.codahale.metrics.Gauge;
@@ -61,7 +60,9 @@ import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.component.ComponentInitializationException;
import net.shibboleth.shared.component.InitializableComponent;
import net.shibboleth.shared.component.UninitializedComponentException;
+import net.shibboleth.shared.httpclient.HttpClientSupport;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
/**
@@ -296,7 +297,7 @@ public class HTTPReporter extends ScheduledReporter implements InitializableComp
* @return the client context instance
*/
@Nonnull private HttpClientContext buildHttpContext(@Nonnull final HttpRequest request) {
- final HttpClientContext clientContext = HttpClientContext.create();
+ final HttpClientContext clientContext = HttpClientSupport.buildHttpClientContext();
HttpClientSecuritySupport.marshalSecurityParameters(clientContext, httpClientSecurityParameters, false);
HttpClientSecuritySupport.addDefaultTLSTrustEngineCriteria(clientContext, request);
return clientContext;
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/MetricRegistryInitializer.java b/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/MetricRegistryInitializer.java
index 3a622072b..4ff8d40d2 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/MetricRegistryInitializer.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/metrics/impl/MetricRegistryInitializer.java
@@ -23,10 +23,11 @@ import org.opensaml.core.config.ConfigurationService;
import org.opensaml.core.config.InitializationException;
import org.opensaml.core.config.Initializer;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.codahale.metrics.MetricRegistry;
+import net.shibboleth.shared.primitive.LoggerFactory;
+
/**
* An initializer for the {@link MetricRegistry} held by the {@link ConfigurationService}.
*/
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/persist/impl/SegmentingIntermediateDirectoryStrategy.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/persist/impl/SegmentingIntermediateDirectoryStrategy.java
index a449a41b7..8a4d8d7da 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/persist/impl/SegmentingIntermediateDirectoryStrategy.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/persist/impl/SegmentingIntermediateDirectoryStrategy.java
@@ -26,10 +26,10 @@ import javax.annotation.Nonnull;
import org.opensaml.core.xml.XMLRuntimeException;
import org.opensaml.core.xml.persist.FilesystemLoadSaveManager;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import net.shibboleth.shared.annotation.ParameterName;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
/**
* Strategy function for producing intermediate directories from an input key.
@@ -41,10 +41,10 @@ import net.shibboleth.shared.logic.Constraint;
public class SegmentingIntermediateDirectoryStrategy implements Function<String, List<String>> {
/** Logger. **/
- private Logger log = LoggerFactory.getLogger(SegmentingIntermediateDirectoryStrategy.class);
+ @Nonnull private Logger log = LoggerFactory.getLogger(SegmentingIntermediateDirectoryStrategy.class);
/** Strategy function for generating the source data from the input key.*/
- private Function<String,String> sourceStrategy;
+ @Nonnull private Function<String,String> sourceStrategy;
/** The number of segments to produce. **/
private int segmentNumber;
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSAnyImpl.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSAnyImpl.java
index 78ae23bee..ddebaca57 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSAnyImpl.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSAnyImpl.java
@@ -75,6 +75,7 @@ public class XSAnyImpl extends AbstractXMLObject implements XSAny {
}
/** {@inheritDoc} */
+ @SuppressWarnings("unchecked")
@Nonnull public List<XMLObject> getUnknownXMLObjects(@Nonnull final QName typeOrName) {
return (List<XMLObject>) unknownXMLObjects.subList(typeOrName);
}
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSBooleanMarshaller.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSBooleanMarshaller.java
index b7c9dfe33..1f9e82407 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSBooleanMarshaller.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSBooleanMarshaller.java
@@ -23,6 +23,7 @@ import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectMarshaller;
import org.opensaml.core.xml.io.MarshallingException;
import org.opensaml.core.xml.schema.XSBoolean;
+import org.opensaml.core.xml.schema.XSBooleanValue;
import org.w3c.dom.Element;
import net.shibboleth.shared.xml.ElementSupport;
@@ -36,8 +37,15 @@ public class XSBooleanMarshaller extends AbstractXMLObjectMarshaller {
throws MarshallingException {
final XSBoolean xsiBoolean = (XSBoolean) xmlObject;
- if (xsiBoolean.getValue() != null && xsiBoolean.getValue().getValue() != null) {
- ElementSupport.appendTextContent(domElement, xsiBoolean.getValue().getValue().toString());
+ if (xsiBoolean.getValue() != null) {
+ final XSBooleanValue xbool = xsiBoolean.getValue();
+ if (xbool != null) {
+ final Boolean bval = xbool.getValue();
+ if (bval != null) {
+ ElementSupport.appendTextContent(domElement, bval.toString());
+ }
+ }
}
}
+
}
\ No newline at end of file
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSDateTimeMarshaller.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSDateTimeMarshaller.java
index a5bdc0483..052dec01f 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSDateTimeMarshaller.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSDateTimeMarshaller.java
@@ -17,6 +17,10 @@
package org.opensaml.core.xml.schema.impl;
+import java.time.Instant;
+
+import javax.annotation.Nonnull;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectMarshaller;
import org.opensaml.core.xml.io.MarshallingException;
@@ -32,11 +36,13 @@ import net.shibboleth.shared.xml.ElementSupport;
public class XSDateTimeMarshaller extends AbstractXMLObjectMarshaller {
/** {@inheritDoc} */
- protected void marshallElementContent(final XMLObject xmlObject, final Element domElement)
+ protected void marshallElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
throws MarshallingException {
- final XSDateTime xsDateTime = (XSDateTime) xmlObject;
- ElementSupport.appendTextContent(domElement, DOMTypeSupport.instantToString(xsDateTime.getValue()));
+ final Instant i = ((XSDateTime) xmlObject).getValue();
+ if (i != null) {
+ ElementSupport.appendTextContent(domElement, DOMTypeSupport.instantToString(i));
+ }
}
}
\ No newline at end of file
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSDateTimeUnmarshaller.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSDateTimeUnmarshaller.java
index e833b0ffe..31920b3f6 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSDateTimeUnmarshaller.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSDateTimeUnmarshaller.java
@@ -17,6 +17,8 @@
package org.opensaml.core.xml.schema.impl;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectUnmarshaller;
import org.opensaml.core.xml.schema.XSDateTime;
@@ -29,7 +31,7 @@ import net.shibboleth.shared.xml.DOMTypeSupport;
public class XSDateTimeUnmarshaller extends AbstractXMLObjectUnmarshaller{
/** {@inheritDoc} */
- protected void processElementContent(final XMLObject xmlObject, final String elementContent) {
+ protected void processElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final String elementContent) {
final XSDateTime xsDateTime = (XSDateTime) xmlObject;
xsDateTime.setValue(DOMTypeSupport.stringToInstant(elementContent));
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerImpl.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerImpl.java
index 0434dcd85..4c97c5055 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerImpl.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerImpl.java
@@ -19,6 +19,9 @@ package org.opensaml.core.xml.schema.impl;
import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
import org.opensaml.core.xml.AbstractXMLObject;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.schema.XSInteger;
@@ -38,28 +41,29 @@ public class XSIntegerImpl extends AbstractXMLObject implements XSInteger {
* @param elementLocalName the local name of the XML element this Object represents
* @param namespacePrefix the prefix for the given namespace
*/
- protected XSIntegerImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) {
+ protected XSIntegerImpl(@Nullable final String namespaceURI, @Nonnull final String elementLocalName,
+ @Nullable final String namespacePrefix) {
super(namespaceURI, elementLocalName, namespacePrefix);
}
/**
* {@inheritDoc}
*/
- public Integer getValue() {
+ @Nullable public Integer getValue() {
return value;
}
/**
* {@inheritDoc}
*/
- public void setValue(final Integer newValue) {
+ public void setValue(@Nullable final Integer newValue) {
value = prepareForAssignment(value, newValue);
}
/**
* {@inheritDoc}
*/
- public List<XMLObject> getOrderedChildren() {
+ @Nullable public List<XMLObject> getOrderedChildren() {
// no children
return null;
}
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerMarshaller.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerMarshaller.java
index d62ebfae6..1898f5fae 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerMarshaller.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerMarshaller.java
@@ -17,6 +17,8 @@
package org.opensaml.core.xml.schema.impl;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectMarshaller;
import org.opensaml.core.xml.io.MarshallingException;
@@ -31,12 +33,12 @@ import net.shibboleth.shared.xml.ElementSupport;
public class XSIntegerMarshaller extends AbstractXMLObjectMarshaller {
/** {@inheritDoc} */
- protected void marshallElementContent(final XMLObject xmlObject, final Element domElement)
+ protected void marshallElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
throws MarshallingException {
- final XSInteger xsiInteger = (XSInteger) xmlObject;
-
- if (xsiInteger.getValue() != null) {
- ElementSupport.appendTextContent(domElement, xsiInteger.getValue().toString());
+
+ final Integer i = ((XSInteger) xmlObject).getValue();
+ if (i != null) {
+ ElementSupport.appendTextContent(domElement, i.toString());
}
}
}
\ No newline at end of file
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerUnmarshaller.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerUnmarshaller.java
index 42ef6083c..42cd19fc7 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerUnmarshaller.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSIntegerUnmarshaller.java
@@ -17,6 +17,8 @@
package org.opensaml.core.xml.schema.impl;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectUnmarshaller;
import org.opensaml.core.xml.schema.XSInteger;
@@ -27,7 +29,7 @@ import org.opensaml.core.xml.schema.XSInteger;
public class XSIntegerUnmarshaller extends AbstractXMLObjectUnmarshaller {
/** {@inheritDoc} */
- protected void processElementContent(final XMLObject xmlObject, final String elementContent) {
+ protected void processElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final String elementContent) {
final XSInteger xsiInteger = (XSInteger) xmlObject;
if (elementContent != null) {
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameImpl.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameImpl.java
index b30c57c52..c4ddea8eb 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameImpl.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameImpl.java
@@ -17,10 +17,10 @@
package org.opensaml.core.xml.schema.impl;
-import java.util.Collections;
-import java.util.LinkedList;
import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.namespace.QName;
import org.opensaml.core.xml.AbstractXMLObject;
@@ -42,22 +42,23 @@ public class XSQNameImpl extends AbstractXMLObject implements XSQName {
* @param elementLocalName the local name of the XML element this Object represents
* @param namespacePrefix the prefix for the given namespace
*/
- protected XSQNameImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) {
+ protected XSQNameImpl(@Nullable final String namespaceURI, @Nonnull final String elementLocalName,
+ @Nullable final String namespacePrefix) {
super(namespaceURI, elementLocalName, namespacePrefix);
}
/** {@inheritDoc} */
- public QName getValue() {
+ @Nullable public QName getValue() {
return value;
}
/** {@inheritDoc} */
- public void setValue(final QName newValue) {
+ public void setValue(@Nullable final QName newValue) {
value = prepareElementContentForAssignment(value, newValue);
}
/** {@inheritDoc} */
- public List<XMLObject> getOrderedChildren() {
- return Collections.unmodifiableList(new LinkedList<XMLObject>());
+ @Nullable public List<XMLObject> getOrderedChildren() {
+ return null;
}
}
\ No newline at end of file
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameMarshaller.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameMarshaller.java
index 262b1831f..ffb5a6b59 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameMarshaller.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameMarshaller.java
@@ -17,6 +17,9 @@
package org.opensaml.core.xml.schema.impl;
+import javax.annotation.Nonnull;
+import javax.xml.namespace.QName;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectMarshaller;
import org.opensaml.core.xml.io.MarshallingException;
@@ -32,9 +35,13 @@ import net.shibboleth.shared.xml.QNameSupport;
public class XSQNameMarshaller extends AbstractXMLObjectMarshaller {
/** {@inheritDoc} */
- protected void marshallElementContent(final XMLObject xmlObject, final Element domElement)
+ protected void marshallElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
throws MarshallingException {
- final XSQName qname = (XSQName) xmlObject;
- ElementSupport.appendTextContent(domElement, QNameSupport.qnameToContentString(qname.getValue()));
+
+ final QName qname = ((XSQName) xmlObject).getValue();
+ if (qname != null) {
+ ElementSupport.appendTextContent(domElement, QNameSupport.qnameToContentString(qname));
+ }
}
+
}
\ No newline at end of file
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameUnmarshaller.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameUnmarshaller.java
index 02f1b50c9..e152fc081 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameUnmarshaller.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSQNameUnmarshaller.java
@@ -27,6 +27,7 @@ import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectUnmarshaller;
import org.opensaml.core.xml.io.UnmarshallingException;
import org.opensaml.core.xml.schema.XSQName;
+import org.w3c.dom.Element;
import org.w3c.dom.Text;
/**
@@ -44,10 +45,16 @@ public class XSQNameUnmarshaller extends AbstractXMLObjectUnmarshaller {
/** {@inheritDoc} */
protected void unmarshallTextContent(@Nonnull final XMLObject xmlObject, @Nonnull final Text content)
throws UnmarshallingException {
+
+ final Element parent = ElementSupport.getElementAncestor(content);
+ if (parent == null) {
+ throw new UnmarshallingException("No parent element from which to reconstitute QName");
+ }
+
final String textContent = StringSupport.trimOrNull(content.getData());
if (textContent != null) {
final XSQName qname = (XSQName) xmlObject;
- qname.setValue(QNameSupport.constructQName(ElementSupport.getElementAncestor(content), textContent));
+ qname.setValue(QNameSupport.constructQName(parent, textContent));
}
}
}
\ No newline at end of file
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringImpl.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringImpl.java
index 68c9caef4..3265616a6 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringImpl.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringImpl.java
@@ -19,6 +19,9 @@ package org.opensaml.core.xml.schema.impl;
import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
import org.opensaml.core.xml.AbstractXMLObject;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.schema.XSString;
@@ -38,28 +41,29 @@ public class XSStringImpl extends AbstractXMLObject implements XSString {
* @param elementLocalName the local name of the XML element this Object represents
* @param namespacePrefix the prefix for the given namespace
*/
- protected XSStringImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) {
+ protected XSStringImpl(@Nullable final String namespaceURI, @Nonnull final String elementLocalName,
+ @Nullable final String namespacePrefix) {
super(namespaceURI, elementLocalName, namespacePrefix);
}
/**
* {@inheritDoc}
*/
- public String getValue() {
+ @Nullable public String getValue() {
return value;
}
/**
* {@inheritDoc}
*/
- public void setValue(final String newValue) {
+ public void setValue(@Nullable final String newValue) {
value = prepareForAssignment(value, newValue);
}
/**
* {@inheritDoc}
*/
- public List<XMLObject> getOrderedChildren() {
+ @Nullable public List<XMLObject> getOrderedChildren() {
// no children
return null;
}
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringMarshaller.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringMarshaller.java
index 89bfdb33c..b47d44751 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringMarshaller.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringMarshaller.java
@@ -17,6 +17,8 @@
package org.opensaml.core.xml.schema.impl;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectMarshaller;
import org.opensaml.core.xml.io.MarshallingException;
@@ -31,7 +33,7 @@ import net.shibboleth.shared.xml.ElementSupport;
public class XSStringMarshaller extends AbstractXMLObjectMarshaller {
/** {@inheritDoc} */
- protected void marshallElementContent(final XMLObject xmlObject, final Element domElement)
+ protected void marshallElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
throws MarshallingException {
final XSString xsiString = (XSString) xmlObject;
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringUnmarshaller.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringUnmarshaller.java
index f81633d1f..dc2dc0fa5 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringUnmarshaller.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSStringUnmarshaller.java
@@ -17,6 +17,8 @@
package org.opensaml.core.xml.schema.impl;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectUnmarshaller;
import org.opensaml.core.xml.schema.XSString;
@@ -27,7 +29,7 @@ import org.opensaml.core.xml.schema.XSString;
public class XSStringUnmarshaller extends AbstractXMLObjectUnmarshaller {
/** {@inheritDoc} */
- protected void processElementContent(final XMLObject xmlObject, final String elementContent) {
+ protected void processElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final String elementContent) {
final XSString xsiString = (XSString) xmlObject;
xsiString.setValue(elementContent);
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIImpl.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIImpl.java
index c9ca04cc1..263cb8713 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIImpl.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIImpl.java
@@ -19,6 +19,7 @@ package org.opensaml.core.xml.schema.impl;
import java.util.List;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opensaml.core.xml.AbstractXMLObject;
@@ -40,7 +41,8 @@ public class XSURIImpl extends AbstractXMLObject implements XSURI {
* @param elementLocalName the local name of the XML element this Object represents
* @param namespacePrefix the prefix for the given namespace
*/
- protected XSURIImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) {
+ protected XSURIImpl(@Nullable final String namespaceURI, @Nonnull final String elementLocalName,
+ @Nullable final String namespacePrefix) {
super(namespaceURI, elementLocalName, namespacePrefix);
}
@@ -55,7 +57,7 @@ public class XSURIImpl extends AbstractXMLObject implements XSURI {
}
/** {@inheritDoc} */
- public List<XMLObject> getOrderedChildren() {
+ @Nullable public List<XMLObject> getOrderedChildren() {
return null;
}
}
\ No newline at end of file
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIMarshaller.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIMarshaller.java
index da1810125..5e459365b 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIMarshaller.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIMarshaller.java
@@ -17,6 +17,8 @@
package org.opensaml.core.xml.schema.impl;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectMarshaller;
import org.opensaml.core.xml.io.MarshallingException;
@@ -31,7 +33,7 @@ import net.shibboleth.shared.xml.ElementSupport;
public class XSURIMarshaller extends AbstractXMLObjectMarshaller {
/** {@inheritDoc} */
- protected void marshallElementContent(final XMLObject xmlObject, final Element domElement)
+ protected void marshallElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
throws MarshallingException {
final XSURI uri = (XSURI) xmlObject;
diff --git a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIUnmarshaller.java b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIUnmarshaller.java
index bdf217cc1..3f9dfbccb 100644
--- a/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIUnmarshaller.java
+++ b/opensaml-core-impl/src/main/java/org/opensaml/core/xml/schema/impl/XSURIUnmarshaller.java
@@ -17,6 +17,8 @@
package org.opensaml.core.xml.schema.impl;
+import javax.annotation.Nonnull;
+
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.io.AbstractXMLObjectUnmarshaller;
import org.opensaml.core.xml.schema.XSURI;
@@ -27,7 +29,7 @@ import org.opensaml.core.xml.schema.XSURI;
public class XSURIUnmarshaller extends AbstractXMLObjectUnmarshaller {
/** {@inheritDoc} */
- protected void processElementContent(final XMLObject xmlObject, final String elementContent) {
+ protected void processElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final String elementContent) {
final XSURI uri = (XSURI) xmlObject;
uri.setURI(elementContent);
}
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/ConfigurationTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/ConfigurationTest.java
index aa9944c17..f40be7d2e 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/ConfigurationTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/ConfigurationTest.java
@@ -52,7 +52,31 @@ public class ConfigurationTest {
/** SimpleElement QName */
private QName simpleXMLObjectQName;
+
+ @BeforeClass
+ protected void initClass() throws ComponentInitializationException {
+ parserPool = new BasicParserPool();
+ parserPool.setNamespaceAware(true);
+ parserPool.initialize();
+
+ simpleXMLObjectQName = new QName("http://www.example.org/testObjects", "SimpleElement");
+ }
+ @BeforeMethod
+ protected void setUp() throws Exception {
+ final Properties props = new Properties();
+ props.setProperty(ConfigurationService.PROPERTY_PARTITION_NAME, this.getClass().getName());
+ ThreadLocalConfigurationPropertiesHolder.setProperties(props);
+
+ ConfigurationService.register(XMLObjectProviderRegistry.class, new XMLObjectProviderRegistry());
+ }
+
+ @AfterMethod
+ protected void tearDown() throws Exception {
+ ConfigurationService.deregister(XMLObjectProviderRegistry.class);
+ ThreadLocalConfigurationPropertiesHolder.clear();
+ }
+
/**
* Tests that a schema invalid configuration file is properly identified as such.
*
@@ -62,7 +86,7 @@ public class ConfigurationTest {
public void testInvalidConfiguration() throws Exception {
XMLConfigurator configurator = new XMLConfigurator();
try {
- InputStream sxConfig = XMLObjectProviderRegistrySupport.class
+ final InputStream sxConfig = XMLObjectProviderRegistrySupport.class
.getResourceAsStream("/org/opensaml/core/xml/config/InvalidConfiguration.xml");
configurator.load(sxConfig);
} catch (XMLConfigurationException e) {
@@ -82,7 +106,7 @@ public class ConfigurationTest {
XMLConfigurator configurator = new XMLConfigurator();
// Test loading the SimpleXMLObject configuration where builder contains additional children
- InputStream sxConfig = ConfigurationTest.class
+ final InputStream sxConfig = ConfigurationTest.class
.getResourceAsStream("/org/opensaml/core/xml/config/SimpleXMLObjectConfiguration.xml");
configurator.load(sxConfig);
@@ -96,7 +120,7 @@ public class ConfigurationTest {
Assert.assertNotNull(sxUnmarshaller, "SimpleXMLObject did not have a registered unmarshaller");
// Test loading a configuration with bogus classes
- InputStream nonConfig = XMLObjectProviderRegistrySupport.class
+ final InputStream nonConfig = XMLObjectProviderRegistrySupport.class
.getResourceAsStream("/org/opensaml/core/xml/config/NonexistantClassConfiguration.xml");
try {
configurator.load(nonConfig);
@@ -111,7 +135,7 @@ public class ConfigurationTest {
*/
@Test
public void testIDAttributeRegistration() {
- QName attribQname = new QName("http://example.org", "someIDAttribName", "test");
+ final QName attribQname = new QName("http://example.org", "someIDAttribName", "test");
Assert.assertFalse(XMLObjectProviderRegistrySupport.isIDAttribute(attribQname), "Non-registered ID attribute check returned true");
@@ -122,7 +146,7 @@ public class ConfigurationTest {
Assert.assertFalse(XMLObjectProviderRegistrySupport.isIDAttribute(attribQname), "Non-registered ID attribute check returned true");
// Check xml:id, which is hardcoded in the Configuration static initializer
- QName xmlIDQName = new QName(XMLConstants.XML_NS_URI, "id");
+ final QName xmlIDQName = new QName(XMLConstants.XML_NS_URI, "id");
Assert.assertTrue(XMLObjectProviderRegistrySupport.isIDAttribute(xmlIDQName), "Registered ID attribute check returned false");
}
@@ -137,11 +161,11 @@ public class ConfigurationTest {
public void testIDAttributeConfiguration() throws XMLParserException, XMLConfigurationException {
XMLConfigurator configurator = new XMLConfigurator();
- QName fooQName = new QName("http://www.example.org/testObjects", "foo", "test");
- QName barQName = new QName("http://www.example.org/testObjects", "bar", "test");
- QName bazQName = new QName("http://www.example.org/testObjects", "baz", "test");
+ final QName fooQName = new QName("http://www.example.org/testObjects", "foo", "test");
+ final QName barQName = new QName("http://www.example.org/testObjects", "bar", "test");
+ final QName bazQName = new QName("http://www.example.org/testObjects", "baz", "test");
- InputStream idAttributeConfig = XMLObjectProviderRegistrySupport.class
+ final InputStream idAttributeConfig = XMLObjectProviderRegistrySupport.class
.getResourceAsStream("/org/opensaml/core/xml/config/IDAttributeConfiguration.xml");
configurator.load(idAttributeConfig);
@@ -153,29 +177,5 @@ public class ConfigurationTest {
XMLObjectProviderRegistrySupport.deregisterIDAttribute(barQName);
XMLObjectProviderRegistrySupport.deregisterIDAttribute(bazQName);
}
-
- @BeforeClass
- protected void initClass() throws ComponentInitializationException {
- parserPool = new BasicParserPool();
- parserPool.setNamespaceAware(true);
- parserPool.initialize();
- simpleXMLObjectQName = new QName("http://www.example.org/testObjects", "SimpleElement");
- }
-
- @BeforeMethod
- protected void setUp() throws Exception {
- Properties props = new Properties();
- props.setProperty(ConfigurationService.PROPERTY_PARTITION_NAME, this.getClass().getName());
- ThreadLocalConfigurationPropertiesHolder.setProperties(props);
-
- ConfigurationService.register(XMLObjectProviderRegistry.class, new XMLObjectProviderRegistry());
- }
-
- @AfterMethod
- protected void tearDown() throws Exception {
- ConfigurationService.deregister(XMLObjectProviderRegistry.class);
- ThreadLocalConfigurationPropertiesHolder.clear();
- }
-
}
\ No newline at end of file
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/InitializationServiceTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/InitializationServiceTest.java
index 88467ec2e..4f6e2112b 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/InitializationServiceTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/InitializationServiceTest.java
@@ -48,6 +48,11 @@ public class InitializationServiceTest {
ThreadLocalConfigurationPropertiesHolder.clear();
}
+ /**
+ * Unit test.
+ *
+ * @throws InitializationException
+ */
@Test
public void testProviderInit() throws InitializationException {
XMLObjectProviderRegistry registry = ConfigurationService.get(XMLObjectProviderRegistry.class);
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/XMLObjectProviderInitializerTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/XMLObjectProviderInitializerTest.java
index 6c359f1cc..143ebb25e 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/XMLObjectProviderInitializerTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/config/tests/XMLObjectProviderInitializerTest.java
@@ -39,7 +39,7 @@ public class XMLObjectProviderInitializerTest extends XMLObjectProviderInitializ
/** {@inheritDoc} */
protected QName[] getTestedProviders() {
return new QName[] {
- ConfigurationService.get(XMLObjectProviderRegistry.class).getDefaultProviderQName(),
+ ConfigurationService.ensure(XMLObjectProviderRegistry.class).getDefaultProviderQName(),
XSString.TYPE_NAME,
};
}
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/persist/impl/FilesystemLoadSaveManagerTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/persist/impl/FilesystemLoadSaveManagerTest.java
index e6664e1e6..e91111983 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/persist/impl/FilesystemLoadSaveManagerTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/persist/impl/FilesystemLoadSaveManagerTest.java
@@ -56,6 +56,7 @@ import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.collection.Pair;
import net.shibboleth.shared.logic.ConstraintViolationException;
+ at SuppressWarnings("javadoc")
public class FilesystemLoadSaveManagerTest extends XMLObjectBaseTestCase {
private Logger log = LoggerFactory.getLogger(FilesystemLoadSaveManagerTest.class);
@@ -336,11 +337,6 @@ public class FilesystemLoadSaveManagerTest extends XMLObjectBaseTestCase {
new FilesystemLoadSaveManager<>(" ");
}
- @Test(expectedExceptions=ConstraintViolationException.class)
- public void ctorNullFile() {
- new FilesystemLoadSaveManager<>((File)null);
- }
-
@Test(expectedExceptions=ConstraintViolationException.class)
public void ctorRelativeDir() {
new FilesystemLoadSaveManager<>("my/relative/dir");
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSBase64BinaryTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSBase64BinaryTest.java
index ea517ae0a..74e4e11cc 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSBase64BinaryTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSBase64BinaryTest.java
@@ -60,7 +60,7 @@ public class XSBase64BinaryTest extends XMLObjectBaseTestCase {
XSBase64Binary xsb64b = xsb64bBuilder.buildObject(expectedXMLObjectQName, XSBase64Binary.TYPE_NAME);
xsb64b.setValue(expectedValue);
- Marshaller marshaller = marshallerFactory.getMarshaller(xsb64b);
+ Marshaller marshaller = marshallerFactory.ensureMarshaller(xsb64b);
marshaller.marshall(xsb64b);
Document document = parserPool.parse(XSBase64BinaryTest.class.getResourceAsStream(testDocumentLocation));
@@ -77,7 +77,7 @@ public class XSBase64BinaryTest extends XMLObjectBaseTestCase {
public void testUnmarshall() throws XMLParserException, UnmarshallingException{
Document document = parserPool.parse(XSBase64BinaryTest.class.getResourceAsStream(testDocumentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
XSBase64Binary xsb64b = (XSBase64Binary) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(xsb64b.getElementQName(), expectedXMLObjectQName, "Unexpected XSBase64Binary QName");
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSBooleanTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSBooleanTest.java
index 82979e148..a4a077318 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSBooleanTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSBooleanTest.java
@@ -41,13 +41,13 @@ public class XSBooleanTest extends XMLObjectBaseTestCase {
private String testDocumentLocation;
private QName expectedXMLObjectQName;
- private String expectedValue;
+ private XSBooleanValue expectedValue;
@BeforeMethod
protected void setUp() throws Exception{
testDocumentLocation = "/org/opensaml/core/xml/schema/impl/xsBoolean.xml";
expectedXMLObjectQName = new QName("urn:example.org:foo", "bar", "foo");
- expectedValue = "true";
+ expectedValue = XSBooleanValue.valueOf("true");
}
/**
@@ -59,9 +59,9 @@ public class XSBooleanTest extends XMLObjectBaseTestCase {
public void testMarshall() throws MarshallingException, XMLParserException{
XMLObjectBuilder<XSBoolean> xsbBuilder = builderFactory.ensureBuilder(XSBoolean.TYPE_NAME);
XSBoolean xsBoolean = xsbBuilder.buildObject(expectedXMLObjectQName, XSBoolean.TYPE_NAME);
- xsBoolean.setValue(XSBooleanValue.valueOf(expectedValue));
+ xsBoolean.setValue(expectedValue);
- Marshaller marshaller = marshallerFactory.getMarshaller(xsBoolean);
+ Marshaller marshaller = marshallerFactory.ensureMarshaller(xsBoolean);
marshaller.marshall(xsBoolean);
Document document = parserPool.parse(XSBooleanTest.class.getResourceAsStream(testDocumentLocation));
@@ -78,11 +78,11 @@ public class XSBooleanTest extends XMLObjectBaseTestCase {
public void testUnmarshall() throws XMLParserException, UnmarshallingException{
Document document = parserPool.parse(XSBooleanTest.class.getResourceAsStream(testDocumentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
XSBoolean xsBoolean = (XSBoolean) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(xsBoolean.getElementQName(), expectedXMLObjectQName, "Unexpected XSBoolean QName");
Assert.assertEquals(xsBoolean.getSchemaType(), XSBoolean.TYPE_NAME, "Unexpected XSBoolean schema type");
- Assert.assertEquals(expectedValue, xsBoolean.getValue().toString(), "Unexpected value of XSBoolean");
+ Assert.assertEquals(expectedValue, xsBoolean.getValue(), "Unexpected value of XSBoolean");
}
}
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSDateTimeTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSDateTimeTest.java
index f2d95cbcb..37e009888 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSDateTimeTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSDateTimeTest.java
@@ -65,7 +65,7 @@ public class XSDateTimeTest extends XMLObjectBaseTestCase {
XSDateTime xsDateTime = xsdtBuilder.buildObject(expectedXMLObjectQName, XSDateTime.TYPE_NAME);
xsDateTime.setValue(expectedValue);
- Marshaller marshaller = marshallerFactory.getMarshaller(xsDateTime);
+ Marshaller marshaller = marshallerFactory.ensureMarshaller(xsDateTime);
marshaller.marshall(xsDateTime);
Document document = parserPool.parse(XSDateTimeTest.class.getResourceAsStream(testDocumentLocation));
@@ -84,7 +84,7 @@ public class XSDateTimeTest extends XMLObjectBaseTestCase {
Document document = parserPool.parse(XSDateTimeTest.class.getResourceAsStream(testDocumentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
XSDateTime xsDateTime = (XSDateTime) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(xsDateTime.getElementQName(), expectedXMLObjectQName, "Unexpected XSDate QName");
@@ -105,7 +105,7 @@ public class XSDateTimeTest extends XMLObjectBaseTestCase {
Document document = parserPool.parse(XSDateTimeTest.class.getResourceAsStream(testDocumentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
XSDateTime xsDateTime = (XSDateTime) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(xsDateTime.getElementQName(), expectedXMLObjectQName, "Unexpected XSDate QName");
@@ -127,7 +127,7 @@ public class XSDateTimeTest extends XMLObjectBaseTestCase {
Document document = parserPool.parse(XSDateTimeTest.class.getResourceAsStream(testDocumentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
XSDateTime xsDateTime = (XSDateTime) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(xsDateTime.getElementQName(), expectedXMLObjectQName, "Unexpected XSDate QName");
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSIntegerTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSIntegerTest.java
index aebca0954..342c62591 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSIntegerTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSIntegerTest.java
@@ -61,7 +61,7 @@ public class XSIntegerTest extends XMLObjectBaseTestCase {
XSInteger xsInteger = xsintBuilder.buildObject(expectedXMLObjectQName, XSInteger.TYPE_NAME);
xsInteger.setValue(expectedValue);
- Marshaller marshaller = marshallerFactory.getMarshaller(xsInteger);
+ Marshaller marshaller = marshallerFactory.ensureMarshaller(xsInteger);
marshaller.marshall(xsInteger);
Document document = parserPool.parse(XSIntegerTest.class.getResourceAsStream(testDocumentLocation));
@@ -78,7 +78,7 @@ public class XSIntegerTest extends XMLObjectBaseTestCase {
public void testUnmarshall() throws XMLParserException, UnmarshallingException{
Document document = parserPool.parse(XSIntegerTest.class.getResourceAsStream(testDocumentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
XSInteger xsInteger = (XSInteger) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(xsInteger.getElementQName(), expectedXMLObjectQName, "Unexpected XSInteger QName");
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSQNameTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSQNameTest.java
index e6067731b..d667afeb4 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSQNameTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSQNameTest.java
@@ -61,7 +61,7 @@ public class XSQNameTest extends XMLObjectBaseTestCase {
XSQName xsQName = xsQNameBuilder.buildObject(expectedXMLObjectQName, XSQName.TYPE_NAME);
xsQName.setValue(expectedValue);
- Marshaller marshaller = marshallerFactory.getMarshaller(xsQName);
+ Marshaller marshaller = marshallerFactory.ensureMarshaller(xsQName);
marshaller.marshall(xsQName);
Document document = parserPool.parse(XSQNameTest.class.getResourceAsStream(testDocumentLocation));
@@ -78,7 +78,7 @@ public class XSQNameTest extends XMLObjectBaseTestCase {
public void testUnmarshall() throws XMLParserException, UnmarshallingException{
Document document = parserPool.parse(XSQNameTest.class.getResourceAsStream(testDocumentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
XSQName xsQName = (XSQName) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(xsQName.getElementQName(), expectedXMLObjectQName, "Unexpected XSQName QName");
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSStringTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSStringTest.java
index 040fb3482..c116f6e29 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSStringTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSStringTest.java
@@ -61,7 +61,7 @@ public class XSStringTest extends XMLObjectBaseTestCase {
XSString xsString = xssBuilder.buildObject(expectedXMLObjectQName, XSString.TYPE_NAME);
xsString.setValue(expectedValue);
- Marshaller marshaller = marshallerFactory.getMarshaller(xsString);
+ Marshaller marshaller = marshallerFactory.ensureMarshaller(xsString);
marshaller.marshall(xsString);
Document document = parserPool.parse(XSStringTest.class.getResourceAsStream(testDocumentLocation));
@@ -78,7 +78,7 @@ public class XSStringTest extends XMLObjectBaseTestCase {
public void testUnmarshall() throws XMLParserException, UnmarshallingException{
Document document = parserPool.parse(XSStringTest.class.getResourceAsStream(testDocumentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
XSString xsString = (XSString) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(xsString.getElementQName(), expectedXMLObjectQName, "Unexpected XSString QName");
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSURITest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSURITest.java
index 503995a9d..f52a79ce9 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSURITest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/schema/impl/XSURITest.java
@@ -61,7 +61,7 @@ public class XSURITest extends XMLObjectBaseTestCase {
XSURI xsURI = uriBuilder.buildObject(expectedXMLObjectQName, XSURI.TYPE_NAME);
xsURI.setURI(expectedValue);
- Marshaller marshaller = marshallerFactory.getMarshaller(xsURI);
+ Marshaller marshaller = marshallerFactory.ensureMarshaller(xsURI);
marshaller.marshall(xsURI);
Document document = parserPool.parse(XSURITest.class.getResourceAsStream(testDocumentLocation));
@@ -78,7 +78,7 @@ public class XSURITest extends XMLObjectBaseTestCase {
public void testUnmarshall() throws XMLParserException, UnmarshallingException{
Document document = parserPool.parse(XSURITest.class.getResourceAsStream(testDocumentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
XSURI xsURI = (XSURI) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(xsURI.getElementQName(), expectedXMLObjectQName, "Unexpected XSURI QName");
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/ElementProxyTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/ElementProxyTest.java
index bc5614dc4..205c19887 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/ElementProxyTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/ElementProxyTest.java
@@ -19,6 +19,9 @@ package org.opensaml.core.xml.tests;
import org.testng.annotations.Test;
import org.testng.Assert;
+
+import java.util.List;
+
import org.opensaml.core.testing.XMLObjectBaseTestCase;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
@@ -43,12 +46,18 @@ public class ElementProxyTest extends XMLObjectBaseTestCase {
String documentLocation = "/org/opensaml/core/xml/UnknownContent.xml";
Document document = parserPool.parse(UnmarshallingTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(XMLObjectProviderRegistrySupport.getDefaultProviderQName());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(XMLObjectProviderRegistrySupport.getDefaultProviderQName());
XMLObject xmlobject = unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(xmlobject.getElementQName().getLocalPart(), "products", "Unexpted root element name");
- Assert.assertEquals(xmlobject.getOrderedChildren().size(), 2, "Unexpected number of children");
- Assert.assertEquals(((XSAny) xmlobject.getOrderedChildren().get(1).getOrderedChildren().get(0)).getTextContent(),
+
+ final List<XMLObject> children = xmlobject.getOrderedChildren();
+ assert children != null;
+ Assert.assertEquals(children.size(), 2, "Unexpected number of children");
+
+ final List<XMLObject> nestedChildren = children.get(1).getOrderedChildren();
+ assert nestedChildren != null;
+ Assert.assertEquals(((XSAny) nestedChildren.get(0)).getTextContent(),
"<strong>XSLT Perfect IDE</strong>", "Unexpected CDATA content");
}
}
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/IDAttributeTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/IDAttributeTest.java
index ff8537f4e..71b676ef7 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/IDAttributeTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/IDAttributeTest.java
@@ -53,8 +53,9 @@ public class IDAttributeTest extends XMLObjectBaseTestCase {
*/
@Test
public void testSimpleUnmarshall() {
- SimpleXMLObject sxObject = (SimpleXMLObject) unmarshallElement("/org/opensaml/core/xml/IDAttribute.xml");
-
+ final SimpleXMLObject sxObject = (SimpleXMLObject) unmarshallElement("/org/opensaml/core/xml/IDAttribute.xml");
+ assert sxObject != null;
+
Assert.assertEquals(sxObject.resolveID("IDLevel1"), sxObject, "ID lookup failed");
Assert.assertEquals(sxObject.resolveIDFromRoot("IDLevel1"), sxObject, "ID lookup failed");
Assert.assertNull(sxObject.resolveID("NonExistent"), "Lookup of non-existent ID didn't return null");
@@ -70,9 +71,9 @@ public class IDAttributeTest extends XMLObjectBaseTestCase {
*/
@Test
public void testComplexUnmarshallInList() {
- SimpleXMLObject sxObject =
+ final SimpleXMLObject sxObject =
(SimpleXMLObject) unmarshallElement("/org/opensaml/core/xml/IDAttributeWithChildrenList.xml");
-
+ assert sxObject != null;
Assert.assertNull(sxObject.resolveID("NonExistent"), "Lookup of non-existent ID didn't return null");
Assert.assertNull(sxObject.resolveIDFromRoot("NonExistent"), "Lookup of non-existent ID didn't return null");
@@ -111,9 +112,9 @@ public class IDAttributeTest extends XMLObjectBaseTestCase {
"Lookup of non-existent ID didn't return null");
// Resolving from lower-level child to a non-ancestor object using resolveIDFromRoot.
- SimpleXMLObject sxoIDLevel4A = sxObject.getSimpleXMLObjects().get(0)
+ final SimpleXMLObject sxoIDLevel4A = sxObject.getSimpleXMLObjects().get(0)
.getSimpleXMLObjects().get(0).getSimpleXMLObjects().get(0);
- SimpleXMLObject sxoIDLevel2C = sxObject.getSimpleXMLObjects().get(3);
+ final SimpleXMLObject sxoIDLevel2C = sxObject.getSimpleXMLObjects().get(3);
Assert.assertEquals(sxoIDLevel4A.resolveIDFromRoot("IDLevel2C"), sxoIDLevel2C, "ID lookup failed");
}
@@ -124,8 +125,9 @@ public class IDAttributeTest extends XMLObjectBaseTestCase {
*/
@Test
public void testChangePropagationInList() {
- SimpleXMLObject sxObject =
+ final SimpleXMLObject sxObject =
(SimpleXMLObject) unmarshallElement("/org/opensaml/core/xml/IDAttributeWithChildrenList.xml");
+ assert sxObject != null;
// Test propagation of attribute value change up the tree
sxObject.getSimpleXMLObjects().get(1).setId("NewIDLevel2B");
@@ -161,10 +163,11 @@ public class IDAttributeTest extends XMLObjectBaseTestCase {
@Test
public void testListOpChangePropagation() {
- SimpleXMLObject sxObject =
+ final SimpleXMLObject sxObject =
(SimpleXMLObject) unmarshallElement("/org/opensaml/core/xml/IDAttributeWithChildrenList.xml");
+ assert sxObject != null;
- SimpleXMLObject targetIDLevel3B = sxObject.getSimpleXMLObjects().get(0).getSimpleXMLObjects().get(2);
+ final SimpleXMLObject targetIDLevel3B = sxObject.getSimpleXMLObjects().get(0).getSimpleXMLObjects().get(2);
Assert.assertEquals(sxObject.resolveID("IDLevel3B"), targetIDLevel3B, "ID lookup failed");
// remove(int)
@@ -183,7 +186,7 @@ public class IDAttributeTest extends XMLObjectBaseTestCase {
Assert.assertNull(sxObject.resolveID("IDLevel3B"), "Lookup of non-existent ID didn't return null");
// Ops using new object
- SimpleXMLObject newSimpleObject = (SimpleXMLObject) buildXMLObject(SimpleXMLObject.ELEMENT_NAME);
+ final SimpleXMLObject newSimpleObject = (SimpleXMLObject) buildXMLObject(SimpleXMLObject.ELEMENT_NAME);
newSimpleObject.setId("NewSimpleElement");
sxObject.getSimpleXMLObjects().get(3).getSimpleXMLObjects().add(newSimpleObject);
@@ -212,19 +215,19 @@ public class IDAttributeTest extends XMLObjectBaseTestCase {
*/
@Test
public void testAttributeMap() throws XMLParserException, UnmarshallingException{
- String documentLocation = "/org/opensaml/core/xml/IDAttributeWithAttributeMap.xml";
- Document document = parserPool.parse(IDAttributeTest.class.getResourceAsStream(documentLocation));
+ final String documentLocation = "/org/opensaml/core/xml/IDAttributeWithAttributeMap.xml";
+ final Document document = parserPool.parse(IDAttributeTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(XMLObjectProviderRegistrySupport.getDefaultProviderQName());
- XMLObject xmlobject = unmarshaller.unmarshall(document.getDocumentElement());
+ final Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(XMLObjectProviderRegistrySupport.getDefaultProviderQName());
+ final XMLObject xmlobject = unmarshaller.unmarshall(document.getDocumentElement());
- XSAny epParent = (XSAny) xmlobject;
+ final XSAny epParent = (XSAny) xmlobject;
Assert.assertNotNull(epParent, "Cast of parent to XSAny failed");
- XSAny epChild0 = (XSAny) epParent.getUnknownXMLObjects().get(0);
+ final XSAny epChild0 = (XSAny) epParent.getUnknownXMLObjects().get(0);
Assert.assertNotNull(epChild0, "Cast of child 0 to XSAny failed");
- XSAny epChild1 = (XSAny) epParent.getUnknownXMLObjects().get(1);
+ final XSAny epChild1 = (XSAny) epParent.getUnknownXMLObjects().get(1);
Assert.assertNotNull(epChild1, "Cast of child 1 to XSAny failed");
// Since not doing schema validation, etc, the parser won't register the ID type in the DOM
@@ -235,7 +238,7 @@ public class IDAttributeTest extends XMLObjectBaseTestCase {
// Now manually register the "id" attribute in the AttributeMap of child 0 as being an ID type.
// This should cause the expected ID-to-XMLObject mapping behaviour to take place.
- QName idName = QNameSupport.constructQName(null, "id", null);
+ final QName idName = QNameSupport.constructQName(null, "id", null);
epChild0.getUnknownAttributes().registerID(idName);
Assert.assertEquals(epParent.resolveID("1144"), epChild0, "Lookup of ID mapping failed");
@@ -257,21 +260,21 @@ public class IDAttributeTest extends XMLObjectBaseTestCase {
*/
@Test
public void testAttributeMapOps() throws XMLParserException, UnmarshallingException{
- String documentLocation = "/org/opensaml/core/xml/IDAttributeWithAttributeMap.xml";
- Document document = parserPool.parse(IDAttributeTest.class.getResourceAsStream(documentLocation));
+ final String documentLocation = "/org/opensaml/core/xml/IDAttributeWithAttributeMap.xml";
+ final Document document = parserPool.parse(IDAttributeTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(XMLObjectProviderRegistrySupport.getDefaultProviderQName());
+ final Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(XMLObjectProviderRegistrySupport.getDefaultProviderQName());
XMLObject xmlobject = unmarshaller.unmarshall(document.getDocumentElement());
- XSAny epParent = (XSAny) xmlobject;
+ final XSAny epParent = (XSAny) xmlobject;
Assert.assertNotNull(epParent, "Cast of parent to XSAny failed");
- XSAny epChild0 = (XSAny) epParent.getUnknownXMLObjects().get(0);
+ final XSAny epChild0 = (XSAny) epParent.getUnknownXMLObjects().get(0);
Assert.assertNotNull(epChild0, "Cast of child 0 to XSAny failed");
// Now manually register the "id" attribute in the AttributeMap of child 0 as being an ID type.
// This should cause the expected ID-to-XMLObject mapping behaviour to take place.
- QName idName = QNameSupport.constructQName(null, "id", null);
+ final QName idName = QNameSupport.constructQName(null, "id", null);
epChild0.getUnknownAttributes().registerID(idName);
Assert.assertEquals(epParent.resolveID("1144"), epChild0, "Lookup of ID mapping failed");
@@ -307,11 +310,11 @@ public class IDAttributeTest extends XMLObjectBaseTestCase {
@Test
public void testGlobalIDRegistration() throws XMLParserException, UnmarshallingException {
XMLObject xmlObject;
- QName attribQName = new QName("http://www.example.org", "id", "test");
+ final QName attribQName = new QName("http://www.example.org", "id", "test");
- String documentLocation = "/org/opensaml/core/xml/IDAttributeGlobal.xml";
+ final String documentLocation = "/org/opensaml/core/xml/IDAttributeGlobal.xml";
Document document = parserPool.parse(IDAttributeTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(XMLObjectProviderRegistrySupport.getDefaultProviderQName());
+ final Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(XMLObjectProviderRegistrySupport.getDefaultProviderQName());
// With no registration
xmlObject = unmarshaller.unmarshall(document.getDocumentElement());
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/MarshallingTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/MarshallingTest.java
index e09ccfac3..dde0193e9 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/MarshallingTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/MarshallingTest.java
@@ -22,10 +22,10 @@ import org.testng.Assert;
import javax.xml.namespace.QName;
import org.opensaml.core.testing.XMLObjectBaseTestCase;
+import org.opensaml.core.xml.XMLObjectBuilder;
import org.opensaml.core.xml.io.Marshaller;
import org.opensaml.core.xml.io.MarshallingException;
import org.opensaml.core.xml.mock.SimpleXMLObject;
-import org.opensaml.core.xml.mock.SimpleXMLObjectBuilder;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.xmlunit.builder.DiffBuilder;
@@ -55,13 +55,14 @@ public class MarshallingTest extends XMLObjectBaseTestCase {
*/
@Test
public void testMarshallingWithAttributes() throws XMLParserException {
- String expectedId = "Firefly";
- String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithAttribute.xml";
- Document expectedDocument = parserPool.parse(MarshallingTest.class
+ final String expectedId = "Firefly";
+ final String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithAttribute.xml";
+ final Document expectedDocument = parserPool.parse(MarshallingTest.class
.getResourceAsStream(expectedDocumentLocation));
- SimpleXMLObjectBuilder sxoBuilder = (SimpleXMLObjectBuilder) builderFactory.getBuilder(simpleXMLObjectQName);
- SimpleXMLObject sxObject = sxoBuilder.buildObject();
+ final XMLObjectBuilder<SimpleXMLObject> sxoBuilder =
+ (XMLObjectBuilder<SimpleXMLObject>) builderFactory.<SimpleXMLObject>ensureBuilder(simpleXMLObjectQName);
+ final SimpleXMLObject sxObject = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
sxObject.setId(expectedId);
assertXMLEquals(expectedDocument, sxObject);
@@ -75,26 +76,26 @@ public class MarshallingTest extends XMLObjectBaseTestCase {
*/
@Test
public void testMarshallingWithElementContent() throws XMLParserException {
- String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithContent.xml";
- Document expectedDocument = parserPool.parse(MarshallingTest.class
+ final String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithContent.xml";
+ final Document expectedDocument = parserPool.parse(MarshallingTest.class
.getResourceAsStream(expectedDocumentLocation));
- SimpleXMLObjectBuilder sxoBuilder = (SimpleXMLObjectBuilder) builderFactory.getBuilder(simpleXMLObjectQName);
+ final XMLObjectBuilder<SimpleXMLObject> sxoBuilder =
+ (XMLObjectBuilder<SimpleXMLObject>) builderFactory.<SimpleXMLObject>ensureBuilder(simpleXMLObjectQName);
+ final SimpleXMLObject sxObject = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
- SimpleXMLObject sxObject = sxoBuilder.buildObject();
-
- SimpleXMLObject child1 = sxoBuilder.buildObject();
+ final SimpleXMLObject child1 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
child1.setValue("Content1");
sxObject.getSimpleXMLObjects().add(child1);
- SimpleXMLObject child2 = sxoBuilder.buildObject();
+ final SimpleXMLObject child2 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
child2.setValue("Content2");
sxObject.getSimpleXMLObjects().add(child2);
- SimpleXMLObject child3 = sxoBuilder.buildObject();
+ final SimpleXMLObject child3 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
sxObject.getSimpleXMLObjects().add(child3);
- SimpleXMLObject grandchild1 = sxoBuilder.buildObject();
+ final SimpleXMLObject grandchild1 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
grandchild1.setValue("Content3");
child3.getSimpleXMLObjects().add(grandchild1);
@@ -110,14 +111,15 @@ public class MarshallingTest extends XMLObjectBaseTestCase {
*/
@Test
public void testMarshallingWithChildElements() throws XMLParserException, MarshallingException {
- String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithChildren.xml";
- Document expectedDocument = parserPool.parse(MarshallingTest.class
+ final String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithChildren.xml";
+ final Document expectedDocument = parserPool.parse(MarshallingTest.class
.getResourceAsStream(expectedDocumentLocation));
- SimpleXMLObjectBuilder sxoBuilder = (SimpleXMLObjectBuilder) builderFactory.getBuilder(simpleXMLObjectQName);
- SimpleXMLObject sxObject = sxoBuilder.buildObject();
- SimpleXMLObject sxObjectChild1 = sxoBuilder.buildObject();
- SimpleXMLObject sxObjectChild2 = sxoBuilder.buildObject();
+ final XMLObjectBuilder<SimpleXMLObject> sxoBuilder =
+ (XMLObjectBuilder<SimpleXMLObject>) builderFactory.<SimpleXMLObject>ensureBuilder(simpleXMLObjectQName);
+ final SimpleXMLObject sxObject = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
+ final SimpleXMLObject sxObjectChild1 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
+ final SimpleXMLObject sxObjectChild2 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
sxObject.getSimpleXMLObjects().add(sxObjectChild1);
sxObject.getSimpleXMLObjects().add(sxObjectChild2);
@@ -133,26 +135,27 @@ public class MarshallingTest extends XMLObjectBaseTestCase {
*/
@Test
public void testMarshallingXMLFragment() throws XMLParserException, MarshallingException {
- String expectedDocumentLocation = "/org/opensaml/core/xml/SOAPMessageWithContent.xml";
- String soapDocLocation = "/org/opensaml/core/xml/SOAPMessage.xml";
+ final String expectedDocumentLocation = "/org/opensaml/core/xml/SOAPMessageWithContent.xml";
+ final String soapDocLocation = "/org/opensaml/core/xml/SOAPMessage.xml";
Document soapDoc = parserPool.parse(MarshallingTest.class.getResourceAsStream(soapDocLocation));
Element soapBody = (Element) soapDoc.getDocumentElement().getElementsByTagNameNS(
"http://schemas.xmlsoap.org/soap/envelope/", "Body").item(0);
- SimpleXMLObjectBuilder sxoBuilder = (SimpleXMLObjectBuilder) builderFactory.getBuilder(simpleXMLObjectQName);
+ final XMLObjectBuilder<SimpleXMLObject> sxoBuilder =
+ (XMLObjectBuilder<SimpleXMLObject>) builderFactory.<SimpleXMLObject>ensureBuilder(simpleXMLObjectQName);
- SimpleXMLObject response = sxoBuilder.buildObject(SimpleXMLObject.NAMESPACE, "Response", SimpleXMLObject.NAMESPACE_PREFIX);
- SimpleXMLObject statement = sxoBuilder.buildObject(SimpleXMLObject.NAMESPACE, "Statement", SimpleXMLObject.NAMESPACE_PREFIX);
+ final SimpleXMLObject response = sxoBuilder.buildObject(SimpleXMLObject.NAMESPACE, "Response", SimpleXMLObject.NAMESPACE_PREFIX);
+ final SimpleXMLObject statement = sxoBuilder.buildObject(SimpleXMLObject.NAMESPACE, "Statement", SimpleXMLObject.NAMESPACE_PREFIX);
response.getSimpleXMLObjects().add(statement);
// Marshall it once so the DOM is cached
- Marshaller marshaller = marshallerFactory.getMarshaller(simpleXMLObjectQName);
+ final Marshaller marshaller = marshallerFactory.ensureMarshaller(simpleXMLObjectQName);
marshaller.marshall(response);
Assert.assertNotNull(response.getDOM(), "DOM was not cached after marshalling");
// Marshall statement (with cached DOM) into SOAP Body element child
- Document expectedDocument = parserPool.parse(MarshallingTest.class.getResourceAsStream(expectedDocumentLocation));
- Element statementElem = marshaller.marshall(statement, soapBody);
+ final Document expectedDocument = parserPool.parse(MarshallingTest.class.getResourceAsStream(expectedDocumentLocation));
+ final Element statementElem = marshaller.marshall(statement, soapBody);
final Diff diff = DiffBuilder.compare(statementElem.getOwnerDocument()).withTest(expectedDocument)
.checkForIdentical().build();
Assert.assertFalse(diff.hasDifferences(), diff.toString());
@@ -169,13 +172,13 @@ public class MarshallingTest extends XMLObjectBaseTestCase {
*/
@Test
public void testMarshallingExistingEmptyDocument() throws XMLParserException, MarshallingException {
- Document document = parserPool.newDocument();
+ final Document document = parserPool.newDocument();
Assert.assertNull(document.getDocumentElement(), "Incorrect document root");
- SimpleXMLObject sxo = (SimpleXMLObject) buildXMLObject(SimpleXMLObject.ELEMENT_NAME);
+ final SimpleXMLObject sxo = (SimpleXMLObject) buildXMLObject(SimpleXMLObject.ELEMENT_NAME);
sxo.setId("idValue");
- marshallerFactory.getMarshaller(sxo).marshall(sxo, document);
+ marshallerFactory.ensureMarshaller(sxo).marshall(sxo, document);
Assert.assertNotNull(document.getDocumentElement(), "Incorrect document root");
Assert.assertTrue(document.getDocumentElement().isSameNode(sxo.getDOM()), "Incorrect document root");
}
@@ -189,15 +192,15 @@ public class MarshallingTest extends XMLObjectBaseTestCase {
*/
@Test
public void testMarshallingReplaceDocumentRoot() throws XMLParserException, MarshallingException {
- Document document = parserPool.newDocument();
- Element element = document.createElementNS(null, "Foo");
+ final Document document = parserPool.newDocument();
+ final Element element = document.createElementNS(null, "Foo");
document.appendChild(element);
Assert.assertTrue(document.getDocumentElement().isSameNode(element), "Incorrect document root");
- SimpleXMLObject sxo = (SimpleXMLObject) buildXMLObject(SimpleXMLObject.ELEMENT_NAME);
+ final SimpleXMLObject sxo = (SimpleXMLObject) buildXMLObject(SimpleXMLObject.ELEMENT_NAME);
sxo.setId("idValue");
- marshallerFactory.getMarshaller(sxo).marshall(sxo, document);
+ marshallerFactory.ensureMarshaller(sxo).marshall(sxo, document);
Assert.assertFalse(document.getDocumentElement().isSameNode(element), "Document root should have been replaced");
Assert.assertTrue(document.getDocumentElement().isSameNode(sxo.getDOM()), "Incorrect document root");
}
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/NamespaceManagerTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/NamespaceManagerTest.java
index 6e5edbf65..064f0b21f 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/NamespaceManagerTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/NamespaceManagerTest.java
@@ -39,6 +39,7 @@ import org.opensaml.core.xml.schema.XSAny;
/**
* Test the NamespaceManger used by XMLObjects.
*/
+ at SuppressWarnings("javadoc")
public class NamespaceManagerTest extends XMLObjectBaseTestCase {
private XSAny xsAny;
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/UnmarshallingSecurityTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/UnmarshallingSecurityTest.java
index 4f0c2efcd..608a1b989 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/UnmarshallingSecurityTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/UnmarshallingSecurityTest.java
@@ -38,6 +38,7 @@ public class UnmarshallingSecurityTest extends XMLObjectBaseTestCase {
private BasicParserPool parserPoolDefaults, parserPoolInsecure;
@BeforeClass
+ /** Test setup. */
public void setup() throws ComponentInitializationException {
parserPoolDefaults = new BasicParserPool();
parserPoolDefaults.initialize();
@@ -59,7 +60,7 @@ public class UnmarshallingSecurityTest extends XMLObjectBaseTestCase {
String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithCommentInContent.xml";
Document document = parserPoolDefaults.parse(UnmarshallingSecurityTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(sxObject.getValue(), "Content1");
@@ -76,7 +77,7 @@ public class UnmarshallingSecurityTest extends XMLObjectBaseTestCase {
String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithCommentInContent.xml";
Document document = parserPoolInsecure.parse(UnmarshallingSecurityTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
unmarshaller.unmarshall(document.getDocumentElement());
}
@@ -91,7 +92,7 @@ public class UnmarshallingSecurityTest extends XMLObjectBaseTestCase {
String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithCDATAInContent.xml";
Document document = parserPoolDefaults.parse(UnmarshallingSecurityTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(sxObject.getValue(), "Content1");
@@ -108,7 +109,7 @@ public class UnmarshallingSecurityTest extends XMLObjectBaseTestCase {
String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithCDATAInContent.xml";
Document document = parserPoolInsecure.parse(UnmarshallingSecurityTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
unmarshaller.unmarshall(document.getDocumentElement());
}
@@ -123,7 +124,7 @@ public class UnmarshallingSecurityTest extends XMLObjectBaseTestCase {
String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithCommentBetweenChildren.xml";
Document document = parserPoolDefaults.parse(UnmarshallingSecurityTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(sxObject.getSimpleXMLObjects().size(), 2, "Number of children elements was not expected value");
@@ -140,7 +141,7 @@ public class UnmarshallingSecurityTest extends XMLObjectBaseTestCase {
String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithCommentBetweenChildren.xml";
Document document = parserPoolInsecure.parse(UnmarshallingSecurityTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
unmarshaller.unmarshall(document.getDocumentElement());
}
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/UnmarshallingTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/UnmarshallingTest.java
index 38dd1404c..1d9efa628 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/UnmarshallingTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/UnmarshallingTest.java
@@ -53,7 +53,7 @@ public class UnmarshallingTest extends XMLObjectBaseTestCase {
String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithAttribute.xml";
Document document = parserPool.parse(UnmarshallingTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertNotNull(sxObject.getDOM(), "DOM was not cached after unmarshalling");
@@ -71,7 +71,7 @@ public class UnmarshallingTest extends XMLObjectBaseTestCase {
String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithContent.xml";
Document document = parserPool.parse(UnmarshallingTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertNotNull(sxObject.getDOM(), "DOM was not cached after unmarshalling");
@@ -106,7 +106,7 @@ public class UnmarshallingTest extends XMLObjectBaseTestCase {
String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithChildren.xml";
Document document = parserPool.parse(UnmarshallingTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertNotNull(sxObject.getDOM(), "DOM was not cached after unmarshalling");
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/XMLObjectXSIAttribsTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/XMLObjectXSIAttribsTest.java
index 210a29a57..724c296a8 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/XMLObjectXSIAttribsTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/tests/XMLObjectXSIAttribsTest.java
@@ -22,6 +22,7 @@ import org.testng.Assert;
import javax.xml.namespace.QName;
import org.opensaml.core.testing.XMLObjectBaseTestCase;
+import org.opensaml.core.xml.XMLObjectBuilder;
import org.opensaml.core.xml.io.Unmarshaller;
import org.opensaml.core.xml.io.UnmarshallingException;
import org.opensaml.core.xml.mock.SimpleXMLObject;
@@ -33,6 +34,7 @@ import net.shibboleth.shared.xml.XMLParserException;
/**
* Test support for attributes from the XML Schema Instance namespace.
*/
+ at SuppressWarnings("javadoc")
public class XMLObjectXSIAttribsTest extends XMLObjectBaseTestCase {
/** QName for SimpleXMLObject. */
@@ -40,18 +42,16 @@ public class XMLObjectXSIAttribsTest extends XMLObjectBaseTestCase {
/** Constructor. */
public XMLObjectXSIAttribsTest() {
- super();
-
simpleXMLObjectQName = new QName(SimpleXMLObject.NAMESPACE, SimpleXMLObject.LOCAL_NAME);
}
@Test
public void testUnmarshallNoNil() throws XMLParserException, UnmarshallingException {
- String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithAttribute.xml";
- Document document = parserPool.parse(XMLObjectXSIAttribsTest.class.getResourceAsStream(documentLocation));
+ final String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectWithAttribute.xml";
+ final Document document = parserPool.parse(XMLObjectXSIAttribsTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
- SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
+ final Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
+ final SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertNull(sxObject.isNilXSBoolean());
Assert.assertFalse(sxObject.isNil(), "Expected isNil() false");
@@ -62,7 +62,7 @@ public class XMLObjectXSIAttribsTest extends XMLObjectBaseTestCase {
String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectNil.xml";
Document document = parserPool.parse(XMLObjectXSIAttribsTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
+ Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertNotNull(sxObject.isNilXSBoolean());
@@ -71,12 +71,13 @@ public class XMLObjectXSIAttribsTest extends XMLObjectBaseTestCase {
@Test
public void testMarshallNil() throws XMLParserException {
- String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectNil.xml";
- Document expectedDocument = parserPool.parse(XMLObjectXSIAttribsTest.class
+ final String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectNil.xml";
+ final Document expectedDocument = parserPool.parse(XMLObjectXSIAttribsTest.class
.getResourceAsStream(expectedDocumentLocation));
- SimpleXMLObjectBuilder sxoBuilder = (SimpleXMLObjectBuilder) builderFactory.getBuilder(simpleXMLObjectQName);
- SimpleXMLObject sxObject = sxoBuilder.buildObject();
+ final XMLObjectBuilder<SimpleXMLObject> sxoBuilder =
+ (XMLObjectBuilder<SimpleXMLObject>) builderFactory.<SimpleXMLObject>ensureBuilder(simpleXMLObjectQName);
+ final SimpleXMLObject sxObject = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
sxObject.setNil(true);
assertXMLEquals(expectedDocument, sxObject);
@@ -84,25 +85,26 @@ public class XMLObjectXSIAttribsTest extends XMLObjectBaseTestCase {
@Test
public void testUnmarshallSchemaLocation() throws XMLParserException, UnmarshallingException {
- String expectedValue = "http://www.example.com/Test http://www.example.com/Test.xsd";
- String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectSchemaLocation.xml";
- Document document = parserPool.parse(XMLObjectXSIAttribsTest.class.getResourceAsStream(documentLocation));
+ final String expectedValue = "http://www.example.com/Test http://www.example.com/Test.xsd";
+ final String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectSchemaLocation.xml";
+ final Document document = parserPool.parse(XMLObjectXSIAttribsTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
- SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
+ final Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
+ final SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(sxObject.getSchemaLocation(), expectedValue, "Incorrect xsi:schemaLocation value");
}
@Test
public void testMarshallSchemaLocation() throws XMLParserException {
- String expectedValue = "http://www.example.com/Test http://www.example.com/Test.xsd";
- String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectSchemaLocation.xml";
- Document expectedDocument = parserPool.parse(XMLObjectXSIAttribsTest.class
+ final String expectedValue = "http://www.example.com/Test http://www.example.com/Test.xsd";
+ final String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectSchemaLocation.xml";
+ final Document expectedDocument = parserPool.parse(XMLObjectXSIAttribsTest.class
.getResourceAsStream(expectedDocumentLocation));
- SimpleXMLObjectBuilder sxoBuilder = (SimpleXMLObjectBuilder) builderFactory.getBuilder(simpleXMLObjectQName);
- SimpleXMLObject sxObject = sxoBuilder.buildObject();
+ final XMLObjectBuilder<SimpleXMLObject> sxoBuilder =
+ (XMLObjectBuilder<SimpleXMLObject>) builderFactory.<SimpleXMLObject>ensureBuilder(simpleXMLObjectQName);
+ final SimpleXMLObject sxObject = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
sxObject.setSchemaLocation(expectedValue);
assertXMLEquals(expectedDocument, sxObject);
@@ -110,25 +112,26 @@ public class XMLObjectXSIAttribsTest extends XMLObjectBaseTestCase {
@Test
public void testUnmarshallNoNamespaceSchemaLocation() throws XMLParserException, UnmarshallingException {
- String expectedValue = "http://www.example.com/Test.xsd";
- String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectNoNamespaceSchemaLocation.xml";
- Document document = parserPool.parse(XMLObjectXSIAttribsTest.class.getResourceAsStream(documentLocation));
+ final String expectedValue = "http://www.example.com/Test.xsd";
+ final String documentLocation = "/org/opensaml/core/xml/SimpleXMLObjectNoNamespaceSchemaLocation.xml";
+ final Document document = parserPool.parse(XMLObjectXSIAttribsTest.class.getResourceAsStream(documentLocation));
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(document.getDocumentElement());
- SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
+ final Unmarshaller unmarshaller = unmarshallerFactory.ensureUnmarshaller(document.getDocumentElement());
+ final SimpleXMLObject sxObject = (SimpleXMLObject) unmarshaller.unmarshall(document.getDocumentElement());
Assert.assertEquals(sxObject.getNoNamespaceSchemaLocation(), expectedValue, "Incorrect xsi:noNamespaceSchemaLocation value");
}
@Test
public void testMarshallNoNamespaceSchemaLocation() throws XMLParserException {
- String expectedValue = "http://www.example.com/Test.xsd";
- String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectNoNamespaceSchemaLocation.xml";
- Document expectedDocument = parserPool.parse(XMLObjectXSIAttribsTest.class
+ final String expectedValue = "http://www.example.com/Test.xsd";
+ final String expectedDocumentLocation = "/org/opensaml/core/xml/SimpleXMLObjectNoNamespaceSchemaLocation.xml";
+ final Document expectedDocument = parserPool.parse(XMLObjectXSIAttribsTest.class
.getResourceAsStream(expectedDocumentLocation));
- SimpleXMLObjectBuilder sxoBuilder = (SimpleXMLObjectBuilder) builderFactory.getBuilder(simpleXMLObjectQName);
- SimpleXMLObject sxObject = sxoBuilder.buildObject();
+ final XMLObjectBuilder<SimpleXMLObject> sxoBuilder =
+ (XMLObjectBuilder<SimpleXMLObject>) builderFactory.<SimpleXMLObject>ensureBuilder(simpleXMLObjectQName);
+ final SimpleXMLObject sxObject = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
sxObject.setNoNamespaceSchemaLocation(expectedValue);
assertXMLEquals(expectedDocument, sxObject);
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/IndexedXMLObjectChildrenListTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/IndexedXMLObjectChildrenListTest.java
index c154f2bbd..bba3bc040 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/IndexedXMLObjectChildrenListTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/IndexedXMLObjectChildrenListTest.java
@@ -47,23 +47,23 @@ public class IndexedXMLObjectChildrenListTest {
*/
@Test
public void testAdd() {
- SimpleXMLObject parentObject = sxoBuilder.buildObject();
- IndexedXMLObjectChildrenList<SimpleXMLObject> indexedList = new IndexedXMLObjectChildrenList<>(
+ final SimpleXMLObject parentObject = sxoBuilder.buildObject();
+ final IndexedXMLObjectChildrenList<SimpleXMLObject> indexedList = new IndexedXMLObjectChildrenList<>(
parentObject);
- SimpleXMLObject child1 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME, type1);
+ final SimpleXMLObject child1 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME, type1);
indexedList.add(child1);
Assert.assertEquals(indexedList.get(
child1.getElementQName()).size(), 1, "List gotten by element QName index should have had 1 element");
- Assert.assertEquals(indexedList.get(
- child1.getSchemaType()).size(), 1, "List gotten by type QName index should have had 1 element");
+ final QName type = child1.getSchemaType();
+ assert type != null;
+ Assert.assertEquals(indexedList.get(type).size(), 1, "List gotten by type QName index should have had 1 element");
- SimpleXMLObject child2 = sxoBuilder.buildObject();
+ final SimpleXMLObject child2 = sxoBuilder.buildObject();
indexedList.add(child2);
Assert.assertEquals(indexedList.get(
child1.getElementQName()).size(), 2, "List gotten by element QName index should have had 1 element");
- Assert.assertEquals(indexedList.get(
- child1.getSchemaType()).size(), 1, "List gotten by type QName index should have had 1 element");
+ Assert.assertEquals(indexedList.get(type).size(), 1, "List gotten by type QName index should have had 1 element");
}
/**
@@ -71,20 +71,22 @@ public class IndexedXMLObjectChildrenListTest {
*/
@Test
public void testSet() {
- SimpleXMLObject parentObject = sxoBuilder.buildObject();
- IndexedXMLObjectChildrenList<SimpleXMLObject> indexedList = new IndexedXMLObjectChildrenList<>(
+ final SimpleXMLObject parentObject = sxoBuilder.buildObject();
+ final IndexedXMLObjectChildrenList<SimpleXMLObject> indexedList = new IndexedXMLObjectChildrenList<>(
parentObject);
- SimpleXMLObject child1 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME, type1);
+ final SimpleXMLObject child1 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME, type1);
indexedList.add(child1);
- SimpleXMLObject child2 = sxoBuilder.buildObject();
+ final SimpleXMLObject child2 = sxoBuilder.buildObject();
indexedList.set(0, child2);
+ final QName type = child1.getSchemaType();
+ assert type != null;
+
Assert.assertEquals(indexedList.get(
child1.getElementQName()).size(), 1, "List gotten by element QName index should have had 1 element");
- Assert.assertTrue(indexedList.get(
- child1.getSchemaType()).isEmpty(), "List gotten by type QName index should have been empty");
+ Assert.assertTrue(indexedList.get(type).isEmpty(), "List gotten by type QName index should have been empty");
}
/**
@@ -92,21 +94,23 @@ public class IndexedXMLObjectChildrenListTest {
*/
@Test
public void testRemove() {
- SimpleXMLObject parentObject = sxoBuilder.buildObject();
- IndexedXMLObjectChildrenList<SimpleXMLObject> indexedList = new IndexedXMLObjectChildrenList<>(
+ final SimpleXMLObject parentObject = sxoBuilder.buildObject();
+ final IndexedXMLObjectChildrenList<SimpleXMLObject> indexedList = new IndexedXMLObjectChildrenList<>(
parentObject);
- SimpleXMLObject child1 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME, type1);
+ final SimpleXMLObject child1 = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME, type1);
indexedList.add(child1);
- SimpleXMLObject child2 = sxoBuilder.buildObject();
+ final SimpleXMLObject child2 = sxoBuilder.buildObject();
indexedList.add(child2);
+ final QName type = child1.getSchemaType();
+ assert type != null;
+
indexedList.remove(child1);
Assert.assertEquals(indexedList.get(
child1.getElementQName()).size(), 1, "List gotten by element QName index should have had 1 element");
- Assert.assertTrue(indexedList.get(
- child1.getSchemaType()).isEmpty(), "List gotten by type QName index should have been empty");
+ Assert.assertTrue(indexedList.get(type).isEmpty(), "List gotten by type QName index should have been empty");
}
/**
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectChildrenListTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectChildrenListTest.java
index ea51ec0a3..9d34c3437 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectChildrenListTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectChildrenListTest.java
@@ -93,6 +93,7 @@ public class XMLObjectChildrenListTest {
SimpleXMLObject child2 = sxoBuilder.buildObject();
SimpleXMLObject replacedChild = objectList.set(0, child2);
+ assert replacedChild != null;
Assert.assertEquals(objectList.size(), 1,
"XMLObject list was supposed to have 1 element but instead had " + objectList.size());
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectSourceTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectSourceTest.java
index 2e6317d1a..8b9e27c19 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectSourceTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectSourceTest.java
@@ -52,13 +52,6 @@ public class XMLObjectSourceTest {
@Test
public void testBadCtorParams() {
- try {
- new XMLObjectSource(null);
- Assert.fail("Should have failed ctor with null arg");
- } catch (Exception e){
- // expected, do nothing
- }
-
try {
new XMLObjectSource(new byte[] { } );
Assert.fail("Should have failed ctor with 0 lenght array");
diff --git a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectSupportTest.java b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectSupportTest.java
index 42e8b8fcc..d873f24d1 100644
--- a/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectSupportTest.java
+++ b/opensaml-core-impl/src/test/java/org/opensaml/core/xml/util/tests/XMLObjectSupportTest.java
@@ -20,12 +20,11 @@ package org.opensaml.core.xml.util.tests;
import javax.xml.namespace.QName;
import org.opensaml.core.testing.XMLObjectBaseTestCase;
+import org.opensaml.core.xml.XMLObjectBuilder;
import org.opensaml.core.xml.XMLRuntimeException;
-import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
import org.opensaml.core.xml.io.MarshallingException;
import org.opensaml.core.xml.io.UnmarshallingException;
import org.opensaml.core.xml.mock.SimpleXMLObject;
-import org.opensaml.core.xml.mock.SimpleXMLObjectBuilder;
import org.opensaml.core.xml.schema.XSString;
import org.opensaml.core.xml.util.XMLObjectSupport;
import org.opensaml.core.xml.util.XMLObjectSupport.CloneOutputOption;
@@ -42,13 +41,13 @@ public class XMLObjectSupportTest extends XMLObjectBaseTestCase {
/** Tests cloning an XMLObject. */
@Test
public void testXMLObjectCloneWithDropDOM() {
- SimpleXMLObjectBuilder sxoBuilder = (SimpleXMLObjectBuilder) XMLObjectProviderRegistrySupport.getBuilderFactory()
- .getBuilder(SimpleXMLObject.ELEMENT_NAME);
-
- SimpleXMLObject origChildObj = sxoBuilder.buildObject();
+ final XMLObjectBuilder<SimpleXMLObject> sxoBuilder =
+ (XMLObjectBuilder<SimpleXMLObject>) builderFactory.<SimpleXMLObject>ensureBuilder(simpleXMLObjectQName);
+ final SimpleXMLObject origChildObj = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
+
origChildObj.setValue("FooBarBaz");
- SimpleXMLObject origParentObj = sxoBuilder.buildObject();
+ final SimpleXMLObject origParentObj = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
origParentObj.getSimpleXMLObjects().add(origChildObj);
SimpleXMLObject clonedParentObj = null;
@@ -61,6 +60,7 @@ public class XMLObjectSupportTest extends XMLObjectBaseTestCase {
}
Assert.assertFalse(origParentObj == clonedParentObj, "Parent XMLObjects were the same reference");
+ assert clonedParentObj != null;
Assert.assertNull(clonedParentObj.getDOM(), "Cloned parent DOM node was not null");
Assert.assertFalse(clonedParentObj.getSimpleXMLObjects().isEmpty(), "Cloned parent had no children");
@@ -75,13 +75,13 @@ public class XMLObjectSupportTest extends XMLObjectBaseTestCase {
/** Tests cloning an XMLObject. */
@Test
public void testXMLObjectCloneWithUnrootedDOM() {
- SimpleXMLObjectBuilder sxoBuilder = (SimpleXMLObjectBuilder) XMLObjectProviderRegistrySupport.getBuilderFactory()
- .getBuilder(SimpleXMLObject.ELEMENT_NAME);
+ final XMLObjectBuilder<SimpleXMLObject> sxoBuilder =
+ (XMLObjectBuilder<SimpleXMLObject>) builderFactory.<SimpleXMLObject>ensureBuilder(simpleXMLObjectQName);
- SimpleXMLObject origChildObj = sxoBuilder.buildObject();
+ final SimpleXMLObject origChildObj = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
origChildObj.setValue("FooBarBaz");
- SimpleXMLObject origParentObj = sxoBuilder.buildObject();
+ final SimpleXMLObject origParentObj = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
origParentObj.getSimpleXMLObjects().add(origChildObj);
SimpleXMLObject clonedParentObj = null;
@@ -93,9 +93,13 @@ public class XMLObjectSupportTest extends XMLObjectBaseTestCase {
Assert.fail("Object cloning failed on unmarshalling: " + e.getMessage());
}
+ final Element preCloneElement = origParentObj.getDOM();
+ assert preCloneElement != null;
+ assert clonedParentObj != null;
+
Assert.assertFalse(origParentObj == clonedParentObj, "Parent XMLObjects were the same reference");
Assert.assertNotNull(clonedParentObj.getDOM(), "Cloned parent DOM node was null");
- Assert.assertFalse(origParentObj.getDOM().isSameNode(clonedParentObj.getDOM()),
+ Assert.assertFalse(preCloneElement.isSameNode(clonedParentObj.getDOM()),
"Parent DOM node was not cloned properly");
Assert.assertFalse(clonedParentObj.getSimpleXMLObjects().isEmpty(), "Cloned parent had no children");
@@ -103,7 +107,7 @@ public class XMLObjectSupportTest extends XMLObjectBaseTestCase {
Assert.assertFalse(origChildObj == clonedChildObj, "Child XMLObjects were the same reference");
Assert.assertNotNull(clonedChildObj.getDOM(), "Cloned child DOM node was null");
- Assert.assertFalse(origChildObj.getDOM().isSameNode(clonedChildObj.getDOM()),
+ Assert.assertFalse(preCloneElement.isSameNode(clonedChildObj.getDOM()),
"Child DOM node was not cloned properly");
Assert.assertEquals(clonedChildObj.getValue(), "FooBarBaz", "Text content of child was not the expected value");
@@ -112,13 +116,13 @@ public class XMLObjectSupportTest extends XMLObjectBaseTestCase {
/** Tests cloning an XMLObject. */
@Test
public void testXMLObjectCloneWithRootInNewDocument() {
- SimpleXMLObjectBuilder sxoBuilder = (SimpleXMLObjectBuilder) XMLObjectProviderRegistrySupport.getBuilderFactory()
- .getBuilder(SimpleXMLObject.ELEMENT_NAME);
+ final XMLObjectBuilder<SimpleXMLObject> sxoBuilder =
+ (XMLObjectBuilder<SimpleXMLObject>) builderFactory.<SimpleXMLObject>ensureBuilder(simpleXMLObjectQName);
- SimpleXMLObject origChildObj = sxoBuilder.buildObject();
+ final SimpleXMLObject origChildObj = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
origChildObj.setValue("FooBarBaz");
- SimpleXMLObject origParentObj = sxoBuilder.buildObject();
+ final SimpleXMLObject origParentObj = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
origParentObj.getSimpleXMLObjects().add(origChildObj);
SimpleXMLObject clonedParentObj = null;
@@ -130,9 +134,16 @@ public class XMLObjectSupportTest extends XMLObjectBaseTestCase {
Assert.fail("Object cloning failed on unmarshalling: " + e.getMessage());
}
+ final Element preCloneElement = origParentObj.getDOM();
+ assert preCloneElement != null;
+
+ assert clonedParentObj != null;
+ final Element clonedElement = clonedParentObj.getDOM();
+ assert clonedElement != null;
+
Assert.assertFalse(origParentObj == clonedParentObj, "Parent XMLObjects were the same reference");
Assert.assertNotNull(clonedParentObj.getDOM(), "Cloned parent DOM node was null");
- Assert.assertFalse(origParentObj.getDOM().isSameNode(clonedParentObj.getDOM()),
+ Assert.assertFalse(preCloneElement.isSameNode(clonedParentObj.getDOM()),
"Parent DOM node was not cloned properly");
Assert.assertFalse(clonedParentObj.getSimpleXMLObjects().isEmpty(), "Cloned parent had no children");
@@ -140,27 +151,27 @@ public class XMLObjectSupportTest extends XMLObjectBaseTestCase {
Assert.assertFalse(origChildObj == clonedChildObj, "Child XMLObjects were the same reference");
Assert.assertNotNull(clonedChildObj.getDOM(), "Cloned child DOM node was null");
- Assert.assertFalse(origChildObj.getDOM().isSameNode(clonedChildObj.getDOM()),
+ Assert.assertFalse(preCloneElement.isSameNode(clonedChildObj.getDOM()),
"Child DOM node was not cloned properly");
Assert.assertEquals(clonedChildObj.getValue(), "FooBarBaz", "Text content of child was not the expected value");
// Test rootInNewDocument requirements
- Assert.assertFalse(origParentObj.getDOM().getOwnerDocument().isSameNode(clonedParentObj.getDOM().getOwnerDocument()),
+ Assert.assertFalse(preCloneElement.getOwnerDocument().isSameNode(clonedElement.getOwnerDocument()),
"Cloned objects DOM's were owned by the same Document");
- Assert.assertTrue(clonedParentObj.getDOM().getOwnerDocument().getDocumentElement().isSameNode(clonedParentObj.getDOM()),
+ Assert.assertTrue(clonedElement.getOwnerDocument().getDocumentElement().isSameNode(clonedParentObj.getDOM()),
"Cloned object was not the new Document root");
}
@Test
public void testXMLObjectCloneInputMarshalling() throws MarshallingException, UnmarshallingException {
- SimpleXMLObjectBuilder sxoBuilder = (SimpleXMLObjectBuilder) XMLObjectProviderRegistrySupport.getBuilderFactory()
- .getBuilder(SimpleXMLObject.ELEMENT_NAME);
+ final XMLObjectBuilder<SimpleXMLObject> sxoBuilder =
+ (XMLObjectBuilder<SimpleXMLObject>) builderFactory.<SimpleXMLObject>ensureBuilder(simpleXMLObjectQName);
- SimpleXMLObject origChildObj = sxoBuilder.buildObject();
+ final SimpleXMLObject origChildObj = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
origChildObj.setValue("FooBarBaz");
- SimpleXMLObject origParentObj = sxoBuilder.buildObject();
+ final SimpleXMLObject origParentObj = sxoBuilder.buildObject(SimpleXMLObject.ELEMENT_NAME);
origParentObj.getSimpleXMLObjects().add(origChildObj);
Assert.assertNull(origParentObj.getDOM());
@@ -168,16 +179,16 @@ public class XMLObjectSupportTest extends XMLObjectBaseTestCase {
SimpleXMLObject clonedParentObj = XMLObjectSupport.cloneXMLObject(origParentObj, CloneOutputOption.DropDOM);
Assert.assertNotNull(clonedParentObj);
- Assert.assertNotNull(origParentObj.getDOM());
- Element preCloneElement = origParentObj.getDOM();
- Document preCloneDocument = origParentObj.getDOM().getOwnerDocument();
+ final Element preCloneElement = origParentObj.getDOM();
+ assert preCloneElement != null;
+ final Document preCloneDocument = preCloneElement.getOwnerDocument();
clonedParentObj = XMLObjectSupport.cloneXMLObject(origParentObj, CloneOutputOption.DropDOM);
Assert.assertNotNull(clonedParentObj);
Assert.assertNotNull(origParentObj.getDOM());
Assert.assertTrue(preCloneElement.isSameNode(origParentObj.getDOM()));
- Assert.assertTrue(preCloneDocument.isSameNode(origParentObj.getDOM().getOwnerDocument()));
+ Assert.assertTrue(preCloneDocument.isSameNode(preCloneElement.getOwnerDocument()));
}
@Test
diff --git a/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObject.java b/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObject.java
index 5d53a045c..41f433ebd 100644
--- a/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObject.java
+++ b/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObject.java
@@ -24,6 +24,8 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.xml.namespace.QName;
import org.opensaml.core.xml.AbstractXMLObject;
@@ -34,40 +36,42 @@ import org.opensaml.core.xml.util.AttributeMap;
import org.opensaml.core.xml.util.IndexedXMLObjectChildrenList;
import org.opensaml.core.xml.util.XMLObjectChildrenList;
+import net.shibboleth.shared.annotation.constraint.NotEmpty;
+
/**
* Simple XMLObject that can be used for testing
*/
public class SimpleXMLObject extends AbstractXMLObject implements ElementExtensibleXMLObject, AttributeExtensibleXMLObject {
/** Default namespace */
- public final static String NAMESPACE = "http://www.example.org/testObjects";
+ @Nonnull @NotEmpty public final static String NAMESPACE = "http://www.example.org/testObjects";
/** Default namespace prefix */
- public final static String NAMESPACE_PREFIX = "test";
+ @Nonnull @NotEmpty public final static String NAMESPACE_PREFIX = "test";
/** Element local name */
- public final static String LOCAL_NAME = "SimpleElement";
+ @Nonnull @NotEmpty public final static String LOCAL_NAME = "SimpleElement";
/** Default element name */
- public final static QName ELEMENT_NAME = new QName(NAMESPACE, LOCAL_NAME, NAMESPACE_PREFIX);
+ @Nonnull public final static QName ELEMENT_NAME = new QName(NAMESPACE, LOCAL_NAME, NAMESPACE_PREFIX);
/** Name attribute name */
- public final static String ID_ATTRIB_NAME = "Id";
+ @Nonnull @NotEmpty public final static String ID_ATTRIB_NAME = "Id";
/** Name attribute */
- private String id;
+ @Nullable private String id;
/** Value of the object stored as text content in the element */
- private String value;
+ @Nullable private String value;
/** Child SimpleXMLObjects */
- private XMLObjectChildrenList<SimpleXMLObject> simpleXMLObjects;
+ @Nonnull private XMLObjectChildrenList<SimpleXMLObject> simpleXMLObjects;
/** Other children */
- private IndexedXMLObjectChildrenList<XMLObject> unknownXMLObjects;
+ @Nonnull private IndexedXMLObjectChildrenList<XMLObject> unknownXMLObjects;
/** anyAttribute wildcard attributes. */
- private AttributeMap unknownAttributes;
+ @Nonnull private AttributeMap unknownAttributes;
/**
* Constructor
@@ -76,7 +80,8 @@ public class SimpleXMLObject extends AbstractXMLObject implements ElementExtens
* @param localName local name for the node
* @param namespacePrefix namespace prefix for the node
*/
- public SimpleXMLObject(String namspaceURI, String localName, String namespacePrefix) {
+ public SimpleXMLObject(@Nullable final String namspaceURI, @Nonnull final String localName,
+ @Nullable final String namespacePrefix) {
super(namspaceURI, localName, namespacePrefix);
simpleXMLObjects = new XMLObjectChildrenList<>(this);
@@ -89,7 +94,7 @@ public class SimpleXMLObject extends AbstractXMLObject implements ElementExtens
*
* @return the name attribute
*/
- public String getId() {
+ @Nullable public String getId() {
return id;
}
@@ -98,7 +103,7 @@ public class SimpleXMLObject extends AbstractXMLObject implements ElementExtens
*
* @param newId the name attribute
*/
- public void setId(String newId) {
+ public void setId(@Nullable final String newId) {
registerOwnID(id, newId);
id = newId;
}
@@ -108,7 +113,7 @@ public class SimpleXMLObject extends AbstractXMLObject implements ElementExtens
*
* @return the value of this object
*/
- public String getValue(){
+ @Nullable public String getValue() {
return value;
}
@@ -117,7 +122,7 @@ public class SimpleXMLObject extends AbstractXMLObject implements ElementExtens
*
* @param newValue the value of this object
*/
- public void setValue(String newValue){
+ public void setValue(@Nullable final String newValue) {
value = prepareForAssignment(value, newValue);
}
@@ -126,22 +131,23 @@ public class SimpleXMLObject extends AbstractXMLObject implements ElementExtens
*
* @return the list of child SimpleXMLObjects
*/
- public List<SimpleXMLObject> getSimpleXMLObjects(){
+ @Nonnull public List<SimpleXMLObject> getSimpleXMLObjects(){
return simpleXMLObjects;
}
/** {@inheritDoc} */
- public List<XMLObject> getUnknownXMLObjects() {
+ @Nonnull public List<XMLObject> getUnknownXMLObjects() {
return unknownXMLObjects;
}
/** {@inheritDoc} */
- public List<XMLObject> getUnknownXMLObjects(QName typeOrName) {
+ @SuppressWarnings("unchecked")
+ @Nonnull public List<XMLObject> getUnknownXMLObjects(QName typeOrName) {
return (List<XMLObject>) unknownXMLObjects.subList(typeOrName);
}
/** {@inheritDoc} */
- public List<XMLObject> getOrderedChildren() {
+ @Nullable public List<XMLObject> getOrderedChildren() {
List<XMLObject> children = new LinkedList<>();
children.addAll(simpleXMLObjects);
@@ -151,7 +157,7 @@ public class SimpleXMLObject extends AbstractXMLObject implements ElementExtens
}
/** {@inheritDoc} */
- public AttributeMap getUnknownAttributes() {
+ @Nonnull public AttributeMap getUnknownAttributes() {
return unknownAttributes;
}
}
\ No newline at end of file
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list