Search in sources :

Example 6 with ImportLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp in project liferay-ide by liferay.

the class ImportWorkspaceProjectTests method testImportLiferayWorkspaceCustomBundleURL.

@Test
public void testImportLiferayWorkspaceCustomBundleURL() throws Exception {
    IWorkspace ws = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = ws.getRoot();
    File src = new File("projects/testWorkspaceCustomBundleUrl");
    File dst = new File(root.getLocation().toFile(), src.getName());
    TestUtil.copyDir(src, dst);
    ImportLiferayWorkspaceOp op = ImportLiferayWorkspaceOp.TYPE.instantiate();
    op.setWorkspaceLocation(dst.getAbsolutePath());
    String bundleUrl = op.getBundleUrl().content(true);
    assertEquals("https://api.liferay.com/downloads/portal/7.0.10.6/liferay-dxp-digital-enterprise-tomcat-7.0-sp6-20171010144253003.zip", bundleUrl);
}
Also used : ImportLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IWorkspace(org.eclipse.core.resources.IWorkspace) File(java.io.File) Test(org.junit.Test)

Example 7 with ImportLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp in project liferay-ide by liferay.

the class ImportWorkspaceProjectTests method testImportLiferayWorkspaceDontOverrideGradleProperties.

@Test
public void testImportLiferayWorkspaceDontOverrideGradleProperties() throws Exception {
    IWorkspace ws = ResourcesPlugin.getWorkspace();
    IWorkspaceRoot root = ws.getRoot();
    File src = new File("projects/testWorkspace");
    File dst = new File(root.getLocation().toFile(), src.getName());
    TestUtil.copyDir(src, dst);
    ImportLiferayWorkspaceOp op = ImportLiferayWorkspaceOp.TYPE.instantiate();
    op.setWorkspaceLocation(dst.getAbsolutePath());
    op.setProvisionLiferayBundle(true);
    op.execute(ProgressMonitorBridge.create(new NullProgressMonitor()));
    IProject eeProject = CoreUtil.getProject("testWorkspace");
    assertNotNull(eeProject);
    Util.waitForBuildAndValidation();
    assertNotLiferayProject("testWorkspace");
    assertLiferayProject("sample-portlet");
    File originalProperities = new File("projects/testWorkspace/gradle.properties");
    File importedProperties = eeProject.getFile("gradle.properties").getLocation().toFile();
    String originalContent = CoreUtil.readStreamToString(Files.newInputStream(originalProperities.toPath()));
    String importedContent = CoreUtil.readStreamToString(Files.newInputStream(importedProperties.toPath()));
    originalContent = originalContent.replaceAll("\r", "");
    importedContent = importedContent.replaceAll("\r", "");
    assertEquals(importedContent, originalContent, importedContent);
}
Also used : ImportLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IWorkspaceRoot(org.eclipse.core.resources.IWorkspaceRoot) IWorkspace(org.eclipse.core.resources.IWorkspace) File(java.io.File) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 8 with ImportLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp in project liferay-ide by liferay.

the class ImportMavenLiferayWorkspaceOpTests method testImportMavenLiferayWorkspaceInitBundle.

@Test
public void testImportMavenLiferayWorkspaceInitBundle() throws Exception {
    ImportLiferayWorkspaceOp op = ImportLiferayWorkspaceOp.TYPE.instantiate();
    final URL wsZipUrl = Platform.getBundle("com.liferay.ide.maven.core.tests").getEntry("projects/maven-liferay-workspace.zip");
    final File wsZipFile = new File(FileLocator.toFileURL(wsZipUrl).getFile());
    File eclipseWorkspaceLocation = CoreUtil.getWorkspaceRoot().getLocation().toFile();
    ZipUtil.unzip(wsZipFile, eclipseWorkspaceLocation);
    File wsFolder = new File(eclipseWorkspaceLocation, "maven-liferay-workspace");
    op.setWorkspaceLocation(wsFolder.getAbsolutePath());
    op.setProvisionLiferayBundle(true);
    String bundleUrl = op.getBundleUrl().content(true);
    assertEquals("https://cdn.lfrs.sl/releases.liferay.com/portal/7.0.4-ga5/liferay-ce-portal-tomcat-7.0-ga5-20171018150113838.zip", bundleUrl);
    op.setServerName("test-bundle");
    Status validationStatus = op.validation();
    assertTrue(validationStatus.ok());
    op.execute(new ProgressMonitor());
    File bundleDir = new File(wsFolder, "bundles");
    assertTrue(bundleDir.exists());
    IServer server = ServerUtil.getServer(op.getServerName().content());
    assertTrue(ServerUtil.isLiferayRuntime(server));
    IProject project = CoreUtil.getProject("maven-liferay-workspace");
    assertTrue(project.exists());
    op = ImportLiferayWorkspaceOp.TYPE.instantiate();
    assertEquals(LiferayWorkspaceUtil.hasLiferayWorkspaceMsg, op.validation().message());
    project = CoreUtil.getProject("maven-liferay-workspace");
    project.delete(true, true, new NullProgressMonitor());
}
Also used : ImportLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp) Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProgressMonitor(org.eclipse.sapphire.modeling.ProgressMonitor) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IServer(org.eclipse.wst.server.core.IServer) File(java.io.File) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 9 with ImportLiferayWorkspaceOp

