Search in sources :

Example 6 with Parameters

use of org.junit.runners.Parameterized.Parameters in project jetty.project by eclipse.

the class ResourceTest method data.

@Parameters(name = "{0}")
public static Collection<Data[]> data() throws Exception {
    UseCases cases = new UseCases("src/test/resources/");
    File testDir = MavenTestingUtils.getTargetTestingDir(ResourceTest.class.getName());
    FS.ensureEmpty(testDir);
    File tmpFile = File.createTempFile("test", null, testDir);
    cases.addCase(new Data(tmpFile.toString(), EXISTS, !DIR));
    // Some resource references.
    cases.addAllSimpleCases("resource.txt", EXISTS, !DIR);
    cases.addAllSimpleCases("NoName.txt", !EXISTS, !DIR);
    // Some addPath() forms
    cases.addAllAddPathCases("resource.txt", EXISTS, !DIR);
    cases.addAllAddPathCases("/resource.txt", EXISTS, !DIR);
    cases.addAllAddPathCases("//resource.txt", EXISTS, !DIR);
    cases.addAllAddPathCases("NoName.txt", !EXISTS, !DIR);
    cases.addAllAddPathCases("/NoName.txt", !EXISTS, !DIR);
    cases.addAllAddPathCases("//NoName.txt", !EXISTS, !DIR);
    Data tdata1 = cases.addAllAddPathCases("TestData", EXISTS, DIR);
    Data tdata2 = cases.addAllAddPathCases("TestData/", EXISTS, DIR);
    cases.addCase(new Data(tdata1, "alphabet.txt", EXISTS, !DIR, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
    cases.addCase(new Data(tdata2, "alphabet.txt", EXISTS, !DIR, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
    cases.addCase(new Data("jar:file:/somejar.jar!/content/", !EXISTS, DIR));
    cases.addCase(new Data("jar:file:/somejar.jar!/", !EXISTS, DIR));
    String urlRef = cases.uriRef.toASCIIString();
    Data zdata = new Data("jar:" + urlRef + "TestData/test.zip!/", EXISTS, DIR);
    cases.addCase(zdata);
    cases.addCase(new Data(zdata, "Unkown", !EXISTS, !DIR));
    cases.addCase(new Data(zdata, "/Unkown/", !EXISTS, DIR));
    cases.addCase(new Data(zdata, "subdir", EXISTS, DIR));
    cases.addCase(new Data(zdata, "/subdir/", EXISTS, DIR));
    cases.addCase(new Data(zdata, "alphabet", EXISTS, !DIR, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
    cases.addCase(new Data(zdata, "/subdir/alphabet", EXISTS, !DIR, "ABCDEFGHIJKLMNOPQRSTUVWXYZ"));
    cases.addAllAddPathCases("/TestData/test/subdir/subsubdir/", EXISTS, DIR);
    cases.addAllAddPathCases("//TestData/test/subdir/subsubdir/", EXISTS, DIR);
    cases.addAllAddPathCases("/TestData//test/subdir/subsubdir/", EXISTS, DIR);
    cases.addAllAddPathCases("/TestData/test//subdir/subsubdir/", EXISTS, DIR);
    cases.addAllAddPathCases("/TestData/test/subdir//subsubdir/", EXISTS, DIR);
    cases.addAllAddPathCases("TestData/test/subdir/subsubdir/", EXISTS, DIR);
    cases.addAllAddPathCases("TestData/test/subdir/subsubdir//", EXISTS, DIR);
    cases.addAllAddPathCases("TestData/test/subdir//subsubdir/", EXISTS, DIR);
    cases.addAllAddPathCases("TestData/test//subdir/subsubdir/", EXISTS, DIR);
    cases.addAllAddPathCases("/TestData/../TestData/test/subdir/subsubdir/", EXISTS, DIR);
    return cases.data;
}
Also used : File(java.io.File) Parameters(org.junit.runners.Parameterized.Parameters)

Example 7 with Parameters

use of org.junit.runners.Parameterized.Parameters in project jsonschema2pojo by joelittlejohn.

the class CompilerWarningIT method parameters.

@Parameters(name = "{0}")
public static Collection<Object[]> parameters() {
    JavaCompiler systemJavaCompiler = Compiler.systemJavaCompiler();
    JavaCompiler eclipseCompiler = Compiler.eclipseCompiler();
    return Arrays.asList(new Object[][] { { "includeAccessorsWithSystemJavaCompiler", systemJavaCompiler, config("includeDynamicAccessors", true), "/schema/dynamic/parentType.json", Matchers.empty() }, { "includeAccessorsWithEclipseCompiler", eclipseCompiler, config("includeDynamicAccessors", true), "/schema/dynamic/parentType.json", onlyCastExceptions() } });
}
Also used : JavaCompiler(javax.tools.JavaCompiler) Parameters(org.junit.runners.Parameterized.Parameters)

Example 8 with Parameters

use of org.junit.runners.Parameterized.Parameters in project camel by apache.

the class BulkApiJobIntegrationTest method getJobs.

// test jobs for testJobLifecycle
@Parameters(name = "operation = {1}")
public static Iterable<Object[]> getJobs() {
    final List<JobInfo> result = new ArrayList<>();
    // insert XML
    final JobInfo insertXml = new JobInfo();
    insertXml.setObject(Merchandise__c.class.getSimpleName());
    insertXml.setContentType(ContentType.XML);
    insertXml.setOperation(OperationEnum.INSERT);
    result.add(insertXml);
    // insert CSV
    JobInfo insertCsv = new JobInfo();
    insertCsv = new JobInfo();
    insertCsv.setObject(Merchandise__c.class.getSimpleName());
    insertCsv.setContentType(ContentType.CSV);
    insertCsv.setOperation(OperationEnum.INSERT);
    result.add(insertCsv);
    // update CSV
    final JobInfo updateCsv = new JobInfo();
    updateCsv.setObject(Merchandise__c.class.getSimpleName());
    updateCsv.setContentType(ContentType.CSV);
    updateCsv.setOperation(OperationEnum.UPDATE);
    result.add(updateCsv);
    // upsert CSV
    final JobInfo upsertCsv = new JobInfo();
    upsertCsv.setObject(Merchandise__c.class.getSimpleName());
    upsertCsv.setContentType(ContentType.CSV);
    upsertCsv.setOperation(OperationEnum.UPSERT);
    upsertCsv.setExternalIdFieldName("Name");
    result.add(upsertCsv);
    // delete CSV
    final JobInfo deleteCsv = new JobInfo();
    deleteCsv.setObject(Merchandise__c.class.getSimpleName());
    deleteCsv.setContentType(ContentType.CSV);
    deleteCsv.setOperation(OperationEnum.DELETE);
    result.add(deleteCsv);
    // hard delete CSV
    final JobInfo hardDeleteCsv = new JobInfo();
    hardDeleteCsv.setObject(Merchandise__c.class.getSimpleName());
    hardDeleteCsv.setContentType(ContentType.CSV);
    hardDeleteCsv.setOperation(OperationEnum.HARD_DELETE);
    result.add(hardDeleteCsv);
    // query CSV
    final JobInfo queryCsv = new JobInfo();
    queryCsv.setObject(Merchandise__c.class.getSimpleName());
    queryCsv.setContentType(ContentType.CSV);
    queryCsv.setOperation(OperationEnum.QUERY);
    result.add(queryCsv);
    return result.stream().map(j -> new Object[] { j, j.getOperation().name() }).collect(Collectors.toList());
}
Also used : JobInfo(org.apache.camel.component.salesforce.api.dto.bulk.JobInfo) JobStateEnum(org.apache.camel.component.salesforce.api.dto.bulk.JobStateEnum) OperationEnum(org.apache.camel.component.salesforce.api.dto.bulk.OperationEnum) Parameter(org.junit.runners.Parameterized.Parameter) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) IOException(java.io.IOException) Test(org.junit.Test) Merchandise__c(org.apache.camel.component.salesforce.dto.generated.Merchandise__c) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) ParallelParameterized(com.googlecode.junittoolbox.ParallelParameterized) List(java.util.List) ContentType(org.apache.camel.component.salesforce.api.dto.bulk.ContentType) Before(org.junit.Before) JobInfo(org.apache.camel.component.salesforce.api.dto.bulk.JobInfo) ArrayList(java.util.ArrayList) Merchandise__c(org.apache.camel.component.salesforce.dto.generated.Merchandise__c) Parameters(org.junit.runners.Parameterized.Parameters)

Example 9 with Parameters

use of org.junit.runners.Parameterized.Parameters in project cas by apereo.

the class CRLDistributionPointRevocationCheckerTests method getTestParameters.

/**
     * Gets the unit test parameters.
     *
     * @return Test parameter data.
     */
@Parameters
public static Collection<Object[]> getTestParameters() throws Exception {
    CacheManager.getInstance().removeAllCaches();
    final Collection<Object[]> params = new ArrayList<>();
    Cache cache;
    final ThresholdExpiredCRLRevocationPolicy defaultPolicy = new ThresholdExpiredCRLRevocationPolicy(0);
    final ThresholdExpiredCRLRevocationPolicy zeroThresholdPolicy = new ThresholdExpiredCRLRevocationPolicy(0);
    // Test case #0
    // Valid certificate on valid CRL data with encoded url
    cache = new Cache("crlCache-0", 100, false, false, 20, 10);
    CacheManager.getInstance().addCache(cache);
    params.add(new Object[] { new CRLDistributionPointRevocationChecker(cache, defaultPolicy, null), new String[] { "uservalid-encoded-crl.crt" }, "test ca.crl", null });
    // Test case #1
    // Valid certificate on valid CRL data
    cache = new Cache("crlCache-1", 100, false, false, 20, 10);
    CacheManager.getInstance().addCache(cache);
    params.add(new Object[] { new CRLDistributionPointRevocationChecker(cache, defaultPolicy, null, true), new String[] { "user-valid-distcrl.crt" }, "userCA-valid.crl", null });
    // Test case #2
    // Revoked certificate on valid CRL data
    cache = new Cache("crlCache-2", 100, false, false, 20, 10);
    CacheManager.getInstance().addCache(cache);
    params.add(new Object[] { new CRLDistributionPointRevocationChecker(cache, defaultPolicy, null), new String[] { "user-revoked-distcrl.crt" }, "userCA-valid.crl", new RevokedCertificateException(ZonedDateTime.now(ZoneOffset.UTC), new BigInteger("1")) });
    // Test case #3
    // Valid certificate on expired CRL data
    cache = new Cache("crlCache-3", 100, false, false, 20, 10);
    CacheManager.getInstance().addCache(cache);
    params.add(new Object[] { new CRLDistributionPointRevocationChecker(cache, zeroThresholdPolicy, null), new String[] { "user-valid-distcrl.crt" }, "userCA-expired.crl", new ExpiredCRLException("test", ZonedDateTime.now(ZoneOffset.UTC)) });
    // Test case #4
    // Valid certificate on expired CRL data with custom expiration
    // policy to always allow expired CRL data
    cache = new Cache("crlCache-4", 100, false, false, 20, 10);
    CacheManager.getInstance().addCache(cache);
    params.add(new Object[] { new CRLDistributionPointRevocationChecker(cache, crl -> {
    }, null), new String[] { "user-valid-distcrl.crt" }, "userCA-expired.crl", null });
    // Test case #5
    // Valid certificate with no CRL distribution points defined but with
    // "AllowRevocationPolicy" set to allow unavailable CRL data
    cache = new Cache("crlCache-5", 100, false, false, 20, 10);
    CacheManager.getInstance().addCache(cache);
    final CRLDistributionPointRevocationChecker checker5 = new CRLDistributionPointRevocationChecker(cache, defaultPolicy, new AllowRevocationPolicy());
    params.add(new Object[] { checker5, new String[] { "user-valid.crt" }, "userCA-expired.crl", null });
    // Test case #6
    // EJBCA test case
    // Revoked certificate with CRL distribution point URI that is technically
    // not a valid URI since the issuer DN in the query string is not encoded per
    // the escaping of reserved characters in RFC 2396.
    // Make sure we can convert given URI to valid URI and confirm it's revoked
    cache = new Cache("crlCache-6", 100, false, false, 20, 10);
    CacheManager.getInstance().addCache(cache);
    params.add(new Object[] { new CRLDistributionPointRevocationChecker(cache, defaultPolicy, null), new String[] { "user-revoked-distcrl2.crt" }, "userCA-valid.crl", new RevokedCertificateException(ZonedDateTime.now(ZoneOffset.UTC), new BigInteger("1")) });
    return params;
}
Also used : ZonedDateTime(java.time.ZonedDateTime) ExpiredCRLException(org.apereo.cas.adaptors.x509.authentication.ExpiredCRLException) CacheManager(net.sf.ehcache.CacheManager) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) LoggerFactory(org.slf4j.LoggerFactory) ClassPathResource(org.springframework.core.io.ClassPathResource) RevokedCertificateException(org.apereo.cas.adaptors.x509.authentication.revocation.RevokedCertificateException) ArrayList(java.util.ArrayList) GeneralSecurityException(java.security.GeneralSecurityException) RevocationChecker(org.apereo.cas.adaptors.x509.authentication.revocation.checker.RevocationChecker) After(org.junit.After) BigInteger(java.math.BigInteger) ZoneOffset(java.time.ZoneOffset) Parameterized(org.junit.runners.Parameterized) Before(org.junit.Before) MockWebServer(org.apereo.cas.adaptors.x509.util.MockWebServer) OutputStream(java.io.OutputStream) AfterClass(org.junit.AfterClass) Logger(org.slf4j.Logger) Collection(java.util.Collection) FileSystemResource(org.springframework.core.io.FileSystemResource) FileOutputStream(java.io.FileOutputStream) File(java.io.File) CRLDistributionPointRevocationChecker(org.apereo.cas.adaptors.x509.authentication.revocation.checker.CRLDistributionPointRevocationChecker) IOUtils(org.apache.commons.io.IOUtils) ThresholdExpiredCRLRevocationPolicy(org.apereo.cas.adaptors.x509.authentication.revocation.policy.ThresholdExpiredCRLRevocationPolicy) AllowRevocationPolicy(org.apereo.cas.adaptors.x509.authentication.revocation.policy.AllowRevocationPolicy) Cache(net.sf.ehcache.Cache) ExpiredCRLException(org.apereo.cas.adaptors.x509.authentication.ExpiredCRLException) CRLDistributionPointRevocationChecker(org.apereo.cas.adaptors.x509.authentication.revocation.checker.CRLDistributionPointRevocationChecker) RevokedCertificateException(org.apereo.cas.adaptors.x509.authentication.revocation.RevokedCertificateException) AllowRevocationPolicy(org.apereo.cas.adaptors.x509.authentication.revocation.policy.AllowRevocationPolicy) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ThresholdExpiredCRLRevocationPolicy(org.apereo.cas.adaptors.x509.authentication.revocation.policy.ThresholdExpiredCRLRevocationPolicy) Cache(net.sf.ehcache.Cache) Parameters(org.junit.runners.Parameterized.Parameters)

Example 10 with Parameters

use of org.junit.runners.Parameterized.Parameters in project cas by apereo.

the class ResourceCRLRevocationCheckerTests method getTestParameters.

/**
     * Gets the unit test parameters.
     *
     * @return Test parameter data.
     */
@Parameters
public static Collection<Object[]> getTestParameters() {
    final Collection<Object[]> params = new ArrayList<>();
    final ThresholdExpiredCRLRevocationPolicy zeroThresholdPolicy = new ThresholdExpiredCRLRevocationPolicy(0);
    // Test case #1
    // Valid certificate on valid CRL data
    params.add(new Object[] { new ResourceCRLRevocationChecker(new ClassPathResource[] { new ClassPathResource("userCA-valid.crl") }, zeroThresholdPolicy), new String[] { "user-valid.crt" }, null });
    // Test case #2
    // Revoked certificate on valid CRL data
    params.add(new Object[] { new ResourceCRLRevocationChecker(new ClassPathResource[] { new ClassPathResource("userCA-valid.crl"), new ClassPathResource("intermediateCA-valid.crl"), new ClassPathResource("rootCA-valid.crl") }, zeroThresholdPolicy), new String[] { "user-revoked.crt", "userCA.crt", "intermediateCA.crt", "rootCA.crt" }, new RevokedCertificateException(ZonedDateTime.now(ZoneOffset.UTC), new BigInteger("1")) });
    // Test case #3
    // Valid certificate on expired CRL data for head cert
    params.add(new Object[] { new ResourceCRLRevocationChecker(new ClassPathResource[] { new ClassPathResource("userCA-expired.crl"), new ClassPathResource("intermediateCA-valid.crl"), new ClassPathResource("rootCA-valid.crl") }, zeroThresholdPolicy), new String[] { "user-valid.crt", "userCA.crt", "intermediateCA.crt", "rootCA.crt" }, new ExpiredCRLException("test", ZonedDateTime.now(ZoneOffset.UTC)) });
    // Test case #4
    // Valid certificate on expired CRL data for intermediate cert
    params.add(new Object[] { new ResourceCRLRevocationChecker(new ClassPathResource[] { new ClassPathResource("userCA-valid.crl"), new ClassPathResource("intermediateCA-expired.crl"), new ClassPathResource("rootCA-valid.crl") }, zeroThresholdPolicy), new String[] { "user-valid.crt", "userCA.crt", "intermediateCA.crt", "rootCA.crt" }, new ExpiredCRLException("test", ZonedDateTime.now(ZoneOffset.UTC)) });
    // Test case #5
    // Valid certificate on expired CRL data with custom expiration
    // policy to always allow expired CRL data
    params.add(new Object[] { new ResourceCRLRevocationChecker(new ClassPathResource[] { new ClassPathResource("userCA-expired.crl") }, crl -> {
    }), new String[] { "user-valid.crt" }, null });
    return params;
}
Also used : ZonedDateTime(java.time.ZonedDateTime) Collection(java.util.Collection) ExpiredCRLException(org.apereo.cas.adaptors.x509.authentication.ExpiredCRLException) RunWith(org.junit.runner.RunWith) Parameters(org.junit.runners.Parameterized.Parameters) ClassPathResource(org.springframework.core.io.ClassPathResource) RevokedCertificateException(org.apereo.cas.adaptors.x509.authentication.revocation.RevokedCertificateException) ResourceCRLRevocationChecker(org.apereo.cas.adaptors.x509.authentication.revocation.checker.ResourceCRLRevocationChecker) ArrayList(java.util.ArrayList) GeneralSecurityException(java.security.GeneralSecurityException) RevocationChecker(org.apereo.cas.adaptors.x509.authentication.revocation.checker.RevocationChecker) ThresholdExpiredCRLRevocationPolicy(org.apereo.cas.adaptors.x509.authentication.revocation.policy.ThresholdExpiredCRLRevocationPolicy) BigInteger(java.math.BigInteger) ZoneOffset(java.time.ZoneOffset) Parameterized(org.junit.runners.Parameterized) ExpiredCRLException(org.apereo.cas.adaptors.x509.authentication.ExpiredCRLException) RevokedCertificateException(org.apereo.cas.adaptors.x509.authentication.revocation.RevokedCertificateException) ResourceCRLRevocationChecker(org.apereo.cas.adaptors.x509.authentication.revocation.checker.ResourceCRLRevocationChecker) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) ThresholdExpiredCRLRevocationPolicy(org.apereo.cas.adaptors.x509.authentication.revocation.policy.ThresholdExpiredCRLRevocationPolicy) ClassPathResource(org.springframework.core.io.ClassPathResource) Parameters(org.junit.runners.Parameterized.Parameters)

Aggregations

Parameters (org.junit.runners.Parameterized.Parameters)70 ArrayList (java.util.ArrayList)41 File (java.io.File)20 TestCaseContext (org.apache.asterix.testframework.context.TestCaseContext)6 Date (java.util.Date)5 SslContext (io.netty.handler.ssl.SslContext)4 ExpiredCRLException (org.apereo.cas.adaptors.x509.authentication.ExpiredCRLException)4 ThresholdExpiredCRLRevocationPolicy (org.apereo.cas.adaptors.x509.authentication.revocation.policy.ThresholdExpiredCRLRevocationPolicy)4 RunWith (org.junit.runner.RunWith)4 ClassPathResource (org.springframework.core.io.ClassPathResource)4 ZonedDateTime (java.time.ZonedDateTime)3 Configuration (org.apache.hadoop.conf.Configuration)3 YarnConfiguration (org.apache.hadoop.yarn.conf.YarnConfiguration)3 RevokedCertificateException (org.apereo.cas.adaptors.x509.authentication.revocation.RevokedCertificateException)3 Parameterized (org.junit.runners.Parameterized)3 CollectionAgentDTO (org.opennms.netmgt.collection.dto.CollectionAgentDTO)3 FileFilter (java.io.FileFilter)2 Field (java.lang.reflect.Field)2 BigInteger (java.math.BigInteger)2 GeneralSecurityException (java.security.GeneralSecurityException)2