diff --git a/pom.xml b/pom.xml
index fc892cfb..46fcfe30 100644
--- a/pom.xml
+++ b/pom.xml
@@ -44,6 +44,18 @@
+
+
+
+ org.junit
+ junit-bom
+ 5.10.0
+ pom
+ import
+
+
+
+
@@ -52,19 +64,7 @@
guava
32.1.2-jre
-
-
- junit
- junit
- 4.13.2
- test
-
-
- org.slf4j
- slf4j-simple
- 2.0.9
- test
-
+
com.google.inject
guice
@@ -96,6 +96,21 @@
4.0.4
runtime
+
+
+
+
+ org.junit.jupiter
+ junit-jupiter
+ test
+
+
+ org.slf4j
+ slf4j-simple
+ 2.0.9
+ test
+
+
diff --git a/src/test/java/xades4j/algorithms/XPath2FilterTransformTest.java b/src/test/java/xades4j/algorithms/XPath2FilterTransformTest.java
index 179b8e54..98e52a66 100644
--- a/src/test/java/xades4j/algorithms/XPath2FilterTransformTest.java
+++ b/src/test/java/xades4j/algorithms/XPath2FilterTransformTest.java
@@ -1,28 +1,29 @@
/*
* XAdES4j - A Java library for generation and verification of XAdES signatures.
* Copyright (C) 2012 Luis Goncalves.
- *
+ *
* XAdES4j is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or any later version.
- *
+ *
* XAdES4j is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public License along
* with XAdES4j. If not, see .
*/
package xades4j.algorithms;
import java.util.List;
+
+import org.junit.jupiter.api.Test;
import xades4j.algorithms.XPath2FilterTransform.XPath2Filter;
-import org.junit.Test;
-import static org.junit.Assert.*;
+
+import static org.junit.jupiter.api.Assertions.*;
/**
- *
* @author Luís
*/
public class XPath2FilterTransformTest
@@ -53,10 +54,12 @@ public void testCreation()
assertEquals("subtract", f.getFilterType());
}
- @Test(expected = UnsupportedOperationException.class)
+ @Test
public void testChangeFiltersListFails()
{
XPath2FilterTransform t = XPath2Filter.intersect("1").union("2");
- t.getFilters().clear();
+ assertThrows(UnsupportedOperationException.class, () -> {
+ t.getFilters().clear();
+ });
}
}
diff --git a/src/test/java/xades4j/production/KeyInfoBuilderTest.java b/src/test/java/xades4j/production/KeyInfoBuilderTest.java
index 53ca3e63..15f736d7 100644
--- a/src/test/java/xades4j/production/KeyInfoBuilderTest.java
+++ b/src/test/java/xades4j/production/KeyInfoBuilderTest.java
@@ -1,16 +1,16 @@
/*
* XAdES4j - A Java library for generation and verification of XAdES signatures.
* Copyright (C) 2011 Luis Goncalves.
- *
+ *
* XAdES4j is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 3 of the License, or any later version.
- *
+ *
* XAdES4j is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
- *
+ *
* You should have received a copy of the GNU Lesser General Public License along
* with XAdES4j. If not, see .
*/
@@ -26,16 +26,16 @@
import org.apache.xml.security.keys.content.x509.XMLX509Certificate;
import org.apache.xml.security.signature.SignedInfo;
import org.apache.xml.security.signature.XMLSignature;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import xades4j.providers.impl.DefaultX500NameStyleProvider;
import xades4j.utils.SignatureServicesTestBase;
+import static org.junit.jupiter.api.Assertions.*;
+
/**
- *
* @author Luís
*/
public class KeyInfoBuilderTest extends SignatureServicesTestBase
@@ -44,7 +44,7 @@ public class KeyInfoBuilderTest extends SignatureServicesTestBase
private static X509Certificate intermCertificate;
private static List certificates;
- @BeforeClass
+ @BeforeAll
public static void setUpClass() throws Exception
{
org.apache.xml.security.Init.init();
@@ -58,8 +58,6 @@ public static void setUpClass() throws Exception
@Test
public void testIncludeCertAndKey() throws Exception
{
- System.out.println("includeCertAndKey");
-
KeyInfoBuilder keyInfoBuilder = new KeyInfoBuilder(
new BasicSignatureOptions().includeSigningCertificate(SigningCertificateMode.SIGNING_CERTIFICATE).includePublicKey(true),
new SignatureAlgorithms(),
@@ -69,20 +67,18 @@ public void testIncludeCertAndKey() throws Exception
keyInfoBuilder.buildKeyInfo(certificates, xmlSignature);
- Assert.assertEquals(0, xmlSignature.getSignedInfo().getLength());
+ assertEquals(0, xmlSignature.getSignedInfo().getLength());
KeyValue kv = xmlSignature.getKeyInfo().itemKeyValue(0);
- Assert.assertTrue(kv.getPublicKey().getAlgorithm().startsWith("RSA"));
+ assertTrue(kv.getPublicKey().getAlgorithm().startsWith("RSA"));
XMLX509Certificate x509Certificate = xmlSignature.getKeyInfo().itemX509Data(0).itemCertificate(0);
- Assert.assertEquals(testCertificate, x509Certificate.getX509Certificate());
+ assertEquals(testCertificate, x509Certificate.getX509Certificate());
}
-
- @Test
+
+ @Test
public void testIncludeCertChain() throws Exception
{
- System.out.println("includeCertChain");
-
KeyInfoBuilder keyInfoBuilder = new KeyInfoBuilder(
new BasicSignatureOptions().includeSigningCertificate(SigningCertificateMode.FULL_CHAIN),
new SignatureAlgorithms(),
@@ -92,23 +88,21 @@ public void testIncludeCertChain() throws Exception
keyInfoBuilder.buildKeyInfo(certificates, xmlSignature);
- Assert.assertEquals(0, xmlSignature.getSignedInfo().getLength());
-
- Assert.assertEquals(1, xmlSignature.getKeyInfo().lengthX509Data());
- Assert.assertEquals(2, xmlSignature.getKeyInfo().itemX509Data(0).lengthCertificate());
+ assertEquals(0, xmlSignature.getSignedInfo().getLength());
+
+ assertEquals(1, xmlSignature.getKeyInfo().lengthX509Data());
+ assertEquals(2, xmlSignature.getKeyInfo().itemX509Data(0).lengthCertificate());
XMLX509Certificate x509Certificate = xmlSignature.getKeyInfo().itemX509Data(0).itemCertificate(0);
- Assert.assertEquals(testCertificate, x509Certificate.getX509Certificate());
-
+ assertEquals(testCertificate, x509Certificate.getX509Certificate());
+
x509Certificate = xmlSignature.getKeyInfo().itemX509Data(0).itemCertificate(1);
- Assert.assertEquals(intermCertificate, x509Certificate.getX509Certificate());
+ assertEquals(intermCertificate, x509Certificate.getX509Certificate());
}
-
+
@Test
public void testIncludeIssuerSerial() throws Exception
{
- System.out.println("includeIssuerSerial");
-
KeyInfoBuilder keyInfoBuilder = new KeyInfoBuilder(
new BasicSignatureOptions().includeIssuerSerial(true),
new SignatureAlgorithms(),
@@ -118,15 +112,13 @@ public void testIncludeIssuerSerial() throws Exception
keyInfoBuilder.buildKeyInfo(certificates, xmlSignature);
- Assert.assertEquals(1, xmlSignature.getKeyInfo().lengthX509Data());
- Assert.assertEquals(1, xmlSignature.getKeyInfo().itemX509Data(0).lengthIssuerSerial());
+ assertEquals(1, xmlSignature.getKeyInfo().lengthX509Data());
+ assertEquals(1, xmlSignature.getKeyInfo().itemX509Data(0).lengthIssuerSerial());
}
-
+
@Test
public void testIncludeSubjectName() throws Exception
{
- System.out.println("includeSubjectName");
-
KeyInfoBuilder keyInfoBuilder = new KeyInfoBuilder(
new BasicSignatureOptions().includeSubjectName(true),
new SignatureAlgorithms(),
@@ -136,15 +128,13 @@ public void testIncludeSubjectName() throws Exception
keyInfoBuilder.buildKeyInfo(certificates, xmlSignature);
- Assert.assertEquals(1, xmlSignature.getKeyInfo().lengthX509Data());
- Assert.assertEquals(1, xmlSignature.getKeyInfo().itemX509Data(0).lengthSubjectName());
+ assertEquals(1, xmlSignature.getKeyInfo().lengthX509Data());
+ assertEquals(1, xmlSignature.getKeyInfo().itemX509Data(0).lengthSubjectName());
}
@Test
public void testSignKeyInfo() throws Exception
{
- System.out.println("signKeyInfo");
-
KeyInfoBuilder keyInfoBuilder = new KeyInfoBuilder(
new BasicSignatureOptions().signKeyInfo(true),
new SignatureAlgorithms(),
@@ -155,10 +145,10 @@ public void testSignKeyInfo() throws Exception
keyInfoBuilder.buildKeyInfo(certificates, xmlSignature);
SignedInfo signedInfo = xmlSignature.getSignedInfo();
- Assert.assertEquals(1, signedInfo.getLength());
+ assertEquals(1, signedInfo.getLength());
Node refNode = signedInfo.item(0).getContentsBeforeTransformation().getSubNode();
- Assert.assertSame(xmlSignature.getKeyInfo().getElement(), refNode);
+ assertSame(xmlSignature.getKeyInfo().getElement(), refNode);
}
private XMLSignature getTestSignature() throws Exception
diff --git a/src/test/java/xades4j/production/OtherSignerTests.java b/src/test/java/xades4j/production/OtherSignerTests.java
index fb0613b1..8adccd23 100644
--- a/src/test/java/xades4j/production/OtherSignerTests.java
+++ b/src/test/java/xades4j/production/OtherSignerTests.java
@@ -28,7 +28,7 @@
import xades4j.algorithms.EnvelopedSignatureTransform;
import xades4j.algorithms.ExclusiveCanonicalXMLWithoutComments;
import xades4j.properties.DataObjectDesc;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import xades4j.properties.QualifyingProperty;
@@ -49,7 +49,7 @@
import static org.apache.xml.security.c14n.Canonicalizer.ALGO_ID_C14N_OMIT_COMMENTS;
import static org.apache.xml.security.signature.XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA512;
import static org.apache.xml.security.utils.Constants.*;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Luís
@@ -59,8 +59,6 @@ public class OtherSignerTests extends SignerTestBase
@Test
public void testSignAndAppendAsFirstChild() throws Exception
{
- System.out.println("signAndAppendAsFirstChild");
-
Document doc = getTestDocument();
Element root = doc.getDocumentElement();
XadesSigner signer = new XadesBesSigningProfile(keyingProviderMy).newSigner();
@@ -94,8 +92,6 @@ public void testSignWithManifest() throws Exception
@Test
public void testSignUsingCustomResolver() throws Exception
{
- System.out.println("signUsingCustomResolver");
-
Document doc = getNewDocument();
XadesSigner signer = new XadesBesSigningProfile(keyingProviderMy).newSigner();
MyResolverSpi resolverSpi = new MyResolverSpi();
diff --git a/src/test/java/xades4j/production/PtCcSignerTests.java b/src/test/java/xades4j/production/PtCcSignerTests.java
index f96d6335..40f7d2ec 100644
--- a/src/test/java/xades4j/production/PtCcSignerTests.java
+++ b/src/test/java/xades4j/production/PtCcSignerTests.java
@@ -1,6 +1,6 @@
package xades4j.production;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import xades4j.providers.impl.DirectPasswordProvider;
@@ -17,7 +17,6 @@ public class PtCcSignerTests extends SignerTestBase
@Test
public void testSignTPtCC() throws Exception
{
- System.out.println("signTPtCitizenCard");
assumePtCcPkcs11();
Document doc = getTestDocument();
@@ -36,7 +35,6 @@ public void testSignTPtCC() throws Exception
@Test
public void testSignBesPtCCWindowsMy() throws Exception
{
- System.out.println("signBESPtCitizenCardWindowsMy");
assumeWindows();
assumePtCcPkcs11();
diff --git a/src/test/java/xades4j/production/SignedDataObjectsProcessorTest.java b/src/test/java/xades4j/production/SignedDataObjectsProcessorTest.java
index 78791fbd..dc29ff1f 100644
--- a/src/test/java/xades4j/production/SignedDataObjectsProcessorTest.java
+++ b/src/test/java/xades4j/production/SignedDataObjectsProcessorTest.java
@@ -30,22 +30,22 @@
import org.apache.xml.security.signature.ObjectContainer;
import org.apache.xml.security.signature.Reference;
import org.apache.xml.security.signature.XMLSignature;
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import xades4j.properties.DataObjectDesc;
import xades4j.utils.DOMHelper;
import xades4j.utils.SignatureServicesTestBase;
import xades4j.utils.StringUtils;
-import static org.junit.Assert.*;
+import static org.junit.jupiter.api.Assertions.*;
/**
* @author Luís
*/
public class SignedDataObjectsProcessorTest extends SignatureServicesTestBase
{
- @BeforeClass
+ @BeforeAll
public static void setUpClass()
{
Init.initXMLSec();
@@ -54,8 +54,6 @@ public static void setUpClass()
@Test
public void testProcess() throws Exception
{
- System.out.println("process");
-
Document doc = getNewDocument();
SignedDataObjects dataObjsDescs = new SignedDataObjects()
@@ -183,8 +181,6 @@ public boolean engineCanResolveURI(ResourceResolverContext context)
@Test
public void testAddNullReference() throws Exception
{
- System.out.println("addNullReference");
-
Document doc = SignatureServicesTestBase.getNewDocument();
SignedDataObjects dataObjsDescs = new SignedDataObjects()
@@ -204,21 +200,14 @@ public void testAddNullReference() throws Exception
assertNull(r.getElement().getAttributeNodeNS(Constants.SignatureSpecNS, "URI"));
}
- @Test(expected = IllegalStateException.class)
+ @Test
public void testAddMultipleNullReferencesFails() throws Exception
{
- System.out.println("addMultipleNullReferencesFails");
-
- Document doc = SignatureServicesTestBase.getNewDocument();
-
- SignedDataObjects dataObjsDescs = new SignedDataObjects()
- .withSignedDataObject(new AnonymousDataObjectReference("data1".getBytes()))
- .withSignedDataObject(new AnonymousDataObjectReference("data2".getBytes()));
-
- XMLSignature xmlSignature = new XMLSignature(doc, "", XMLSignature.ALGO_ID_SIGNATURE_RSA_SHA256);
- xmlSignature.setId("sigId");
-
- SignedDataObjectsProcessor processor = new SignedDataObjectsProcessor(new SignatureAlgorithms(), new AllwaysNullAlgsParamsMarshaller());
- processor.process(dataObjsDescs, xmlSignature);
+ SignedDataObjects dataObjsDescs = new SignedDataObjects();
+ assertThrows(IllegalStateException.class, () -> {
+ dataObjsDescs
+ .withSignedDataObject(new AnonymousDataObjectReference("data1".getBytes()))
+ .withSignedDataObject(new AnonymousDataObjectReference("data2".getBytes()));
+ });
}
}
diff --git a/src/test/java/xades4j/production/SignerBESTest.java b/src/test/java/xades4j/production/SignerBESTest.java
index ed775363..cd558318 100644
--- a/src/test/java/xades4j/production/SignerBESTest.java
+++ b/src/test/java/xades4j/production/SignerBESTest.java
@@ -19,7 +19,7 @@
import org.apache.xml.security.stax.impl.resourceResolvers.ResolverHttp;
import org.apache.xml.security.utils.resolver.implementations.ResolverDirectHTTP;
import org.apache.xml.security.utils.resolver.implementations.ResolverLocalFilesystem;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
@@ -51,8 +51,6 @@ public SignerBESTest()
@Test
public void testSignBES() throws Exception
{
- System.out.println("signBES");
-
Document doc1 = getTestDocument();
Document doc2 = getDocument("content.xml");
Node objectContent = doc1.importNode(doc2.getDocumentElement(), true);
@@ -74,8 +72,6 @@ public void testSignBES() throws Exception
@Test
public void testSignBESWithEllipticCurveKey() throws Exception
{
- System.out.println("testSignBESWithEllipticCurveKey");
-
Document doc = getTestDocument();
Element elemToSign = doc.getDocumentElement();
@@ -90,8 +86,6 @@ public void testSignBESWithEllipticCurveKey() throws Exception
@Test
public void testSignBESExternalRes() throws Exception
{
- System.out.println("signBESExternalRes");
-
Document doc = getNewDocument();
XadesSigner signer = new XadesBesSigningProfile(keyingProviderNist).with(DEFAULT_TEST_TSA).newSigner();
@@ -109,8 +103,6 @@ public void testSignBESExternalRes() throws Exception
@Test
public void testSignBESWithCounterSig() throws Exception
{
- System.out.println("signBESWithCounterSig");
-
Document doc = getTestDocument();
Element elemToSign = doc.getDocumentElement();
@@ -139,8 +131,6 @@ public void provideProperties(
@Test
public void testSignBESDetachedWithXPathAndNamespaces() throws Exception
{
- System.out.println("signBESDetachedWithXPathAndNamespaces");
-
Document doc = getNewDocument();
XadesSigner signer = new XadesBesSigningProfile(keyingProviderMy)
diff --git a/src/test/java/xades4j/production/SignerCTest.java b/src/test/java/xades4j/production/SignerCTest.java
index 60d99c5c..65d29cf8 100644
--- a/src/test/java/xades4j/production/SignerCTest.java
+++ b/src/test/java/xades4j/production/SignerCTest.java
@@ -18,7 +18,7 @@
import java.io.FileInputStream;
import java.io.InputStream;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import xades4j.providers.impl.HttpTsaConfiguration;
@@ -35,8 +35,6 @@ public class SignerCTest extends SignerTestBase
@Test
public void testSignC() throws Exception
{
- System.out.println("signC");
-
Document doc = getTestDocument();
Element elemToSign = doc.getDocumentElement();
@@ -50,8 +48,6 @@ public void testSignC() throws Exception
@Test
public void testSignFileDetachedC() throws Exception
{
- System.out.println("signFileDetachedC");
-
ValidationDataProvider vdp = new ValidationDataFromCertValidationProvider(VerifierTestBase.validationProviderNist);
XadesSigner signer = new XadesCSigningProfile(keyingProviderNist, vdp).with(DEFAULT_TEST_TSA).newSigner();
diff --git a/src/test/java/xades4j/production/SignerEPESTest.java b/src/test/java/xades4j/production/SignerEPESTest.java
index ca355dab..fbd3f5be 100644
--- a/src/test/java/xades4j/production/SignerEPESTest.java
+++ b/src/test/java/xades4j/production/SignerEPESTest.java
@@ -16,16 +16,8 @@
*/
package xades4j.production;
-import java.io.ByteArrayInputStream;
-import java.util.Arrays;
-import java.util.Collection;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.CsvSource;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import xades4j.properties.IdentifierType;
@@ -34,35 +26,23 @@
import xades4j.properties.SignaturePolicyIdentifierProperty;
import xades4j.providers.SignaturePolicyInfoProvider;
+import java.io.ByteArrayInputStream;
+
/**
- *
* @author Luís
*/
-@RunWith(Parameterized.class)
public class SignerEPESTest extends SignerTestBase
{
- @Parameter(0)
- public String locationUrl;
- @Parameter(1)
- public String output;
-
- @Parameters
- public static Collection