+ private static final Logger logger = LoggerFactory.getLogger(Util.class);
+
+
+ public static boolean isSubset(NetconfClient netconfClient, Set<String> expectedCaps) {
+ return isSubset(netconfClient.getCapabilities(), expectedCaps);
+
+ }
+
+ private static boolean isSubset(Set<String> currentCapabilities, Set<String> expectedCaps) {
+ for (String exCap : expectedCaps) {
+ if (currentCapabilities.contains(exCap) == false)
+ return false;
+ }
+ return true;
+ }
+
+
+ // TODO: check if closing in correct order
+ public static void closeClientAndDispatcher(NetconfClient client) {
+ NetconfClientDispatcher dispatcher = client.getNetconfClientDispatcher();
+ Exception fromClient = null;
+ try {
+ client.close();
+ } catch (Exception e) {
+ fromClient = e;
+ } finally {
+ try {
+ dispatcher.close();
+ } catch (Exception e) {
+ if (fromClient != null) {
+ e.addSuppressed(fromClient);
+ }
+ throw new RuntimeException("Error closing temporary client ", e);
+ }
+ }
+ }