### Question:
PhantomServiceManager { public static IService getService(String category, String name) { synchronized (CATEGORY_SERVICES_MAP) { final HashMap<String, Object> services = CATEGORY_SERVICES_MAP.get(category); if (services == null) { return null; } return new ServiceModule(services.get(name)); } } private  PhantomServiceManager(); static synchronized void init(String hostPackage,
            String hostVersionName,
            int hostVersionCode,
            String phantomVersionName,
            int phantomVersionCode); static String getHostPackage(); static String getHostVersionName(); static int getHostVersionCode(); static String getPhantomVersionName(); static int getPhantomVersionCode(); static boolean registerService(String category, String name, Object service); static boolean registerService(String name, Object service); static boolean registerService(Object service); static void unregisterService(String category); static void unregisterAllService(); static List<IService> getServices(String category); static IService getService(String category, String name); static IService getService(String name); static T getService(String name, Class<T> type); static boolean hasService(String name); static T asInterface(IService service, Class<T> type); static boolean hasService(String category, String name);  }### Answer:
@Test public void getService_CanGetServiceInfo() throws Exception { final IService service1 = PhantomServiceManager.getService("remote_service_1"); Assert.assertEquals("remote_service_1", service1.getServiceName()); Assert.assertEquals(2, service1.getServiceVersion()); }
@Test public void callRemoteService_isCorrect() throws Exception { { final IService service1 = PhantomServiceManager.getService("remote_service_1"); Assert.assertEquals("remote_method_1", service1.call("remote_method_1")); String message1 = "hahaha"; Assert.assertEquals("remote_method_2 reply " + message1, service1.call("remote_method_2", message1)); } { final IService service2 = PhantomServiceManager.getService("remote_service_2"); Assert.assertEquals("remote_method_1", service2.call("remote_method_1")); String message2 = "hahaha"; Assert.assertEquals("remote_method_2 reply " + message2, service2.call("remote_method_2", message2)); } }
@Test public void callRemoteServiceAsInterface_isCorrect() throws Exception { { final RemoteServiceProxy service1 = PhantomServiceManager.getService( "remote_service_1", RemoteServiceProxy.class); Assert.assertEquals("remote_method_1", service1.remote_method_1()); String message1 = "hahaha"; Assert.assertEquals("remote_method_2 reply " + message1, service1.remote_method_2(message1)); } { final RemoteServiceProxy service2 = PhantomServiceManager.getService( "remote_service_2", RemoteServiceProxy.class); Assert.assertEquals("remote_method_1", service2.remote_method_1()); String message2 = "hahaha"; Assert.assertEquals("remote_method_2 reply " + message2, service2.remote_method_2(message2)); } }