use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class DbImportIT method emptyDbTaskSuccess.
@Test
public void emptyDbTaskSuccess() throws Exception {
// create empty db to avoid problems on Java 11
prepareDerbyDatabase("empty_db");
GradleRunner runner = createRunner("dbimport_empty_db", "cdbimport", "--info");
BuildResult result = runner.build();
assertNotNull(result.task(":cdbimport"));
assertEquals(TaskOutcome.SUCCESS, result.task(":cdbimport").getOutcome());
File dataMap = new File(projectDir.getAbsolutePath() + "/datamap.map.xml");
assertTrue(dataMap.exists());
assertTrue(result.getOutput().contains("Detected changes: No changes to import."));
}
use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class DbImportIT method simpleDbTaskSuccess.
@Test
public void simpleDbTaskSuccess() throws Exception {
String dbUrl = prepareDerbyDatabase("test_map_db");
File dataMap = new File(projectDir.getAbsolutePath() + "/datamap.map.xml");
assertFalse(dataMap.exists());
GradleRunner runner = createRunner("dbimport_simple_db", "cdbimport", "--info", "-PdbUrl=" + dbUrl);
BuildResult result = runner.build();
assertNotNull(result.task(":cdbimport"));
assertEquals(TaskOutcome.SUCCESS, result.task(":cdbimport").getOutcome());
assertTrue(dataMap.exists());
// Check few lines from reverse engineering output
assertTrue(result.getOutput().contains("Table: APP.PAINTING"));
assertTrue(result.getOutput().contains("Db Relationship : toOne (EXHIBIT.GALLERY_ID, GALLERY.GALLERY_ID)"));
assertTrue(result.getOutput().contains("Db Relationship : toMany (GALLERY.GALLERY_ID, PAINTING.GALLERY_ID)"));
assertTrue(result.getOutput().contains("Create Table ARTIST"));
assertFalse(result.getOutput().contains("Create Table PAINTING1"));
assertTrue(result.getOutput().contains("Skip relation: '.APP.ARTIST.ARTIST_ID <- .APP.PAINTING1.ARTIST_ID # 1'"));
assertTrue(result.getOutput().contains("Migration Complete Successfully."));
}
use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class DbImportIT method withProjectTaskSuccess.
@Test
public void withProjectTaskSuccess() throws Exception {
String dbUrl = prepareDerbyDatabase("test_project_db");
File dataMap = new File(projectDir.getAbsolutePath() + "/datamap.map.xml");
assertFalse(dataMap.exists());
File project = new File(projectDir.getAbsolutePath() + "/cayenne-project.xml");
assertFalse(project.exists());
GradleRunner runner = createRunner("dbimport_with_project", "cdbimport", "--info", "-PdbUrl=" + dbUrl);
BuildResult result = runner.build();
assertNotNull(result.task(":cdbimport"));
assertEquals(TaskOutcome.SUCCESS, result.task(":cdbimport").getOutcome());
assertTrue(dataMap.isFile());
assertTrue(project.isFile());
// Check few lines from reverse engineering output
assertTrue(result.getOutput().contains("Table: APP.PAINTING"));
assertTrue(result.getOutput().contains("Db Relationship : toOne (EXHIBIT.GALLERY_ID, GALLERY.GALLERY_ID)"));
assertTrue(result.getOutput().contains("Db Relationship : toMany (GALLERY.GALLERY_ID, PAINTING.GALLERY_ID)"));
assertTrue(result.getOutput().contains("Create Table ARTIST"));
assertFalse(result.getOutput().contains("Create Table PAINTING1"));
assertTrue(result.getOutput().contains("Skip relation: '.APP.ARTIST.ARTIST_ID <- .APP.PAINTING1.ARTIST_ID # 1'"));
assertTrue(result.getOutput().contains("Migration Complete Successfully."));
}
use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class GradlePluginIT method testDbImportWithGradleVersion.
private void testDbImportWithGradleVersion(String version) throws Exception {
String dbUrl = "jdbc:derby:" + projectDir.getAbsolutePath() + "/build/" + version.replace('.', '_');
dbUrl += ";create=true";
GradleRunner runner = createRunner("dbimport_simple_db", "cdbimport", "--info", "-PdbUrl=" + dbUrl);
runner.withGradleVersion(version);
runner.build();
}
use of org.gradle.testkit.runner.GradleRunner in project cayenne by apache.
the class GradlePluginIT method testCgenWithGradleVersion.
private void testCgenWithGradleVersion(String version) throws Exception {
GradleRunner runner = createRunner("cgen_default_config", "cgen", "-PdataMap=test_datamap.map.xml");
runner.withGradleVersion(version);
runner.build();
}
Aggregations