RCLJava { public static void rclJavaInit(final String... args) { synchronized (RCLJava.class) { if (!RCLJava.initialized) { if (args != null) { RCLJava.arguments = args; for (final String arg : RCLJava.arguments) { if (arg.contains("=")) { final String[] keyVal = arg.split("="); RCLJava.logger.debug("Args : " + keyVal[0] + "\t : " + keyVal[1]); } else { RCLJava.logger.debug("Args : " + arg); } } } if (RCLJava.rmwImplementation == null) { RCLJava.displayContext(); RCLJava.autoLoadRmw(); } if (RCLJava.rmwImplementation == null) { RCLJava.logger.error("No RMW implementation found..."); System.exit(1); } else { RCLJava.logger.debug("Initialize rclJava with " + RCLJava.rmwImplementation); RCLJava.nativeRCLJavaInit(RCLJava.arguments); RCLJava.initialized = true; } } else { final NotInitializedException ex = new NotInitializedException("Cannot intialized twice !"); logger.error(ex.getMessage()); throw ex; } } } 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 testInitShutdownSequence() { logger.debug(new Object(){}.getClass().getEnclosingMethod().getName()); boolean test = true; this.initRCLjava(); this.releaseRCLjava(); try { RCLJava.rclJavaInit(); this.releaseRCLjava(); } catch (Exception e) { test = false; } Assert.assertTrue("failed to initialize rclJava after shutdown", test); }