Package com.dubture.composer.test

Source Code of com.dubture.composer.test.BuildPathTest

package com.dubture.composer.test;

import static org.hamcrest.core.Is.is;
import static org.junit.Assert.assertThat;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.dltk.core.IScriptProject;
import org.eclipse.php.internal.core.PHPVersion;
import org.eclipse.php.internal.core.facet.PHPFacets;
import org.eclipse.php.internal.core.project.PHPNature;
import org.eclipse.php.internal.core.project.ProjectOptions;
import org.junit.Test;

import com.dubture.composer.core.ComposerNature;
import com.dubture.composer.core.ComposerPlugin;
import com.dubture.composer.core.buildpath.BuildPathParser;
import com.dubture.composer.core.facet.FacetManager;
import com.dubture.composer.core.resources.IComposerProject;

@SuppressWarnings("restriction")
public class BuildPathTest extends ComposerModelTests {

  public BuildPathTest() {
    super("BuildPath tests");
  }
 
  @Test
  public void testBuildpathParser() throws CoreException, IOException, InterruptedException {
    IScriptProject scriptProject = ensureScriptProject("buildpath");

    assertNotNull(scriptProject);

    IProjectDescription desc = scriptProject.getProject().getDescription();
    desc.setNatureIds(new String[] { PHPNature.ID });
    scriptProject.getProject().setDescription(desc, null);

    ProjectOptions.setPhpVersion(PHPVersion.PHP5_3, scriptProject.getProject());

    PHPFacets.setFacetedVersion(scriptProject.getProject(), PHPVersion.PHP5_3);
    FacetManager.installFacets(scriptProject.getProject(), PHPVersion.PHP5_3, new NullProgressMonitor());

    scriptProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
    scriptProject.getProject().build(IncrementalProjectBuilder.FULL_BUILD, null);

    ComposerCoreTestPlugin.waitForIndexer();
    ComposerCoreTestPlugin.waitForAutoBuild();

    IFile file = scriptProject.getProject().getFile("composer.json");
    assertNotNull(file);

    assertTrue(scriptProject.getProject().hasNature(PHPNature.ID));
    assertTrue(scriptProject.getProject().hasNature(ComposerNature.NATURE_ID));

    IComposerProject composerProject = ComposerPlugin.getDefault().getComposerProject(scriptProject.getProject());
    BuildPathParser parser = new BuildPathParser(composerProject);
    List<String> paths = parser.getPaths();
    List<String> expected = new ArrayList<String>(Arrays.asList(
        "src",
        "test",
        "nother",
        "mordor/composer",
        "mordor/phing/phing/classes/phing",
        "mordor/propel/propel1/runtime/lib",
        "mordor/propel/propel1/generator/lib",
        "mordor/gossi/ldap/src",
        "mordor/symfony/console"));
    assertThat(paths, is(expected));
   
    // let indexing threads shutdown to avoid SWT thread access errors
    Thread.sleep(2000);

  }
 
}
TOP

Related Classes of com.dubture.composer.test.BuildPathTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.