use of org.gradle.testkit.runner.GradleRunner in project crate by crate.
the class JdkDownloadPluginFunctionalTest method runBuild.
private static void runBuild(String task, Consumer<BuildResult> assertions, String os, String arch, String vendor, String version) {
var testKitDirPath = Paths.get(System.getProperty("user.dir"), "build", System.getProperty("user.name"));
WireMockServer wireMock = new WireMockServer(0);
try {
wireMock.stubFor(head(urlEqualTo(urlPath(vendor, version, os, arch))).willReturn(aResponse().withStatus(200)));
wireMock.stubFor(get(urlEqualTo(urlPath(vendor, version, os, arch))).willReturn(aResponse().withStatus(200).withBody(filebytes(vendor, version, os, arch))));
wireMock.start();
GradleRunner runner = GradleRunner.create().withDebug(true).withProjectDir(getTestKitProjectDir("jdk-download")).withTestKitDir(testKitDirPath.toFile()).withArguments(task, "-Dtests.jdk_vendor=" + vendor, "-Dtests.jdk_version=" + version, "-Dtests.jdk_repo=" + wireMock.baseUrl(), "-i").withPluginClasspath();
BuildResult result = runner.build();
assertions.accept(result);
} catch (IOException e) {
fail("cannot get artifacts from resources: " + e.getLocalizedMessage());
} finally {
wireMock.stop();
}
}
use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class CgenTaskIT method classGeneratingWithCustomConfigSuccess.
@Test
public void classGeneratingWithCustomConfigSuccess() throws Exception {
GradleRunner runner = createRunner("cgen_custom_config", "cgen", "-PdataMap=test_datamap.map.xml");
BuildResult result = runner.build();
String generatedDirectoryPath = projectDir.getAbsolutePath() + "/customDirectory/org/example/cayenne/persistent/";
String generatedClassPath = generatedDirectoryPath + "City.groovy";
String excludedClassPath = generatedDirectoryPath + "Artist.groovy";
String generatedParentClassPath = generatedDirectoryPath + "auto/_City.groovy";
String excludedParentClassPath = generatedDirectoryPath + "auto/_Artist.groovy";
File generatedClass = new File(generatedClassPath);
File excludedClass = new File(excludedClassPath);
File generatedParentClass = new File(generatedParentClassPath);
File excludedParentClass = new File(excludedParentClassPath);
assertTrue(generatedClass.exists());
assertTrue(!excludedClass.exists());
assertTrue(!excludedParentClass.exists());
assertTrue(!generatedParentClass.exists());
assertEquals(TaskOutcome.SUCCESS, result.task(":cgen").getOutcome());
}
use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class CgenTaskIT method testWithConfigsInDmAndPom.
@Test
public void testWithConfigsInDmAndPom() throws Exception {
GradleRunner runner = createRunner("cgen_with_configs", "cgen", "-PdataMap=cgenMap.map.xml");
BuildResult result = runner.forwardOutput().build();
String generatedDirectoryPath = projectDir.getAbsolutePath() + "/customDirectory/";
String generatedClassPath = generatedDirectoryPath + "ObjEntity.groovy";
Path generatedClass = Paths.get(generatedClassPath);
assertTrue(Files.exists(generatedClass));
String notIncludedEntity = generatedDirectoryPath + "ObjEntity1.groovy";
Path generatedNotIncludedEntity = Paths.get(notIncludedEntity);
assertFalse(Files.exists(generatedNotIncludedEntity));
String includedDataMap = generatedDirectoryPath + "CgenMap.groovy";
Path generatedIncludedDataMap = Paths.get(includedDataMap);
assertTrue(Files.exists(generatedIncludedDataMap));
assertEquals(TaskOutcome.SUCCESS, result.task(":cgen").getOutcome());
}
use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class CgenTaskIT method classGeneratingWithDefaultConfigSuccess.
@Test
public void classGeneratingWithDefaultConfigSuccess() throws Exception {
GradleRunner runner = createRunner("cgen_default_config", "cgen", "-PdataMap=test_datamap.map.xml");
BuildResult result = runner.forwardOutput().build();
String generatedDirectoryPath = projectDir.getAbsolutePath() + "/src/main/java/org/example/cayenne/persistent/";
String generatedClassPath = generatedDirectoryPath + "City.java";
String generatedParentClassPath = generatedDirectoryPath + "auto/_City.java";
File generatedClass = new File(generatedClassPath);
File generatedParentClass = new File(generatedParentClassPath);
assertTrue(generatedClass.exists());
assertTrue(generatedParentClass.exists());
assertEquals(TaskOutcome.SUCCESS, result.task(":cgen").getOutcome());
}
use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class DbImportIT method notConfiguredTaskFailure.
@Test
public void notConfiguredTaskFailure() throws Exception {
GradleRunner runner = createRunner("dbimport_failure", "cdbimport", "--info");
BuildResult result = runner.buildAndFail();
// new version of Gradle (4.3.1 as of 05/12/2017) seems not return task status, so ignore this
// assertNotNull(result.task(":cdbimport"));
// assertEquals(TaskOutcome.FAILED, result.task(":cdbimport").getOutcome());
assertTrue(result.getOutput().contains("No datamap configured in task or in cayenne.defaultDataMap"));
}
Aggregations