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 "http://anonsvn.icesoft.org/repo/maven2/releases/" } maven { url "https://repository.jboss.org/nexus/content/repositories/thirdparty-releases/" } } configurations{ pdfBox2Compile pdfBox1Compile } sourceSets{ pdfBox2{ compileClasspath = configurations.pdfBox2Compile } pdfBox1{ compileClasspath = configurations.pdfBox1Compile } } dependencies { compile project (':pdf-as-lib') testCompile project (':pdf-as-moa') compile project (':signature-standards:sigs-pkcs7detached') compile project (':signature-standards:sigs-pades') compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.7' testCompile group: 'junit', name: 'junit', version: '4.+' testCompile group: 'org.icepdf', name: 'icepdf-core', version: '5.0.7' pdfBox1Compile project (':pdf-as-pdfbox') pdfBox1Compile group: 'org.apache.pdfbox', name: 'preflight', version: '1.8.7' pdfBox1Compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '1.8.7' pdfBox2Compile project (':pdf-as-pdfbox-2') pdfBox2Compile group: 'org.apache.pdfbox', name: 'preflight', version: '2.0.2' pdfBox2Compile group: 'org.apache.pdfbox', name: 'pdfbox', version: '2.0.2' pdfBox2Compile group: 'org.apache.pdfbox', name: 'pdfbox-tools', version: '2.0.2' } 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 //based on executed testsuit we setup the classpath if(dirname =="public_pdfbox1"){ classpath += sourceSets.pdfBox1.compileClasspath compileTestJava.classpath += sourceSets.pdfBox1.compileClasspath } 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()}"() << { 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) } }