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()));
}
}
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() );
}
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());
}
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));
}
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);
}
Aggregations