Search in sources :

Example 21 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class MavenModuleProjectTests method testNewLiferayComponentBndAndMavenForPortleActionCommandAndRest.

@Test
public void testNewLiferayComponentBndAndMavenForPortleActionCommandAndRest() throws Exception {
    NewLiferayModuleProjectOp pop = NewLiferayModuleProjectOp.TYPE.instantiate();
    pop.setProjectName("testMavenModuleComponentBnd");
    pop.setProjectTemplateName("portlet");
    pop.setProjectProvider("maven-module");
    Status modulePorjectStatus = NewLiferayModuleProjectOpMethods.execute(pop, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertTrue(modulePorjectStatus.ok());
    IProject modPorject = CoreUtil.getProject(pop.getProjectName().content());
    modPorject.open(new NullProgressMonitor());
    NewLiferayComponentOp cop = NewLiferayComponentOp.TYPE.instantiate();
    cop.setProjectName(pop.getProjectName().content());
    cop.setComponentClassTemplateName("PortletActionCommand");
    NewLiferayComponentOpMethods.execute(cop, ProgressMonitorBridge.create(new NullProgressMonitor()));
    IFile bgd = modPorject.getFile("bnd.bnd");
    String bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
    String bndConfig = "-includeresource: \\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.bridges-2.0.0.jar!/com/liferay/util/bridges/freemarker/FreeMarkerPortlet.class,\\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.taglib-2.0.0.jar!/META-INF/*.tld" + System.getProperty("line.separator");
    assertTrue(bndcontent.contains(bndConfig));
    IFile pomFile = modPorject.getFile(IMavenConstants.POM_FILE_NAME);
    final IMaven maven = MavenPlugin.getMaven();
    Model model = maven.readModel(pomFile.getLocation().toFile());
    List<Dependency> dependencies = model.getDependencies();
    boolean hasDependency = false;
    for (Dependency de : dependencies) {
        String managementKey = de.getManagementKey();
        if (managementKey.equals("com.liferay.portal:com.liferay.util.bridges:jar")) {
            hasDependency = true;
            break;
        }
    }
    assertTrue(hasDependency);
    NewLiferayComponentOp copRest = NewLiferayComponentOp.TYPE.instantiate();
    copRest.setProjectName(pop.getProjectName().content());
    copRest.setComponentClassTemplateName("RestService");
    NewLiferayComponentOpMethods.execute(copRest, ProgressMonitorBridge.create(new NullProgressMonitor()));
    bgd = modPorject.getFile("bnd.bnd");
    bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
    assertTrue(bndcontent.contains(bndConfig));
    final String restConfig = "Require-Capability: osgi.contract; filter:=\"(&(osgi.contract=JavaJAXRS)(version=2))\"";
    assertTrue(bndcontent.contains(restConfig));
    model = maven.readModel(pomFile.getLocation().toFile());
    dependencies = model.getDependencies();
    hasDependency = false;
    for (Dependency de : dependencies) {
        String managementKey = de.getManagementKey();
        if (managementKey.equals("javax.ws.rs:javax.ws.rs-api:jar")) {
            hasDependency = true;
            break;
        }
    }
    assertTrue(hasDependency);
    NewLiferayComponentOp copAuth = NewLiferayComponentOp.TYPE.instantiate();
    copAuth.setProjectName(pop.getProjectName().content());
    copAuth.setComponentClassTemplateName("Authenticator");
    NewLiferayComponentOpMethods.execute(copAuth, ProgressMonitorBridge.create(new NullProgressMonitor()));
    bgd = modPorject.getFile("bnd.bnd");
    bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
    bndConfig = "-includeresource: \\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.bridges-2.0.0.jar!/com/liferay/util/bridges/freemarker/FreeMarkerPortlet.class,\\" + System.getProperty("line.separator") + "\t" + "@com.liferay.util.taglib-2.0.0.jar!/META-INF/*.tld,\\" + System.getProperty("line.separator") + "\t" + "@shiro-core-1.1.0.jar";
    assertTrue(bndcontent.contains(bndConfig));
    model = maven.readModel(pomFile.getLocation().toFile());
    dependencies = model.getDependencies();
    hasDependency = false;
    for (Dependency de : dependencies) {
        String managementKey = de.getManagementKey();
        if (managementKey.equals("org.apache.shiro:shiro-core:jar")) {
            hasDependency = true;
            break;
        }
    }
    assertTrue(hasDependency);
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) NewLiferayComponentOp(com.liferay.ide.project.core.modules.NewLiferayComponentOp) Model(org.apache.maven.model.Model) Dependency(org.apache.maven.model.Dependency) IProject(org.eclipse.core.resources.IProject) IMaven(org.eclipse.m2e.core.embedder.IMaven) Test(org.junit.Test)

Example 22 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class MavenModuleProjectTests method testNewLiferayModuleProjectDefaultLocation.

@Test
public void testNewLiferayModuleProjectDefaultLocation() throws Exception {
    final URL wsZipUrl = Platform.getBundle("com.liferay.ide.maven.core.tests").getEntry("projects/gradle-liferay-workspace.zip");
    final File wsZipFile = new File(FileLocator.toFileURL(wsZipUrl).getFile());
    File eclipseWorkspaceLocation = CoreUtil.getWorkspaceRoot().getLocation().toFile();
    ZipUtil.unzip(wsZipFile, eclipseWorkspaceLocation);
    File wsFolder = new File(eclipseWorkspaceLocation, "gradle-liferay-workspace");
    importExistingProject(wsFolder, new NullProgressMonitor());
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("my-test-project");
    op.setProjectTemplateName("mvc-portlet");
    op.setProjectProvider("maven-module");
    // don't put maven type project inside liferay-workspace
    assertTrue(op.getLocation().content().toFile().equals(eclipseWorkspaceLocation));
    op.setProjectProvider("gradle-module");
    op.setProjectTemplateName("theme");
    // put gradle type theme project inside liferay-workspace/wars
    assertTrue(op.getLocation().content().toPortableString().contains("gradle-liferay-workspace/wars"));
    op.setProjectTemplateName("mvc-portlet");
    // put gradle type project inside liferay-workspace/modules
    assertTrue(op.getLocation().content().toPortableString().contains("gradle-liferay-workspace/modules"));
    IProject project = CoreUtil.getProject("gradle-liferay-workspace");
    if (project != null && project.isAccessible() && project.exists()) {
        project.delete(true, true, new NullProgressMonitor());
    }
    op.setProjectTemplateName("service-builder");
    // no liferay-workspace
    assertTrue(op.getLocation().content().toFile().equals(eclipseWorkspaceLocation));
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) IFile(org.eclipse.core.resources.IFile) File(java.io.File) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 23 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class MavenModuleProjectTests method testProjectTemplateSimulationPanelEntry.

@Test
public void testProjectTemplateSimulationPanelEntry() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("simulation-panel-entry-test");
    op.setProjectProvider("maven-module");
    op.setProjectTemplateName("simulation-panel-entry");
    createAndBuild(op);
}
Also used : NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) Test(org.junit.Test)

