BAEL-8219 Fix tests for core-java, maven and core-java-io projects

-Test fixes
This commit is contained in:
Dhawal Kapil
2018-08-15 14:14:50 +05:30
parent fdf5871cd5
commit 1212404897
8 changed files with 158 additions and 143 deletions

View File

@@ -25,11 +25,7 @@ public class Exceptions {
}
public List<Player> loadAllPlayers(String playersFile) throws IOException{
try {
throw new IOException();
} catch(IOException ex) {
throw new IllegalStateException();
}
throw new IOException();
}
public int getPlayerScoreThrows(String playerFile) throws FileNotFoundException {
@@ -163,14 +159,8 @@ public class Exceptions {
}
}
public void throwAsGotoAntiPattern() {
try {
// bunch of code
throw new MyException();
// second bunch of code
} catch ( MyException e ) {
// third bunch of code
}
public void throwAsGotoAntiPattern() throws MyException {
throw new MyException();
}
public int getPlayerScoreSwallowingExceptionAntiPattern(String playerFile) {

View File

@@ -16,8 +16,11 @@ import org.slf4j.LoggerFactory;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.util.List;
/**
* Created by madhumita.g on 01-08-2018.
*/
@@ -66,20 +69,18 @@ public class AnimalUnitTest {
int testValue = 3;
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.getFormattedMessage(),
is("generic animal noise countdown 3\n"
+ "generic animal noise countdown 2\n"
+ "generic animal noise countdown 1\n"));
testValue-=1;
is("generic animal noise countdown "+testValue));
testValue--;
}
}