Search in sources :

Example 6 with PropertyKey

use of com.liferay.ide.project.core.modules.PropertyKey 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)

Aggregations

PropertyKey (com.liferay.ide.project.core.modules.PropertyKey)6 IProject (org.eclipse.core.resources.IProject)4 NewLiferayModuleProjectOp (com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp)3 SearchFilesVisitor (com.liferay.ide.project.core.util.SearchFilesVisitor)3 IFile (org.eclipse.core.resources.IFile)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)3 Status (org.eclipse.sapphire.modeling.Status)3 Test (org.junit.Test)3 ProjectName (com.liferay.ide.project.core.model.ProjectName)2 File (java.io.File)2 ArrayList (java.util.ArrayList)2 CoreException (org.eclipse.core.runtime.CoreException)2 IPath (org.eclipse.core.runtime.IPath)2 IStatus (org.eclipse.core.runtime.IStatus)2 NewLiferayComponentOp (com.liferay.ide.project.core.modules.NewLiferayComponentOp)1