Example 24 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class MavenModuleProjectTests method testProjectTemplateContentTargetingRule.

@Test
public void testProjectTemplateContentTargetingRule() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("content-targeting-rule-test");
    op.setProjectProvider("maven-module");
    op.setProjectTemplateName("content-targeting-rule");
    createAndBuild(op);
}
Also used : NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) Test(org.junit.Test)

Example 25 with NewLiferayModuleProjectOp

use of com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp in project liferay-ide by liferay.

the class MavenModuleProjectTests method testProjectTemplateControlMenuEntry.

@Test
public void testProjectTemplateControlMenuEntry() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("control-menu-entry-test");
    op.setProjectProvider("maven-module");
    op.setProjectTemplateName("control-menu-entry");
    createAndBuild(op);
}
Also used : NewLiferayModuleProjectOp(com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp) Test(org.junit.Test)

Aggregations

NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)95 Test (org.junit.Test)94 IProject (org.eclipse.core.resources.IProject)30 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)18 IFile (org.eclipse.core.resources.IFile)12 Status (org.eclipse.sapphire.modeling.Status)9 Ignore (org.junit.Ignore)6 IBundleProject (com.liferay.ide.core.IBundleProject)5 NewLiferayComponentOp (com.liferay.ide.project.core.modules.NewLiferayComponentOp)5 PropertyKey (com.liferay.ide.project.core.modules.PropertyKey)3 SearchFilesVisitor (com.liferay.ide.project.core.util.SearchFilesVisitor)3 IPath (org.eclipse.core.runtime.IPath)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 File (java.io.File)2 URL (java.net.URL)2 ILiferayProjectImporter (com.liferay.ide.core.ILiferayProjectImporter)1 IProjectBuilder (com.liferay.ide.project.core.IProjectBuilder)1 ProjectName (com.liferay.ide.project.core.model.ProjectName)1 NewLiferayWorkspaceOp (com.liferay.ide.project.core.workspace.NewLiferayWorkspaceOp)1 ArrayList (java.util.ArrayList)1