aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-duplications
diff options
context:
space:
mode:
authorDavid Gageot <david@gageot.net>2012-04-24 10:12:28 +0200
committerDavid Gageot <david@gageot.net>2012-04-27 14:58:59 +0200
commit872b3923f80d9a2bcc13713f41cf801f2a7024eb (patch)
tree2ef0a5003c3becb1b0e53d5683e60ed3c9f759b5 /sonar-duplications
parent4b262d15878b31c6c2c7efd8236fb5c65093ba11 (diff)
downloadsonarqube-872b3923f80d9a2bcc13713f41cf801f2a7024eb.tar.gz
sonarqube-872b3923f80d9a2bcc13713f41cf801f2a7024eb.zip
Remove warnings
Diffstat (limited to 'sonar-duplications')
-rw-r--r--sonar-duplications/src/test/java/net/sourceforge/pmd/cpd/AbstractLanguageTest.java3
-rw-r--r--sonar-duplications/src/test/java/org/sonar/duplications/java/JavaStatementBuilderTest.java50
-rw-r--r--sonar-duplications/src/test/java/org/sonar/duplications/java/JavaTokenProducerTest.java29
3 files changed, 42 insertions, 40 deletions
diff --git a/sonar-duplications/src/test/java/net/sourceforge/pmd/cpd/AbstractLanguageTest.java b/sonar-duplications/src/test/java/net/sourceforge/pmd/cpd/AbstractLanguageTest.java
index eac34fb50a9..404df716657 100644
--- a/sonar-duplications/src/test/java/net/sourceforge/pmd/cpd/AbstractLanguageTest.java
+++ b/sonar-duplications/src/test/java/net/sourceforge/pmd/cpd/AbstractLanguageTest.java
@@ -23,7 +23,6 @@ import org.junit.Test;
import java.io.File;
import java.io.FilenameFilter;
-import java.io.IOException;
import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertThat;
@@ -36,7 +35,7 @@ import static org.junit.Assert.assertThat;
public class AbstractLanguageTest {
@Test
- public void shouldCreateCorrectFilenameFilterForExtensions() throws IOException {
+ public void shouldCreateCorrectFilenameFilterForExtensions() {
AbstractLanguage language = new AbstractLanguage(null, "java") {
};
diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaStatementBuilderTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaStatementBuilderTest.java
index 93a8a604b75..840ad390df0 100644
--- a/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaStatementBuilderTest.java
+++ b/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaStatementBuilderTest.java
@@ -19,14 +19,7 @@
*/
package org.sonar.duplications.java;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.junit.Assert.assertThat;
-
-import java.io.*;
-import java.nio.charset.Charset;
-import java.util.List;
-
+import com.google.common.base.Charsets;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.sonar.duplications.DuplicationsTestUtil;
@@ -34,10 +27,21 @@ import org.sonar.duplications.statement.Statement;
import org.sonar.duplications.statement.StatementChunker;
import org.sonar.duplications.token.TokenChunker;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.List;
+
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.number.OrderingComparisons.greaterThan;
+import static org.junit.Assert.assertThat;
+
public class JavaStatementBuilderTest {
- private TokenChunker tokenChunker = JavaTokenProducer.build();
- private StatementChunker statementChunker = JavaStatementBuilder.build();
+ private final TokenChunker tokenChunker = JavaTokenProducer.build();
+ private final StatementChunker statementChunker = JavaStatementBuilder.build();
private List<Statement> chunk(String sourceCode) {
return statementChunker.chunk(tokenChunker.chunk(sourceCode));
@@ -56,9 +60,9 @@ public class JavaStatementBuilderTest {
@Test
public void shouldHandleAnnotation() {
List<Statement> statements = chunk("" +
- "@Entity" +
- "@Table(name = \"properties\")" +
- "@Column(updatable = true, nullable = true)");
+ "@Entity" +
+ "@Table(name = \"properties\")" +
+ "@Column(updatable = true, nullable = true)");
assertThat(statements.size(), is(3));
assertThat(statements.get(0).getValue(), is("@Entity"));
assertThat(statements.get(1).getValue(), is("@Table(name=$CHARS)"));
@@ -124,11 +128,11 @@ public class JavaStatementBuilderTest {
@Test
public void shouldHandleSwitch() {
List<Statement> statements = chunk("" +
- "switch (month) {" +
- " case 1 : monthString=\"January\"; break;" +
- " case 2 : monthString=\"February\"; break;" +
- " default: monthString=\"Invalid\";" +
- "}");
+ "switch (month) {" +
+ " case 1 : monthString=\"January\"; break;" +
+ " case 2 : monthString=\"February\"; break;" +
+ " default: monthString=\"Invalid\";" +
+ "}");
assertThat(statements.size(), is(6));
assertThat(statements.get(0).getValue(), is("switch(month)"));
assertThat(statements.get(1).getValue(), is("case$NUMBER:monthString=$CHARS"));
@@ -144,10 +148,10 @@ public class JavaStatementBuilderTest {
@Test
public void shouldHandleNestedSwitch() {
List<Statement> statements = chunk("" +
- "switch (a) {" +
- " case 'a': case 'b': case 'c': something(); break;" +
- " case 'd': case 'e': case 'f': somethingOther(); break;" +
- "}");
+ "switch (a) {" +
+ " case 'a': case 'b': case 'c': something(); break;" +
+ " case 'd': case 'e': case 'f': somethingOther(); break;" +
+ "}");
assertThat(statements.size(), is(5));
assertThat(statements.get(0).getValue(), is("switch(a)"));
assertThat(statements.get(1).getValue(), is("case$CHARS:case$CHARS:case$CHARS:something()"));
@@ -325,7 +329,7 @@ public class JavaStatementBuilderTest {
private List<Statement> chunk(File file) {
Reader reader = null;
try {
- reader = new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8"));
+ reader = new InputStreamReader(new FileInputStream(file), Charsets.UTF_8);
return statementChunker.chunk(tokenChunker.chunk(reader));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
diff --git a/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaTokenProducerTest.java b/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaTokenProducerTest.java
index 9e225025d8a..86641ad98fd 100644
--- a/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaTokenProducerTest.java
+++ b/sonar-duplications/src/test/java/org/sonar/duplications/java/JavaTokenProducerTest.java
@@ -19,32 +19,31 @@
*/
package org.sonar.duplications.java;
-import static org.hamcrest.Matchers.is;
-import static org.hamcrest.number.OrderingComparisons.greaterThan;
-import static org.junit.Assert.assertThat;
+import com.google.common.base.Charsets;
+import com.google.common.collect.Lists;
+import org.apache.commons.io.IOUtils;
+import org.hamcrest.Matcher;
+import org.junit.Test;
+import org.sonar.duplications.DuplicationsTestUtil;
+import org.sonar.duplications.token.Token;
+import org.sonar.duplications.token.TokenChunker;
+import org.sonar.duplications.token.TokenQueue;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStreamReader;
import java.io.Reader;
-import java.nio.charset.Charset;
import java.util.Arrays;
import java.util.List;
-import org.apache.commons.io.IOUtils;
-import org.hamcrest.Matcher;
-import org.junit.Test;
-import org.sonar.duplications.DuplicationsTestUtil;
-import org.sonar.duplications.token.Token;
-import org.sonar.duplications.token.TokenChunker;
-import org.sonar.duplications.token.TokenQueue;
-
-import com.google.common.collect.Lists;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.number.OrderingComparisons.greaterThan;
+import static org.junit.Assert.assertThat;
public class JavaTokenProducerTest {
- private TokenChunker chunker = JavaTokenProducer.build();
+ private final TokenChunker chunker = JavaTokenProducer.build();
/**
* <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.6">White Space</a>
@@ -313,7 +312,7 @@ public class JavaTokenProducerTest {
private TokenQueue chunk(File file) {
Reader reader = null;
try {
- reader = new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8"));
+ reader = new InputStreamReader(new FileInputStream(file), Charsets.UTF_8);
return chunker.chunk(reader);
} catch (FileNotFoundException e) {
throw new RuntimeException(e);