aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-duplications/src/test/java/org/sonar/duplications/token/TokenChunkerTest.java
blob: d9a421ac4d0c69f292cd6e1bc8e8a8447133afa8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * 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.duplications.token;

import org.junit.Test;

public class TokenChunkerTest {

  /**
   * In fact this test does not guarantee that we will be able to consume even more great comments,
   * because {@link org.sonar.channel.CodeBuffer} does not expand dynamically - see issue SONAR-2632.
   * But at least guarantees that we able to consume source files from JDK 1.6,
   * because buffer capacity has been increased in comparison with default value,
   * which is {@link org.sonar.channel.CodeReaderConfiguration#DEFAULT_BUFFER_CAPACITY}.
   */
  @Test(timeout = 5000)
  public void shouldConsumeBigComments() {
    int capacity = 80000;
    StringBuilder sb = new StringBuilder(capacity);
    sb.append("/");
    for (int i = 3; i < capacity; i++) {
      sb.append('*');
    }
    sb.append("/");
    TokenChunker chunker = TokenChunker.builder().token("/.*/", "LITERAL").build();
    chunker.chunk(sb.toString());
  }

}