* BAEL-1861 Replaced real tests with demo test "placeholders"

* BAEL-1861 Moved code from new module into existing ones

* BAEL-1861 Renamed main() classes to not violate PMD rules
This commit is contained in:
Predrag Maric 2018-08-07 18:50:33 +02:00 committed by GitHub
parent ddc106ccd9
commit e730b0d8f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 91 additions and 213 deletions

View File

@ -0,0 +1,24 @@
package com.baeldung.runfromjava;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
class FirstUnitTest {
@Test
void whenThis_thenThat() {
assertTrue(true);
}
@Test
void whenSomething_thenSomething() {
assertTrue(true);
}
@Test
void whenSomethingElse_thenSomethingElse() {
assertTrue(true);
}
}

View File

@ -1,4 +1,4 @@
package com.baeldung.junit5.runfromjava;
package com.baeldung.runfromjava;
import org.junit.platform.launcher.Launcher;
import org.junit.platform.launcher.LauncherDiscoveryRequest;
@ -14,7 +14,7 @@ import static org.junit.platform.engine.discovery.ClassNameFilter.includeClassNa
import static org.junit.platform.engine.discovery.DiscoverySelectors.selectClass;
import static org.junit.platform.engine.discovery.DiscoverySelectors.selectPackage;
public class RunJUnit5Tests {
public class RunJUnit5TestsFromJava {
SummaryGeneratingListener listener = new SummaryGeneratingListener();
public void runOne() {
@ -32,7 +32,7 @@ public class RunJUnit5Tests {
public void runAll() {
LauncherDiscoveryRequest request = LauncherDiscoveryRequestBuilder
.request()
.selectors(selectPackage("com.baeldung.junit5.runfromjava"))
.selectors(selectPackage("com.baeldung.runfromjava"))
.filters(includeClassNamePatterns(".*Test"))
.build();
Launcher launcher = LauncherFactory.create();
@ -45,7 +45,7 @@ public class RunJUnit5Tests {
}
public static void main(String[] args) {
RunJUnit5Tests runner = new RunJUnit5Tests();
RunJUnit5TestsFromJava runner = new RunJUnit5TestsFromJava();
runner.runAll();
TestExecutionSummary summary = runner.listener.getSummary();

View File

@ -0,0 +1,18 @@
package com.baeldung.runfromjava;
import org.junit.jupiter.api.RepeatedTest;
import static org.junit.jupiter.api.Assertions.assertTrue;
class SecondUnitTest {
@RepeatedTest(10)
void whenSomething_thenSomething() {
assertTrue(true);
}
@RepeatedTest(5)
void whenSomethingElse_thenSomethingElse() {
assertTrue(true);
}
}

View File

@ -1,54 +0,0 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.baeldung.junit</groupId>
<artifactId>applicationtesting</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>applicationtesting</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>
<junit-jupiter.version>5.2.0</junit-jupiter.version>
<junit-launcher.version>1.2.0</junit-launcher.version>
<junit4.version>4.12</junit4.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>${junit-jupiter.version}</version>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit-launcher.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit4.version}</version>
</dependency>
</dependencies>
</project>

View File

@ -1,41 +0,0 @@
package com.baeldung.junit.runfromjava.listnode;
public class ListNode {
private int value;
private ListNode next;
public ListNode(int v) {
value = v;
}
public ListNode(int v, ListNode next) {
value = v;
this.next = next;
}
public int getValue() {
return value;
}
public ListNode getNext() {
return next;
}
public void setNext(ListNode next) {
this.next = next;
}
public String toString() {
String result = "";
ListNode tmp = this;
while (tmp.next != null) {
result += tmp.value + "->";
tmp = tmp.next;
}
result += tmp.value;
return result.toString();
}
}

View File

@ -1,22 +0,0 @@
package com.baeldung.junit.runfromjava.listnode;
public class MergeLists {
public ListNode merge(ListNode list1, ListNode list2) {
if (list1 == null) {
return list2;
}
if (list2 == null) {
return list1;
}
if (list1.getValue() <= list2.getValue()) {
list1.setNext(merge(list1.getNext(), list2));
return list1;
} else {
list2.setNext(merge(list2.getNext(), list1));
return list2;
}
}
}

View File

@ -1,26 +0,0 @@
package com.baeldung.junit.runfromjava.listnode;
public class RemovedNthElement {
public ListNode removeNthFromEnd(ListNode head, int n) {
ListNode start = new ListNode(0);
start.setNext(head);
ListNode fast = start;
ListNode slow = start;
for (int i = 0; i < n + 1 && fast != null; i++) {
fast = fast.getNext();
}
while (fast != null) {
fast = fast.getNext();
slow = slow.getNext();
}
slow.setNext(slow.getNext()
.getNext());
return start.getNext();
}
}

View File

@ -1,30 +0,0 @@
package com.baeldung.junit.runfromjava.listnode;
public class RotateList {
public ListNode rotateRight(ListNode list, int n) {
if (list == null || list.getNext() == null) {
return list;
}
ListNode tmpList = new ListNode(0);
tmpList.setNext(list);
ListNode fast = tmpList;
ListNode slow = tmpList;
int listLength;
for (listLength = 0; fast.getNext() != null; listLength++) {
fast = fast.getNext();
}
for (int j = listLength - n % listLength; j > 0; j--) {
slow = slow.getNext();
}
fast.setNext(tmpList.getNext());
tmpList.setNext(slow.getNext());
slow.setNext(null);
return tmpList.getNext();
}
}

View File

@ -1,33 +0,0 @@
package com.baeldung.junit.runfromjava.listnode;
public class SwapNodes {
public ListNode swapPairs(ListNode listHead) {
ListNode result = new ListNode(0);
result.setNext(listHead);
ListNode current = result;
while (current.getNext() != null && current
.getNext()
.getNext() != null) {
ListNode first = current.getNext();
ListNode second = current
.getNext()
.getNext();
first.setNext(second.getNext());
current.setNext(second);
current
.getNext()
.setNext(first);
current = current
.getNext()
.getNext();
}
return result.getNext();
}
}

View File

@ -0,0 +1,24 @@
package com.baeldung.runfromjava;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class FirstUnitTest {
@Test
public void whenThis_thenThat() {
assertTrue(true);
}
@Test
public void whenSomething_thenSomething() {
assertTrue(true);
}
@Test
public void whenSomethingElse_thenSomethingElse() {
assertTrue(true);
}
}

View File

@ -1,4 +1,4 @@
package com.baeldung.junit4.runfromjava;
package com.baeldung.runfromjava;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;

View File

@ -1,4 +1,4 @@
package com.baeldung.junit4.runfromjava;
package com.baeldung.runfromjava;
import junit.extensions.ActiveTestSuite;
import junit.extensions.RepeatedTest;
@ -10,7 +10,7 @@ import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.notification.Failure;
public class RunJUnit4Tests {
public class RunJUnit4TestsFromJava {
public static void runOne() {
JUnitCore junit = new JUnitCore();

View File

@ -0,0 +1,18 @@
package com.baeldung.runfromjava;
import org.junit.Test;
import static org.junit.Assert.assertTrue;
public class SecondUnitTest {
@Test
public void whenSomething_thenSomething() {
assertTrue(true);
}
@Test
public void whensomethingElse_thenSomethingElse() {
assertTrue(true);
}
}