diff options
author | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-10-21 14:22:52 +0400 |
---|---|---|
committer | Evgeny Mandrikov <mandrikov@gmail.com> | 2011-10-24 10:49:42 +0400 |
commit | df62fc28559228713caf3382183556d4c41e5647 (patch) | |
tree | d2740cc265120df1dbf74467875359fe50587db2 /sonar-channel/src/test/java/org | |
parent | 1f0558ea12501d8d47b02004ccbdaf59099d07ce (diff) | |
download | sonarqube-df62fc28559228713caf3382183556d4c41e5647.tar.gz sonarqube-df62fc28559228713caf3382183556d4c41e5647.zip |
SONAR-2632 Remove sonar-channel buffer restriction
* Add test for backward compatibility with a COBOL plugin
* Fix violations
* Simplify code
Diffstat (limited to 'sonar-channel/src/test/java/org')
-rw-r--r-- | sonar-channel/src/test/java/org/sonar/channel/CodeBufferTest.java | 19 |
1 files changed, 19 insertions, 0 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 387978fe069..b56b0fde1ea 100644 --- a/sonar-channel/src/test/java/org/sonar/channel/CodeBufferTest.java +++ b/sonar-channel/src/test/java/org/sonar/channel/CodeBufferTest.java @@ -257,11 +257,29 @@ public class CodeBufferTest { assertThat(code.pop(), is( -1)); } + /** + * Backward compatibility with a COBOL plugin: filter returns 0 instead of -1, when end of the stream has been reached. + */ + @Test(timeout = 1000) + public void testWrongEndOfStreamFilter() { + CodeReaderConfiguration configuration = new CodeReaderConfiguration(); + configuration.setCodeReaderFilters(new WrongEndOfStreamFilter()); + new CodeBuffer("foo", configuration); + } + + class WrongEndOfStreamFilter extends CodeReaderFilter<Object> { + @Override + public int read(char[] filteredBuffer, int offset, int length) throws IOException { + return 0; + } + } + class ReplaceNumbersFilter extends CodeReaderFilter<Object> { private Pattern pattern = Pattern.compile("\\d"); private String REPLACEMENT = "-"; + @Override public int read(char[] cbuf, int off, int len) throws IOException { char[] tempBuffer = new char[cbuf.length]; int charCount = getReader().read(tempBuffer, off, len); @@ -278,6 +296,7 @@ public class CodeBufferTest { private Pattern pattern = Pattern.compile("[a-zA-Z]"); private String REPLACEMENT = "*"; + @Override public int read(char[] cbuf, int off, int len) throws IOException { char[] tempBuffer = new char[cbuf.length]; int charCount = getReader().read(tempBuffer, off, len); |