????????????????????????????????????main_process??????????????????mock??????????????????????????????????

????1?????????private????

????2????main_process??????????????setup????????????????и?????????????????map??????????????????????mock???????mock setup?????

????3????setup?????У???????HTable???????????????????zookeeper??hbase???????????????mock HTable??

????4????setup?????У?????????Configuration??????????mock??

????5????setup?????У????и?????Counter??????????new??????????????????protected??????????涼mock??????£????????mock Counter??

????6????main_process?????У??????????HTable????????????????????mock??HTable?????????????mock get????????????????ò??????

???????????????????????mock??Context?????????????????????????????Context?????????????????????????????????mock???????????????????????????????????????????????????

????????????????

??????????????????mock??????????

????1??Private???????????????????????????????public int mainProcess???????÷??????????main_process????????????????÷???????á????PowerMock?????mock??з?????????????????????????????????

????2???????powermock???????????????????


@RunWith(PowerMockRunner.class)
@PrepareForTest({ ShopScanMap.class })
public class TestMockito {
    @Test
    public void test01() throws Exception {…}


??????setup?????漰????????????????????????mock


Mapper.Context context = mock(Mapper.Context.class);
Counter counter = mock(Counter.class);
Configuration config = mock(Configuration.class);


????3????HTable????mock?????????shop_info??????????????????mock????thenReturn??????new????????mock???HTable????PowerMockito????????????????whenNew???????new???????withArguments????????????????thenReturn???????????????


HTable shop_info = PowerMockito.mock(HTable.class);
       PowerMockito.whenNew(HTable.class)
              .withArguments(config?? "sp_shopinfo".getBytes())
              .thenReturn(shop_info);


????4?????setup?????е?????getConfiguration?????????????????mock???????????????????????


when(context.getConfiguration()).thenReturn(config);


????5??????getConfiguration??????????????????????????????????????????????????????????????з????????????


when(context.getCounter("Statistics"?? "sp_bmw_shops")).thenReturn(counter);