Search in sources :

Example 1 with BuildTask

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);
}
Also used : BuildTask(org.gradle.testkit.runner.BuildTask) File(java.io.File) Test(org.junit.Test)

Example 2 with BuildTask

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);
}
Also used : BuildTask(org.gradle.testkit.runner.BuildTask) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer) Test(org.junit.Test)

Example 3 with BuildTask

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);
}
Also used : BuildTask(org.gradle.testkit.runner.BuildTask) File(java.io.File) Test(org.junit.Test)

Example 4 with BuildTask

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);
}
Also used : BuildTask(org.gradle.testkit.runner.BuildTask) File(java.io.File) Test(org.junit.Test)

Example 5 with BuildTask

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);
}
Also used : BuildTask(org.gradle.testkit.runner.BuildTask) File(java.io.File) Test(org.junit.Test)

Aggregations

BuildTask (org.gradle.testkit.runner.BuildTask)14 Test (org.junit.Test)11 File (java.io.File)9 BuildResult (org.gradle.testkit.runner.BuildResult)4 ArrayList (java.util.ArrayList)2 TaskOutcome (org.gradle.testkit.runner.TaskOutcome)2 Command (com.google.cloud.tools.jib.Command)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 OutputStream (java.io.OutputStream)1 Writer (java.io.Writer)1 TeeOutputStream (org.apache.commons.io.output.TeeOutputStream)1 StreamByteBuffer (org.gradle.internal.io.StreamByteBuffer)1 GradleRunner (org.gradle.testkit.runner.GradleRunner)1 InvalidRunnerConfigurationException (org.gradle.testkit.runner.InvalidRunnerConfigurationException)1 UnsupportedFeatureException (org.gradle.testkit.runner.UnsupportedFeatureException)1 NoCloseOutputStream (org.gradle.testkit.runner.internal.io.NoCloseOutputStream)1 SynchronizedOutputStream (org.gradle.testkit.runner.internal.io.SynchronizedOutputStream)1 BuildException (org.gradle.tooling.BuildException)1