Search in sources :

Example 11 with JMXBundleDeployer

use of aQute.remote.util.JMXBundleDeployer in project liferay-blade-samples by liferay.

the class BladeSamplesUpdatePortletTest method tearDownClass.

@AfterClass
public static void tearDownClass() throws Exception {
    new JMXBundleDeployer().uninstall(_helloWorldJarBSN);
    if (_projectPath.exists()) {
        IO.delete(_projectPath);
        Assert.assertFalse(_projectPath.exists());
    }
}
Also used : JMXBundleDeployer(aQute.remote.util.JMXBundleDeployer) AfterClass(org.junit.AfterClass)

Example 12 with JMXBundleDeployer

use of aQute.remote.util.JMXBundleDeployer in project liferay-blade-samples by liferay.

the class BladeSamplesUpdatePortletTest method create.

@Deployment
public static JavaArchive create() throws Exception {
    final File jarFile = new File(System.getProperty("jspPortletJarFile"));
    _appsDir = new File(System.getProperty("projectDir"), "apps");
    _projectPath = BladeCLIUtil.createProject(_appsDir, "mvc-portlet", "helloworld");
    BladeCLIUtil.execute(_projectPath, "gw", "assemble");
    File buildOutput = new File(_projectPath + "/build/libs/helloworld-1.0.0.jar");
    new JMXBundleDeployer().deploy(_helloWorldJarBSN, buildOutput);
    return ShrinkWrap.createFromZipFile(JavaArchive.class, jarFile);
}
Also used : JMXBundleDeployer(aQute.remote.util.JMXBundleDeployer) File(java.io.File) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 13 with JMXBundleDeployer

use of aQute.remote.util.JMXBundleDeployer in project liferay-blade-samples by liferay.

the class BladeSamplesUpdatePortletTest method testUpdateMVCPortletProject.

@Test
public void testUpdateMVCPortletProject() throws Exception {
    _webDriver.get(_portletURL.toExternalForm());
    Assert.assertTrue("Portlet was not deployed", BladeSampleFunctionalActionUtil.isVisible(_webDriver, _helloWorldPortlet));
    Assert.assertTrue(_portletTitle.getText(), _portletTitle.getText().contentEquals("helloworld Portlet"));
    Assert.assertTrue(_portletBody.getText(), _portletBody.getText().contentEquals("Hello from helloworld JSP!"));
    File dynamicFile = new File(_projectPath + "/src/main/java/helloworld/portlet/HelloworldPortlet.java");
    List<String> lines = new ArrayList<>();
    String line = null;
    try (BufferedReader reader = new BufferedReader(new FileReader(dynamicFile))) {
        while ((line = reader.readLine()) != null) {
            lines.add(line);
            if (line.equals("import javax.portlet.Portlet;")) {
                String imports = StringTestUtil.merge(Arrays.asList("import java.io.IOException;", "import javax.portlet.PortletException;", "import javax.portlet.RenderRequest;", "import javax.portlet.RenderResponse;"), "\n");
                lines.add(imports);
            }
            if (line.equals("public class HelloworldPortlet extends MVCPortlet {")) {
                StringBuilder sb = new StringBuilder();
                sb.append("public void doView(\nRenderRequest renderRequest,").append(" RenderResponse renderResponse)\n").append("throws IOException, PortletException {\n").append("renderRequest.setAttribute(\n").append("\"foo\", \"bar\");\nsuper.doView(renderRequest, ").append("renderResponse);\n}\n");
                lines.add(sb.toString());
            }
        }
    }
    try (Writer writer = new FileWriter(dynamicFile)) {
        for (String string : lines) {
            writer.write(string + "\n");
        }
    }
    File staticFile = new File(_projectPath + "/src/main/resources/META-INF/resources/view.jsp");
    String content = new String(Files.readAllBytes(staticFile.toPath()));
    StringBuilder sb = new StringBuilder(content);
    sb.insert(content.lastIndexOf("b") + 2, "<b><%= renderRequest.getAttribute(\"foo\") %></b>\n");
    Files.write(staticFile.toPath(), sb.toString().getBytes());
    _buildStatus = BladeCLIUtil.execute(_projectPath, "gw", "assemble");
    Assert.assertTrue("Expected Build Successful, but saw: " + _buildStatus, !_buildStatus.contains("failed"));
    File buildOutput = new File(_projectPath + "/build/libs/helloworld-1.0.0.jar");
    new JMXBundleDeployer().deploy(_helloWorldJarBSN, buildOutput);
    Thread.sleep(1000);
    _webDriver.get(_portletURL.toExternalForm());
    Assert.assertTrue("Portlet was not deployed", BladeSampleFunctionalActionUtil.isVisible(_webDriver, _helloWorldPortlet));
    Assert.assertTrue(_portletTitle.getText(), _portletTitle.getText().contentEquals("helloworld Portlet"));
    Assert.assertTrue(_portletBody.getText(), _portletBody.getText().contentEquals("Hello from helloworld JSP!bar"));
}
Also used : FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) JMXBundleDeployer(aQute.remote.util.JMXBundleDeployer) File(java.io.File) FileWriter(java.io.FileWriter) Writer(java.io.Writer) Test(org.junit.Test)

