Search in sources :

Example 11 with TextFile

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

the class IntegrationTest method testFileInJar.

@Test
public void testFileInJar() throws Exception {
    IJavaProject project = createJavaProject("foo");
    addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
    IFile file = project.getProject().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());
}
Also used : IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) Test(org.junit.Test)

Example 12 with TextFile

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

the class IntegrationTest method testEvents.

@Test
public void testEvents() 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());
    file.setLocalTimeStamp(100L);
    addJarToClasspath(project, file);
    someProject.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 13 with TextFile

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

the class ProfilerAbstractBuilderTest method testFullBuildBigProjectWithRefeernceToJar.

@Test
public void testFullBuildBigProjectWithRefeernceToJar() throws Exception {
    IJavaProject project = workspace.createJavaProject("foo");
    workspace.addNature(project.getProject(), XtextProjectHelper.NATURE_ID);
    IFolder folder = project.getProject().getFolder("src");
    IFile jarFile = project.getProject().getFile("my.jar");
    jarFile.create(jarInputStream(new TextFile("my/element" + F_EXT, "object ReferenceMe")), true, workspace.monitor());
    workspace.addJarToClasspath(project, jarFile);
    int NUM_FILES = 2000;
    IFile[] files = new IFile[NUM_FILES];
    StopWatch timer = new StopWatch();
    for (int i = 0; i < NUM_FILES; i++) {
        IFile file = folder.getFile("Test_" + i + "_" + F_EXT);
        files[i] = file;
        String contents = "object Foo" + i + " references ReferenceMe";
        file.create(new StringInputStream(contents), true, workspace.monitor());
    }
    logAndReset("Creating files", timer);
    workspace.build();
    logAndReset("Auto build", timer);
    IMarker[] iMarkers = folder.findMarkers(EValidator.MARKER, true, IResource.DEPTH_INFINITE);
    for (IMarker iMarker : iMarkers) {
        System.out.println(iMarker.getAttribute(IMarker.MESSAGE));
    }
    assertEquals(0, iMarkers.length);
}
Also used : StringInputStream(org.eclipse.xtext.util.StringInputStream) IJavaProject(org.eclipse.jdt.core.IJavaProject) IFile(org.eclipse.core.resources.IFile) TextFile(org.eclipse.xtext.ui.testing.util.JavaProjectSetupUtil.TextFile) IMarker(org.eclipse.core.resources.IMarker) IFolder(org.eclipse.core.resources.IFolder) StopWatch(org.eclipse.xtext.util.StopWatch) Test(org.junit.Test)

Example 14 with TextFile

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

the class SimpleProjectsIntegrationTest method testReexportedJarRemoved.

@Test
public void testReexportedJarRemoved() 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);
    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);
    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(0, countMarkers(bazFile));
    deleteClasspathEntry(foo, newLibraryEntry.getPath());
    build();
    assertEquals(1, countMarkers(bazFile));
    assertEquals(1, countResourcesInIndex());
    Iterator<IReferenceDescription> references = getContainedReferences(URI.createPlatformResourceURI(bazFile.getFullPath().toString(), true)).iterator();
    assertFalse(references.hasNext());
}
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) IReferenceDescription(org.eclipse.xtext.resource.IReferenceDescription) Test(org.junit.Test)

Example 15 with TextFile

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

the class SimpleProjectsIntegrationTest method testReexportedSource.

@Test
public void testReexportedSource() 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);
    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);
    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(0, countMarkers(bazFile));
    assertEquals(2, countResourcesInIndex());
    Iterator<IReferenceDescription> references = getContainedReferences(URI.createPlatformResourceURI(bazFile.getFullPath().toString(), true)).iterator();
    IReferenceDescription next = references.next();
    assertFalse(references.hasNext());
    assertEquals("platform:/resource/baz/src/Baz.buildertestlanguage#/", next.getSourceEObjectUri().toString());
    assertEquals("archive:platform:/resource/foo/foo.jar!/foo/Foo.buildertestlanguage#/", next.getTargetEObjectUri().toString());
    assertEquals(-1, next.getIndexInList());
    assertEquals(BuilderTestLanguagePackage.Literals.ELEMENT__REFERENCES, next.getEReference());
}
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) IReferenceDescription(org.eclipse.xtext.resource.IReferenceDescription) 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