Search in sources :

Example 1 with LiferayMavenLegacyProjectUpdater

use of com.liferay.ide.maven.core.LiferayMavenLegacyProjectUpdater in project liferay-ide by liferay.

the class LiferayMavenLegacyProjectUpdaterTests method testUpgrade.

@Test
public void testUpgrade() throws Exception {
    IProject project = CoreUtil.getProject("testMavenProjects");
    if (project != null && project.exists()) {
        project.delete(true, true, new NullProgressMonitor());
    }
    final URL projectZipUrl = Platform.getBundle("com.liferay.ide.maven.core.tests").getEntry("projects/testMavenProjects.zip");
    final File projectZipFile = new File(FileLocator.toFileURL(projectZipUrl).getFile());
    IPath stateLocation = LiferayMavenCore.getDefault().getStateLocation();
    File targetFolder = new File(stateLocation.toFile(), "testMavenProjects");
    if (targetFolder.exists()) {
        targetFolder.delete();
    }
    ZipUtil.unzip(projectZipFile, stateLocation.toFile());
    assertTrue(targetFolder.exists());
    ILiferayProjectImporter importer = LiferayCore.getImporter("maven");
    importer.importProjects(targetFolder.getAbsolutePath(), new NullProgressMonitor());
    LiferayMavenLegacyProjectUpdater updater = new LiferayMavenLegacyProjectUpdater();
    // portlet project
    IProject ppProject = CoreUtil.getProject("testpp");
    assertTrue(updater.isNeedUpgrade(ppProject));
    updater.upgradePomFile(ppProject, null);
    assertFalse(updater.isNeedUpgrade(ppProject));
    assertTrue(containString(ppProject, "com.liferay.css.builder"));
    makeSureNoLegacyElememnts(ppProject);
    // service builder parent project
    IProject testsbProject = CoreUtil.getProject("testsb");
    assertTrue(updater.isNeedUpgrade(testsbProject));
    updater.upgradePomFile(testsbProject, null);
    assertFalse(updater.isNeedUpgrade(testsbProject));
    makeSureNoLegacyElememnts(testsbProject);
    // service builder -portlet subproject
    IProject testsbPortletProject = CoreUtil.getProject("testsb-portlet");
    assertTrue(updater.isNeedUpgrade(testsbPortletProject));
    updater.upgradePomFile(testsbPortletProject, null);
    assertFalse(updater.isNeedUpgrade(testsbPortletProject));
    assertTrue(containString(testsbPortletProject, "com.liferay.css.builder"));
    assertTrue(containString(testsbPortletProject, "com.liferay.portal.tools.service.builder"));
    assertTrue(containString(testsbPortletProject, "biz.aQute.bnd.annotation"));
    makeSureNoLegacyElememnts(testsbPortletProject);
    // // service builder -service subproject
    IProject testsbPortletServiceProject = CoreUtil.getProject("testsb-portlet-service");
    assertTrue(updater.isNeedUpgrade(testsbPortletServiceProject));
    updater.upgradePomFile(testsbPortletServiceProject, null);
    assertFalse(updater.isNeedUpgrade(testsbPortletServiceProject));
    assertTrue(containString(testsbPortletServiceProject, "biz.aQute.bnd.annotation"));
    makeSureNoLegacyElememnts(testsbPortletServiceProject);
    // theme project
    IProject testthemeProject = CoreUtil.getProject("testtheme");
    assertTrue(updater.isNeedUpgrade(testthemeProject));
    updater.upgradePomFile(testthemeProject, null);
    assertFalse(updater.isNeedUpgrade(testthemeProject));
    assertTrue(containString(testthemeProject, "com.liferay.portal.tools.theme.builder.outputDir"));
    assertTrue(containString(testthemeProject, "project.build.sourceEncoding"));
    assertTrue(containString(testthemeProject, "maven-war-plugin"));
    assertTrue(containString(testthemeProject, "maven-dependency-plugin"));
    assertTrue(containString(testthemeProject, "com.liferay.css.builder"));
    assertTrue(containString(testthemeProject, "com.liferay.portal.tools.theme.builder"));
    makeSureNoLegacyElememnts(testthemeProject);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) LiferayMavenLegacyProjectUpdater(com.liferay.ide.maven.core.LiferayMavenLegacyProjectUpdater) IPath(org.eclipse.core.runtime.IPath) ILiferayProjectImporter(com.liferay.ide.core.ILiferayProjectImporter) File(java.io.File) IFile(org.eclipse.core.resources.IFile) IProject(org.eclipse.core.resources.IProject) URL(java.net.URL) Test(org.junit.Test)

Aggregations

ILiferayProjectImporter (com.liferay.ide.core.ILiferayProjectImporter)1 LiferayMavenLegacyProjectUpdater (com.liferay.ide.maven.core.LiferayMavenLegacyProjectUpdater)1 File (java.io.File)1 URL (java.net.URL)1 IFile (org.eclipse.core.resources.IFile)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 Test (org.junit.Test)1