aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-squid/src/test/java
diff options
context:
space:
mode:
authorFreddy Mallet <freddy.mallet@gmail.com>2011-10-24 17:25:08 +0200
committerFreddy Mallet <freddy.mallet@gmail.com>2011-10-24 17:25:08 +0200
commit7b85ebdefdd22560fcfeb22e5c60116690149314 (patch)
tree03fd47312299a8ffce18d42179d5872afe8fac81 /sonar-squid/src/test/java
parent31e06917a220453a328a6edfaea6fa686dbcb1de (diff)
downloadsonarqube-7b85ebdefdd22560fcfeb22e5c60116690149314.tar.gz
sonarqube-7b85ebdefdd22560fcfeb22e5c60116690149314.zip
SONAR-2741 The method JavaAstScanner.scanDirectory(..) can't be called several times
Diffstat (limited to 'sonar-squid/src/test/java')
-rw-r--r--sonar-squid/src/test/java/org/sonar/squid/MyCodeScanner.java35
-rw-r--r--sonar-squid/src/test/java/org/sonar/squid/SquidTest.java33
2 files changed, 68 insertions, 0 deletions
diff --git a/sonar-squid/src/test/java/org/sonar/squid/MyCodeScanner.java b/sonar-squid/src/test/java/org/sonar/squid/MyCodeScanner.java
new file mode 100644
index 00000000000..409bef945c4
--- /dev/null
+++ b/sonar-squid/src/test/java/org/sonar/squid/MyCodeScanner.java
@@ -0,0 +1,35 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package org.sonar.squid;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.sonar.squid.api.CodeScanner;
+import org.sonar.squid.api.CodeVisitor;
+
+public class MyCodeScanner extends CodeScanner<CodeVisitor> {
+
+ @Override
+ public Collection<Class<? extends CodeVisitor>> getVisitorClasses() {
+ return new ArrayList<Class<? extends CodeVisitor>>();
+ }
+}
diff --git a/sonar-squid/src/test/java/org/sonar/squid/SquidTest.java b/sonar-squid/src/test/java/org/sonar/squid/SquidTest.java
new file mode 100644
index 00000000000..576b7fed6a2
--- /dev/null
+++ b/sonar-squid/src/test/java/org/sonar/squid/SquidTest.java
@@ -0,0 +1,33 @@
+/*
+ * Sonar, open source software quality management tool.
+ * Copyright (C) 2008-2011 SonarSource
+ * mailto:contact AT sonarsource DOT com
+ *
+ * Sonar is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * Sonar is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Sonar; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02
+ */
+
+package org.sonar.squid;
+
+import org.junit.Test;
+
+public class SquidTest {
+
+ @Test(expected = IllegalStateException.class)
+ public void shouldNotAcceptToRegisterTwiceTheSameScanner() {
+ Squid squid = new Squid();
+ squid.register(MyCodeScanner.class);
+ squid.register(MyCodeScanner.class);
+ }
+}