Example 14 with JMXBundleDeployer

use of aQute.remote.util.JMXBundleDeployer in project liferay-blade-samples by liferay.

the class BladeJspWarPortletTest method create.

@Deployment
public static JavaArchive create() throws Exception {
    final File jarFile = new File(System.getProperty("jarFile"));
    final File fooApiJar = new File(System.getProperty("fooApiJarFile"));
    final File fooServiceJar = new File(System.getProperty("fooServiceJarFile"));
    new JMXBundleDeployer().deploy(_fooApiJarBSN, fooApiJar);
    new JMXBundleDeployer().deploy(_fooServiceJarBSN, fooServiceJar);
    final File jspPortletWarFile = new File(System.getProperty("jspPortletWarFile"));
    String bundleID = BladeCLIUtil.installBundle(jspPortletWarFile);
    BladeCLIUtil.startBundle(bundleID);
    return ShrinkWrap.createFromZipFile(JavaArchive.class, jarFile);
}
Also used : JMXBundleDeployer(aQute.remote.util.JMXBundleDeployer) File(java.io.File) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Example 15 with JMXBundleDeployer

use of aQute.remote.util.JMXBundleDeployer in project liferay-blade-samples by liferay.

the class BladeServiceBuilderTest method create.

@Deployment
public static JavaArchive create() throws Exception {
    final File jarFile = new File(System.getProperty("jarFile"));
    final File fooApiJar = new File(System.getProperty("fooApiJarFile"));
    final File fooServiceJar = new File(System.getProperty("fooServiceJarFile"));
    final File fooWebJar = new File(System.getProperty("fooWebJarFile"));
    new JMXBundleDeployer().deploy(_fooApiJarBSN, fooApiJar);
    new JMXBundleDeployer().deploy(_fooServiceJarBSN, fooServiceJar);
    new JMXBundleDeployer().deploy(_fooWebJarBSN, fooWebJar);
    return ShrinkWrap.createFromZipFile(JavaArchive.class, jarFile);
}
Also used : JMXBundleDeployer(aQute.remote.util.JMXBundleDeployer) File(java.io.File) Deployment(org.jboss.arquillian.container.test.api.Deployment)

Aggregations

JMXBundleDeployer (aQute.remote.util.JMXBundleDeployer)17 File (java.io.File)12 Deployment (org.jboss.arquillian.container.test.api.Deployment)8 AfterClass (org.junit.AfterClass)4 Test (org.junit.Test)3 Jar (aQute.bnd.osgi.Jar)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1 Writer (java.io.Writer)1 ArrayList (java.util.ArrayList)1 BundleDTO (org.osgi.framework.dto.BundleDTO)1