RCLJava { public static void spin(final Node node) { RCLJava.lockAndCheckInitialized(); DefaultThreadedExecutor.getInstance().spinNodeSome(node); } private  RCLJava(); static void rclJavaInit(final String... args); static boolean isInitialized(); static Node createNode(final String defaultName); static Node createNode(final String namespace, final String defaultName); static void spinOnce(final Node node); static void spin(final Node node); static boolean ok(); static void shutdown(); static String getRMWIdentifier(); static String getTypesupportIdentifier(); @SuppressWarnings("PMD.AvoidUsingNativeCode") static void setRMWImplementation(final String rmwImplementation); @SuppressWarnings("PMD.AvoidUsingNativeCode") static void loadLibrary(final String name); static long convertQoSProfileToHandle(final QoSProfile qosProfile); static void disposeQoSProfile(final long qosProfileHandle);  }
@Test public final void testSpin() { logger.debug(new Object(){}.getClass().getEnclosingMethod().getName()); boolean test = true; try { this.initRCLjava(); final Node node = RCLJava.createNode("_" + RCLJavaTest.class.getSimpleName()); final Publisher<Bool> publisher = node.createPublisher(Bool.class, RCLJavaTest.TEST_TOPIC); final Bool msg = new Bool(); msg.setData(true); final RCLFuture<Bool> future = new RCLFuture<Bool>(new WeakReference<Node>(node)); final Subscription<Bool> subscription = node.createSubscription( Bool.class, RCLJavaTest.TEST_TOPIC, new TestConsumer<Bool>(future)); final Thread thread = new Thread(new Runnable() { @Override public void run() { RCLJava.spin(node); } }); thread.start(); while (RCLJava.ok() && !future.isDone()) { publisher.publish(msg); } final Bool value = future.get(); Assert.assertNotNull(value); publisher.dispose(); subscription.dispose(); DefaultThreadedExecutor.getInstance().removeNode(node); node.dispose(); this.releaseRCLjava(); } catch (Exception e) { test = false; } Assert.assertTrue(ERROR_RUNTIME, test); }