Search in sources :

Example 1 with TextFile

use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.

the class IntegrationTest method testFullBuild.

@Test
public void testFullBuild() throws Exception {
    IJavaProject project = createJavaProject("foo");
    addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
    IProject someProject = createProject("bar");
    IFile file = someProject.getFile("foo.jar");
    file.create(jarInputStream(new TextFile("foo/Bar" + F_EXT, "object Foo")), true, monitor());
    assertEquals(0, countResourcesInIndex());
    addJarToClasspath(project, file);
    assertEquals(1, countResourcesInIndex());
    getBuilderState().addListener(this);
    fullBuild();
    assertEquals(1, countResourcesInIndex());
    assertEquals(1, getEvents().size());
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 2 with TextFile

use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.

the class SimpleProjectsIntegrationTest method testEvents.

@Test
public void testEvents() throws Exception {
    IJavaProject xtextProject = createJavaProject("xtextProject");
    addNature(xtextProject.getProject(), XtextProjectHelper.NATURE_ID);
    IProject projectWithJarFile = createProject("projectWithJar");
    IFile jarFile = projectWithJarFile.getFile("jarFile.jar");
    jarFile.create(JavaProjectSetupUtil.jarInputStream(new TextFile("inJar/Bar" + F_EXT, "object InJar")), true, monitor());
    jarFile.setLocalTimeStamp(100L);
    addJarToClasspath(xtextProject, jarFile);
    projectWithJarFile.delete(true, monitor());
    build();
    assertEmptyIndex();
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) IProject(org.eclipse.core.resources.IProject) Test(org.junit.Test)

Example 3 with TextFile

use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.

the class SimpleProjectsIntegrationTest method testNewlyAddedReexportedSource.

@Test
public void testNewlyAddedReexportedSource() throws Exception {
    IJavaProject foo = createJavaProject("foo");
    IJavaProject bar = createJavaProject("bar");
    IJavaProject baz = createJavaProject("baz");
    addNature(foo.getProject(), XtextProjectHelper.NATURE_ID);
    addNature(bar.getProject(), XtextProjectHelper.NATURE_ID);
    addNature(baz.getProject(), XtextProjectHelper.NATURE_ID);
    addToClasspath(bar, JavaCore.newProjectEntry(foo.getPath(), true));
    addToClasspath(baz, JavaCore.newProjectEntry(bar.getPath(), false));
    addSourceFolder(baz, "src");
    IFile bazFile = createFile("baz/src/Baz" + F_EXT, "object Baz references Foo");
    build();
    assertEquals(1, countMarkers(bazFile));
    IFile file = foo.getProject().getFile("foo.jar");
    file.create(JavaProjectSetupUtil.jarInputStream(new TextFile("foo/Foo" + F_EXT, "object Foo")), true, monitor());
    IClasspathEntry newLibraryEntry = JavaCore.newLibraryEntry(file.getFullPath(), null, null, true);
    addToClasspath(foo, newLibraryEntry);
    build();
    assertEquals(0, countMarkers(bazFile));
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) IClasspathEntry(org.eclipse.jdt.core.IClasspathEntry) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) Test(org.junit.Test)

Example 4 with TextFile

use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.

the class Storage2UriMapperJdtImplTest method testBug463258_03a.

@Test
public void testBug463258_03a() throws Exception {
    IJavaProject project = createJavaProject("foo");
    IFile file = project.getProject().getFile("foo.jar");
    file.create(jarInputStream(new TextFile("foo/bar.notindexed", "//empty")), true, monitor());
    addJarToClasspath(project, file);
    Storage2UriMapperJavaImpl impl = getStorage2UriMapper();
    IPackageFragmentRoot root = project.getPackageFragmentRoot(file);
    IPackageFragment foo = root.getPackageFragment("foo");
    JarEntryFile fileInJar = new JarEntryFile("bar.notindexed");
    fileInJar.setParent(foo);
    File jarFile = file.getRawLocation().toFile();
    assertTrue("exists", jarFile.exists());
    assertTrue("delete", jarFile.delete());
    URI uri = impl.getUri(fileInJar);
    assertEquals("archive:platform:/resource/foo/foo.jar!/foo/bar.notindexed", uri.toString());
}
Also used : IPackageFragment(org.eclipse.jdt.core.IPackageFragment) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) Storage2UriMapperJavaImpl(org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) JarEntryFile(org.eclipse.jdt.internal.core.JarEntryFile) JarEntryFile(org.eclipse.jdt.internal.core.JarEntryFile) IFile(org.eclipse.core.resources.IFile) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) File(java.io.File) URI(org.eclipse.emf.common.util.URI) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) Test(org.junit.Test)

Example 5 with TextFile

use of org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile in project xtext-eclipse by eclipse.

the class Storage2UriMapperJdtImplTest method testBug463258_02.

@Test
public void testBug463258_02() throws Exception {
    IJavaProject project = createJavaProject("foo");
    IFile file = project.getProject().getFile("foo.jar");
    file.create(jarInputStream(new TextFile("do/not", "care")), true, monitor());
    addJarToClasspath(project, file);
    Storage2UriMapperJavaImpl impl = getStorage2UriMapper();
    IPackageFragmentRoot root = project.getPackageFragmentRoot(file);
    IPackageFragment foo = root.getPackageFragment("unknown");
    JarEntryFile fileInJar = new JarEntryFile("doesNotExist.notindexed");
    fileInJar.setParent(foo);
    URI uri = impl.getUri(fileInJar);
    assertEquals("archive:platform:/resource/foo/foo.jar!/unknown/doesNotExist.notindexed", uri.toString());
}
Also used : IPackageFragment(org.eclipse.jdt.core.IPackageFragment) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) Storage2UriMapperJavaImpl(org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) JarEntryFile(org.eclipse.jdt.internal.core.JarEntryFile) URI(org.eclipse.emf.common.util.URI) IPackageFragmentRoot(org.eclipse.jdt.core.IPackageFragmentRoot) Test(org.junit.Test)

Aggregations

IFile (org.eclipse.core.resources.IFile)23 IJavaProject (org.eclipse.jdt.core.IJavaProject)23 TextFile (org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile)23 Test (org.junit.Test)23 IPackageFragmentRoot (org.eclipse.jdt.core.IPackageFragmentRoot)12 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)10 JarEntryFile (org.eclipse.jdt.internal.core.JarEntryFile)10 URI (org.eclipse.emf.common.util.URI)7 Storage2UriMapperJavaImpl (org.eclipse.xtext.ui.resource.Storage2UriMapperJavaImpl)7 File (java.io.File)6 IClasspathEntry (org.eclipse.jdt.core.IClasspathEntry)5 XtextReadonlyEditorInput (org.eclipse.xtext.ui.editor.XtextReadonlyEditorInput)5 AbstractWorkbenchTest (org.eclipse.xtext.ui.testing.AbstractWorkbenchTest)5 IProject (org.eclipse.core.resources.IProject)3 IResource (org.eclipse.core.resources.IResource)3 Resource (org.eclipse.emf.ecore.resource.Resource)3 NonJavaResource (org.eclipse.jdt.internal.core.NonJavaResource)3 IReferenceDescription (org.eclipse.xtext.resource.IReferenceDescription)3 IOException (java.io.IOException)2 IStorage (org.eclipse.core.resources.IStorage)2