This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void shouldIncrementLogCounter() | |
| { | |
| assertEquals(0, logger.getLogCount()); | |
| logger.log(LEVEL, MESSAGE); | |
| assertEquals(1, logger.getLogCount()); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| //This can be tested in the abstract class, | |
| //but the child classes will cover it. | |
| public void shouldFormatAndLog() | |
| { | |
| logger.log(LEVEL, MESSAGE); | |
| verify(logger).log(FORMATTED_LOG); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class TestStreamLogger | |
| { | |
| private static final String LOGGER_NAME = "logger_name"; | |
| private static final Level LEVEL = Level.INFO; | |
| private static final String MESSAGE = "message"; | |
| private StreamLogger logger; | |
| private OutputStream stream; | |
| @Before | |
| public void setup() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface StatefulProcessor | |
| { | |
| public void processRequest(HttpRequest request); | |
| public void processResponse(HttpResponse response); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void shouldReverse() | |
| { | |
| when(headers.get(TRANSFORM_HEADER)).thenReturn("REVERSE"); | |
| transformer.processRequest(request); | |
| transformer.processResponse(response); | |
| verify(response).setBody(new StringBuffer(BODY) | |
| .reverse().toString()); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface StatelessProcessor | |
| { | |
| public void processRequest(HttpRequest request, | |
| ProcessorContext context); | |
| public void processResponse(HttpResponse response, | |
| ProcessorContext context); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void shouldStoreReverseInContext() | |
| { | |
| when(headers.get(TRANSFORM_HEADER)).thenReturn("REVERSE"); | |
| transformer.processRequest(request, context); | |
| verify(context).setAttribute(TRANSFORM_HEADER, | |
| Transform.REVERSE); | |
| } | |
| @Test |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface Coder | |
| { | |
| public Code writeCodeFor(String[] requirements); | |
| } | |
| public class TestExpertCoder | |
| { | |
| private static final String[] REQUIREMENTS = {"simple requirement"}; | |
| private ExpertCoder coder; | |
| private RequirementsImporter requirementsImporter; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Employee { | |
| private String name; | |
| private int age; | |
| private int salary; | |
| private float targetBonus; | |
| public Employee() | |
| {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Employee { | |
| private final String name; | |
| private final int age; | |
| private final int salary; | |
| private final float targetBonus; | |
| public Employee(String name, int age, int salary, float targetBonus) { | |
| this.name = name; | |
| this.age = age; |