Search in sources :

Example 71 with Status

use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.

the class MavenModuleFragmentProjectTests method testNewModuleFragmentFileProjectValidation.

@Test
public void testNewModuleFragmentFileProjectValidation() throws Exception {
    deleteAllWorkspaceProjects();
    NewModuleFragmentFilesOp fop = NewModuleFragmentFilesOp.TYPE.instantiate();
    Status projectValidationStatus = fop.getProjectName().validation();
    assertEquals("No suitable Liferay fragment project.", projectValidationStatus.message());
    NewModuleFragmentOp op = NewModuleFragmentOp.TYPE.instantiate();
    final String runtimeName = "liferay-portal-7.0";
    final NullProgressMonitor npm = new NullProgressMonitor();
    IRuntime runtime = ServerCore.findRuntime(runtimeName);
    if (runtime == null) {
        final IRuntimeWorkingCopy runtimeWC = ServerCore.findRuntimeType(getRuntimeId()).createRuntime(runtimeName, npm);
        runtimeWC.setName(runtimeName);
        runtimeWC.setLocation(getLiferayRuntimeDir());
        runtime = runtimeWC.save(true, npm);
    }
    assertNotNull(runtime);
    List<String> bundles = ServerUtil.getModuleFileListFrom70Server(runtime);
    assertNotNull(bundles);
    for (String hostOsgiBundle : bundles) {
        if (hostOsgiBundle.contains("com.liferay.asset.display.web")) {
            op.setProjectName("test-project-validation");
            op.setProjectProvider("gradle-module-fragment");
            op.setLiferayRuntimeName(runtimeName);
            op.setHostOsgiBundle(hostOsgiBundle);
            OverrideFilePath overrideFilePath = op.getOverrideFiles().insert();
            overrideFilePath.setValue("META-INF/resources/view.jsp");
            Status gradleExeStatus = NewModuleFragmentOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
            assertTrue(gradleExeStatus.ok());
            IProject existedGradleProject = CoreUtil.getProject(op.getProjectName().content());
            assertNotNull(existedGradleProject);
            IFile bndFile = existedGradleProject.getFile("bnd.bnd");
            bndFile.delete(true, true, new NullProgressMonitor());
            fop.setProjectName(op.getProjectName().content());
            projectValidationStatus = fop.getProjectName().validation();
            assertEquals("Can't find bnd.bnd file in the project.", projectValidationStatus.message());
        }
    }
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) OverrideFilePath(com.liferay.ide.project.core.modules.fragment.OverrideFilePath) NewModuleFragmentOp(com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp) NewModuleFragmentFilesOp(com.liferay.ide.project.core.modules.fragment.NewModuleFragmentFilesOp) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) IProject(org.eclipse.core.resources.IProject) IRuntime(org.eclipse.wst.server.core.IRuntime) Test(org.junit.Test)

Example 72 with Status

use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.

the class MavenModuleFragmentProjectTests method testNewModuleFragmentProjectOpProject.

@Test
public void testNewModuleFragmentProjectOpProject() throws Exception {
    NewModuleFragmentOp op = NewModuleFragmentOp.TYPE.instantiate();
    final String runtimeName = "liferay-portal-7.0";
    final NullProgressMonitor npm = new NullProgressMonitor();
    IRuntime runtime = ServerCore.findRuntime(runtimeName);
    if (runtime == null) {
        final IRuntimeWorkingCopy runtimeWC = ServerCore.findRuntimeType(getRuntimeId()).createRuntime(runtimeName, npm);
        runtimeWC.setName(runtimeName);
        runtimeWC.setLocation(getLiferayRuntimeDir());
        runtime = runtimeWC.save(true, npm);
    }
    assertNotNull(runtime);
    List<String> bundles = ServerUtil.getModuleFileListFrom70Server(runtime);
    assertNotNull(bundles);
    for (String hostOsgiBundle : bundles) {
        if (hostOsgiBundle.contains("com.liferay.asset.display.web")) {
            op.setProjectName("test-gradle-module-fragment");
            op.setProjectProvider("gradle-module-fragment");
            op.setLiferayRuntimeName(runtimeName);
            op.setHostOsgiBundle(hostOsgiBundle);
            OverrideFilePath overrideFilePath = op.getOverrideFiles().insert();
            overrideFilePath.setValue("META-INF/resources/view.jsp");
            Status gradleExeStatus = NewModuleFragmentOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
            assertTrue(gradleExeStatus.ok());
            IProject existedGradleProject = CoreUtil.getProject(op.getProjectName().content());
            assertNotNull(existedGradleProject);
            IFile gradleFile = existedGradleProject.getFile("build.gradle");
            assertTrue(gradleFile.exists());
            IFile overrideFile = existedGradleProject.getFile("src/main/resources/META-INF/resources/view.jsp");
            assertTrue(overrideFile.exists());
        }
        if (hostOsgiBundle.contains("com.liferay.login.web")) {
            op.setProjectName("test-maven-module-fragment");
            op.setProjectProvider("maven-module-fragment");
            op.setLiferayRuntimeName(runtimeName);
            op.setHostOsgiBundle(hostOsgiBundle);
            OverrideFilePath file = op.getOverrideFiles().insert();
            file.setValue("META-INF/resources/login.jsp");
            Status mavenExeStatus = NewModuleFragmentOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
            assertTrue(mavenExeStatus.ok());
            IProject existedMavenProject = CoreUtil.getProject(op.getProjectName().content());
            assertNotNull(existedMavenProject);
            IFile pomFile = existedMavenProject.getFile("pom.xml");
            assertTrue(pomFile.exists());
            IFile overrideFile1 = existedMavenProject.getFile("src/main/resources/META-INF/resources/login.jsp");
            assertTrue(overrideFile1.exists());
        }
    }
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) OverrideFilePath(com.liferay.ide.project.core.modules.fragment.OverrideFilePath) NewModuleFragmentOp(com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp) IRuntimeWorkingCopy(org.eclipse.wst.server.core.IRuntimeWorkingCopy) IProject(org.eclipse.core.resources.IProject) IRuntime(org.eclipse.wst.server.core.IRuntime) Test(org.junit.Test)

