package org.jscep.response;

import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

@RunWith(Parameterized.class)
public class CapabilitiesMessageDigestTest {
    @Parameters
    public static Collection<Object[]> getParameters() {
        List<Object[]> params = new ArrayList<Object[]>();

        Capabilities capabilities;

        capabilities = new Capabilities();
        params.add(new Object[]{capabilities, "MD5"});
        capabilities = new Capabilities(Capability.SHA_1);
        params.add(new Object[]{capabilities, "SHA-1"});
        capabilities = new Capabilities(Capability.SHA_1, Capability.SHA_256);
        params.add(new Object[]{capabilities, "SHA-256"});
        capabilities = new Capabilities(Capability.SHA_1, Capability.SHA_256, Capability.SHA_512);
        params.add(new Object[]{capabilities, "SHA-512"});

        return params;
    }

    private final Capabilities capabilities;
    private final String algorithm;

    public CapabilitiesMessageDigestTest(Capabilities capabilities, String algorithm) {
        this.capabilities = capabilities;
        this.algorithm = algorithm;
    }

    @Test
    public void testStrongestMessageDigest() {
        Assert.assertEquals(algorithm, capabilities.getStrongestMessageDigest());
    }
}

@@ -33,24 +33,231 @@
 ort 
-org.junit.Assert
+java.security.Provider;%0Aimport java.security.Provider.Service;%0Aimport java.security.Security;%0Aimport java.util.ArrayList;%0Aimport java.util.Collection;%0Aimport java.util.List;%0A%0Aimport org.junit.Assert;%0Aimport org.junit.Assume
 ;%0Aim
@@ -406,89 +406,8 @@
 s;%0A%0A
-import java.util.ArrayList;%0Aimport java.util.Collection;%0Aimport java.util.List;%0A%0A
 @Run
@@ -1495,24 +1495,76 @@
 eDigest() %7B%0A
+    %09Assume.assumeTrue(algorithmExists(algorithm));%0A
         Asse
@@ -1639,10 +1639,333 @@
 ;%0A    %7D%0A
+    %0A    private boolean algorithmExists(String algorithm) %7B%0A%09%09for (Provider provider : Security.getProviders()) %7B%0A%09%09%09for (Service service : provider.getServices()) %7B%0A%09%09%09%09if (service.getType().equals(%22MessageDigest%22)%0A%09%09%09%09%09%09&& service.getAlgorithm().equals(algorithm)) %7B%0A%09%09%09%09%09return true;%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return false;%0A%09%7D%0A
 %7D%0A

Add assumption for test.