@Test public void getFeature() { Point requestPoint = Point.newBuilder().setLatitude(-1).setLongitude(-1).build(); Point responsePoint = Point.newBuilder().setLatitude(-123).setLongitude(-123).build(); final AtomicReference<Point> pointDelivered = new AtomicReference<Point>(); final Feature responseFeature = Feature.newBuilder().setName("dummyFeature").setLocation(responsePoint).build(); RouteGuideImplBase getFeatureImpl = new RouteGuideImplBase() { @Override public void getFeature(Point point, StreamObserver<Feature> responseObserver) { pointDelivered.set(point); responseObserver.onNext(responseFeature); responseObserver.onCompleted(); } }; serviceRegistry.addService(getFeatureImpl); client.getFeature(-1, -1); assertEquals(requestPoint, pointDelivered.get()); verify(testHelper).onMessage(responseFeature); verify(testHelper, never()).onRpcError(any(Throwable.class)); }
public void getFeature(int lat, int lon) { info("*** GetFeature: lat={0} lon={1}", lat, lon); Point request = Point.newBuilder().setLatitude(lat).setLongitude(lon).build(); Feature feature; try { feature = blockingStub.getFeature(request); if (testHelper != null) { testHelper.onMessage(feature); } } catch (StatusRuntimeException e) { warning("RPC failed: {0}", e.getStatus()); if (testHelper != null) { testHelper.onRpcError(e); } return; } if (RouteGuideUtil.exists(feature)) { info("Found feature called \"{0}\" at {1}, {2}", feature.getName(), RouteGuideUtil.getLatitude(feature.getLocation()), RouteGuideUtil.getLongitude(feature.getLocation())); } else { info("Found no feature at {0}, {1}", RouteGuideUtil.getLatitude(feature.getLocation()), RouteGuideUtil.getLongitude(feature.getLocation())); } }
RouteGuideClient { public void getFeature(int lat, int lon) { info("*** GetFeature: lat={0} lon={1}", lat, lon); Point request = Point.newBuilder().setLatitude(lat).setLongitude(lon).build(); Feature feature; try { feature = blockingStub.getFeature(request); if (testHelper != null) { testHelper.onMessage(feature); } } catch (StatusRuntimeException e) { warning("RPC failed: {0}", e.getStatus()); if (testHelper != null) { testHelper.onRpcError(e); } return; } if (RouteGuideUtil.exists(feature)) { info("Found feature called \"{0}\" at {1}, {2}", feature.getName(), RouteGuideUtil.getLatitude(feature.getLocation()), RouteGuideUtil.getLongitude(feature.getLocation())); } else { info("Found no feature at {0}, {1}", RouteGuideUtil.getLatitude(feature.getLocation()), RouteGuideUtil.getLongitude(feature.getLocation())); } } }
RouteGuideClient { public void getFeature(int lat, int lon) { info("*** GetFeature: lat={0} lon={1}", lat, lon); Point request = Point.newBuilder().setLatitude(lat).setLongitude(lon).build(); Feature feature; try { feature = blockingStub.getFeature(request); if (testHelper != null) { testHelper.onMessage(feature); } } catch (StatusRuntimeException e) { warning("RPC failed: {0}", e.getStatus()); if (testHelper != null) { testHelper.onRpcError(e); } return; } if (RouteGuideUtil.exists(feature)) { info("Found feature called \"{0}\" at {1}, {2}", feature.getName(), RouteGuideUtil.getLatitude(feature.getLocation()), RouteGuideUtil.getLongitude(feature.getLocation())); } else { info("Found no feature at {0}, {1}", RouteGuideUtil.getLatitude(feature.getLocation()), RouteGuideUtil.getLongitude(feature.getLocation())); } } RouteGuideClient(String host, int port);  RouteGuideClient(ManagedChannelBuilder<?> channelBuilder); }
RouteGuideClient { public void getFeature(int lat, int lon) { info("*** GetFeature: lat={0} lon={1}", lat, lon); Point request = Point.newBuilder().setLatitude(lat).setLongitude(lon).build(); Feature feature; try { feature = blockingStub.getFeature(request); if (testHelper != null) { testHelper.onMessage(feature); } } catch (StatusRuntimeException e) { warning("RPC failed: {0}", e.getStatus()); if (testHelper != null) { testHelper.onRpcError(e); } return; } if (RouteGuideUtil.exists(feature)) { info("Found feature called \"{0}\" at {1}, {2}", feature.getName(), RouteGuideUtil.getLatitude(feature.getLocation()), RouteGuideUtil.getLongitude(feature.getLocation())); } else { info("Found no feature at {0}, {1}", RouteGuideUtil.getLatitude(feature.getLocation()), RouteGuideUtil.getLongitude(feature.getLocation())); } } RouteGuideClient(String host, int port);  RouteGuideClient(ManagedChannelBuilder<?> channelBuilder); void shutdown(); void getFeature(int lat, int lon); void listFeatures(int lowLat, int lowLon, int hiLat, int hiLon); void recordRoute(List<Feature> features, int numPoints); CountDownLatch routeChat(); static void main(String[] args); }
RouteGuideClient { public void getFeature(int lat, int lon) { info("*** GetFeature: lat={0} lon={1}", lat, lon); Point request = Point.newBuilder().setLatitude(lat).setLongitude(lon).build(); Feature feature; try { feature = blockingStub.getFeature(request); if (testHelper != null) { testHelper.onMessage(feature); } } catch (StatusRuntimeException e) { warning("RPC failed: {0}", e.getStatus()); if (testHelper != null) { testHelper.onRpcError(e); } return; } if (RouteGuideUtil.exists(feature)) { info("Found feature called \"{0}\" at {1}, {2}", feature.getName(), RouteGuideUtil.getLatitude(feature.getLocation()), RouteGuideUtil.getLongitude(feature.getLocation())); } else { info("Found no feature at {0}, {1}", RouteGuideUtil.getLatitude(feature.getLocation()), RouteGuideUtil.getLongitude(feature.getLocation())); } } RouteGuideClient(String host, int port);  RouteGuideClient(ManagedChannelBuilder<?> channelBuilder); void shutdown(); void getFeature(int lat, int lon); void listFeatures(int lowLat, int lowLon, int hiLat, int hiLon); void recordRoute(List<Feature> features, int numPoints); CountDownLatch routeChat(); static void main(String[] args);  }