Example 73 with Status

use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.

the class MavenModuleProjectTests method testNewLiferayModuleProjectNewProperties.

@Test
public void testNewLiferayModuleProjectNewProperties() throws Exception {
    NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
    op.setProjectName("test-properties-in-portlet");
    op.setProjectProvider("maven-module");
    op.setProjectTemplateName("portlet");
    op.setComponentName("Test");
    PropertyKey pk = op.getPropertyKeys().insert();
    pk.setName("property-test-key");
    pk.setValue("property-test-value");
    Status exStatus = NewLiferayModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(monitor));
    assertEquals("OK", exStatus.message());
    IProject modProject = CoreUtil.getProject(op.getProjectName().content());
    modProject.open(new NullProgressMonitor());
    SearchFilesVisitor sv = new SearchFilesVisitor();
    List<IFile> searchFiles = sv.searchFiles(modProject, "TestPortlet.java");
    IFile componentClassFile = searchFiles.get(0);
    assertEquals(componentClassFile.exists(), true);
    String actual = CoreUtil.readStreamToString(componentClassFile.getContents());
    assertTrue(actual, actual.contains("\"property-test-key=property-test-value\""));
}
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) SearchFilesVisitor(com.liferay.ide.project.core.util.SearchFilesVisitor) PropertyKey(com.liferay.ide.project.core.modules.PropertyKey) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 74 with Status

use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.

the class NewLiferayJSFModuleProjectOpTests method testRichfacesGradleProject.

@Test
public void testRichfacesGradleProject() throws Exception {
    NewLiferayJSFModuleProjectOp op = NewLiferayJSFModuleProjectOp.TYPE.instantiate();
    op.setProjectProvider("gradle-jsf");
    op.setProjectName("Test17");
    op.setTemplateName("richfaces");
    Status status = NewLiferayJSFModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertTrue(status.ok());
    waitForBuildAndValidation2();
    IProject project = CoreUtil.getProject("Test17");
    assertNotNull(project);
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) NewLiferayJSFModuleProjectOp(com.liferay.ide.project.core.jsf.NewLiferayJSFModuleProjectOp) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 75 with Status

use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.

the class NewLiferayJSFModuleProjectOpTests method testMavenPrimeFacesNewLiferayJSFModuleProjectOp.

@Test
public void testMavenPrimeFacesNewLiferayJSFModuleProjectOp() throws Exception {
    NewLiferayJSFModuleProjectOp existedProjectop = NewLiferayJSFModuleProjectOp.TYPE.instantiate();
    existedProjectop.setProjectProvider("maven-jsf");
    existedProjectop.setProjectName("Test8");
    existedProjectop.setTemplateName("primefaces");
    Status exStatus = NewLiferayJSFModuleProjectOpMethods.execute(existedProjectop, ProgressMonitorBridge.create(new NullProgressMonitor()));
    assertTrue(exStatus.ok());
    IProject existedProject = CoreUtil.getProject(existedProjectop.getProjectName().content());
    assertNotNull(existedProject);
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) NewLiferayJSFModuleProjectOp(com.liferay.ide.project.core.jsf.NewLiferayJSFModuleProjectOp) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Aggregations

Status (org.eclipse.sapphire.modeling.Status)83 IProject (org.eclipse.core.resources.IProject)33 Test (org.junit.Test)31 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)29 IStatus (org.eclipse.core.runtime.IStatus)25 Path (org.eclipse.sapphire.modeling.Path)18 CoreException (org.eclipse.core.runtime.CoreException)15 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)15 NewLiferayJSFModuleProjectOp (com.liferay.ide.project.core.jsf.NewLiferayJSFModuleProjectOp)14 IFile (org.eclipse.core.resources.IFile)12 IPath (org.eclipse.core.runtime.IPath)11 NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)10 NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)9 SDK (com.liferay.ide.sdk.core.SDK)9 File (java.io.File)6 NewLiferayComponentOp (com.liferay.ide.project.core.modules.NewLiferayComponentOp)5 IRuntime (org.eclipse.wst.server.core.IRuntime)5 PropertyKey (com.liferay.ide.project.core.modules.PropertyKey)3 NewModuleFragmentOp (com.liferay.ide.project.core.modules.fragment.NewModuleFragmentOp)3 ArrayList (java.util.ArrayList)3