[java-opensaml] branch main updated: Fix javadoc and checkstyle warnings.
Scott Cantor
cantor.2 at osu.edu
Wed Oct 18 15:02:50 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=55d503cde359bfcd811cd9508c94e22fdd4615e6
The following commit(s) were added to refs/heads/main by this push:
new 55d503cde Fix javadoc and checkstyle warnings.
55d503cde is described below
commit 55d503cde359bfcd811cd9508c94e22fdd4615e6
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed Oct 18 11:02:46 2023 -0400
Fix javadoc and checkstyle warnings.
---
.../messaging/decoder/AbstractMessageDecoder.java | 5 +-
.../messaging/encoder/AbstractMessageEncoder.java | 5 +-
.../resolver/ChainingMetadataResolver.java | 2 +-
.../storage/annotation/AnnotationSupport.java | 14 ++--
.../core/testing/InitializerBaseTestCase.java | 12 +++-
.../core/testing/XMLObjectBaseTestCase.java | 56 ++++++++-------
.../testing/XMLObjectProviderBaseTestCase.java | 53 ++++++++------
.../XMLObjectProviderInitializerBaseTestCase.java | 4 +-
.../opensaml/core/xml/mock/SimpleXMLObject.java | 39 +++++-----
.../core/xml/mock/SimpleXMLObjectBuilder.java | 13 +++-
.../core/xml/mock/SimpleXMLObjectMarshaller.java | 10 +--
.../opensaml/security/testing/MockTrustEngine.java | 28 ++++++--
.../testing/SecurityProviderTestSupport.java | 13 ++--
.../storage/testing/StorageServiceTest.java | 82 +++++++++++++++++-----
14 files changed, 222 insertions(+), 114 deletions(-)
diff --git a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/AbstractMessageDecoder.java b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/AbstractMessageDecoder.java
index ee3d7f844..5e8458d62 100644
--- a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/AbstractMessageDecoder.java
+++ b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/decoder/AbstractMessageDecoder.java
@@ -31,6 +31,7 @@ import net.shibboleth.shared.primitive.StringSupport;
public abstract class AbstractMessageDecoder extends AbstractInitializableComponent
implements MessageDecoder, UnmodifiableComponent {
+ /** Logging category for protocol messages. */
@Nonnull public static final String BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY = "PROTOCOL_MESSAGE";
/** Used to log protocol messages. */
@@ -43,7 +44,7 @@ public abstract class AbstractMessageDecoder extends AbstractInitializableCompon
@Nullable private MessageContext messageContext;
/** The configured logging sub-category for protocol messages. */
- @Nonnull private String protocolMessageLoggerSubCategory;
+ @Nullable private String protocolMessageLoggerSubCategory;
/** {@inheritDoc} */
@Nullable public MessageContext getMessageContext() {
@@ -80,7 +81,7 @@ public abstract class AbstractMessageDecoder extends AbstractInitializableCompon
*
* @return the logging sub-category
*/
- @Nonnull protected String getProtocolMessageLoggerSubCategory() {
+ @Nullable protected String getProtocolMessageLoggerSubCategory() {
return protocolMessageLoggerSubCategory;
}
diff --git a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/AbstractMessageEncoder.java b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/AbstractMessageEncoder.java
index 88456225a..87fac9270 100644
--- a/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/AbstractMessageEncoder.java
+++ b/opensaml-messaging-api/src/main/java/org/opensaml/messaging/encoder/AbstractMessageEncoder.java
@@ -33,6 +33,7 @@ import net.shibboleth.shared.primitive.StringSupport;
public abstract class AbstractMessageEncoder extends AbstractInitializableComponent
implements MessageEncoder, UnmodifiableComponent {
+ /** Logging category for protocol messages. */
@Nonnull public static final String BASE_PROTOCOL_MESSAGE_LOGGER_CATEGORY = "PROTOCOL_MESSAGE";
/** Used to log protocol messages. */
@@ -45,7 +46,7 @@ public abstract class AbstractMessageEncoder extends AbstractInitializableCompon
@NonnullAfterInit private MessageContext messageContext;
/** The configured logging sub-category for protocol messages. */
- @Nonnull private String protocolMessageLoggerSubCategory;
+ @Nullable private String protocolMessageLoggerSubCategory;
/** {@inheritDoc} */
public synchronized void setMessageContext(@Nullable final MessageContext context) {
@@ -101,7 +102,7 @@ public abstract class AbstractMessageEncoder extends AbstractInitializableCompon
*
* @return the logging sub-category
*/
- @Nonnull protected String getProtocolMessageLoggerSubCategory() {
+ @Nullable protected String getProtocolMessageLoggerSubCategory() {
return protocolMessageLoggerSubCategory;
}
diff --git a/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/ChainingMetadataResolver.java b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/ChainingMetadataResolver.java
index 896aeb019..2008c6998 100644
--- a/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/ChainingMetadataResolver.java
+++ b/opensaml-saml-api/src/main/java/org/opensaml/saml/metadata/resolver/ChainingMetadataResolver.java
@@ -314,7 +314,7 @@ public class ChainingMetadataResolver extends AbstractIdentifiableInitializableC
/**
* Collect the unique entityIDs from the supplied iterable of entity descriptors.
*
- * @param descriptors
+ * @param descriptors the input objects
* @return the unique entityIDs from the supplied descriptors
*/
private Set<String> collectEntityIDs(@Nonnull final Iterable<EntityDescriptor> descriptors) {
diff --git a/opensaml-storage-api/src/main/java/org/opensaml/storage/annotation/AnnotationSupport.java b/opensaml-storage-api/src/main/java/org/opensaml/storage/annotation/AnnotationSupport.java
index 0a35194b3..ac2d2ef0f 100644
--- a/opensaml-storage-api/src/main/java/org/opensaml/storage/annotation/AnnotationSupport.java
+++ b/opensaml-storage-api/src/main/java/org/opensaml/storage/annotation/AnnotationSupport.java
@@ -32,7 +32,7 @@ import net.shibboleth.shared.annotation.constraint.NotEmpty;
public final class AnnotationSupport {
/** Simple cache of fields we have seen. */
- private static final Map<String, Field> FIELD_CACHE = new ConcurrentHashMap<>();
+ @Nonnull private static final Map<String, Field> FIELD_CACHE = new ConcurrentHashMap<>();
/** Private constructor of utility class. */
private AnnotationSupport() {
@@ -43,7 +43,7 @@ public final class AnnotationSupport {
* Gets the value of the field indicated by the {@link Context} annotation on the given object.
*
* <p>If the value is not a {@link String}, then it is converted to one
- * by calling {@link Object#toString()} on the object.<p>
+ * by calling {@link Object#toString()} on the object.</p>
*
* @param target object from which to get context
*
@@ -81,7 +81,7 @@ public final class AnnotationSupport {
* Gets the value of the field indicated by the {@link Key} annotation on the given object.
*
* <p>If the value is not a {@link String}, then it is converted to one
- * by calling {@link Object#toString()} on the object.<p>
+ * by calling {@link Object#toString()} on the object.</p>
*
* @param target object from which to get key
*
@@ -119,7 +119,7 @@ public final class AnnotationSupport {
* Gets the value of the field indicated by the {@link Value} annotation on the given object.
*
* <p>If the value is not a {@link String}, then it is converted to one
- * by calling {@link Object#toString()} on the object.<p>
+ * by calling {@link Object#toString()} on the object.</p>
*
* @param target Object from which to get value
*
@@ -158,8 +158,7 @@ public final class AnnotationSupport {
* or null if none.
*
* <p>The value is returned as a long, in milliseconds since the beginning of the Unix epoch.
- * The following data types are supported:
- * </p>
+ * The following data types are supported:</p>
* <ul>
* <li><code>long</code></li>
* <li>{@link Date}</li>
@@ -191,8 +190,7 @@ public final class AnnotationSupport {
* Sets the value of the field indicated by the {@link Expiration} annotation on the given object.
*
* <p>The expiration is expressed in milliseconds since the beginning of the Unix epoch.
- * The following data types are supported:
- * </p>
+ * The following data types are supported:</p>
* <ul>
* <li><code>long</code></li>
* <li>{@link Date}</li>
diff --git a/opensaml-testing/src/main/java/org/opensaml/core/testing/InitializerBaseTestCase.java b/opensaml-testing/src/main/java/org/opensaml/core/testing/InitializerBaseTestCase.java
index 4b4be183a..dac6306c4 100644
--- a/opensaml-testing/src/main/java/org/opensaml/core/testing/InitializerBaseTestCase.java
+++ b/opensaml-testing/src/main/java/org/opensaml/core/testing/InitializerBaseTestCase.java
@@ -27,15 +27,25 @@ import org.opensaml.core.config.provider.ThreadLocalConfigurationPropertiesHolde
*/
public abstract class InitializerBaseTestCase {
+ /**
+ * Test set up.
+ *
+ * @throws Exception on error
+ */
@BeforeMethod
protected void setUp() throws Exception {
- Properties props = new Properties();
+ final Properties props = new Properties();
props.setProperty(ConfigurationService.PROPERTY_PARTITION_NAME, this.getClass().getName());
ThreadLocalConfigurationPropertiesHolder.setProperties(props);
}
+ /**
+ * Test tear down.
+ *
+ * @throws Exception on error
+ */
@AfterMethod
protected void tearDown() throws Exception {
ThreadLocalConfigurationPropertiesHolder.clear();
diff --git a/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectBaseTestCase.java b/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectBaseTestCase.java
index f5393f671..c7c78ffc0 100644
--- a/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectBaseTestCase.java
+++ b/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectBaseTestCase.java
@@ -52,35 +52,41 @@ import net.shibboleth.shared.xml.XMLParserException;
/**
* Base test case class for tests that operate on XMLObjects.
*/
+ at SuppressWarnings("null")
public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
- /** Logger */
- @Nonnull private final Logger log = LoggerFactory.getLogger(XMLObjectBaseTestCase.class);
-
- /** Parser pool */
- protected static ParserPool parserPool;
+ /** Parser pool. */
+ @Nullable protected static ParserPool parserPool;
- /** XMLObject builder factory */
+ /** XMLObject builder factory. */
protected static XMLObjectBuilderFactory builderFactory;
- /** XMLObject marshaller factory */
+ /** XMLObject marshaller factory. */
protected static MarshallerFactory marshallerFactory;
- /** XMLObject unmarshaller factory */
+ /** XMLObject unmarshaller factory. */
protected static UnmarshallerFactory unmarshallerFactory;
- /** QName for SimpleXMLObject */
+ /** QName for SimpleXMLObject. */
@Nonnull protected static QName simpleXMLObjectQName =
new QName(SimpleXMLObject.NAMESPACE, SimpleXMLObject.LOCAL_NAME);
+ /** Logger. */
+ @Nonnull private final Logger log = LoggerFactory.getLogger(XMLObjectBaseTestCase.class);
+
+ /**
+ * Init support of XMLObjects.
+ *
+ * @throws Exception on error
+ */
@BeforeClass
- protected void initXMLObjectSupport() throws Exception {
+ protected void initXMLObjectSupport() throws Exception {
try {
parserPool = XMLObjectProviderRegistrySupport.getParserPool();
builderFactory = XMLObjectProviderRegistrySupport.getBuilderFactory();
marshallerFactory = XMLObjectProviderRegistrySupport.getMarshallerFactory();
unmarshallerFactory = XMLObjectProviderRegistrySupport.getUnmarshallerFactory();
- } catch (Exception e) {
+ } catch (final Exception e) {
log.error("Can not initialize XMLObjectBaseTestCase: {}", e.getMessage());
throw e;
}
@@ -93,7 +99,7 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
* @param expectedDOM the expected DOM
* @param xmlObject the XMLObject to be marshalled and compared against the expected DOM
*/
- protected void assertXMLEquals(Document expectedDOM, @Nonnull XMLObject xmlObject) {
+ protected void assertXMLEquals(final Document expectedDOM, @Nonnull final XMLObject xmlObject) {
assertXMLEquals("Marshalled DOM was not the same as the expected DOM", expectedDOM, xmlObject);
}
@@ -105,7 +111,7 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
* @param expectedDOM the expected DOM
* @param xmlObject the XMLObject to be marshalled and compared against the expected DOM
*/
- protected void assertXMLEquals(String failMessage, Document expectedDOM, XMLObject xmlObject) {
+ protected void assertXMLEquals(final String failMessage, final Document expectedDOM, final XMLObject xmlObject) {
assert xmlObject!=null;
final Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
if (marshaller == null) {
@@ -139,9 +145,6 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
*/
@Nonnull protected <T extends XMLObject> T buildXMLObject(@Nonnull final QName name) {
final XMLObjectBuilder<T> builder = getBuilder(name);
- if (builder == null) {
- Assert.fail("no builder registered for: " + name);
- }
final T wsObj = builder.buildObject(name);
Assert.assertNotNull(wsObj);
return wsObj;
@@ -158,7 +161,7 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
@Nullable protected <T extends XMLObject> T unmarshallElement(@Nonnull final String elementFile) {
try {
return unmarshallElement(elementFile, false);
- } catch (XMLParserException | UnmarshallingException e) {
+ } catch (final XMLParserException | UnmarshallingException e) {
// Won't happen due to flag being passed
Assert.fail("Unable to parse or unmarshall element file " + elementFile + ": " + e);
return null;
@@ -169,7 +172,8 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
* Unmarshalls an element file into its XMLObject.
*
* @param elementFile the element file to unmarshall
- * @param propagateErrors if true, checked exceptions will be thrown, if false then they cause assertion of test failure
+ * @param propagateErrors if true, checked exceptions will be thrown,
+ * if false then they cause assertion of test failure
* @param <T> expected type
*
* @return the XMLObject from the file
@@ -177,12 +181,14 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
* @throws XMLParserException ...
* @throws UnmarshallingException ...
*/
- @Nullable protected <T extends XMLObject> T unmarshallElement(@Nonnull final String elementFile, boolean propagateErrors)
+ @Nullable protected <T extends XMLObject> T unmarshallElement(@Nonnull final String elementFile,
+ final boolean propagateErrors)
throws XMLParserException, UnmarshallingException {
try {
final Document doc = parseXMLDocument(elementFile);
final Element element = doc.getDocumentElement();
final Unmarshaller unmarshaller = getUnmarshaller(element);
+ @SuppressWarnings("unchecked")
final T object = (T) unmarshaller.unmarshall(element);
Assert.assertNotNull(object);
return object;
@@ -211,7 +217,7 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
protected void printXML(@Nonnull final Node node, @Nonnull final String filename) {
try {
SerializeSupport.writeNode(node, new FileOutputStream(new File(filename)));
- } catch (IOException e) {
+ } catch (final IOException e) {
e.printStackTrace();
}
}
@@ -229,7 +235,7 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
final Marshaller marshaller = marshallerFactory.getMarshaller(xmlObject);
assert marshaller!= null;
elem = marshaller.marshall(xmlObject);
- } catch (MarshallingException e) {
+ } catch (final MarshallingException e) {
e.printStackTrace();
}
assert elem != null;
@@ -249,7 +255,7 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
}
/**
- * Lookup the marshaller for a QName
+ * Lookup the marshaller for a QName.
*
* @param qname the QName for which to find the marshaller
* @return the marshaller
@@ -275,7 +281,7 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
* @return the unmarshaller
*/
@Nonnull protected Unmarshaller getUnmarshaller(@Nonnull final QName qname) {
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(qname);
+ final Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(qname);
if (unmarshaller == null) {
Assert.fail("no unmarshaller registered for " + qname);
}
@@ -300,7 +306,7 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
* @return the unmarshaller
*/
@Nonnull protected Unmarshaller getUnmarshaller(@Nonnull final Element element) {
- Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
+ final Unmarshaller unmarshaller = unmarshallerFactory.getUnmarshaller(element);
if (unmarshaller == null) {
Assert.fail("no unmarshaller registered for " + QNameSupport.getNodeQName(element));
}
@@ -318,7 +324,7 @@ public abstract class XMLObjectBaseTestCase extends OpenSAMLInitBaseTestCase {
@Nonnull protected Document parseXMLDocument(@Nonnull final String xmlFilename) throws XMLParserException {
final InputStream is = getClass().getResourceAsStream(xmlFilename);
assert is != null;
- Document doc = parserPool.parse(is);
+ final Document doc = parserPool.parse(is);
return doc;
}
diff --git a/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectProviderBaseTestCase.java b/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectProviderBaseTestCase.java
index a3a90797e..b86c6c653 100644
--- a/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectProviderBaseTestCase.java
+++ b/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectProviderBaseTestCase.java
@@ -36,41 +36,46 @@ import net.shibboleth.shared.xml.XMLParserException;
* of object provider tests, i.e marshalling and unmarshalling of single elements; with optional
* attributes; and with child elements.
*/
+ at SuppressWarnings("null")
public abstract class XMLObjectProviderBaseTestCase extends XMLObjectBaseTestCase {
- /** Location of file containing a single element with NO optional attributes */
+ /** Location of file containing a single element with NO optional attributes. */
protected String singleElementFile;
- /** Location of file containing a single element with all optional attributes */
+ /** Location of file containing a single element with all optional attributes. */
protected String singleElementOptionalAttributesFile;
- /** Location of file containing a single element with some unknown attributes */
+ /** Location of file containing a single element with some unknown attributes. */
protected String singleElementUnknownAttributesFile;
- /** Location of file containing a single element with child elements */
+ /** Location of file containing a single element with child elements. */
protected String childElementsFile;
/** Location of file containing some kind of invalid content. */
protected String invalidFile;
- /** The expected result of a marshalled single element with no optional attributes */
+ /** The expected result of a marshalled single element with no optional attributes. */
protected Document expectedDOM;
- /** The expected result of a marshalled single element with all optional attributes */
+ /** The expected result of a marshalled single element with all optional attributes. */
protected Document expectedOptionalAttributesDOM;
- /** The expected result of a marshalled single element some unknown attributes */
+ /** The expected result of a marshalled single element some unknown attributes. */
protected Document expectedUnknownAttributesDOM;
- /** The expected result of a marshalled single element with child elements */
+ /** The expected result of a marshalled single element with child elements. */
protected Document expectedChildElementsDOM;
/** The result of parsing the invalid file. */
protected Document invalidDOM;
- @SuppressWarnings("null")
+ /**
+ * Init testing fields.
+ *
+ * @throws Exception on error
+ */
@BeforeClass
- protected void initXMLObjectProviderTestingSupprt() throws Exception {
+ protected void initXMLObjectProviderTestingSupprt() throws Exception {
if (singleElementFile != null) {
expectedDOM = parserPool.parse(XMLObjectProviderBaseTestCase.class
.getResourceAsStream(singleElementFile));
@@ -100,15 +105,16 @@ public abstract class XMLObjectProviderBaseTestCase extends XMLObjectBaseTestCas
/**
* Tests unmarshalling a document that contains a single element (no children) with no optional attributes.
*/
- public abstract void testSingleElementUnmarshall();
+ public abstract void testSingleElementUnmarshall();
/**
* Tests unmarshalling a document that contains a single element (no children) with all that element's optional
* attributes.
*/
@Test
- public void testSingleElementOptionalAttributesUnmarshall() {
- Assert.assertNull(singleElementOptionalAttributesFile, "No testSingleElementOptionalAttributesUnmarshall present");
+ public void testSingleElementOptionalAttributesUnmarshall() {
+ Assert.assertNull(singleElementOptionalAttributesFile,
+ "No testSingleElementOptionalAttributesUnmarshall present");
}
/**
@@ -117,27 +123,28 @@ public abstract class XMLObjectProviderBaseTestCase extends XMLObjectBaseTestCas
*/
@Test
public void testSingleElementUnknownAttributesUnmarshall() {
- Assert.assertNull(singleElementUnknownAttributesFile, "No testSingleElementUnknownAttributesUnmarshall present");
+ Assert.assertNull(singleElementUnknownAttributesFile,
+ "No testSingleElementUnknownAttributesUnmarshall present");
}
/**
* Tests unmarshalling a document that contains a single element with children.
*/
@Test
- public void testChildElementsUnmarshall() {
+ public void testChildElementsUnmarshall() {
Assert.assertNull(childElementsFile, "No testSingleElementChildElementsUnmarshall present");
}
/**
* Tests marshalling the contents of a single element, with no optional attributes, to a DOM document.
*/
- public abstract void testSingleElementMarshall();
+ public abstract void testSingleElementMarshall();
/**
* Tests marshalling the contents of a single element, with all optional attributes, to a DOM document.
*/
@Test
- public void testSingleElementOptionalAttributesMarshall() {
+ public void testSingleElementOptionalAttributesMarshall() {
Assert.assertNull(expectedOptionalAttributesDOM, "No testSingleElementOptionalAttributesMarshall");
}
@@ -153,19 +160,23 @@ public abstract class XMLObjectProviderBaseTestCase extends XMLObjectBaseTestCas
* Tests marshalling the contents of a single element with child elements to a DOM document.
*/
@Test
- public void testChildElementsMarshall() {
+ public void testChildElementsMarshall() {
Assert.assertNull(expectedChildElementsDOM, "No testSingleElementChildElementsMarshall");
}
/**
* Test marshalling of attribute IDness.
+ *
+ * @param target target object
+ * @param idValue ID value
*
* @throws MarshallingException
* @throws XMLParserException
* */
- public void testAttributeIDnessMarshall(@Nonnull final XMLObject target, final String idValue) throws MarshallingException, XMLParserException {
+ public void testAttributeIDnessMarshall(@Nonnull final XMLObject target, final String idValue)
+ throws MarshallingException, XMLParserException {
// Test marshall of newly constructed object
- Marshaller marshaller = XMLObjectSupport.getMarshaller(target);
+ final Marshaller marshaller = XMLObjectSupport.getMarshaller(target);
assert marshaller!=null;
Element origDOM = marshaller.marshall(target);
Element resolvedDOM = origDOM.getOwnerDocument().getElementById(idValue);
@@ -183,7 +194,7 @@ public abstract class XMLObjectProviderBaseTestCase extends XMLObjectBaseTestCas
// Remarshall existing DOM as child of new parent Element in new Document
newDocument = parserPool.newDocument();
- Element parent = ElementSupport.constructElement(newDocument, "urn:test:foo", "Foo", "foo");
+ final Element parent = ElementSupport.constructElement(newDocument, "urn:test:foo", "Foo", "foo");
ElementSupport.setDocumentElement(newDocument, parent);
origDOM = marshaller.marshall(target, parent);
resolvedDOM = newDocument.getElementById(idValue);
diff --git a/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectProviderInitializerBaseTestCase.java b/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectProviderInitializerBaseTestCase.java
index cef5de41a..24a5a871f 100644
--- a/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectProviderInitializerBaseTestCase.java
+++ b/opensaml-testing/src/main/java/org/opensaml/core/testing/XMLObjectProviderInitializerBaseTestCase.java
@@ -40,13 +40,13 @@ public abstract class XMLObjectProviderInitializerBaseTestCase extends Initializ
XMLObjectProviderRegistry registry = ConfigurationService.get(XMLObjectProviderRegistry.class);
Assert.assertNull(registry, "Registry was non-null");
- Initializer initializer = getTestedInitializer();
+ final Initializer initializer = getTestedInitializer();
initializer.init();
registry = ConfigurationService.get(XMLObjectProviderRegistry.class);
assert registry!= null;
- for (QName providerName : getTestedProviders()) {
+ for (final QName providerName : getTestedProviders()) {
assert providerName!=null;
Assert.assertNotNull(registry.getBuilderFactory().getBuilder(providerName),
"Builder for provider '" + providerName + "'was null");
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 28161642d..8c5810ec1 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
@@ -36,42 +36,43 @@ import net.shibboleth.shared.annotation.constraint.NotEmpty;
import net.shibboleth.shared.collection.CollectionSupport;
/**
- * Simple XMLObject that can be used for testing
+ * Simple XMLObject that can be used for testing.
*/
-public class SimpleXMLObject extends AbstractXMLObject implements ElementExtensibleXMLObject, AttributeExtensibleXMLObject {
+public class SimpleXMLObject extends AbstractXMLObject
+ implements ElementExtensibleXMLObject, AttributeExtensibleXMLObject {
- /** Default namespace */
- @Nonnull @NotEmpty public final static String NAMESPACE = "http://www.example.org/testObjects";
+ /** Default namespace. */
+ @Nonnull @NotEmpty public static final String NAMESPACE = "http://www.example.org/testObjects";
- /** Default namespace prefix */
- @Nonnull @NotEmpty public final static String NAMESPACE_PREFIX = "test";
+ /** Default namespace prefix. */
+ @Nonnull @NotEmpty public static final String NAMESPACE_PREFIX = "test";
- /** Element local name */
- @Nonnull @NotEmpty public final static String LOCAL_NAME = "SimpleElement";
+ /** Element local name. */
+ @Nonnull @NotEmpty public static final String LOCAL_NAME = "SimpleElement";
- /** Default element name */
- @Nonnull public final static QName ELEMENT_NAME = new QName(NAMESPACE, LOCAL_NAME, NAMESPACE_PREFIX);
+ /** Default element name. */
+ @Nonnull public static final QName ELEMENT_NAME = new QName(NAMESPACE, LOCAL_NAME, NAMESPACE_PREFIX);
- /** Name attribute name */
- @Nonnull @NotEmpty public final static String ID_ATTRIB_NAME = "Id";
+ /** Name attribute name. */
+ @Nonnull @NotEmpty public static final String ID_ATTRIB_NAME = "Id";
- /** Name attribute */
+ /** Name attribute. */
@Nullable private String id;
- /** Value of the object stored as text content in the element */
+ /** Value of the object stored as text content in the element. */
@Nullable private String value;
- /** Child SimpleXMLObjects */
+ /** Child SimpleXMLObjects. */
@Nonnull private XMLObjectChildrenList<SimpleXMLObject> simpleXMLObjects;
- /** Other children */
+ /** Other children. */
@Nonnull private IndexedXMLObjectChildrenList<XMLObject> unknownXMLObjects;
/** anyAttribute wildcard attributes. */
@Nonnull private AttributeMap unknownAttributes;
/**
- * Constructor
+ * Constructor.
*
* @param namspaceURI namespace for the node
* @param localName local name for the node
@@ -139,13 +140,13 @@ public class SimpleXMLObject extends AbstractXMLObject implements ElementExtens
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
- @Nonnull public List<XMLObject> getUnknownXMLObjects(@Nonnull QName typeOrName) {
+ @Nonnull public List<XMLObject> getUnknownXMLObjects(@Nonnull final QName typeOrName) {
return (List<XMLObject>) unknownXMLObjects.subList(typeOrName);
}
/** {@inheritDoc} */
@Nullable public List<XMLObject> getOrderedChildren() {
- List<XMLObject> children = new LinkedList<>();
+ final List<XMLObject> children = new LinkedList<>();
children.addAll(simpleXMLObjects);
children.addAll(unknownXMLObjects);
diff --git a/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObjectBuilder.java b/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObjectBuilder.java
index a105d1446..0f3480240 100644
--- a/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObjectBuilder.java
+++ b/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObjectBuilder.java
@@ -27,13 +27,20 @@ import org.opensaml.core.xml.AbstractXMLObjectBuilder;
* Builder of {@link org.opensaml.core.xml.mock.SimpleXMLObject}s.
*/
public class SimpleXMLObjectBuilder extends AbstractXMLObjectBuilder<SimpleXMLObject> {
-
- public SimpleXMLObject buildObject(){
+
+ /**
+ * Default builder method.
+ *
+ * @return new object
+ */
+ @Nonnull public SimpleXMLObject buildObject(){
return buildObject(SimpleXMLObject.NAMESPACE, SimpleXMLObject.LOCAL_NAME, SimpleXMLObject.NAMESPACE_PREFIX);
}
/** {@inheritDoc} */
- public @Nonnull SimpleXMLObject buildObject(@Nullable String namespaceURI, @Nonnull String localName, @Nullable String namespacePrefix) {
+ @Nonnull public SimpleXMLObject buildObject(@Nullable final String namespaceURI, @Nonnull final String localName,
+ @Nullable final String namespacePrefix) {
return new SimpleXMLObject(namespaceURI, localName, namespacePrefix);
}
+
}
\ No newline at end of file
diff --git a/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObjectMarshaller.java b/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObjectMarshaller.java
index 871e9cccc..d3098db2c 100644
--- a/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObjectMarshaller.java
+++ b/opensaml-testing/src/main/java/org/opensaml/core/xml/mock/SimpleXMLObjectMarshaller.java
@@ -28,8 +28,9 @@ import org.w3c.dom.Element;
public class SimpleXMLObjectMarshaller extends AbstractXMLObjectMarshaller {
/** {@inheritDoc} */
- protected void marshallAttributes(@Nonnull XMLObject xmlObject, @Nonnull Element domElement) throws MarshallingException {
- SimpleXMLObject simpleXMLObject = (SimpleXMLObject) xmlObject;
+ protected void marshallAttributes(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
+ throws MarshallingException {
+ final SimpleXMLObject simpleXMLObject = (SimpleXMLObject) xmlObject;
if (simpleXMLObject.getId() != null) {
domElement.setAttributeNS(null, SimpleXMLObject.ID_ATTRIB_NAME, simpleXMLObject.getId());
@@ -41,8 +42,9 @@ public class SimpleXMLObjectMarshaller extends AbstractXMLObjectMarshaller {
}
/** {@inheritDoc} */
- protected void marshallElementContent(@Nonnull XMLObject xmlObject, @Nonnull Element domElement) throws MarshallingException {
- SimpleXMLObject simpleXMLObject = (SimpleXMLObject) xmlObject;
+ protected void marshallElementContent(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
+ throws MarshallingException {
+ final SimpleXMLObject simpleXMLObject = (SimpleXMLObject) xmlObject;
if (simpleXMLObject.getValue() != null) {
domElement.setTextContent(simpleXMLObject.getValue());
diff --git a/opensaml-testing/src/main/java/org/opensaml/security/testing/MockTrustEngine.java b/opensaml-testing/src/main/java/org/opensaml/security/testing/MockTrustEngine.java
index bac88feb2..060286705 100644
--- a/opensaml-testing/src/main/java/org/opensaml/security/testing/MockTrustEngine.java
+++ b/opensaml-testing/src/main/java/org/opensaml/security/testing/MockTrustEngine.java
@@ -22,22 +22,40 @@ import org.opensaml.security.trust.TrustEngine;
import net.shibboleth.shared.resolver.CriteriaSet;
+/**
+ * Mock trust engine.
+ *
+ * @param <TokenType> token type for trust engine
+ */
public class MockTrustEngine<TokenType> implements TrustEngine<TokenType> {
+ /** Trusted flag. */
private boolean trusted;
- private Throwable throwable;
+ /** Exception to raise. */
+ @Nullable private Throwable throwable;
- public MockTrustEngine(boolean flag) {
+ /**
+ * Constructor.
+ *
+ * @param flag flag controlling whether the trust engine mock should accept the input or not.
+ */
+ public MockTrustEngine(final boolean flag) {
trusted = flag;
}
- public MockTrustEngine(Throwable t) {
+ /**
+ * Constructor.
+ *
+ * @param t exception to raise from mock.
+ */
+ public MockTrustEngine(@Nullable final Throwable t) {
throwable = t;
}
/** {@inheritDoc} */
- public boolean validate(@Nonnull TokenType token, @Nullable CriteriaSet trustBasisCriteria) throws SecurityException {
+ public boolean validate(@Nonnull final TokenType token, @Nullable final CriteriaSet trustBasisCriteria)
+ throws SecurityException {
if (throwable != null) {
if (SecurityException.class.isInstance(throwable)) {
throw SecurityException.class.cast(throwable);
@@ -53,4 +71,4 @@ public class MockTrustEngine<TokenType> implements TrustEngine<TokenType> {
return trusted;
}
-}
+}
\ No newline at end of file
diff --git a/opensaml-testing/src/main/java/org/opensaml/security/testing/SecurityProviderTestSupport.java b/opensaml-testing/src/main/java/org/opensaml/security/testing/SecurityProviderTestSupport.java
index 5f78d57b1..286d410a1 100644
--- a/opensaml-testing/src/main/java/org/opensaml/security/testing/SecurityProviderTestSupport.java
+++ b/opensaml-testing/src/main/java/org/opensaml/security/testing/SecurityProviderTestSupport.java
@@ -28,22 +28,27 @@ import net.shibboleth.shared.annotation.constraint.NotEmpty;
*
* <p>
* One major feature is the ability to check and load the Bouncy Castle security provider for tests which require
- * advanced crypto capabilities, and unload it afterwards, if it wasn't loaded originally. The goal of this is to preserve
- * the pre-test condition of whether BC was originally loaded or not, so we don't muck with the environment of JVM in which
- * the tests are running. For example, the JVM may actually have been configured with BC deliberately,
+ * advanced crypto capabilities, and unload it afterwards, if it wasn't loaded originally.
+ * The goal of this is to preserve the pre-test condition of whether BC was originally loaded or not,
+ * so we don't muck with the environment of JVM in which the tests are running.
+ * For example, the JVM may actually have been configured with BC deliberately,
* so we don't want to unload it by mistake.
* </p>
*/
public class SecurityProviderTestSupport {
+ /** Name of Bouncy Castle JCE provider. */
@Nonnull @NotEmpty public static final String BC_PROVIDER_NAME = "BC";
+ /** Name of Sun Elliptic Curve JCE provider. */
@Nonnull @NotEmpty public static final String SUNEC_PROVIDER_NAME = "SunEC";
+ /** BC flag. */
private boolean hadBCOriginally;
+ /** Constructor. */
public SecurityProviderTestSupport() {
- hadBCOriginally = (Security.getProvider(BC_PROVIDER_NAME) != null);
+ hadBCOriginally = Security.getProvider(BC_PROVIDER_NAME) != null;
}
/**
diff --git a/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java b/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java
index 66be3665b..ee222e7ff 100644
--- a/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java
+++ b/opensaml-testing/src/main/java/org/opensaml/storage/testing/StorageServiceTest.java
@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.List;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import org.opensaml.storage.EnumeratableStorageService;
import org.opensaml.storage.StorageRecord;
@@ -44,12 +45,14 @@ import net.shibboleth.shared.component.InitializableComponent;
/**
* Test of {@link StorageService} implementations.
*/
- at SuppressWarnings({"javadoc", "null"})
+ at SuppressWarnings({"null"})
public abstract class StorageServiceTest {
- protected SecureRandom random;
+ /** Random source. */
+ @Nullable protected SecureRandom random;
- protected EnumeratableStorageService shared;
+ /** Service being tested. */
+ @Nullable protected EnumeratableStorageService shared;
/**
* Returns a fresh service instance to test.
@@ -79,6 +82,11 @@ public abstract class StorageServiceTest {
}
}
+ /**
+ * Basic test of string records.
+ *
+ * @throws IOException on error
+ */
@Test(threadPoolSize = 10, invocationCount = 10)
public void strings() throws IOException {
threadInit();
@@ -86,7 +94,8 @@ public abstract class StorageServiceTest {
final String context = Long.toString(random.nextLong());
for (int i = 1; i <= 100; i++) {
- boolean result = shared.create(context, Integer.toString(i), Integer.toString(i + 1), System.currentTimeMillis() + 300000);
+ final boolean result = shared.create(context, Integer.toString(i), Integer.toString(i + 1),
+ System.currentTimeMillis() + 300000);
Assert.assertTrue(result);
}
@@ -96,30 +105,31 @@ public abstract class StorageServiceTest {
Assert.assertEquals(keylist.size(), 100);
for (int i = 1; i <= 100; i++) {
- StorageRecord<?> rec = shared.read(context, Integer.toString(i));
+ final StorageRecord<?> rec = shared.read(context, Integer.toString(i));
assert rec!=null;
Assert.assertEquals(rec.getValue(), Integer.toString(i + 1));
}
for (int i = 1; i <= 100; i++) {
- boolean result = shared.update(context, Integer.toString(i), Integer.toString(i + 2), System.currentTimeMillis() + 300000);
+ final boolean result = shared.update(context, Integer.toString(i), Integer.toString(i + 2),
+ System.currentTimeMillis() + 300000);
Assert.assertTrue(result);
}
for (int i = 1; i <= 100; i++) {
- StorageRecord<?> rec = shared.read(context, Integer.toString(i));
+ final StorageRecord<?> rec = shared.read(context, Integer.toString(i));
assert rec!=null;
Assert.assertEquals(rec.getValue(), Integer.toString(i + 2));
}
for (int i = 1; i <= 100; i++) {
- boolean result = shared.create(context, Integer.toString(i), Integer.toString(i + 1), null);
+ final boolean result = shared.create(context, Integer.toString(i), Integer.toString(i + 1), null);
Assert.assertFalse(result, "createString should have failed");
}
for (int i = 1; i <= 100; i++) {
shared.delete(context, Integer.toString(i));
- StorageRecord<?> rec = shared.read(context, Integer.toString(i));
+ final StorageRecord<?> rec = shared.read(context, Integer.toString(i));
Assert.assertNull(rec);
}
@@ -129,6 +139,12 @@ public abstract class StorageServiceTest {
Assert.assertEquals(keylist.size(), 0);
}
+ /**
+ * Test of expiration handling.
+ *
+ * @throws IOException on error
+ * @throws InterruptedException on thread interruption
+ */
@Test
public void expiration() throws IOException, InterruptedException {
threadInit();
@@ -142,13 +158,19 @@ public abstract class StorageServiceTest {
Thread.sleep(5150);
for (int i = 1; i <= 100; i++) {
- StorageRecord<?> rec = shared.read(context, Integer.toString(i));
+ final StorageRecord<?> rec = shared.read(context, Integer.toString(i));
Assert.assertNull(rec);
}
Assert.assertFalse(shared.getContextKeys(context, null).iterator().hasNext());
}
+ /**
+ * Test of versioned update.
+ *
+ * @throws IOException on error
+ * @throws VersionMismatchException on record version mismatch
+ */
@Test
public void updates() throws IOException, VersionMismatchException {
threadInit();
@@ -163,17 +185,22 @@ public abstract class StorageServiceTest {
try {
shared.updateWithVersion(1, context, key, "baz", null);
Assert.fail("updateStringWithVersion should have failed");
- } catch (VersionMismatchException e) {
+ } catch (final VersionMismatchException e) {
// expected
}
- StorageRecord<?> rec = shared.read(context, key);
+ final StorageRecord<?> rec = shared.read(context, key);
assert rec!=null;
Assert.assertEquals(rec.getVersion(), 2);
}
+ /**
+ * Test updates.
+ *
+ * @throws IOException on error
+ */
@Test
- public void update() throws ComponentInitializationException, IOException {
+ public void update() throws IOException {
final String context = Long.toString(random.nextLong());
final String value = Long.toString(random.nextLong());
final String newValue = Long.toString(random.nextLong());
@@ -198,6 +225,12 @@ public abstract class StorageServiceTest {
assertNotEquals(rec.getExpiration(), expiration);
}
+ /**
+ * Test object handling.
+ *
+ * @throws IOException on error
+ * @throws InterruptedException on thread interruption
+ */
@Test
public void objects() throws IOException, InterruptedException {
threadInit();
@@ -226,6 +259,11 @@ public abstract class StorageServiceTest {
Assert.assertNull(shared.read(o2));
}
+ /**
+ * Test context enumeration.
+ *
+ * @throws IOException on error
+ */
@Test
public void enumerate() throws IOException {
final String context = "zork";
@@ -251,15 +289,25 @@ public abstract class StorageServiceTest {
Assert.assertEquals(copy.size(), 2);
}
+ /**
+ * Annotated object class to test with.
+ */
@Context("context")
@Key("key")
@Value("value")
@Expiration("expiration")
private class AnnotatedObject {
+ /** Context. */
private String context;
+
+ /** Key. */
private String key;
+
+ /** Value. */
private String value;
+
+ /** Expiration. */
private Long expiration;
public void generate() {
@@ -273,7 +321,7 @@ public abstract class StorageServiceTest {
return context;
}
- public void setContext(String c) {
+ public void setContext(final String c) {
context = c;
}
@@ -281,7 +329,7 @@ public abstract class StorageServiceTest {
return key;
}
- public void setKey(String k) {
+ public void setKey(final String k) {
key = k;
}
@@ -289,7 +337,7 @@ public abstract class StorageServiceTest {
return value;
}
- public void setValue(String val) {
+ public void setValue(final String val) {
value = val;
}
@@ -297,7 +345,7 @@ public abstract class StorageServiceTest {
return expiration;
}
- public void setExpiration(long exp) {
+ public void setExpiration(final long exp) {
expiration = exp;
}
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list