use of com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp in project liferay-ide by liferay.

the class ImportMavenLiferayWorkspaceOpTests method testImportMavenLiferayWorkspaceOp.

@Test
public void testImportMavenLiferayWorkspaceOp() throws Exception {
    ImportLiferayWorkspaceOp op = ImportLiferayWorkspaceOp.TYPE.instantiate();
    final URL wsZipUrl = Platform.getBundle("com.liferay.ide.maven.core.tests").getEntry("projects/maven-liferay-workspace.zip");
    final File wsZipFile = new File(FileLocator.toFileURL(wsZipUrl).getFile());
    File eclipseWorkspaceLocation = CoreUtil.getWorkspaceRoot().getLocation().toFile();
    ZipUtil.unzip(wsZipFile, eclipseWorkspaceLocation);
    File wsFolder = new File(eclipseWorkspaceLocation, "maven-liferay-workspace");
    op.setWorkspaceLocation(wsFolder.getAbsolutePath());
    Status validationStatus = op.validation();
    assertTrue(validationStatus.ok());
    op.execute(new ProgressMonitor());
    IProject project = CoreUtil.getProject("maven-liferay-workspace");
    assertTrue(project.exists());
    project = CoreUtil.getProject("maven-liferay-workspace-modules");
    assertTrue(project.exists());
    project = CoreUtil.getProject("maven-liferay-workspace-themes");
    assertTrue(project.exists());
    project = CoreUtil.getProject("maven-liferay-workspace-wars");
    assertTrue(project.exists());
    op = ImportLiferayWorkspaceOp.TYPE.instantiate();
    assertEquals(LiferayWorkspaceUtil.hasLiferayWorkspaceMsg, op.validation().message());
    project = CoreUtil.getProject("maven-liferay-workspace");
    project.delete(true, true, new NullProgressMonitor());
}
Also used : ImportLiferayWorkspaceOp(com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp) Status(org.eclipse.sapphire.modeling.Status) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProgressMonitor(org.eclipse.sapphire.modeling.ProgressMonitor) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) File(java.io.File) URL(java.net.URL) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Aggregations

ImportLiferayWorkspaceOp (com.liferay.ide.project.core.workspace.ImportLiferayWorkspaceOp)9 File (java.io.File)8 IProject (org.eclipse.core.resources.IProject)7 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)6 Test (org.junit.Test)6 URL (java.net.URL)3 IWorkspace (org.eclipse.core.resources.IWorkspace)3 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)3 ProgressMonitor (org.eclipse.sapphire.modeling.ProgressMonitor)3 IPath (org.eclipse.core.runtime.IPath)2 Status (org.eclipse.sapphire.modeling.Status)2 IServer (org.eclipse.wst.server.core.IServer)2 ImportLiferayWorkspaceWizard (com.liferay.ide.project.ui.workspace.ImportLiferayWorkspaceWizard)1 IFolder (org.eclipse.core.resources.IFolder)1 WorkspaceJob (org.eclipse.core.resources.WorkspaceJob)1 CoreException (org.eclipse.core.runtime.CoreException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Path (org.eclipse.core.runtime.Path)1 Job (org.eclipse.core.runtime.jobs.Job)1 Location (org.eclipse.osgi.service.datalocation.Location)1