seanjmullan commented on code in PR #204:
URL: 
https://github.com/apache/santuario-xml-security-java/pull/204#discussion_r1318772045


##########
src/test/java/org/apache/xml/security/test/dom/algorithms/SignatureAlgorithmTest.java:
##########
@@ -104,18 +104,23 @@ void testConstructionWithProvider() throws Exception {
         assertFalse(algorithmHash.isEmpty());
 
         Document doc = TestUtils.newDocument();
-        Provider provider = new 
org.bouncycastle.jce.provider.BouncyCastleProvider();
-
-        for (String algorithmURI : algorithmHash.keySet()) {
-            try {
-                AlgorithmParameterSpec spec = 
algorithmURI.equals(XMLSignature.ALGO_ID_SIGNATURE_RSA_PSS)
-                        ? new PSSParameterSpec("SHA-256", "MGF1", 
MGF1ParameterSpec.SHA256, 32, 1)
-                        : null;
-                SignatureAlgorithm signatureAlgorithm = new 
SignatureAlgorithm(doc, algorithmURI, provider, spec);
-                assertEquals(provider.getName(), 
signatureAlgorithm.getJCEProviderName());
-            } catch (XMLSecurityException e) {
-                assertEquals("", Arrays.asList(e.getStackTrace()).toString());
+        try {
+            Class<?> bouncyCastleProviderClass = 
Class.forName("org.bouncycastle.jce.provider.BouncyCastleProvider");
+            Provider provider = 
(Provider)bouncyCastleProviderClass.getConstructor().newInstance();
+
+            for (String algorithmURI : algorithmHash.keySet()) {
+                try {
+                    AlgorithmParameterSpec spec = 
algorithmURI.equals(XMLSignature.ALGO_ID_SIGNATURE_RSA_PSS)
+                            ? new PSSParameterSpec("SHA-256", "MGF1", 
MGF1ParameterSpec.SHA256, 32, 1)
+                            : null;
+                    SignatureAlgorithm signatureAlgorithm = new 
SignatureAlgorithm(doc, algorithmURI, provider, spec);
+                    assertEquals(provider.getName(), 
signatureAlgorithm.getJCEProviderName());
+                } catch (XMLSecurityException e) {
+                    assertEquals("", 
Arrays.asList(e.getStackTrace()).toString());
+                }
             }
+        } catch (ReflectiveOperationException e) {
+            // BouncyCastle not installed, ignore
         }

Review Comment:
   It might be useful to add `Assumptions.assumeNotNull(provider)` here so the 
test is skipped instead of ignored. (You will need to expand the scope of the 
`provider` object.)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to