summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorszarnekow2009-04-29 02:46:39 (EDT)
committer sefftinge2009-04-29 02:46:39 (EDT)
commit948ccdc31878b91f4739c16205ff0dbb5471e00c (patch)
treeff03153500b724a53d2f2fa2f38112410547638a
parent972de11c5bbdcc1baba7e27e01b58b2115784d5f (diff)
downloadorg.eclipse.xtext-948ccdc31878b91f4739c16205ff0dbb5471e00c.zip
org.eclipse.xtext-948ccdc31878b91f4739c16205ff0dbb5471e00c.tar.gz
org.eclipse.xtext-948ccdc31878b91f4739c16205ff0dbb5471e00c.tar.bz2
Fix: ImportUriValidator could not be injected
-rw-r--r--tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/validator/ImportUriValidatorTest.java78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/validator/ImportUriValidatorTest.java b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/validator/ImportUriValidatorTest.java
new file mode 100644
index 0000000..e4fab50
--- /dev/null
+++ b/tests/org.eclipse.xtext.generator.tests/src/org/eclipse/xtext/validator/ImportUriValidatorTest.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2009 itemis AG (http://www.itemis.eu) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+package org.eclipse.xtext.validator;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.emf.common.util.Diagnostic;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.Diagnostician;
+import org.eclipse.xtext.crossref.impl.ImportUriValidator;
+import org.eclipse.xtext.crossrefs.ImportUriTestLanguageRuntimeModule;
+import org.eclipse.xtext.crossrefs.ImportUriTestLanguageStandaloneSetup;
+import org.eclipse.xtext.crossrefs.importedURI.ImportedURIPackage;
+import org.eclipse.xtext.junit.AbstractXtextTests;
+
+import com.google.inject.Binder;
+import com.google.inject.Guice;
+import com.google.inject.Injector;
+
+/**
+ * @author Sebastian Zarnekow - Initial contribution and API
+ */
+public class ImportUriValidatorTest extends AbstractXtextTests {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ with(createStandaloneSetup());
+ }
+
+ public void testValidURI() throws Exception {
+ String model = "import 'classpath:/org/eclipse/xtext/crossrefs/ImportUriTestLanguage.xtext'";
+ Resource resource = getResourceFromString(model);
+ Diagnostic diagnostics = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
+ assertEquals(Diagnostic.OK, diagnostics.getSeverity());
+ }
+
+ public void testInvalidURI() throws Exception {
+ String model = "import 'classpath:/org/eclipse/xtext/crossrefs/ImportUriTestLanguage.unknown'";
+ Resource resource = getResourceFromString(model);
+ Diagnostic diagnostics = Diagnostician.INSTANCE.validate(resource.getContents().get(0));
+ assertEquals(Diagnostic.ERROR, diagnostics.getSeverity());
+ }
+
+ @ComposedChecks(validators=ImportUriValidator.class)
+ public static class Validator extends AbstractDeclarativeValidator {
+
+ @Override
+ protected List<? extends EPackage> getEPackages() {
+ return Collections.singletonList(ImportedURIPackage.eINSTANCE);
+ }
+
+ }
+
+ protected ImportUriTestLanguageStandaloneSetup createStandaloneSetup() {
+ return new ImportUriTestLanguageStandaloneSetup() {
+ @Override
+ public Injector createInjector() {
+ return Guice.createInjector(new ImportUriTestLanguageRuntimeModule() {
+
+ @Override
+ public void configure(Binder binder) {
+ super.configure(binder);
+ binder.bind(Validator.class).asEagerSingleton();
+ }
+
+ });
+ }
+ };
+ }
+}