BAEL-8219 Fix tests for core-java, maven and core-java-io projects
-Test fixes
This commit is contained in:
parent
7c94023486
commit
3b64d8ef4e
|
@ -18,7 +18,7 @@ public class FilenameFilterManualTest {
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setupClass() {
|
public static void setupClass() {
|
||||||
directory = new File(FilenameFilterManualTest.class.getClassLoader()
|
directory = new File(FilenameFilterManualTest.class.getClassLoader()
|
||||||
.getResource("testFolder")
|
.getResource("fileNameFilterManualTestFolder")
|
||||||
.getFile());
|
.getFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,7 @@ public class Exceptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Player> loadAllPlayers(String playersFile) throws IOException{
|
public List<Player> loadAllPlayers(String playersFile) throws IOException{
|
||||||
try {
|
throw new IOException();
|
||||||
throw new IOException();
|
|
||||||
} catch(IOException ex) {
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayerScoreThrows(String playerFile) throws FileNotFoundException {
|
public int getPlayerScoreThrows(String playerFile) throws FileNotFoundException {
|
||||||
|
@ -163,14 +159,8 @@ public class Exceptions {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void throwAsGotoAntiPattern() {
|
public void throwAsGotoAntiPattern() throws MyException {
|
||||||
try {
|
throw new MyException();
|
||||||
// bunch of code
|
|
||||||
throw new MyException();
|
|
||||||
// second bunch of code
|
|
||||||
} catch ( MyException e ) {
|
|
||||||
// third bunch of code
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPlayerScoreSwallowingExceptionAntiPattern(String playerFile) {
|
public int getPlayerScoreSwallowingExceptionAntiPattern(String playerFile) {
|
||||||
|
|
|
@ -16,8 +16,11 @@ import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import static org.hamcrest.CoreMatchers.is;
|
import static org.hamcrest.CoreMatchers.is;
|
||||||
import static org.junit.Assert.assertThat;
|
import static org.junit.Assert.assertThat;
|
||||||
|
import static org.mockito.Mockito.times;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by madhumita.g on 01-08-2018.
|
* Created by madhumita.g on 01-08-2018.
|
||||||
*/
|
*/
|
||||||
|
@ -66,20 +69,18 @@ public class AnimalUnitTest {
|
||||||
int testValue = 3;
|
int testValue = 3;
|
||||||
animal.makeNoise(testValue);
|
animal.makeNoise(testValue);
|
||||||
|
|
||||||
verify(mockAppender).doAppend(captorLoggingEvent.capture());
|
verify(mockAppender,times(3)).doAppend(captorLoggingEvent.capture());
|
||||||
|
|
||||||
final LoggingEvent loggingEvent = captorLoggingEvent.getValue();
|
final List<LoggingEvent> loggingEvents = captorLoggingEvent.getAllValues();
|
||||||
|
|
||||||
while (testValue != 0) {
|
for(LoggingEvent loggingEvent : loggingEvents)
|
||||||
|
{
|
||||||
assertThat(loggingEvent.getLevel(), is(Level.INFO));
|
assertThat(loggingEvent.getLevel(), is(Level.INFO));
|
||||||
|
|
||||||
assertThat(loggingEvent.getFormattedMessage(),
|
assertThat(loggingEvent.getFormattedMessage(),
|
||||||
is("generic animal noise countdown 3\n"
|
is("generic animal noise countdown "+testValue));
|
||||||
+ "generic animal noise countdown 2\n"
|
|
||||||
+ "generic animal noise countdown 1\n"));
|
|
||||||
|
|
||||||
testValue-=1;
|
|
||||||
|
|
||||||
|
testValue--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
266
maven/pom.xml
266
maven/pom.xml
|
@ -1,127 +1,151 @@
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<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">
|
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>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>maven</artifactId>
|
<artifactId>maven</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<artifactId>parent-modules</artifactId>
|
<artifactId>parent-modules</artifactId>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<version>1.0.0-SNAPSHOT</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-resources-plugin</artifactId>
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
<version>${maven.resources.version}</version>
|
<version>${maven.resources.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<outputDirectory>output-resources</outputDirectory>
|
<outputDirectory>output-resources</outputDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
<resource>
|
<resource>
|
||||||
<directory>input-resources</directory>
|
<directory>input-resources</directory>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>*.png</exclude>
|
<exclude>*.png</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>${java.version}</source>
|
<source>${java.version}</source>
|
||||||
<target>${java.version}</target>
|
<target>${java.version}</target>
|
||||||
<compilerArgs>
|
<compilerArgs>
|
||||||
<arg>-Xlint:unchecked</arg>
|
<arg>-Xlint:unchecked</arg>
|
||||||
</compilerArgs>
|
</compilerArgs>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
<version>${maven-surefire-plugin.version}</version>
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<excludes>
|
<excludes>
|
||||||
<exclude>DataTest.java</exclude>
|
<exclude>DataTest.java</exclude>
|
||||||
</excludes>
|
</excludes>
|
||||||
<includes>
|
<includes>
|
||||||
<include>TestFail.java</include>
|
<include>TestFail.java</include>
|
||||||
<include>DataCheck.java</include>
|
<include>DataCheck.java</include>
|
||||||
</includes>
|
</includes>
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
<testFailureIgnore>true</testFailureIgnore>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-failsafe-plugin</artifactId>
|
<artifactId>maven-failsafe-plugin</artifactId>
|
||||||
<version>${maven.failsafe.version}</version>
|
<version>${maven.failsafe.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>integration-test</goal>
|
<goal>integration-test</goal>
|
||||||
<goal>verify</goal>
|
<goal>verify</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<!-- configuration similar to surefire -->
|
<!-- configuration similar to surefire -->
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-verifier-plugin</artifactId>
|
<artifactId>maven-verifier-plugin</artifactId>
|
||||||
<version>${maven.verifier.version}</version>
|
<version>${maven.verifier.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<verificationFile>input-resources/verifications.xml</verificationFile>
|
<verificationFile>input-resources/verifications.xml</verificationFile>
|
||||||
</configuration>
|
</configuration>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>verify</goal>
|
<goal>verify</goal>
|
||||||
</goals>
|
</goals>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-clean-plugin</artifactId>
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
<version>${maven.clean.version}</version>
|
<version>${maven.clean.version}</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<filesets>
|
<filesets>
|
||||||
<fileset>
|
<fileset>
|
||||||
<directory>output-resources</directory>
|
<directory>output-resources</directory>
|
||||||
</fileset>
|
</fileset>
|
||||||
</filesets>
|
</filesets>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>build-helper-maven-plugin</artifactId>
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
<version>${maven.build.helper.version}</version>
|
<version>${maven.build.helper.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>generate-sources</phase>
|
<phase>generate-sources</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>add-source</goal>
|
<goal>add-source</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<sources>
|
<sources>
|
||||||
<source>src/main/another-src</source>
|
<source>src/main/another-src</source>
|
||||||
</sources>
|
</sources>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<profiles>
|
||||||
<maven.resources.version>3.0.2</maven.resources.version>
|
<profile>
|
||||||
<maven.failsafe.version>2.21.0</maven.failsafe.version>
|
<id>default</id>
|
||||||
<maven.verifier.version>1.1</maven.verifier.version>
|
<build>
|
||||||
<maven.clean.version>3.0.0</maven.clean.version>
|
<plugins>
|
||||||
<maven.build.helper.version>3.0.0</maven.build.helper.version>
|
<plugin>
|
||||||
<resources.name>Baeldung</resources.name>
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
</properties>
|
<version>${maven-surefire-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<excludes>
|
||||||
|
<exclude>DataTest.java</exclude>
|
||||||
|
</excludes>
|
||||||
|
<includes>
|
||||||
|
<include>TestFail.java</include>
|
||||||
|
<include>DataCheck.java</include>
|
||||||
|
</includes>
|
||||||
|
<testFailureIgnore>true</testFailureIgnore>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
</profiles>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<maven.resources.version>3.0.2</maven.resources.version>
|
||||||
|
<maven.failsafe.version>2.21.0</maven.failsafe.version>
|
||||||
|
<maven.verifier.version>1.1</maven.verifier.version>
|
||||||
|
<maven.clean.version>3.0.0</maven.clean.version>
|
||||||
|
<maven.build.helper.version>3.0.0</maven.build.helper.version>
|
||||||
|
<resources.name>Baeldung</resources.name>
|
||||||
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
Loading…
Reference in New Issue