summaryrefslogtreecommitdiffstats
path: root/sonar-channel/src/test
diff options
context:
space:
mode:
authorDinesh Bolkensteyn <dinesh@dinsoft.net>2011-10-20 20:50:42 +0200
committerDinesh Bolkensteyn <dinesh@dinsoft.net>2011-10-20 20:51:35 +0200
commit0b9c56c76952cc93dea74b386938154158f407dd (patch)
tree2f64114c3f62beb436ba9072cc0e852aa2483974 /sonar-channel/src/test
parent58f71c9c265323a5c341e365816521a7119eae07 (diff)
downloadsonarqube-0b9c56c76952cc93dea74b386938154158f407dd.tar.gz
sonarqube-0b9c56c76952cc93dea74b386938154158f407dd.zip
SONAR-2923 and SONAR-2632: Remove sonar-channel buffer restriction and character pushback feature
Diffstat (limited to 'sonar-channel/src/test')
-rw-r--r--sonar-channel/src/test/java/org/sonar/channel/CodeBufferTest.java22
-rw-r--r--sonar-channel/src/test/java/org/sonar/channel/CodeReaderTest.java18
-rw-r--r--sonar-channel/src/test/java/org/sonar/channel/RegexChannelTest.java21
3 files changed, 21 insertions, 40 deletions
diff --git a/sonar-channel/src/test/java/org/sonar/channel/CodeBufferTest.java b/sonar-channel/src/test/java/org/sonar/channel/CodeBufferTest.java
index 471b16bd975..387978fe069 100644
--- a/sonar-channel/src/test/java/org/sonar/channel/CodeBufferTest.java
+++ b/sonar-channel/src/test/java/org/sonar/channel/CodeBufferTest.java
@@ -117,20 +117,6 @@ public class CodeBufferTest {
}
@Test
- public void testPush() {
- CodeReader reader = new CodeReader("12", defaulConfiguration);
- assertEquals('1', (char) reader.pop());
- reader.push("a");
- assertEquals('a', (char) reader.peek());
- reader.push("45");
- assertEquals("45a2", new String(reader.peek(4)));
- for (int i = 0; i < 4; i++) {
- reader.pop();
- }
- assertEquals( -1, reader.pop());
- }
-
- @Test
public void testCharAtIndexOutOfBoundsException() {
CodeBuffer reader = new CodeBuffer("12345", defaulConfiguration);
assertEquals(reader.charAt(5), (char) -1);
@@ -210,14 +196,6 @@ public class CodeBufferTest {
}
@Test
- public void theLengthShouldBeIntegerMaxValueWhenTheBufferCantContainAllCharacters() {
- String myCode = "myCode";
- CodeReaderConfiguration conf = new CodeReaderConfiguration();
- conf.setBufferCapacity(2);
- assertThat(new CodeBuffer(myCode, conf).length(), is(Integer.MAX_VALUE));
- }
-
- @Test
public void testSeveralCodeReaderFilter() throws Exception {
CodeReaderConfiguration configuration = new CodeReaderConfiguration();
configuration.setCodeReaderFilters(new ReplaceNumbersFilter(), new ReplaceCharFilter());
diff --git a/sonar-channel/src/test/java/org/sonar/channel/CodeReaderTest.java b/sonar-channel/src/test/java/org/sonar/channel/CodeReaderTest.java
index a748cfa6f83..b6f1d0b8289 100644
--- a/sonar-channel/src/test/java/org/sonar/channel/CodeReaderTest.java
+++ b/sonar-channel/src/test/java/org/sonar/channel/CodeReaderTest.java
@@ -84,24 +84,6 @@ public class CodeReaderTest {
}
@Test
- public void testPeekToAndReachingTheBufferLimit() {
- CodeReaderConfiguration configuration = new CodeReaderConfiguration();
- configuration.setBufferCapacity(10);
- CodeReader reader = new CodeReader("word1 word2 word2", configuration);
- for (int i = 0; i < 6; i++) {
- reader.pop();
- }
- StringBuilder result = new StringBuilder();
- reader.peekTo(new EndMatcher() {
-
- public boolean match(int endFlag) {
- return ' ' == (char) endFlag;
- }
- }, result);
- assertEquals("word2", result.toString());
- }
-
- @Test
public void testPopToWithRegex() {
CodeReader reader = new CodeReader(new StringReader("123ABC"));
StringBuilder token = new StringBuilder();
diff --git a/sonar-channel/src/test/java/org/sonar/channel/RegexChannelTest.java b/sonar-channel/src/test/java/org/sonar/channel/RegexChannelTest.java
index 35d9c936b78..322899266ab 100644
--- a/sonar-channel/src/test/java/org/sonar/channel/RegexChannelTest.java
+++ b/sonar-channel/src/test/java/org/sonar/channel/RegexChannelTest.java
@@ -33,7 +33,28 @@ public class RegexChannelTest {
dispatcher.consume(new CodeReader("my word"), output);
assertThat(output.toString(), is("<w>my</w> <w>word</w>"));
}
+
+ @Test
+ public void shouldMatchTokenLongerThanBuffer() {
+ ChannelDispatcher<StringBuilder> dispatcher = ChannelDispatcher.builder().addChannel(new MyLiteralChannel()).build();
+ StringBuilder output = new StringBuilder();
+
+ dispatcher.consume(new CodeReader("\"bonjour\""), output);
+ assertThat(output.toString(), is("<literal>\"bonjour\"</literal>"));
+ }
+
+ private static class MyLiteralChannel extends RegexChannel<StringBuilder> {
+
+ public MyLiteralChannel() {
+ super("\"[^\"]*+\"");
+ }
+ @Override
+ protected void consume(CharSequence token, StringBuilder output) {
+ output.append("<literal>" + token + "</literal>");
+ }
+ }
+
private static class MyWordChannel extends RegexChannel<StringBuilder> {
public MyWordChannel() {