Search in sources :

Example 1 with ZooKeeperGetter

use of com.qlangtech.tis.manage.spring.ZooKeeperGetter in project tis by qlangtech.

the class TestIncrTagHeatBeatMonitor method testBuild.

// public void test(){
// System.out.println(  String.format("hell%d",1) );
// }
public void testBuild() throws Exception {
    String resName = "collection_TopicTags_status_%d.json";
    AtomicInteger resFetchCount = new AtomicInteger();
    HttpUtils.mockConnMaker = new HttpUtils.DefaultMockConnectionMaker() {

        @Override
        protected MockHttpURLConnection createConnection(URL url, List<ConfigFileContext.Header> heads, ConfigFileContext.HTTPMethod method, byte[] content, HttpUtils.IClasspathRes cpRes) {
            String res = String.format(resName, resFetchCount.incrementAndGet());
            try {
                return new MockHttpURLConnection(TestIncrTagHeatBeatMonitor.class.getResourceAsStream(res));
            } catch (Throwable e) {
                throw new RuntimeException(res, e);
            }
        }
    };
    HttpUtils.addMockApply(0, "incr-control", StringUtils.EMPTY, TestIncrTagHeatBeatMonitor.class);
    ZooKeeperGetter zookeeper = EasyMock.createMock("zooKeeperGetter", ZooKeeperGetter.class);
    // EasyMock.createMock("coordinator", ITISCoordinator.class);
    ITISCoordinator coordinator = MockZKUtils.createZkMock();
    int times = 5;
    // TestCollectionAction.createAssembleLogCollectPathMock(coordinator,times);
    // final String childNodeName = "000001";
    // EasyMock.expect(coordinator.getChildren("/tis/incr-transfer-group/incr-state-collect", null, true))
    // .andReturn(Collections.singletonList(childNodeName)).times(times);
    // EasyMock.expect(coordinator.getData("/tis/incr-transfer-group/incr-state-collect/" + childNodeName, null, new Stat(), true))
    // .andReturn("127.0.0.1".getBytes(TisUTF8.get())).times(times);
    EasyMock.expect(zookeeper.getInstance()).andReturn(coordinator).times(times);
    // 增量节点处理
    final Map<String, TopicTagStatus> /* tag */
    transferTagStatus = new HashMap<>();
    final Map<String, TopicTagStatus> /* tag */
    binlogTopicTagStatus = new HashMap<>();
    Collection<TopicTagIncrStatus.FocusTags> focusTags = Lists.newArrayList();
    // String topic, Collection<String> tags
    ArrayList<String> tags = Lists.newArrayList(tag_servicebillinfo, tag_talpayinfo, "orderdetail", "specialfee", "ent_expense", "payinfo", "order_bill", "instancedetail", "ent_expense_order");
    focusTags.add(new TopicTagIncrStatus.FocusTags("test-topic", tags));
    TopicTagIncrStatus topicTagIncrStatus = new TopicTagIncrStatus(focusTags);
    MockWebSocketMessagePush wsMessagePush = new MockWebSocketMessagePush();
    MockMQConsumerStatus mqConsumerStatus = new MockMQConsumerStatus();
    // IncrTagHeatBeatMonitor incrTagHeatBeatMonitor = new IncrTagHeatBeatMonitor(
    // this.collectionName, wsMessagePush, transferTagStatus, binlogTopicTagStatus, topicTagIncrStatus, mqConsumerStatus, zookeeper);
    EasyMock.replay(zookeeper, coordinator);
    // incrTagHeatBeatMonitor.build();
    assertEquals(6, wsMessagePush.count);
    EasyMock.verify(zookeeper, coordinator);
}
Also used : URL(java.net.URL) ConfigFileContext(com.qlangtech.tis.manage.common.ConfigFileContext) ITISCoordinator(com.qlangtech.tis.cloud.ITISCoordinator) ZooKeeperGetter(com.qlangtech.tis.manage.spring.ZooKeeperGetter) HttpUtils(com.qlangtech.tis.manage.common.HttpUtils) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) MockHttpURLConnection(com.qlangtech.tis.manage.common.MockHttpURLConnection)

Aggregations

ITISCoordinator (com.qlangtech.tis.cloud.ITISCoordinator)1 ConfigFileContext (com.qlangtech.tis.manage.common.ConfigFileContext)1 HttpUtils (com.qlangtech.tis.manage.common.HttpUtils)1 MockHttpURLConnection (com.qlangtech.tis.manage.common.MockHttpURLConnection)1 ZooKeeperGetter (com.qlangtech.tis.manage.spring.ZooKeeperGetter)1 URL (java.net.URL)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1