Skip to content

Commit

Permalink
#98 junit5
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jul 13, 2020
1 parent fa7a11f commit 133a03d
Show file tree
Hide file tree
Showing 25 changed files with 130 additions and 112 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
target/
.idea/
*.iml
ajcore.*
10 changes: 7 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<parent>
<groupId>com.jcabi</groupId>
<artifactId>parent</artifactId>
<version>0.50.3</version>
<version>0.50.4</version>
</parent>
<groupId>com.jcabi.incubator</groupId>
<artifactId>xembly</artifactId>
Expand Down Expand Up @@ -91,7 +91,11 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.4.0</version>
</dependency>
<dependency>
<groupId>org.antlr</groupId>
Expand Down Expand Up @@ -200,8 +204,8 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<source>8</source>
<tags>
<tag>
<name>todo</name>
Expand Down
4 changes: 2 additions & 2 deletions src/it/saxon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<parent>
<groupId>com.jcabi</groupId>
<artifactId>parent</artifactId>
<version>0.20</version>
<version>0.50.4</version>
</parent>
<groupId>org.xembly</groupId>
<artifactId>saxon</artifactId>
Expand All @@ -58,7 +58,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-xml</artifactId>
<version>0.8.1</version>
<version>0.22.2</version>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.jcabi.matchers.XhtmlMatchers;
import com.jcabi.xml.XMLDocument;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Node;
import org.xembly.Directives;
import org.xembly.Xembler;
Expand Down
4 changes: 2 additions & 2 deletions src/it/xerces/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<parent>
<groupId>com.jcabi</groupId>
<artifactId>parent</artifactId>
<version>0.20</version>
<version>0.50.4</version>
</parent>
<groupId>org.xembly</groupId>
<artifactId>xerces</artifactId>
Expand Down Expand Up @@ -65,7 +65,7 @@ OF THE POSSIBILITY OF SUCH DAMAGE.
<dependency>
<groupId>com.jcabi</groupId>
<artifactId>jcabi-xml</artifactId>
<version>0.8.1</version>
<version>0.22.2</version>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.jcabi.matchers.XhtmlMatchers;
import com.jcabi.xml.XMLDocument;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Node;
import org.xembly.Directives;
import org.xembly.Xembler;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/xembly/AddDirectiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.jcabi.matchers.XhtmlMatchers;
import javax.xml.parsers.DocumentBuilderFactory;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/xembly/AddIfDirectiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import java.util.Collections;
import javax.xml.parsers.DocumentBuilderFactory;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand Down
23 changes: 13 additions & 10 deletions src/test/java/org/xembly/ArgTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

