Java Code Examples for org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil#createProject()

The following examples show how to use org.eclipse.xtext.ui.testing.util.IResourcesSetupUtil#createProject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PreferenceStoreAccessTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testProjectScope() throws Exception {
	try {
		IProject project = IResourcesSetupUtil.createProject("test");
		final List<String> keys = Lists.newArrayList();
		preferenceStoreAccess.getContextPreferenceStore(project).addPropertyChangeListener(new IPropertyChangeListener() {
			@Override
			public void propertyChange(PropertyChangeEvent event) {
				keys.add(event.getProperty());
			}
		});
		getWritable().setValue("newValue", 1);
		assertEquals(0, keys.size());
		preferenceStoreAccess.getWritablePreferenceStore(project).setValue("newValue", 2);
		assertEquals(1, keys.size());
		assertEquals("newValue", keys.get(0));
		assertEquals(1, getReadable().getInt("newValue"));
		assertEquals(2, preferenceStoreAccess.getContextPreferenceStore(project).getInt("newValue"));
	} finally {
		IResourcesSetupUtil.cleanWorkspace();
	}
}
 
Example 2
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testInMemoryResourceWithProject() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    String _primaryFileExtension = this._fileExtensionProvider.getPrimaryFileExtension();
    String _plus = ("MyProject/myfile." + _primaryFileExtension);
    final Resource resource = rs.createResource(URI.createPlatformResourceURI(_plus, true));
    StringInputStream _stringInputStream = new StringInputStream("stuff foo");
    resource.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap());
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=false {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile.testlanguage exported=[foo]");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String expected = _builder.toString();
    Assert.assertEquals(expected, this.formatContainers(rs));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 3
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testEmptyProject() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=true {");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String expected = _builder.toString();
    Assert.assertEquals(expected, this.formatContainers(rs));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 4
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testPersistedWithoutResource() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    String _primaryFileExtension = this._fileExtensionProvider.getPrimaryFileExtension();
    final String fileName = ("MyProject/myfile." + _primaryFileExtension);
    IResourcesSetupUtil.createFile(fileName, "stuff foo");
    IResourcesSetupUtil.waitForBuild();
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=false {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile.testlanguage exported=[foo]");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String expected = _builder.toString();
    Assert.assertEquals(expected, this.formatContainers(rs));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 5
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Test
public void testPersistedWithResource() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    String _primaryFileExtension = this._fileExtensionProvider.getPrimaryFileExtension();
    final String fileName = ("MyProject/myfile." + _primaryFileExtension);
    IResourcesSetupUtil.createFile(fileName, "stuff foo");
    IResourcesSetupUtil.waitForBuild();
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    Assert.assertNotNull(rs.getResource(URI.createPlatformResourceURI(fileName, true), true));
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=false {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile.testlanguage exported=[foo]");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String expected = _builder.toString();
    Assert.assertEquals(expected, this.formatContainers(rs));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
Example 6
Source File: AbstractResourceRelocationTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Before
public void setup() throws Exception {
	IResourcesSetupUtil.setAutobuild(false);
	project = IResourcesSetupUtil.createProject("test");
	IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
	IResourcesSetupUtil.addBuilder(project, XtextProjectHelper.BUILDER_ID);
}
 
Example 7
Source File: EditorResourceAccessTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	IProject project = IResourcesSetupUtil.createProject("test");
	IResourcesSetupUtil.addNature(project, "org.eclipse.xtext.ui.shared.xtextNature");
	file = project.getFile("test.refactoringtestlanguage");
	file.create(new StringInputStream(""), true, null);
	uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
}
 
Example 8
Source File: OpenDocumentTrackerTests.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void setUp() throws Exception {
	super.setUp();
	tracker = TestsActivator.getInstance().getInjector(getEditorId()).getInstance(OpenDocumentTracker.class);
	IProject project = IResourcesSetupUtil.createProject("test");
	file = project.getFile("test.testlanguage");
	file.create(new StringInputStream("dummdidumm"), true, null);
	uri = URI.createPlatformResourceURI(file.getFullPath().toString(), true);
}
 
Example 9
Source File: LiveShadowedAllContainerStateTest.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@Test
public void testPersistedWithOtherResource() {
  try {
    final IProject project = IResourcesSetupUtil.createProject("MyProject");
    IResourcesSetupUtil.addNature(project, XtextProjectHelper.NATURE_ID);
    String _primaryFileExtension = this._fileExtensionProvider.getPrimaryFileExtension();
    final String fileName = ("MyProject/myfile1." + _primaryFileExtension);
    IResourcesSetupUtil.createFile(fileName, "stuff foo");
    IResourcesSetupUtil.waitForBuild();
    final ResourceSet rs = this.liveScopeResourceSetProvider.get(project);
    String _primaryFileExtension_1 = this._fileExtensionProvider.getPrimaryFileExtension();
    String _plus = ("MyProject/myfile2." + _primaryFileExtension_1);
    final Resource resource = rs.createResource(URI.createPlatformResourceURI(_plus, true));
    StringInputStream _stringInputStream = new StringInputStream("stuff bar");
    resource.load(_stringInputStream, CollectionLiterals.<Object, Object>emptyMap());
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("container MyProject isEmpty=false {");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile1.testlanguage exported=[foo]");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("resourceURI=platform:/resource/MyProject/myfile2.testlanguage exported=[bar]");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    final String expected = _builder.toString();
    Assert.assertEquals(expected, this.formatContainers(rs));
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}