Search in sources :

Example 36 with Path

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

the class JavaIoFileSystemTest method testGetProjectURI.

@Test
public void testGetProjectURI() {
    final Path path = new Path("/foo");
    Assert.assertTrue(this.fs.exists(path));
    Assert.assertNotNull(this.fs.toURI(path));
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 37 with Path

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

the class JavaIoFileSystemTest method testModificationStamp_02.

@Test
public void testModificationStamp_02() {
    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 Bar");
        long _lastModification = this.fs.getLastModification(path);
        boolean _lessThan = (mod < _lastModification);
        Assert.assertTrue(_lessThan);
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : Path(org.eclipse.xtend.lib.macro.file.Path) Test(org.junit.Test)

Example 38 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 39 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 40 with Path

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

the class PathTest method testPath.

@Test
public void testPath() {
    final Path p = new Path("/foo/bar/baz.txt");
    Assert.assertTrue(p.isAbsolute());
    Assert.assertEquals("baz.txt", p.getLastSegment());
    Assert.assertEquals("txt", p.getFileExtension());
    Assert.assertEquals("foo", IterableExtensions.<String>head(p.getSegments()));
    Assert.assertEquals("bar", p.getSegments().get(1));
    Assert.assertEquals(3, p.getSegments().size());
    Assert.assertEquals("/foo/bar/baz.txt", p.toString());
}
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