apply plugin: 'java' apply plugin: 'eclipse' jar { manifest { attributes 'Implementation-Title': 'PDF-AS-4 Test Library', 'JARMANIFEST': 'PDF-AS-LIB' } } repositories { mavenLocal() mavenCentral() maven { url "https://repository.jboss.org/maven2/" } maven { url "http://anonsvn.icesoft.org/repo/maven2/releases/" } maven { url "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/" } } configurations{ pdfBox2Compile } sourceSets{ pdfBox2{ compileClasspath = configurations.pdfBox2Compile } } dependencies { implementation project (':pdf-as-lib') testImplementation project (':pdf-as-moa') implementation project (':signature-standards:sigs-pkcs7detached') implementation project (':signature-standards:sigs-pades') implementation group: 'org.slf4j', name: 'slf4j-api', version: '1.7.7' implementation group: 'javax.activation', name: 'activation', version: '1.1.1' testImplementation group: 'org.icepdf.os', name: 'icepdf-core', version: '6.1.1' implementation project (':pdf-as-pdfbox-2') //compile group: 'org.apache.pdfbox', name: 'preflight', version: '2.0.21' //compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '2.0.21' //compile group: 'org.apache.pdfbox', name: 'pdfbox-tools', version: '2.0.21' } logger.info("Building tasks for Test suites") def suiteDir = new File(projectDir, "src/test/test-suites") logger.info("Searching: " + suiteDir.absolutePath) //Eclipse UI shows an error because source set dependencies are not recognized, so we add the dependencies manually //eclipse.classpath.plusConfigurations+=[configurations.pdfBox1Compile] suiteDir.eachDir { File subDir -> def dirname = subDir.name logger.info("Test Suite " + subDir.name + " found in " + subDir.absolutePath) task "runTestSuite${dirname.capitalize()}"(type: Test) { description "runs tests from Test Suite: " + dirname systemProperties 'test.dir': subDir.absolutePath if(dirname =="public_pdfbox2"){ classpath += sourceSets.pdfBox2.compileClasspath compileTestJava.classpath += sourceSets.pdfBox2.compileClasspath } include '**/ParameterizedSignatureTestSuite.class' beforeSuite { TestDescriptor descriptor -> if(descriptor.getParent() == null) { logger.quiet("++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); } if(descriptor.getClassName().equals("at.gv.egiz.param_tests.ParameterizedSignatureTestSuite")) { logger.quiet("Starting suite: " + dirname + " (" + descriptor.getName() + ")") } } afterSuite { TestDescriptor descriptor, TestResult result -> if(descriptor.getClassName().equals("at.gv.egiz.param_tests.ParameterizedSignatureTestSuite")) { logger.quiet("------------------"); logger.quiet("Ending suite: " + dirname); logger.quiet("\tResult (SUCCESS/ERROR/SKIPPED/TOTAL): " + result.getSuccessfulTestCount() + "/" + result.getFailedTestCount() + "/" + result.getSkippedTestCount() + "/" + result.getTestCount()); float duration_ms = result.getEndTime() - result.getStartTime() float duration_sec = duration_ms / 1000.0f logger.quiet("\tDuration: " + duration_sec + " s [" + duration_ms + " ms]") logger.quiet("\tReport @ file://" + subDir.absolutePath + "/index.html") } if(descriptor.getParent() == null) { logger.quiet("++++++++++++++++++++++++++++++++++++++++++++++++++++++++"); } } beforeTest { TestDescriptor descriptor -> logger.quiet("------------------"); logger.info("Running test: " + descriptor.getName()) } afterTest { TestDescriptor descriptor, TestResult result -> float duration_ms = result.getEndTime() - result.getStartTime() float duration_sec = duration_ms / 1000.0f logger.quiet(result.getResultType().toString() + " => [" + descriptor.getName() + "] took " + duration_sec + " s [" + duration_ms + " ms]") if(TestResult.ResultType.FAILURE.equals(result.getResultType())) { if(result.getException() != null) { logger.error("Failed test: " + result.getException().getMessage()); result.getException().printStackTrace(); } else { logger.error("Failed test provided no exception"); } } } } test.dependsOn tasks.getByPath("runTestSuite${dirname.capitalize()}") task "cleanTestSuite${dirname.capitalize()}"(type: Delete) { outputs.upToDateWhen { false } delete fileTree (dir: subDir.absolutePath, include: "index.html") delete fileTree (dir: subDir.absolutePath, include: "**/test_result.html") } task "cleanOutFolders${dirname.capitalize()}"() { doLast { subDir.eachDir { File tcDir -> File outDir = new File(tcDir, "out"); if(outDir.exists() && outDir.isDirectory()) { outDir.eachFileRecurse { File mfile -> mfile.delete() } outDir.delete() } } } } clean.dependsOn tasks.getByPath("cleanOutFolders${dirname.capitalize()}") clean.dependsOn tasks.getByPath("cleanTestSuite${dirname.capitalize()}") } tasks.getByPath(":pdf-as-lib:test").dependsOn test test { include '**/DummyTest.class' beforeTest { TestDescriptor descriptor -> logger.quiet("------------------"); logger.quiet("Running test: " + descriptor.getName()) } afterTest { TestDescriptor descriptor, TestResult result -> logger.quiet("Ending test: " + descriptor.getName() + " result " + result) } }