Search in sources :

Example 91 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class NewLiferayPluginProjectOpBase method testPluginTypeListener.

protected void testPluginTypeListener(Boolean versionRestriction) throws Exception {
    final NewLiferayPluginProjectOp op = newProjectOp("test-plugin-type-listener");
    final String projectName = op.getProjectName().content();
    op.setProjectProvider("ant");
    op.setUseDefaultLocation(true);
    final SDK sdk = SDKUtil.createSDKFromLocation(getLiferayPluginsSdkDir());
    final String[] pluginTypes = { "portlet", "hook", "layouttpl", "theme", "ext" };
    IPath exceptedLocation = null;
    for (String pluginType : pluginTypes) {
        op.setPluginType(pluginType);
        if (pluginType.equals("portlet")) {
            exceptedLocation = sdk.getLocation().append("portlets").append(projectName + "-portlet");
        } else if (pluginType.equals("hook")) {
            exceptedLocation = sdk.getLocation().append("hooks").append(projectName + "-hook");
        } else if (pluginType.equals("layouttpl")) {
            exceptedLocation = sdk.getLocation().append("layouttpl").append(projectName + "-layouttpl");
        } else if (pluginType.equals("theme")) {
            exceptedLocation = sdk.getLocation().append("themes").append(projectName + "-theme");
        } else {
            exceptedLocation = sdk.getLocation().append("ext").append(projectName + "-ext");
        }
        assertEquals(exceptedLocation, PathBridge.create(op.getLocation().content()));
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK)

Example 92 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class NewLiferayPluginProjectOpBase method testProjectNameValidation.

protected void testProjectNameValidation(final String initialProjectName) throws Exception {
    final NewLiferayPluginProjectOp op1 = newProjectOp("");
    op1.setUseDefaultLocation(true);
    ValidationService vs = op1.getProjectName().service(ValidationService.class);
    final String validProjectName = initialProjectName;
    op1.setProjectName(validProjectName);
    assertEquals("ok", vs.validation().message());
    assertEquals("ok", op1.getProjectName().validation().message());
    op1.setProjectName(validProjectName + "-portlet");
    assertEquals("ok", vs.validation().message());
    assertEquals("ok", op1.getProjectName().validation().message());
    final IProject proj = createProject(op1);
    op1.dispose();
    final NewLiferayPluginProjectOp op2 = newProjectOp("");
    vs = op2.getProjectName().service(ValidationService.class);
    op2.setProjectName(validProjectName + "-portlet");
    assertEquals("A project with that name already exists.", vs.validation().message());
    assertEquals("A project with that name already exists.", op2.getProjectName().validation().message());
    op2.setProjectName(validProjectName);
    assertEquals("A project with that name already exists.", vs.validation().message());
    assertEquals("A project with that name already exists.", op2.getProjectName().validation().message());
    final IPath dotProjectLocation = proj.getLocation().append(".project");
    if (dotProjectLocation.toFile().exists()) {
        dotProjectLocation.toFile().delete();
    }
    op2.dispose();
    final NewLiferayPluginProjectOp op3 = newProjectOp("");
    vs = op3.getProjectName().service(ValidationService.class);
    op3.setProjectName(validProjectName);
    assertEquals("A project with that name already exists.", vs.validation().message());
    assertEquals("A project with that name already exists.", op3.getProjectName().validation().message());
    String invalidProjectName = validProjectName + "/";
    op3.setProjectName(invalidProjectName);
    assertEquals("/ is an invalid character in resource name '" + invalidProjectName + "'.", vs.validation().message());
    op3.dispose();
// invalidProjectName = validProjectName + ".";
// op3.setProjectName( invalidProjectName );
// assertEquals( "'" + invalidProjectName + "' is an invalid name on this platform.", vs.validation().message() );
// assertEquals(
// "'" + invalidProjectName + "' is an invalid name on this platform.",
// op3.getProjectName().validation().message() );
}
Also used : IPath(org.eclipse.core.runtime.IPath) ValidationService(org.eclipse.sapphire.services.ValidationService) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IProject(org.eclipse.core.resources.IProject)

Example 93 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class NewLiferayPluginProjectOpBase method testSDKLocationValidation.

@Test
public void testSDKLocationValidation() throws Exception {
    if (shouldSkipBundleTests())
        return;
    NewLiferayPluginProjectOp op = newProjectOp("test-sdk");
    op.setProjectProvider("ant");
    Status status = op.execute(new ProgressMonitor());
    if (!status.ok()) {
        throw new Exception(status.exception());
    }
    SDK sdk = SDKUtil.getWorkspaceSDK();
    IPath sdkLocation = sdk.getLocation();
    if (sdk != null) {
        CoreUtil.getWorkspaceRoot().getProject(sdk.getName()).delete(false, false, null);
    }
    // set existed project name
    IProject project = getProject("portlets", "test-sdk-" + getRuntimeVersion() + "-portlet");
    project.delete(false, false, null);
    op.setSdkLocation(sdkLocation.toOSString());
    assertTrue(op.validation().message().contains("is not valid because a project already exists at that location."));
    op = newProjectOp("test2-sdk");
    op.setSdkLocation("");
    assertEquals("This sdk location is empty.", op.validation().message());
    op.setSdkLocation(sdk.getLocation().getDevice() + "/");
    assertEquals("This sdk location is not correct.", op.validation().message());
    // sdk has no build.USERNAME.properties file
    sdkLocation.append("build." + System.getenv().get("USER") + ".properties").toFile().delete();
    sdkLocation.append("build." + System.getenv().get("USERNAME") + ".properties").toFile().delete();
    op.setSdkLocation(sdkLocation.toOSString());
    String expectedMessageRegx = ".*app.server.*";
    assertTrue(op.validation().message().matches(expectedMessageRegx));
    assertEquals(false, op.validation().ok());
}
Also used : Status(org.eclipse.sapphire.modeling.Status) ProgressMonitor(org.eclipse.sapphire.modeling.ProgressMonitor) IPath(org.eclipse.core.runtime.IPath) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 94 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class NewLiferayPluginProjectOpBase method testPortletFrameworkValueLabel.

@Test
public void testPortletFrameworkValueLabel() throws Exception {
    if (shouldSkipBundleTests())
        return;
    final NewLiferayPluginProjectOp op = newProjectOp("test-portlet-framework-value-label");
    final ValueLabelService vls = op.getPortletFramework().service(ValueLabelService.class);
    Set<String> acturalLables = new HashSet<String>();
    for (IPortletFramework pf : ProjectCore.getPortletFrameworks()) {
        acturalLables.add(vls.provide(pf.getShortName()));
    }
    assertNotNull(acturalLables);
    Set<String> exceptedLables = new HashSet<String>();
    exceptedLables.add("Liferay MVC");
    exceptedLables.add("JSF 2.x");
    exceptedLables.add("Vaadin");
    exceptedLables.add("JSF standard");
    exceptedLables.add("ICEfaces");
    exceptedLables.add("Liferay Faces Alloy");
    exceptedLables.add("PrimeFaces");
    exceptedLables.add("RichFaces");
    exceptedLables.add("Spring MVC");
    assertEquals(true, exceptedLables.containsAll(acturalLables));
    assertEquals(true, acturalLables.containsAll(exceptedLables));
}
Also used : ValueLabelService(org.eclipse.sapphire.services.ValueLabelService) IPortletFramework(com.liferay.ide.project.core.IPortletFramework) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 95 with NewLiferayPluginProjectOp

use of com.liferay.ide.project.core.model.NewLiferayPluginProjectOp in project liferay-ide by liferay.

the class NewLiferayPluginProjectOpBase method createNewThemeAntProject.

protected IProject createNewThemeAntProject(String themeParent, String themeFramework) throws Exception {
    final String projectName = "test-theme-project-sdk-" + themeParent + "-" + themeFramework;
    final NewLiferayPluginProjectOp op = newProjectOp(projectName);
    op.setPluginType(PluginType.theme);
    op.setThemeParent(themeParent);
    op.setThemeFramework(themeFramework);
    final IProject project = createNewThemeAntProject(op);
    return checkNewThemeAntProject(op, project, null);
}
Also used : NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IProject(org.eclipse.core.resources.IProject)

Aggregations

NewLiferayPluginProjectOp (com.liferay.ide.project.core.model.NewLiferayPluginProjectOp)122 Test (org.junit.Test)61 IProject (org.eclipse.core.resources.IProject)48 IWebProject (com.liferay.ide.core.IWebProject)18 IFile (org.eclipse.core.resources.IFile)18 IPath (org.eclipse.core.runtime.IPath)14 IFolder (org.eclipse.core.resources.IFolder)13 SDK (com.liferay.ide.sdk.core.SDK)12 Status (org.eclipse.sapphire.modeling.Status)10 PropertyContentEvent (org.eclipse.sapphire.PropertyContentEvent)9 Path (org.eclipse.sapphire.modeling.Path)8 CoreException (org.eclipse.core.runtime.CoreException)7 IPortletFramework (com.liferay.ide.project.core.IPortletFramework)6 HashSet (java.util.HashSet)5 PossibleValuesService (org.eclipse.sapphire.PossibleValuesService)5 ValidationService (org.eclipse.sapphire.services.ValidationService)5 IVirtualComponent (org.eclipse.wst.common.componentcore.resources.IVirtualComponent)5 NewLiferayProfile (com.liferay.ide.project.core.model.NewLiferayProfile)4 IStatus (org.eclipse.core.runtime.IStatus)4 LayoutTplDescriptorHelper (com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper)3