use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class ProjectCoreBase method createProject.
public IProject createProject(NewLiferayPluginProjectOp op, String projectName) {
Status status = op.execute(ProgressMonitorBridge.create(new NullProgressMonitor()));
assertNotNull(status);
assertEquals(status.toString(), Status.createOkStatus().message().toLowerCase(), status.message().toLowerCase());
if (projectName == null || op.getProjectProvider().content().getShortName().equalsIgnoreCase("ant")) {
projectName = op.getFinalProjectName().content();
}
// if( op.getProjectProvider().content().getShortName().equalsIgnoreCase( "maven" ) )
// {
// if( op.getPluginType().content().equals( PluginType.ext ) )
// {
// projectName = projectName + "-ext";
// }
// else if( op.getPluginType().content().equals( PluginType.servicebuilder ) )
// {
// projectName = projectName + "-portlet";
// }
// }
final IProject newLiferayPluginProject = project(projectName);
assertNotNull(newLiferayPluginProject);
assertEquals(true, newLiferayPluginProject.exists());
final IFacetedProject facetedProject = ProjectUtil.getFacetedProject(newLiferayPluginProject);
assertNotNull(facetedProject);
final IProjectFacet liferayFacet = ProjectUtil.getLiferayFacet(facetedProject);
assertNotNull(liferayFacet);
final PluginType pluginTypeValue = op.getPluginType().content(true);
if (pluginTypeValue.equals(PluginType.servicebuilder)) {
assertEquals("liferay.portlet", liferayFacet.getId());
} else {
assertEquals("liferay." + pluginTypeValue, liferayFacet.getId());
}
return newLiferayPluginProject;
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class NewLiferayComponentOpTests method testNewLiferayComponentBndAndGradleForPortleActionCommandAndRest.
@Test
public void testNewLiferayComponentBndAndGradleForPortleActionCommandAndRest() throws Exception {
NewLiferayModuleProjectOp pop = NewLiferayModuleProjectOp.TYPE.instantiate();
pop.setProjectName("testGradleModuleComponentBnd");
pop.setProjectTemplateName("portlet");
pop.setProjectProvider("gradle-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 buildgrade = modPorject.getFile("build.gradle");
String buildgradeContent = FileUtil.readContents(buildgrade.getLocation().toFile(), true);
assertTrue(buildgradeContent.contains("compile group: \"com.liferay.portal\", name:\"com.liferay.util.bridges\", version:\"2.0.0\""));
assertTrue(buildgradeContent.contains("compile group: \"org.osgi\", name:\"org.osgi.service.component.annotations\", version:\"1.3.0\""));
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));
buildgrade = modPorject.getFile("build.gradle");
buildgradeContent = FileUtil.readContents(buildgrade.getLocation().toFile(), true);
assertTrue(buildgradeContent.contains("compile group: \"javax.ws.rs\", name:\"javax.ws.rs-api\", version:\"2.0.1\""));
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));
buildgrade = modPorject.getFile("build.gradle");
buildgradeContent = FileUtil.readContents(buildgrade.getLocation().toFile(), true);
assertTrue(buildgradeContent.contains("compile group: \"org.apache.shiro\", name:\"shiro-core\", version:\"1.1.0\""));
NewLiferayComponentOp copStruts = NewLiferayComponentOp.TYPE.instantiate();
copStruts.setProjectName(pop.getProjectName().content());
copStruts.setComponentClassTemplateName("StrutsAction");
NewLiferayComponentOpMethods.execute(copStruts, ProgressMonitorBridge.create(new NullProgressMonitor()));
bgd = modPorject.getFile("bnd.bnd");
bndcontent = FileUtil.readContents(bgd.getLocation().toFile(), true);
bndConfig = "Web-ContextPath: /TestgradlemodulecomponentbndStrutsAction";
assertTrue(bndcontent.contains(bndConfig));
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class NewLiferayComponentOpTests method testNewLiferayComponentStrutsAction.
@Test
public void testNewLiferayComponentStrutsAction() throws Exception {
NewLiferayModuleProjectOp op = NewLiferayModuleProjectOp.TYPE.instantiate();
op.setProjectName("testGradleStrutsActionComponent");
op.setProjectTemplateName("portlet");
op.setProjectProvider("gradle-module");
Status modulePorjectStatus = NewLiferayModuleProjectOpMethods.execute(op, ProgressMonitorBridge.create(new NullProgressMonitor()));
assertTrue(modulePorjectStatus.ok());
IProject modProject = CoreUtil.getProject(op.getProjectName().content());
modProject.open(new NullProgressMonitor());
NewLiferayComponentOp cop = NewLiferayComponentOp.TYPE.instantiate();
cop.setProjectName(op.getProjectName().content());
cop.setComponentClassTemplateName("StrutsAction");
Status status = NewLiferayComponentOpMethods.execute(cop, ProgressMonitorBridge.create(new NullProgressMonitor()));
assertEquals(Status.createOkStatus(), status);
IFile javaFile = modProject.getFile("/src/main/java/testGradleStrutsActionComponent" + "/portlet/TestgradlestrutsactioncomponentStrutsAction.java");
assertTrue(javaFile.exists());
String javaFileContent = FileUtil.readContents(javaFile.getLocation().toFile(), true);
assertTrue(javaFileContent.contains("osgi.web.symbolicname=testGradleStrutsActionComponent"));
IFile jspFile = modProject.getFile("/src/main/resources/META-INF/resources" + "/testgradlestrutsactioncomponentstrutsaction/html/portal/testgradlestrutsactioncomponent.jsp");
assertTrue(jspFile.exists());
String jspFileContent = FileUtil.readContents(jspFile.getLocation().toFile(), true);
assertTrue(jspFileContent.contains("/testgradlestrutsactioncomponentstrutsaction/html/init.jsp"));
}
use of org.eclipse.sapphire.modeling.Status in project liferay-ide by liferay.
the class NewLiferayPluginProjectOp7sp3Tests method testNewExtAntProjectNotSupportedWithWorkspaceSDK.
@Test
public void testNewExtAntProjectNotSupportedWithWorkspaceSDK() throws Exception {
if (shouldSkipBundleTests())
return;
final String projectName = "test-ext-project-sdk";
final NewLiferayPluginProjectOp op = newProjectOp(projectName);
op.setPluginType(PluginType.ext);
op.setSdkLocation(PathBridge.create(getLiferayPluginsSdkDir()));
Status validation = op.validation();
assertEquals(true, validation.ok());
final IProject extProject = createAntProject(op);
assertNotNull(extProject);
}
use of org.eclipse.sapphire.modeling.Status 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());
}
Aggregations