Search in sources :

Example 46 with NewLiferayPluginProjectOp

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

the class VaadinPortletProjectTests method testProfileLiferayMavenPluginVersionCheck.

@Test
public void testProfileLiferayMavenPluginVersionCheck() throws Exception {
    if (shouldSkipBundleTests())
        return;
    NewLiferayPluginProjectOp op = NewLiferayPluginProjectOp.TYPE.instantiate();
    op.setProjectName("profileCheck");
    op.setProjectProvider("maven");
    op.setPortletFramework("vaadin");
    createTestBundleProfile(op);
    final IProject newProject = base.createProject(op);
    assertNotNull(newProject);
    String pomContents = CoreUtil.readStreamToString(newProject.getFile("pom.xml").getContents());
    Matcher matcher = Pattern.compile(".*<liferay.version>(.*)</liferay.version>.*", Pattern.MULTILINE | Pattern.DOTALL).matcher(pomContents);
    matcher.matches();
    String extractedLiferayVersion = matcher.group(1);
    Matcher matcher2 = Pattern.compile(".*<liferay.maven.plugin.version>(.*)</liferay.maven.plugin.version>.*", Pattern.MULTILINE | Pattern.DOTALL).matcher(pomContents);
    matcher2.matches();
    String extractedLiferayPluginVersion = matcher2.group(1);
    assertEquals(extractedLiferayVersion, extractedLiferayPluginVersion);
}
Also used : Matcher(java.util.regex.Matcher) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 47 with NewLiferayPluginProjectOp

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

the class VaadinPortletProjectTests method testNewVaadin7PortletProject.

@Test
public void testNewVaadin7PortletProject() throws Exception {
    NewLiferayPluginProjectOp op = NewLiferayPluginProjectOp.TYPE.instantiate();
    op.setProjectName("vaadin7");
    op.setProjectProvider("maven");
    op.setPortletFramework("vaadin");
    createTestBundleProfile(op);
    final IProject newProject = base.createProject(op);
    assertNotNull(newProject);
    String pomContents = CoreUtil.readStreamToString(newProject.getFile("pom.xml").getContents());
    assertTrue(pomContents.contains("<artifactId>vaadin-server</artifactId>"));
    assertTrue(pomContents.contains("<artifactId>vaadin-client</artifactId>"));
    assertTrue(pomContents.contains("<artifactId>portal-service</artifactId>"));
}
Also used : NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 48 with NewLiferayPluginProjectOp

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

the class LiferaySDKValidationTests method testSDKLocationValidation.

@Test
public void testSDKLocationValidation() throws Exception {
    if (shouldSkipBundleTests())
        return;
    NewLiferayPluginProjectOp op = newProjectOp("test-sdk");
    op.setProjectProvider("ant");
    op.execute(new ProgressMonitor());
    SDK sdk = SDKUtil.getWorkspaceSDK();
    IPath sdkLocation = sdk.getLocation();
    if (sdk != null) {
        CoreUtil.getWorkspaceRoot().getProject(sdk.getName()).delete(false, true, null);
    }
    CoreUtil.getWorkspaceRoot().getProject("test-sdk").delete(false, true, null);
    // set existed project name
    op.setSdkLocation(sdkLocation.toOSString());
    assertTrue(op.validation().message().contains("A project with that name already exists."));
    op = newProjectOp("test2-sdk");
    op.setSdkLocation("");
    assertEquals("This sdk location is empty.", op.validation().message());
    op.setSdkLocation(sdkLocation.getDevice() + "/");
    assertEquals("This sdk location is not correct.", op.validation().message());
    // sdk has no build.USERNAME.properties file
    sdkLocation.append("build." + System.getProperty("user.name") + ".properties").toFile().delete();
    IStatus validateStatus = sdk.validate(true);
    assertEquals(false, validateStatus.isOK());
}
Also used : ProgressMonitor(org.eclipse.sapphire.modeling.ProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) IPath(org.eclipse.core.runtime.IPath) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) SDK(com.liferay.ide.sdk.core.SDK) Test(org.junit.Test)

Example 49 with NewLiferayPluginProjectOp

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

the class NewLiferayPluginProjectOp625Tests method testNewLayoutAntProject.

@Override
@Test
public void testNewLayoutAntProject() throws Exception {
    if (shouldSkipBundleTests())
        return;
    String projectName = "test-layouttpl-project-sdk";
    NewLiferayPluginProjectOp op = newProjectOp(projectName);
    op.setPluginType(PluginType.layouttpl);
    IProject layouttplProject = createAntProject(op);
    IFolder webappRoot = LiferayCore.create(IWebProject.class, layouttplProject).getDefaultDocrootFolder();
    assertNotNull(webappRoot);
    IFile layoutXml = webappRoot.getFile("WEB-INF/liferay-layout-templates.xml");
    assertEquals(true, layoutXml.exists());
    IFile wapTpl = webappRoot.getFile("test_layouttpl_project_sdk_6.2.5.wap.tpl");
    assertTrue(wapTpl.exists());
    IDataModel model = DataModelFactory.createDataModel(new NewLayoutTplDataModelProvider());
    model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_ID, "newtemplate");
    model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_NAME, "New Template");
    model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_THUMBNAIL_FILE, "/newtemplate.png");
    model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_WAP_TEMPLATE_FILE, "/newtemplate.wap.tpl");
    model.setProperty(INewLayoutTplDataModelProperties.LAYOUT_TEMPLATE_FILE, "/newtemplate.tpl");
    LayoutTplDescriptorHelper layoutHelper = new LayoutTplDescriptorHelper(layouttplProject);
    layoutHelper.addNewLayoutTemplate(model);
    String contents = CoreUtil.readStreamToString(layoutXml.getContents(true));
    assertTrue(contents.contains("<wap-template-path>"));
}
Also used : IFile(org.eclipse.core.resources.IFile) IWebProject(com.liferay.ide.core.IWebProject) NewLayoutTplDataModelProvider(com.liferay.ide.layouttpl.core.operation.NewLayoutTplDataModelProvider) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) IDataModel(org.eclipse.wst.common.frameworks.datamodel.IDataModel) LayoutTplDescriptorHelper(com.liferay.ide.layouttpl.core.operation.LayoutTplDescriptorHelper) IProject(org.eclipse.core.resources.IProject) IFolder(org.eclipse.core.resources.IFolder) Test(org.junit.Test)

Example 50 with NewLiferayPluginProjectOp

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

the class NewLiferayPluginProjectOp625Tests method testProjectNameValidationServiceAfterProjectCreated.

@Test
public void testProjectNameValidationServiceAfterProjectCreated() throws Exception {
    if (shouldSkipBundleTests())
        return;
    // test service-builder project
    NewLiferayPluginProjectOp opCreateProjectA = newProjectOp("test-project-name");
    opCreateProjectA.setIncludeSampleCode(false);
    opCreateProjectA.setPluginType(PluginType.portlet);
    createAntProject(opCreateProjectA);
    Status projectNameAValidationResult = opCreateProjectA.getProjectName().validation();
    assertEquals(true, projectNameAValidationResult.ok());
    NewLiferayPluginProjectOp opCreateProjectB = newProjectOp("test-project-name");
    Status projectNameBValidationResult = opCreateProjectB.getProjectName().validation();
    assertEquals(false, projectNameBValidationResult.ok());
}
Also used : Status(org.eclipse.sapphire.modeling.Status) NewLiferayPluginProjectOp(com.liferay.ide.project.core.model.NewLiferayPluginProjectOp) Test(org.junit.Test)

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