use of org.apache.tools.ant.Project in project ignite by apache.
the class GridToolsSelfTest method testAntGarTaskWithExternalP2PDescriptor.
/**
* @throws Exception If failed.
*/
public void testAntGarTaskWithExternalP2PDescriptor() throws Exception {
String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir");
String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir");
String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_1";
String metaDirName = baseDirName + File.separator + "META-INF";
String garFileName = baseDirName + ".gar";
String garDescrDirName = U.resolveIgnitePath(GridTestProperties.getProperty("ant.gar.descriptor.dir")).getAbsolutePath();
// Make base and META-INF dir.
boolean mkdir = new File(baseDirName).mkdirs();
assert mkdir;
mkdir = new File(metaDirName).mkdirs();
assert mkdir;
// Copy files to basedir
U.copy(new File(srcDirName), new File(baseDirName), true);
IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask();
Project garProject = new Project();
garProject.setName("Gar test project");
garTask.setDestFile(new File(garFileName));
garTask.setDescrdir(new File(garDescrDirName));
garTask.setBasedir(new File(baseDirName));
garTask.setProject(garProject);
garTask.execute();
File garFile = new File(garFileName);
assert garFile.exists();
boolean res = checkStructure(garFile, true);
assert res;
}
use of org.apache.tools.ant.Project in project ignite by apache.
the class GridToolsSelfTest method testAntGarTaskWithNullDescriptor.
/**
* @throws Exception If failed.
*/
@SuppressWarnings({ "TypeMayBeWeakened" })
public void testAntGarTaskWithNullDescriptor() throws Exception {
String tmpDirName = GridTestProperties.getProperty("ant.gar.tmpdir");
String srcDirName = GridTestProperties.getProperty("ant.gar.srcdir");
String baseDirName = tmpDirName + File.separator + System.currentTimeMillis() + "_4";
String metaDirName = baseDirName + File.separator + "META-INF";
String garFileName = baseDirName + ".gar";
// Make base and META-INF dir.
boolean mkdir = new File(baseDirName).mkdirs();
assert mkdir;
mkdir = new File(metaDirName).mkdirs();
assert mkdir;
// Copy files to basedir
U.copy(new File(srcDirName), new File(baseDirName), true);
IgniteDeploymentGarAntTask garTask = new IgniteDeploymentGarAntTask();
Project garProject = new Project();
garProject.setName("Gar test project");
garTask.setDestFile(new File(garFileName));
garTask.setBasedir(new File(baseDirName));
garTask.setProject(garProject);
try {
garTask.execute();
} catch (BuildException e) {
if (log().isInfoEnabled())
log().info(e.getMessage());
assert false;
}
}
use of org.apache.tools.ant.Project in project cayenne by apache.
the class CayenneGeneratorTaskCrossMapRelationshipsTest method testCrossDataMapRelationships.
/**
* Tests pairs generation with a cross-DataMap relationship.
*/
@Test
public void testCrossDataMapRelationships() throws Exception {
CayenneGeneratorTask task = new CayenneGeneratorTask();
task.setProject(new Project());
task.setTaskName("Test");
task.setLocation(Location.UNKNOWN_LOCATION);
// prepare destination directory
File destDir = new File(FileUtil.baseTestDirectory(), "cgen12");
// prepare destination directory
if (!destDir.exists()) {
assertTrue(destDir.mkdirs());
}
File map = new File(destDir, "cgen-dependent.map.xml");
ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/cgen-dependent.map.xml", map);
File[] additionalMaps = new File[1];
additionalMaps[0] = new File(destDir, "cgen.map.xml");
ResourceUtil.copyResourceToFile("org/apache/cayenne/tools/cgen.map.xml", additionalMaps[0]);
FileList additionalMapsFilelist = new FileList();
additionalMapsFilelist.setDir(additionalMaps[0].getParentFile());
additionalMapsFilelist.setFiles(additionalMaps[0].getName());
Path additionalMapsPath = new Path(task.getProject());
additionalMapsPath.addFilelist(additionalMapsFilelist);
// setup task
task.setMap(map);
task.setAdditionalMaps(additionalMapsPath);
task.setMakepairs(true);
task.setOverwrite(false);
task.setMode("entity");
task.setIncludeEntities("MyArtGroup");
task.setDestDir(destDir);
task.setSuperpkg("org.apache.cayenne.testdo.cgen2.auto");
task.setUsepkgpath(true);
// run task
task.execute();
// check results
File a = new File(destDir, convertPath("org/apache/cayenne/testdo/cgen2/MyArtGroup.java"));
assertTrue(a.isFile());
assertContents(a, "MyArtGroup", "org.apache.cayenne.testdo.cgen2", "_MyArtGroup");
File _a = new File(destDir, convertPath("org/apache/cayenne/testdo/cgen2/auto/_MyArtGroup.java"));
assertTrue(_a.exists());
assertContents(_a, "_MyArtGroup", "org.apache.cayenne.testdo.cgen2.auto", "BaseDataObject");
assertContents(_a, "import org.apache.cayenne.testdo.testmap.ArtGroup;");
assertContents(_a, " ArtGroup getToParentGroup()");
assertContents(_a, "setToParentGroup(ArtGroup toParentGroup)");
}
use of org.apache.tools.ant.Project in project cayenne by apache.
the class CayenneGeneratorTaskTest method setUp.
@Before
public void setUp() {
Project project = new Project();
project.setBaseDir(baseDir);
task = new CayenneGeneratorTask();
task.setProject(project);
task.setTaskName("Test");
task.setLocation(Location.UNKNOWN_LOCATION);
}
use of org.apache.tools.ant.Project in project cayenne by apache.
the class DbImporterTaskTest method getCdbImport.
private DbImporterTask getCdbImport(String buildFile) {
Project project = new Project();
File map = distDir(buildFile);
ResourceUtil.copyResourceToFile(getPackagePath() + "/" + buildFile, map);
ProjectHelper.configureProject(project, map);
UnknownElement task = (UnknownElement) project.getTargets().get("dist").getTasks()[0];
task.maybeConfigure();
return (DbImporterTask) task.getRealThing();
}
Aggregations