Search in sources :

Example 26 with Path

use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.

the class JavaIoFileSystemTest method testGetProjectChildren.

@Test
public void testGetProjectChildren() {
    final Path projectFolder = new Path("/foo");
    Assert.assertTrue(this.fs.exists(projectFolder));
    int _size = IterableExtensions.size(this.fs.getChildren(projectFolder));
    final int expectedChildrenSize = (_size + 1);
    Path _path = new Path("/foo/Foo.text");
    this.fs.setContents(_path, "Hello Foo");
    Iterable<? extends Path> _children = this.fs.getChildren(projectFolder);
    String _plus = ("" + _children);
    Assert.assertEquals(_plus, expectedChildrenSize, IterableExtensions.size(this.fs.getChildren(projectFolder)));
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 27 with Path

use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.

the class JavaIoFileSystemTest method testMakeAndDeleteFolder.

@Test
public void testMakeAndDeleteFolder() {
    final Path someFolder = new Path("/foo/bar");
    final Path someFile = someFolder.append("Foo.txt");
    Assert.assertFalse(this.fs.exists(someFolder));
    Assert.assertFalse(this.fs.isFile(someFolder));
    Assert.assertFalse(this.fs.isFolder(someFolder));
    this.fs.setContents(someFile, "Hello Foo");
    Assert.assertFalse(this.fs.isFile(someFolder));
    Assert.assertTrue(this.fs.isFolder(someFolder));
    Assert.assertTrue(this.fs.exists(someFolder));
    this.fs.delete(someFolder);
    Assert.assertTrue(this.fs.exists(someFolder));
    this.fs.delete(someFile);
    this.fs.delete(someFolder);
    Assert.assertFalse(this.fs.exists(someFolder));
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 28 with Path

use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.

the class JavaIoFileSystemTest method testGetFolderChildren.

@Test
public void testGetFolderChildren() {
    final Path folder = new Path("/foo/bar");
    Assert.assertFalse(this.fs.exists(folder));
    Path _append = folder.append("Bar.txt");
    this.fs.setContents(_append, "Hello Bar");
    Assert.assertTrue(this.fs.exists(folder));
    Assert.assertEquals(1, IterableExtensions.size(this.fs.getChildren(folder)));
    Path _path = new Path("/foo/bar/Foo.text");
    this.fs.setContents(_path, "Hello Foo");
    Assert.assertEquals(2, IterableExtensions.size(this.fs.getChildren(folder)));
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 29 with Path

use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.

the class JavaIoFileSystemTest method testGetWorkspaceURI.

@Test
public void testGetWorkspaceURI() {
    final Path path = Path.ROOT;
    Assert.assertTrue(this.fs.exists(path));
    Assert.assertNull(this.fs.toURI(path));
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 30 with Path

use of org.eclipse.xtend.lib.macro.file.Path in project xtext-xtend by eclipse.

the class JavaIoFileSystemTest method testModificationStamp_01.

@Test
public void testModificationStamp_01() {
    try {
        final Path path = new Path("/foo/src/my/pack/Foo.txt");
        Assert.assertEquals(0L, this.fs.getLastModification(path));
        this.fs.setContents(path, "Hello Foo");
        final long mod = this.fs.getLastModification(path);
        Assert.assertEquals("Hello Foo", this.fs.getContents(path));
        Assert.assertEquals(mod, this.fs.getLastModification(path));
        Thread.sleep(1000);
        this.fs.setContents(path, "Hello Foo");
        Assert.assertEquals(mod, this.fs.getLastModification(path));
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Aggregations

Path (org.eclipse.xtend.lib.macro.file.Path)42 Test (org.junit.Test)31 File (java.io.File)3 URI (java.net.URI)2 IProject (org.eclipse.core.resources.IProject)2 URI (org.eclipse.emf.common.util.URI)2 JavaIoFileSystemTest (org.eclipse.xtend.ide.tests.macros.JavaIoFileSystemTest)2 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)2 List (java.util.List)1 IProjectDescription (org.eclipse.core.resources.IProjectDescription)1 IWorkspace (org.eclipse.core.resources.IWorkspace)1 IWorkspaceRoot (org.eclipse.core.resources.IWorkspaceRoot)1 Resource (org.eclipse.emf.ecore.resource.Resource)1 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)1 AbstractFileSystemSupport (org.eclipse.xtend.core.macro.AbstractFileSystemSupport)1 ChangeListenerAddingFileSystemSupport (org.eclipse.xtend.core.macro.declaration.ChangeListenerAddingFileSystemSupport)1 UIResourceChangeRegistry (org.eclipse.xtend.ide.builder.UIResourceChangeRegistry)1 MutableFieldDeclaration (org.eclipse.xtend.lib.macro.declaration.MutableFieldDeclaration)1 OutputConfiguration (org.eclipse.xtext.generator.OutputConfiguration)1 Before (org.junit.Before)1