### Question:
ServiceSubscriber extends ServiceBootstrap { public static ClusterHandler subscribeService(ReferenceConfig config) { initHttpServer(RpcRole.INVOKER); ClientConfig clientConfig = genClientConfig(config); InvokerRepository repository; if (isDirectConn(config)) { repository = new InvokerRepository(clientConfig, true); } else { repository = new InvokerRepository(clientConfig); doSubscribeService(config, repository); } ClusterHandler clusterHandler = getClusterHandler(config.getClusterPolicy(), repository); return clusterHandler; }  static ClusterHandler subscribeService(ReferenceConfig config); static void unsubscribeService(ReferenceConfig config);  }### Answer:
@Test public void testSubscribeService() { ReferenceConfig config = MockUtil.getReferenceConfig(); ClusterHandler clusterHandler = ServiceSubscriber.subscribeService(config); Assert.assertTrue(clusterHandler instanceof MockCluster.MockClusterHandler); Assert.assertNull(clusterHandler.getRepository().getRegistry()); config.setRegistry(null); clusterHandler = ServiceSubscriber.subscribeService(config); Assert.assertNull(clusterHandler.getRepository().getRegistry()); config.setDirectConnAddress("localhost:9001,localhost:9002"); clusterHandler = ServiceSubscriber.subscribeService(config); Assert.assertTrue(clusterHandler.getRepository().isDirectConn()); config.setClusterPolicy("error"); try { ServiceSubscriber.subscribeService(config); } catch (Exception e) { Assert.assertTrue(e instanceof RpcException); } }