You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2019/01/03 11:48:58 UTC
svn commit: r1850227 [11/11] - in /webservices/wss4j/trunk: build-tools/
integration/src/test/java/org/apache/wss4j/integration/test/kerberos/
performance/src/test/java/org/apache/wss4j/performance/
policy/src/test/java/org/apache/wss4j/policy/tests/ w...
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenNegativeTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenNegativeTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenNegativeTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenNegativeTest.java Thu Jan 3 11:48:56 2019
@@ -38,12 +38,15 @@ import org.apache.wss4j.stax.setup.Inbou
import org.apache.wss4j.stax.setup.WSSec;
import org.apache.wss4j.stax.test.AbstractTestBase;
import org.apache.wss4j.stax.test.utils.StAX2DOM;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
public class SAMLTokenNegativeTest extends AbstractTestBase {
@Test
@@ -65,7 +68,7 @@ public class SAMLTokenNegativeTest exten
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
NodeList list = securedDocument.getElementsByTagNameNS(WSConstants.SAML2_NS, "Assertion");
Element assertionElement = (Element) list.item(0);
@@ -84,10 +87,10 @@ public class SAMLTokenNegativeTest exten
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
- Assert.assertNotNull(e.getCause().getCause());
+ assertNotNull(e.getCause());
+ assertNotNull(e.getCause().getCause());
}
}
}
@@ -111,7 +114,7 @@ public class SAMLTokenNegativeTest exten
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
Element envelope = securedDocument.getDocumentElement();
NodeList list = envelope.getElementsByTagNameNS(WSConstants.SAML_NS, "Assertion");
@@ -135,10 +138,10 @@ public class SAMLTokenNegativeTest exten
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
- Assert.assertNotNull(e.getCause().getCause());
+ assertNotNull(e.getCause());
+ assertNotNull(e.getCause().getCause());
}
}
}
@@ -161,7 +164,7 @@ public class SAMLTokenNegativeTest exten
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
NodeList list = securedDocument.getElementsByTagNameNS(WSConstants.SAML2_NS, "Assertion");
Element assertionElement = (Element) list.item(0);
@@ -180,10 +183,10 @@ public class SAMLTokenNegativeTest exten
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
- Assert.assertNotNull(e.getCause().getCause());
+ assertNotNull(e.getCause());
+ assertNotNull(e.getCause().getCause());
}
}
}
@@ -208,7 +211,7 @@ public class SAMLTokenNegativeTest exten
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -223,9 +226,9 @@ public class SAMLTokenNegativeTest exten
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
+ assertNotNull(e.getCause());
}
}
}
@@ -249,7 +252,7 @@ public class SAMLTokenNegativeTest exten
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -264,10 +267,10 @@ public class SAMLTokenNegativeTest exten
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
+ assertNotNull(e.getCause());
}
}
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenReferenceTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenReferenceTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenReferenceTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenReferenceTest.java Thu Jan 3 11:48:56 2019
@@ -61,13 +61,14 @@ import org.apache.wss4j.stax.test.utils.
import org.apache.wss4j.stax.test.utils.StAX2DOM;
import org.apache.wss4j.stax.test.utils.XmlReaderToWriter;
import org.apache.xml.security.stax.securityEvent.SecurityEvent;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+
public class SAMLTokenReferenceTest extends AbstractTestBase {
@Test
@@ -98,13 +99,13 @@ public class SAMLTokenReferenceTest exte
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "KeyIdentifier");
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");
- Assert.assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier");
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");
+ assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509SubjectKeyIdentifier");
}
//done signature; now test sig-verification:
@@ -135,13 +136,13 @@ public class SAMLTokenReferenceTest exte
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = securedDocument.getElementsByTagNameNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "KeyIdentifier");
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");
- Assert.assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");
+ assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -176,7 +177,7 @@ public class SAMLTokenReferenceTest exte
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -214,13 +215,13 @@ public class SAMLTokenReferenceTest exte
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
- Assert.assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
+ assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "KeyIdentifier");
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");
}
//done signature; now test sig-verification:
@@ -249,13 +250,13 @@ public class SAMLTokenReferenceTest exte
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
- Assert.assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
+ assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = securedDocument.getElementsByTagNameNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "KeyIdentifier");
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.0#SAMLAssertionID");
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -287,7 +288,7 @@ public class SAMLTokenReferenceTest exte
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
}
}
@@ -311,7 +312,7 @@ public class SAMLTokenReferenceTest exte
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
Element securityHeader = (Element) nodeList.item(1).getParentNode();
nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_SAML_ASSERTION.getNamespaceURI(), WSSConstants.TAG_saml_Assertion.getLocalPart());
Node assertionNode = nodeList.item(0);
@@ -334,7 +335,7 @@ public class SAMLTokenReferenceTest exte
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
}
}
*/
@@ -420,7 +421,7 @@ public class SAMLTokenReferenceTest exte
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -505,7 +506,7 @@ public class SAMLTokenReferenceTest exte
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -545,13 +546,13 @@ public class SAMLTokenReferenceTest exte
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "KeyIdentifier");
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID");
- Assert.assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID");
+ assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");
}
//done signature; now test sig-verification:
@@ -582,13 +583,13 @@ public class SAMLTokenReferenceTest exte
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = securedDocument.getElementsByTagNameNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "KeyIdentifier");
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID");
- Assert.assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID");
+ assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3");
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -623,7 +624,7 @@ public class SAMLTokenReferenceTest exte
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -662,13 +663,13 @@ public class SAMLTokenReferenceTest exte
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
- Assert.assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
+ assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "KeyIdentifier");
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID");
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID");
}
//done signature; now test sig-verification:
@@ -697,13 +698,13 @@ public class SAMLTokenReferenceTest exte
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
- Assert.assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
+ assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = securedDocument.getElementsByTagNameNS("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "KeyIdentifier");
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID");
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "ValueType"), "http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLID");
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -735,9 +736,9 @@ public class SAMLTokenReferenceTest exte
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
- Assert.assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
+ assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
}
}
@@ -774,7 +775,7 @@ public class SAMLTokenReferenceTest exte
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
}
//done signature; now test sig-verification:
@@ -818,14 +819,14 @@ public class SAMLTokenReferenceTest exte
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
- Assert.assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
+ assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = securedDocument.getElementsByTagNameNS(
"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "SecurityTokenReference");
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(
((Element) nodeList.item(0)).
getAttributeNS("http://docs.oasis-open.org/wss/oasis-wss-wssecurity-secext-1.1.xsd", "TokenType"),
"http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");
@@ -860,7 +861,7 @@ public class SAMLTokenReferenceTest exte
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
}
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenSVTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenSVTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenSVTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenSVTest.java Thu Jan 3 11:48:56 2019
@@ -51,12 +51,15 @@ import org.apache.wss4j.stax.test.utils.
import org.apache.wss4j.stax.test.utils.XmlReaderToWriter;
import org.apache.wss4j.stax.utils.WSSUtils;
import org.apache.xml.security.stax.securityEvent.SecurityEvent;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
public class SAMLTokenSVTest extends AbstractTestBase {
@Test
@@ -87,16 +90,16 @@ public class SAMLTokenSVTest extends Abs
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Reference.getNamespaceURI(), WSSConstants.TAG_dsig_Reference.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
nodeList = document.getElementsByTagNameNS(WSSConstants.NS_SOAP11, WSSConstants.TAG_SOAP_BODY_LN);
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
String idAttrValue = ((Element) nodeList.item(0)).getAttributeNS(WSSConstants.ATT_WSU_ID.getNamespaceURI(), WSSConstants.ATT_WSU_ID.getLocalPart());
- Assert.assertNotNull(idAttrValue);
- Assert.assertTrue(idAttrValue.length() > 0);
+ assertNotNull(idAttrValue);
+ assertTrue(idAttrValue.length() > 0);
}
//done signature; now test sig-verification:
@@ -126,7 +129,7 @@ public class SAMLTokenSVTest extends Abs
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -143,7 +146,7 @@ public class SAMLTokenSVTest extends Abs
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -174,22 +177,22 @@ public class SAMLTokenSVTest extends Abs
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
- Assert.assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
+ assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Reference.getNamespaceURI(), WSSConstants.TAG_dsig_Reference.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 3);
+ assertEquals(nodeList.getLength(), 3);
String referenceId = ((Element) nodeList.item(1)).getAttributeNode(WSSConstants.ATT_NULL_URI.getLocalPart()).getValue();
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_WSSE_SECURITY_TOKEN_REFERENCE.getNamespaceURI(), WSSConstants.TAG_WSSE_SECURITY_TOKEN_REFERENCE.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
String tokenId = ((Element) nodeList.item(0)).getAttributeNodeNS(WSSConstants.ATT_WSU_ID.getNamespaceURI(), WSSConstants.ATT_WSU_ID.getLocalPart()).getValue();
- Assert.assertEquals(tokenId, WSSUtils.dropReferenceMarker(referenceId));
+ assertEquals(tokenId, WSSUtils.dropReferenceMarker(referenceId));
nodeList = document.getElementsByTagNameNS(WSSConstants.NS_SOAP11, WSSConstants.TAG_SOAP_BODY_LN);
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
String idAttrValue = ((Element) nodeList.item(0)).getAttributeNS(WSSConstants.ATT_WSU_ID.getNamespaceURI(), WSSConstants.ATT_WSU_ID.getLocalPart());
- Assert.assertNotNull(idAttrValue);
- Assert.assertTrue(idAttrValue.length() > 0);
+ assertNotNull(idAttrValue);
+ assertTrue(idAttrValue.length() > 0);
}
//done signature; now test sig-verification:
@@ -219,7 +222,7 @@ public class SAMLTokenSVTest extends Abs
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -236,7 +239,7 @@ public class SAMLTokenSVTest extends Abs
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
}
}
@@ -268,16 +271,16 @@ public class SAMLTokenSVTest extends Abs
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Reference.getNamespaceURI(), WSSConstants.TAG_dsig_Reference.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
nodeList = document.getElementsByTagNameNS(WSSConstants.NS_SOAP11, WSSConstants.TAG_SOAP_BODY_LN);
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
String idAttrValue = ((Element) nodeList.item(0)).getAttributeNS(WSSConstants.ATT_WSU_ID.getNamespaceURI(), WSSConstants.ATT_WSU_ID.getLocalPart());
- Assert.assertNotNull(idAttrValue);
- Assert.assertTrue(idAttrValue.length() > 0);
+ assertNotNull(idAttrValue);
+ assertTrue(idAttrValue.length() > 0);
}
//done signature; now test sig-verification:
@@ -307,7 +310,7 @@ public class SAMLTokenSVTest extends Abs
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -324,7 +327,7 @@ public class SAMLTokenSVTest extends Abs
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -347,7 +350,7 @@ public class SAMLTokenSVTest extends Abs
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -379,7 +382,7 @@ public class SAMLTokenSVTest extends Abs
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
}
@@ -412,16 +415,16 @@ public class SAMLTokenSVTest extends Abs
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Reference.getNamespaceURI(), WSSConstants.TAG_dsig_Reference.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
nodeList = document.getElementsByTagNameNS(WSSConstants.NS_SOAP11, WSSConstants.TAG_SOAP_BODY_LN);
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
String idAttrValue = ((Element) nodeList.item(0)).getAttributeNS(WSSConstants.ATT_WSU_ID.getNamespaceURI(), WSSConstants.ATT_WSU_ID.getLocalPart());
- Assert.assertNotNull(idAttrValue);
- Assert.assertTrue(idAttrValue.length() > 0);
+ assertNotNull(idAttrValue);
+ assertTrue(idAttrValue.length() > 0);
}
//done signature; now test sig-verification:
@@ -452,7 +455,7 @@ public class SAMLTokenSVTest extends Abs
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -469,7 +472,7 @@ public class SAMLTokenSVTest extends Abs
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -502,16 +505,16 @@ public class SAMLTokenSVTest extends Abs
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Reference.getNamespaceURI(), WSSConstants.TAG_dsig_Reference.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.getLength(), 2);
nodeList = document.getElementsByTagNameNS(WSSConstants.NS_SOAP11, WSSConstants.TAG_SOAP_BODY_LN);
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
String idAttrValue = ((Element) nodeList.item(0)).getAttributeNS(WSSConstants.ATT_WSU_ID.getNamespaceURI(), WSSConstants.ATT_WSU_ID.getLocalPart());
- Assert.assertNotNull(idAttrValue);
- Assert.assertTrue(idAttrValue.length() > 0);
+ assertNotNull(idAttrValue);
+ assertTrue(idAttrValue.length() > 0);
}
//done signature; now test sig-verification:
@@ -542,7 +545,7 @@ public class SAMLTokenSVTest extends Abs
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -559,7 +562,7 @@ public class SAMLTokenSVTest extends Abs
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenTest.java Thu Jan 3 11:48:56 2019
@@ -72,7 +72,6 @@ import org.apache.xml.security.exception
import org.apache.xml.security.keys.KeyInfo;
import org.apache.xml.security.stax.securityEvent.SecurityEvent;
import org.joda.time.DateTime;
-import org.junit.Assert;
import org.junit.Test;
import org.opensaml.core.xml.XMLObjectBuilder;
import org.opensaml.core.xml.XMLObjectBuilderFactory;
@@ -85,6 +84,10 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
+
public class SAMLTokenTest extends AbstractTestBase {
private static final String IP_ADDRESS = "12.34.56.78"; //NOPMD
@@ -112,7 +115,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -141,7 +144,7 @@ public class SAMLTokenTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -159,7 +162,7 @@ public class SAMLTokenTest extends Abstr
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -186,7 +189,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -215,7 +218,7 @@ public class SAMLTokenTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -233,7 +236,7 @@ public class SAMLTokenTest extends Abstr
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -261,7 +264,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -291,7 +294,7 @@ public class SAMLTokenTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -309,7 +312,7 @@ public class SAMLTokenTest extends Abstr
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -337,7 +340,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -366,7 +369,7 @@ public class SAMLTokenTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -384,7 +387,7 @@ public class SAMLTokenTest extends Abstr
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -412,7 +415,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -441,7 +444,7 @@ public class SAMLTokenTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -459,7 +462,7 @@ public class SAMLTokenTest extends Abstr
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -488,7 +491,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -518,7 +521,7 @@ public class SAMLTokenTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -536,7 +539,7 @@ public class SAMLTokenTest extends Abstr
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -568,7 +571,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -607,7 +610,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -645,7 +648,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -684,7 +687,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -722,7 +725,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -782,7 +785,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -815,7 +818,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -844,7 +847,7 @@ public class SAMLTokenTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -864,7 +867,7 @@ public class SAMLTokenTest extends Abstr
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -931,7 +934,7 @@ public class SAMLTokenTest extends Abstr
// Decrypted Assertion element must be there
NodeList nodeList =
document.getElementsByTagNameNS(WSSConstants.TAG_SAML2_ASSERTION.getNamespaceURI(), WSSConstants.TAG_SAML2_ASSERTION.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
}
@@ -954,7 +957,7 @@ public class SAMLTokenTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -978,7 +981,7 @@ public class SAMLTokenTest extends Abstr
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
}
baos = new ByteArrayOutputStream();
@@ -999,7 +1002,7 @@ public class SAMLTokenTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -1023,7 +1026,7 @@ public class SAMLTokenTest extends Abstr
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
fail("Failure expected on a Bearer assertion");
} catch (XMLStreamException e) {
- Assert.assertTrue(e.getCause() instanceof XMLSecurityException);
+ assertTrue(e.getCause() instanceof XMLSecurityException);
}
}
}
@@ -1048,7 +1051,7 @@ public class SAMLTokenTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -1067,7 +1070,7 @@ public class SAMLTokenTest extends Abstr
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
fail("Failure expected on an unknown subject confirmation method");
} catch (XMLStreamException e) {
- Assert.assertTrue(e.getCause() instanceof XMLSecurityException);
+ assertTrue(e.getCause() instanceof XMLSecurityException);
}
}
@@ -1109,7 +1112,7 @@ public class SAMLTokenTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.getLength(), 1);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -1128,7 +1131,7 @@ public class SAMLTokenTest extends Abstr
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
fail("Failure expected on an unsigned bearer token");
} catch (XMLStreamException e) {
- Assert.assertTrue(e.getCause() instanceof XMLSecurityException);
+ assertTrue(e.getCause() instanceof XMLSecurityException);
}
}
@@ -1174,7 +1177,7 @@ public class SAMLTokenTest extends Abstr
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 0);
+ assertEquals(nodeList.getLength(), 0);
}
//done signature; now test sig-verification:
@@ -1232,4 +1235,4 @@ public class SAMLTokenTest extends Abstr
cipher.doFinal(document, elementToEncrypt, content);
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlAuthnTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlAuthnTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlAuthnTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlAuthnTest.java Thu Jan 3 11:48:56 2019
@@ -39,11 +39,15 @@ import org.apache.wss4j.stax.setup.WSSec
import org.apache.wss4j.stax.test.AbstractTestBase;
import org.apache.wss4j.stax.test.utils.StAX2DOM;
import org.joda.time.DateTime;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
/**
* Some tests for SAML Authentication Assertions
*/
@@ -177,9 +181,9 @@ public class SamlAuthnTest extends Abstr
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
- Assert.assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
+ assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -196,14 +200,14 @@ public class SamlAuthnTest extends Abstr
Document document =
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
if (!success) {
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
}
- Assert.assertNotNull(document);
+ assertNotNull(document);
} catch (XMLStreamException e) {
- Assert.assertFalse(success);
- Assert.assertNotNull(e.getCause());
+ assertFalse(success);
+ assertNotNull(e.getCause());
}
}
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlConditionsTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlConditionsTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlConditionsTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlConditionsTest.java Thu Jan 3 11:48:56 2019
@@ -49,13 +49,16 @@ import org.apache.wss4j.stax.test.utils.
import org.apache.wss4j.stax.test.utils.XmlReaderToWriter;
import org.apache.xml.security.stax.securityEvent.SecurityEvent;
import org.joda.time.DateTime;
-import org.junit.Assert;
import org.junit.Test;
import org.opensaml.saml.config.SAMLConfigurationSupport;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
public class SamlConditionsTest extends AbstractTestBase {
/**
@@ -95,14 +98,14 @@ public class SamlConditionsTest extends
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
- Assert.assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
+ assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = document.getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:assertion", "Conditions");
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "NotBefore"), SAMLConfigurationSupport.getSAMLDateFormatter().print(notBefore));
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "NotOnOrAfter"), SAMLConfigurationSupport.getSAMLDateFormatter().print(notAfter));
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "NotBefore"), SAMLConfigurationSupport.getSAMLDateFormatter().print(notBefore));
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "NotOnOrAfter"), SAMLConfigurationSupport.getSAMLDateFormatter().print(notAfter));
}
//done signature; now test sig-verification:
@@ -142,14 +145,14 @@ public class SamlConditionsTest extends
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 2);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
- Assert.assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 2);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_SAML_ASSERTION.getLocalPart());
+ assertEquals(nodeList.item(1).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
nodeList = securedDocument.getElementsByTagNameNS("urn:oasis:names:tc:SAML:1.0:assertion", "Conditions");
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "NotBefore"), SAMLConfigurationSupport.getSAMLDateFormatter().print(notBefore));
- Assert.assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "NotOnOrAfter"), SAMLConfigurationSupport.getSAMLDateFormatter().print(notAfter));
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "NotBefore"), SAMLConfigurationSupport.getSAMLDateFormatter().print(notBefore));
+ assertEquals(((Element) nodeList.item(0)).getAttributeNS(null, "NotOnOrAfter"), SAMLConfigurationSupport.getSAMLDateFormatter().print(notAfter));
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
@@ -163,7 +166,7 @@ public class SamlConditionsTest extends
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.assertNotNull(document);
+ assertNotNull(document);
}
}
@@ -205,9 +208,9 @@ public class SamlConditionsTest extends
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
+ assertNotNull(e.getCause());
}
}
}
@@ -246,9 +249,9 @@ public class SamlConditionsTest extends
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
+ assertNotNull(e.getCause());
}
}
}
@@ -287,9 +290,9 @@ public class SamlConditionsTest extends
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
+ assertNotNull(e.getCause());
}
}
}
@@ -332,9 +335,9 @@ public class SamlConditionsTest extends
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
+ assertNotNull(e.getCause());
}
}
}
@@ -375,7 +378,7 @@ public class SamlConditionsTest extends
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.assertNotNull(document);
+ assertNotNull(document);
}
}
@@ -415,7 +418,7 @@ public class SamlConditionsTest extends
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.assertNotNull(document);
+ assertNotNull(document);
}
}
@@ -461,7 +464,7 @@ public class SamlConditionsTest extends
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.assertNotNull(document);
+ assertNotNull(document);
}
}
@@ -506,7 +509,7 @@ public class SamlConditionsTest extends
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.assertNotNull(document);
+ assertNotNull(document);
}
}
@@ -552,9 +555,9 @@ public class SamlConditionsTest extends
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
+ assertNotNull(e.getCause());
}
}
@@ -568,7 +571,7 @@ public class SamlConditionsTest extends
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.assertNotNull(document);
+ assertNotNull(document);
}
}
@@ -614,9 +617,9 @@ public class SamlConditionsTest extends
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
+ assertNotNull(e.getCause());
}
}
@@ -630,7 +633,7 @@ public class SamlConditionsTest extends
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.assertNotNull(document);
+ assertNotNull(document);
}
}
@@ -681,7 +684,7 @@ public class SamlConditionsTest extends
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.assertNotNull(document);
+ assertNotNull(document);
}
}
@@ -733,9 +736,9 @@ public class SamlConditionsTest extends
try {
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.fail("XMLStreamException expected");
+ fail("XMLStreamException expected");
} catch (XMLStreamException e) {
- Assert.assertNotNull(e.getCause());
+ assertNotNull(e.getCause());
}
}
@@ -749,7 +752,7 @@ public class SamlConditionsTest extends
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
- Assert.assertNotNull(document);
+ assertNotNull(document);
}
}
-}
+}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlTokenDerivedTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlTokenDerivedTest.java?rev=1850227&r1=1850226&r2=1850227&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlTokenDerivedTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SamlTokenDerivedTest.java Thu Jan 3 11:48:56 2019
@@ -50,12 +50,13 @@ import org.apache.wss4j.stax.test.Abstra
import org.apache.wss4j.stax.test.CallbackHandlerImpl;
import org.apache.wss4j.stax.test.utils.SOAPUtil;
import org.apache.wss4j.stax.test.utils.StAX2DOM;
-import org.junit.Assert;
import org.junit.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
+import static org.junit.Assert.assertEquals;
+
public class SamlTokenDerivedTest extends AbstractTestBase {
/**
@@ -136,8 +137,8 @@ public class SamlTokenDerivedTest extend
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
- Assert.assertEquals(nodeList.getLength(), 1);
- Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
+ assertEquals(nodeList.getLength(), 1);
+ assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_WSSE_SECURITY.getLocalPart());
testSecurityEventListener.compare();
}
@@ -203,4 +204,4 @@ public class SamlTokenDerivedTest extend
return sigBuilder;
}
-}
+}
\ No newline at end of file