Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @RunWith(MockitoJUnitRunner.class)
- public class WordCountMapperTest {
- @Mock
- private Mapper.Context mockContext; // declare your mocks
- org.apache.hadoop.examples.WordCount.TokenizerMapper mapper;
- @Before
- public void setUp() throws Exception {
- /*
- * mock and define your components here
- */
- mapper = new WordCount.TokenizerMapper();
- doNothing().when(mockContext.getCounter(TaskCounter.MAP_OUTPUT_RECORDS)).increment(anyLong());
- }
- @Test
- public void testMap() throws IOException, InterruptedException {
- /*
- * whatever you want to test you can write here in the verify statement
- */
- String line1 = "key_value";
- mapper.map(null, new Text(line1), mockContext);
- verify(mockContext.getCounter(TaskCounter.MAP_OUTPUT_RECORDS), times(1)).increment(1);
- }
- }
Add Comment
Please, Sign In to add comment