Adding antlr4 to pom, tests

This commit is contained in:
Fernando Cosso
2020-04-30 15:16:31 -04:00
parent 15da8cb16a
commit 3a3b0a0908
3 changed files with 49 additions and 0 deletions

View File

@ -18,6 +18,10 @@
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.antlr</groupId>
<artifactId>antlr4-maven-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
@ -30,6 +34,10 @@
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.antlr</groupId>
<artifactId>antlr4-runtime</artifactId>
</dependency>
<dependency>
<groupId>net.sourceforge.pmd</groupId>
<artifactId>pmd-core</artifactId>

View File

@ -0,0 +1,36 @@
/**
* BSD-style license; for more info see http://pmd.sourceforge.net/license.html
*/
package net.sourceforge.pmd.cpd;
import java.io.IOException;
import org.apache.commons.io.IOUtils;
import org.junit.Before;
import org.junit.Test;
import net.sourceforge.pmd.testframework.AbstractTokenizerTest;
public class XmlCPDTokenizerTest extends AbstractTokenizerTest {
private static final String FILENAME = "hello.xml";
@Before
@Override
public void buildTokenizer() throws IOException {
this.tokenizer = new XmlTokenizer();
this.sourceCode = new SourceCode(new SourceCode.StringCodeLoader(this.getSampleCode(), FILENAME));
}
@Override
public String getSampleCode() throws IOException {
return IOUtils.toString(XmlTokenizer.class.getResourceAsStream(FILENAME));
}
@Test
public void tokenizeTest() throws IOException {
this.expectedTokenCount = 37;
super.tokenizeTest();
}
}

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<someTag>
<someOtherTag>Somehow we would like to improve this xml so we are not repeating the same content in this file or other files</someOtherTag>
<someOtherTag>Somehow we would like to improve this xml so we are not repeating the same content in this file or other files</someOtherTag>
</someTag>