Merge pull request #4971 from dkapil/task/BAEL-8219
BAEL-8219 Fix tests for core-java, maven and core-java-io projects
This commit is contained in:
commit
7866e3e5e6
|
@ -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 {
|
|
||||||
// bunch of code
|
|
||||||
throw new MyException();
|
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--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -115,6 +115,30 @@
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<profile>
|
||||||
|
<id>default</id>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<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>
|
<properties>
|
||||||
<maven.resources.version>3.0.2</maven.resources.version>
|
<maven.resources.version>3.0.2</maven.resources.version>
|
||||||
<maven.failsafe.version>2.21.0</maven.failsafe.version>
|
<maven.failsafe.version>2.21.0</maven.failsafe.version>
|
||||||
|
|
Loading…
Reference in New Issue