use of org.gradle.testkit.runner.BuildTask in project liferay-blade-samples by liferay.
the class BladeSamplesTest method testPortletProviderGradleTemplates.
@Test
public void testPortletProviderGradleTemplates() throws Exception {
File projectPath = BladeCLIUtil.createProject(_testDir, "portlet-provider", "helloworld");
BuildTask buildtask = GradleRunnerUtil.executeGradleRunner(projectPath, "build");
GradleRunnerUtil.verifyGradleRunnerOutput(buildtask);
File buildOutput = new File(projectPath + "/build/libs/helloworld-1.0.0.jar");
Assert.assertTrue(buildOutput.exists());
String bundleID = BladeCLIUtil.installBundle(buildOutput);
BladeCLIUtil.startBundle(bundleID);
BladeCLIUtil.uninstallBundle(bundleID);
}
use of org.gradle.testkit.runner.BuildTask in project liferay-blade-samples by liferay.
the class BladeSamplesTest method testServiceGradleTemplate.
@Test
public void testServiceGradleTemplate() throws Exception {
BladeCLIUtil.createProject(_testDir, "service", "helloworld", "-s", "com.liferay.portal.kernel.events.LifecycleAction", "-c", "FooAction");
File projectPath = new File(_testDir + "/helloworld");
File file = new File(projectPath + "/src/main/java/helloworld/FooAction.java");
List<String> lines = new ArrayList<>();
String line = null;
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
while ((line = reader.readLine()) != null) {
lines.add(line);
if (line.startsWith("import com.liferay.portal.kernel.events." + "LifecycleAction;")) {
lines.add("import com.liferay.portal.kernel.events." + "LifecycleEvent;");
lines.add("import com.liferay.portal.kernel.events." + "ActionException;");
}
if (line.equals("public class FooAction implements LifecycleAction " + "{")) {
StringBuilder sb = new StringBuilder();
sb.append("@Override\n").append("public void processLifecycleEvent").append("(LifecycleEvent lifecycleEvent)\n").append("throws ActionException {\n").append("System.out.println").append("(\"login.event.pre=\" + lifecycleEvent);\n").append("}\n");
lines.add(sb.toString());
}
}
}
try (Writer writer = new FileWriter(file)) {
for (String string : lines) {
writer.write(string + "\n");
}
}
BuildTask buildtask = GradleRunnerUtil.executeGradleRunner(projectPath, "build");
GradleRunnerUtil.verifyGradleRunnerOutput(buildtask);
File buildOutput = new File(projectPath + "/build/libs/helloworld-1.0.0.jar");
Assert.assertTrue(buildOutput.exists());
String bundleID = BladeCLIUtil.installBundle(buildOutput);
BladeCLIUtil.startBundle(bundleID);
BladeCLIUtil.uninstallBundle(bundleID);
}
use of org.gradle.testkit.runner.BuildTask in project liferay-blade-samples by liferay.
the class BladeSamplesTest method testControlMenuEntryGradleTemplates.
@Test
public void testControlMenuEntryGradleTemplates() throws Exception {
File projectPath = BladeCLIUtil.createProject(_testDir, "control-menu-entry", "helloworld");
BuildTask buildtask = GradleRunnerUtil.executeGradleRunner(projectPath, "build");
GradleRunnerUtil.verifyGradleRunnerOutput(buildtask);
File buildOutput = new File(projectPath + "/build/libs/helloworld-1.0.0.jar");
Assert.assertTrue(buildOutput.exists());
String bundleID = BladeCLIUtil.installBundle(buildOutput);
BladeCLIUtil.startBundle(bundleID);
BladeCLIUtil.uninstallBundle(bundleID);
}
use of org.gradle.testkit.runner.BuildTask in project liferay-blade-samples by liferay.
the class BladeSamplesTest method testServiceBuilderBladeSample.
@Test
public void testServiceBuilderBladeSample() throws Exception {
File projectPath = new File(System.getProperty("user.dir")).getParentFile().getParentFile();
File serviceProperties = new File(projectPath, "apps/service-builder/basic/basic-service/src/main/resources" + "/service.properties");
File servicePropertiesBackup = new File("service.properties.bak");
IO.copy(serviceProperties, servicePropertiesBackup);
BuildTask buildService = GradleRunnerUtil.executeGradleRunner(projectPath, ":apps:service-builder:basic:basic-service:buildService");
GradleRunnerUtil.verifyGradleRunnerOutput(buildService);
IO.copy(servicePropertiesBackup, serviceProperties);
IO.delete(servicePropertiesBackup);
BuildTask cleanTask = GradleRunnerUtil.executeGradleRunner(projectPath, ":apps:service-builder:basic:basic-api:clean");
GradleRunnerUtil.verifyGradleRunnerOutput(cleanTask);
BuildTask buildApiTask = GradleRunnerUtil.executeGradleRunner(projectPath, ":apps:service-builder:basic:basic-api:build");
GradleRunnerUtil.verifyGradleRunnerOutput(buildApiTask);
cleanTask = GradleRunnerUtil.executeGradleRunner(projectPath, ":apps:service-builder:basic:basic-service:clean");
GradleRunnerUtil.verifyGradleRunnerOutput(cleanTask);
BuildTask buildServiceTask = GradleRunnerUtil.executeGradleRunner(projectPath, ":apps:service-builder:basic:basic-service:assemble");
GradleRunnerUtil.verifyGradleRunnerOutput(buildServiceTask);
File buildApiOutput = new File(projectPath + "/apps/service-builder/basic/basic-api/build/libs" + "/com.liferay.blade.basic.api-1.0.0.jar");
File buildServiceOutput = new File(projectPath + "/apps/service-builder/basic/basic-service/build/libs" + "/com.liferay.blade.basic.service-1.0.0.jar");
Assert.assertTrue(buildApiOutput.exists());
Assert.assertTrue(buildServiceOutput.exists());
String bundleIDApi = BladeCLIUtil.installBundle(buildApiOutput);
String bundleIDService = BladeCLIUtil.installBundle(buildServiceOutput);
BladeCLIUtil.startBundle(bundleIDApi);
BladeCLIUtil.startBundle(bundleIDService);
BladeCLIUtil.uninstallBundle(bundleIDApi, bundleIDService);
}
use of org.gradle.testkit.runner.BuildTask in project liferay-blade-samples by liferay.
the class BladeSamplesTest method testPortletGradleTemplates.
@Test
public void testPortletGradleTemplates() throws Exception {
File projectPath = BladeCLIUtil.createProject(_testDir, "portlet", "helloworld");
BuildTask buildtask = GradleRunnerUtil.executeGradleRunner(projectPath, "build");
GradleRunnerUtil.verifyGradleRunnerOutput(buildtask);
File buildOutput = new File(projectPath + "/build/libs/helloworld-1.0.0.jar");
Assert.assertTrue(buildOutput.exists());
String bundleID = BladeCLIUtil.installBundle(buildOutput);
BladeCLIUtil.startBundle(bundleID);
BladeCLIUtil.uninstallBundle(bundleID);
}
Aggregations