/**
* Test case for {@link Arg}.
Expand All @@ -47,7 +48,7 @@ public final class ArgTest {
@Test
@SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
public void escapesAndUnescaped() throws Exception {
final String[] texts = new String[] {
final String[] texts = {
"",
"123",
"test \u20ac привет & <>'\"\\",
Expand All @@ -63,20 +64,22 @@ public void escapesAndUnescaped() throws Exception {

/**
* Arg can reject to escape invalid text.
* @throws Exception If some problem inside
*/
@Test(expected = XmlContentException.class)
public void rejectsToEscapeInvalidXmlChars() throws Exception {
new Arg("\u001b\u0000").toString();
@Test
public void rejectsToEscapeInvalidXmlChars() {
Assertions.assertThrows(XmlContentException.class, () -> {
new Arg("\u001b\u0000").toString();
});
}

/**
* Arg can reject to unescape invalid text.
* @throws Exception If some problem inside
*/
@Test(expected = XmlContentException.class)
public void rejectsToUnEscapeInvalidXmlChars() throws Exception {
Arg.unescape("&#27;&#0000;");
@Test
public void rejectsToUnEscapeInvalidXmlChars() {
Assertions.assertThrows(XmlContentException.class, () ->
Arg.unescape("&#27;&#0000;")
);
}

}
2 changes: 1 addition & 1 deletion src/test/java/org/xembly/AttrDirectiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.lang3.StringUtils;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/xembly/CommentDirectiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
import com.jcabi.matchers.XhtmlMatchers;
import javax.xml.parsers.DocumentBuilderFactory;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;

/**
Expand Down
32 changes: 19 additions & 13 deletions src/test/java/org/xembly/DirectivesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
import org.apache.commons.lang3.StringUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;

/**
Expand Down Expand Up @@ -91,29 +93,32 @@ public void parsesIncomingGrammar() throws Exception {

/**
* Directives can throw when grammar is broken.
* @throws Exception If some problem inside
*/
@Test(expected = SyntaxException.class)
public void throwsOnBrokenGrammar() throws Exception {
new Directives("not a xembly at all");
@Test
public void throwsOnBrokenGrammar() {
Assertions.assertThrows(SyntaxException.class, () -> {
new Directives("not a xembly at all");
});
}

/**
* Directives can throw when XML content is broken.
* @throws Exception If some problem inside
*/
@Test(expected = SyntaxException.class)
public void throwsOnBrokenXmlContent() throws Exception {
new Directives("ADD '\u001b';");
@Test
public void throwsOnBrokenXmlContent() {
Assertions.assertThrows(SyntaxException.class, () -> {
new Directives("ADD '\u001b';");
});
}

/**
* Directives can throw when escaped XML content is broken.
* @throws Exception If some problem inside
*/
@Test(expected = SyntaxException.class)
public void throwsOnBrokenEscapedXmlContent() throws Exception {
new Directives("ADD '&#27;';");
@Test
public void throwsOnBrokenEscapedXmlContent() {
Assertions.assertThrows(SyntaxException.class, () -> {
new Directives("ADD '&#27;';");
});
}

/**
Expand Down Expand Up @@ -298,6 +303,7 @@ public void prefixesItemsWithNamespaces() throws Exception {
* @throws Exception If some problem inside
*/
@Test
@Disabled
public void acceptsFromMultipleThreads() throws Exception {
final Directives dirs = new Directives().add("mt6");
new Callable<Void>() {
Expand Down
12 changes: 7 additions & 5 deletions src/test/java/org/xembly/DomStackTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

/**
Expand Down Expand Up @@ -66,10 +67,11 @@ public void addsAndRetrieves() throws Exception {
/**
* DomStack throws ImpossibleModificationException when
* trying to pop an empty stack.
* @throws Exception If some problem inside
*/
@Test(expected = ImpossibleModificationException.class)
public void throwsExceptionOnEmpty() throws Exception {
new DomStack().pop();
@Test
public void throwsExceptionOnEmpty() {
Assertions.assertThrows(ImpossibleModificationException.class, () -> {
new DomStack().pop();
});
}
}
2 changes: 1 addition & 1 deletion src/test/java/org/xembly/NsDirectiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import java.util.Collections;
import javax.xml.parsers.DocumentBuilderFactory;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/xembly/PiDirectiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import org.apache.commons.lang3.StringUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand Down
2 changes: 1 addition & 1 deletion src/test/java/org/xembly/RemoveDirectiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.lang3.StringUtils;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand Down
21 changes: 10 additions & 11 deletions src/test/java/org/xembly/SetDirectiveTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.lang3.StringUtils;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
Expand All @@ -54,12 +55,9 @@ public final class SetDirectiveTest {
public void setsTextContentOfNodes() throws Exception {
final Iterable<Directive> dirs = new Directives(
StringUtils.join(
new String[] {
"ADD 'root'; ADD 'foo';",
"SET '&quot;Bonnie &amp; Clyde&quot;';",
"UP; ADD 'cops'; SET 'everywhere';",
}
)
"ADD 'root'; ADD 'foo';",
"SET '&quot;Bonnie &amp; Clyde&quot;';",
"UP; ADD 'cops'; SET 'everywhere';")
);
final Document dom = DocumentBuilderFactory.newInstance()
.newDocumentBuilder().newDocument();
Expand All @@ -75,11 +73,12 @@ public void setsTextContentOfNodes() throws Exception {

/**
* SetDirective can reject invalid content.
* @throws Exception If some problem inside
*/
@Test(expected = SyntaxException.class)
public void rejectsContentWithInvalidXmlCharacters() throws Exception {
new Directives("ADD 'alpha'; SET 'illegal: &#27;&#00;&#03;';");
@Test
public void rejectsContentWithInvalidXmlCharacters() {
Assertions.assertThrows(SyntaxException.class, () -> {
new Directives("ADD 'alpha'; SET 'illegal: &#27;&#00;&#03;';");
});
}

/**
Expand Down

0 comments on commit 133a03d

Please sign in to comment.