You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2019/11/13 12:29:30 UTC
[cxf] 03/08: cxf-rt-ws-security: fix SecurityTokenTest for Java 11
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch 3.3.x-fixes
in repository https://gitbox.apache.org/repos/asf/cxf.git
commit e3761516185bcf6c42d643c97e585391b74c68b2
Author: Alexey Markevich <bu...@gmail.com>
AuthorDate: Sat Nov 2 16:08:37 2019 +0300
cxf-rt-ws-security: fix SecurityTokenTest for Java 11
(cherry picked from commit f4060aaa779d7aeb30e92ff3c31d6d07c596bb22)
---
.../ws/security/tokenstore/SecurityTokenTest.java | 36 +++++++++-------------
1 file changed, 14 insertions(+), 22 deletions(-)
diff --git a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/tokenstore/SecurityTokenTest.java b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/tokenstore/SecurityTokenTest.java
index d8b2dea..a4c08e9 100644
--- a/rt/ws/security/src/test/java/org/apache/cxf/ws/security/tokenstore/SecurityTokenTest.java
+++ b/rt/ws/security/src/test/java/org/apache/cxf/ws/security/tokenstore/SecurityTokenTest.java
@@ -20,15 +20,16 @@ package org.apache.cxf.ws.security.tokenstore;
import java.time.Instant;
import java.time.ZoneOffset;
+import java.time.temporal.ChronoUnit;
import org.w3c.dom.Element;
import org.apache.cxf.helpers.DOMUtils;
import org.apache.cxf.staxutils.W3CDOMStreamWriter;
-import org.apache.cxf.ws.security.trust.STSUtils;
-import org.apache.wss4j.common.WSS4JConstants;
import org.apache.wss4j.common.util.DateUtil;
+import static org.apache.wss4j.common.WSS4JConstants.WST_NS_05_12;
+import static org.apache.wss4j.common.WSS4JConstants.WSU_NS;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
@@ -38,7 +39,7 @@ public class SecurityTokenTest {
@org.junit.Test
public void testCreateSecurityToken() throws Exception {
String key = "key";
- Instant created = Instant.now();
+ Instant created = Instant.now().truncatedTo(ChronoUnit.MILLIS);
Instant expires = created.plusSeconds(20L);
SecurityToken token = new SecurityToken(key, created, expires);
@@ -54,18 +55,15 @@ public class SecurityTokenTest {
// Create Lifetime
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
- Instant created = Instant.now();
+ Instant created = Instant.now().truncatedTo(ChronoUnit.MILLIS);
Instant expires = created.plusSeconds(20L);
- String namespace = STSUtils.WST_NS_05_12;
- writer.writeStartElement("wst", "Lifetime", namespace);
- writer.writeNamespace("wst", namespace);
- writer.writeNamespace("wsu", WSS4JConstants.WSU_NS);
- writer.writeStartElement("wsu", "Created", WSS4JConstants.WSU_NS);
+ writer.writeStartElement("wst", "Lifetime", WST_NS_05_12);
+ writer.writeStartElement("wsu", "Created", WSU_NS);
writer.writeCharacters(created.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
writer.writeEndElement();
- writer.writeStartElement("wsu", "Expires", WSS4JConstants.WSU_NS);
+ writer.writeStartElement("wsu", "Expires", WSU_NS);
writer.writeCharacters(expires.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
writer.writeEndElement();
writer.writeEndElement();
@@ -83,15 +81,12 @@ public class SecurityTokenTest {
// Create Lifetime
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
- Instant created = Instant.now();
+ Instant created = Instant.now().truncatedTo(ChronoUnit.MILLIS);
Instant expires = created.plusSeconds(20L);
- String namespace = STSUtils.WST_NS_05_12;
- writer.writeStartElement("wst", "Lifetime", namespace);
- writer.writeNamespace("wst", namespace);
- writer.writeNamespace("wsu", WSS4JConstants.WSU_NS);
+ writer.writeStartElement("wst", "Lifetime", WST_NS_05_12);
- writer.writeStartElement("wsu", "Expires", WSS4JConstants.WSU_NS);
+ writer.writeStartElement("wsu", "Expires", WSU_NS);
writer.writeCharacters(expires.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
writer.writeEndElement();
writer.writeEndElement();
@@ -110,13 +105,10 @@ public class SecurityTokenTest {
// Create Lifetime
W3CDOMStreamWriter writer = new W3CDOMStreamWriter();
- Instant created = Instant.now();
+ Instant created = Instant.now().truncatedTo(ChronoUnit.MILLIS);
- String namespace = STSUtils.WST_NS_05_12;
- writer.writeStartElement("wst", "Lifetime", namespace);
- writer.writeNamespace("wst", namespace);
- writer.writeNamespace("wsu", WSS4JConstants.WSU_NS);
- writer.writeStartElement("wsu", "Created", WSS4JConstants.WSU_NS);
+ writer.writeStartElement("wst", "Lifetime", WST_NS_05_12);
+ writer.writeStartElement("wsu", "Created", WSU_NS);
writer.writeCharacters(created.atZone(ZoneOffset.UTC).format(DateUtil.getDateTimeFormatter(true)));
writer.writeEndElement();