@Test public void shutdown() throws Exception { ZigBeeNetworkManager networkManager = Mockito.mock(ZigBeeNetworkManager.class); Mockito.when(networkManager.getNotificationService()).thenReturn(new NotificationService()); ZigBeeTransactionManager transactionManager = new ZigBeeTransactionManager(networkManager); ZigBeeTransactionMatcher responseMatcher = Mockito.mock(ZigBeeTransactionMatcher.class); ZigBeeNode node = Mockito.mock(ZigBeeNode.class); Mockito.when(node.getIeeeAddress()).thenReturn(new IeeeAddress("1111111111111111")); NodeDescriptor nodeDescriptor = Mockito.mock(NodeDescriptor.class); Set<MacCapabilitiesType> macCapabilities = new HashSet<>(); Mockito.when(nodeDescriptor.getMacCapabilities()).thenReturn(macCapabilities); Mockito.when(node.getNodeDescriptor()).thenReturn(nodeDescriptor); Mockito.when(networkManager.getNode(111)).thenReturn(node); ZigBeeCommand command = getCommand(111); Future<CommandResult> cmdResult = transactionManager.sendTransaction(command, responseMatcher); Mockito.verify(networkManager, Mockito.timeout(TIMEOUT).times(1)).sendCommand(command); assertNotNull(transactionManager.getQueue(new IeeeAddress("1111111111111111"))); transactionManager.shutdown(); await().atMost(TIMEOUT, TimeUnit.MILLISECONDS) .until(() -> assertNull(transactionManager.getQueue(new IeeeAddress("1111111111111111")))); System.out.println(cmdResult); assertTrue(cmdResult.isCancelled()); }
public void shutdown() { logger.debug("Transaction Manager: Shutdown"); isShutdown = true; executorService.shutdown(); networkManager.removeNetworkNodeListener(this); stopRequeueTimer(); broadcastQueue.shutdown(); multicastQueue.shutdown(); for (ZigBeeTransactionQueue queue : nodeQueue.values()) { queue.shutdown(); } nodeQueue.clear(); synchronized (outstandingTransactions) { for (final ZigBeeTransaction transaction : outstandingTransactions) { networkManager.getNotificationService().execute(new Runnable() { @Override public void run() { transaction.cancel(); } }); } } executorService.shutdownNow(); }
ZigBeeTransactionManager implements ZigBeeNetworkNodeListener { public void shutdown() { logger.debug("Transaction Manager: Shutdown"); isShutdown = true; executorService.shutdown(); networkManager.removeNetworkNodeListener(this); stopRequeueTimer(); broadcastQueue.shutdown(); multicastQueue.shutdown(); for (ZigBeeTransactionQueue queue : nodeQueue.values()) { queue.shutdown(); } nodeQueue.clear(); synchronized (outstandingTransactions) { for (final ZigBeeTransaction transaction : outstandingTransactions) { networkManager.getNotificationService().execute(new Runnable() { @Override public void run() { transaction.cancel(); } }); } } executorService.shutdownNow(); } }
ZigBeeTransactionManager implements ZigBeeNetworkNodeListener { public void shutdown() { logger.debug("Transaction Manager: Shutdown"); isShutdown = true; executorService.shutdown(); networkManager.removeNetworkNodeListener(this); stopRequeueTimer(); broadcastQueue.shutdown(); multicastQueue.shutdown(); for (ZigBeeTransactionQueue queue : nodeQueue.values()) { queue.shutdown(); } nodeQueue.clear(); synchronized (outstandingTransactions) { for (final ZigBeeTransaction transaction : outstandingTransactions) { networkManager.getNotificationService().execute(new Runnable() { @Override public void run() { transaction.cancel(); } }); } } executorService.shutdownNow(); } ZigBeeTransactionManager(ZigBeeNetworkManager manager); }
ZigBeeTransactionManager implements ZigBeeNetworkNodeListener { public void shutdown() { logger.debug("Transaction Manager: Shutdown"); isShutdown = true; executorService.shutdown(); networkManager.removeNetworkNodeListener(this); stopRequeueTimer(); broadcastQueue.shutdown(); multicastQueue.shutdown(); for (ZigBeeTransactionQueue queue : nodeQueue.values()) { queue.shutdown(); } nodeQueue.clear(); synchronized (outstandingTransactions) { for (final ZigBeeTransaction transaction : outstandingTransactions) { networkManager.getNotificationService().execute(new Runnable() { @Override public void run() { transaction.cancel(); } }); } } executorService.shutdownNow(); } ZigBeeTransactionManager(ZigBeeNetworkManager manager); void shutdown(); int getMaxOutstandingTransactions(); void setMaxOutstandingTransactions(int maxOutstandingTransactions); int getMaxSleepyTransactions(); void setMaxSleepyTransactions(int maxSleepyTransactions); void setDefaultProfile(ZigBeeTransactionProfile profile); ZigBeeTransactionProfile getDefaultProfile(); void setSleepyProfile(ZigBeeTransactionProfile profile); ZigBeeTransactionProfile getSleepyProfile(); void setMulticastProfile(ZigBeeTransactionProfile profile); ZigBeeTransactionProfile getMulticastProfile(); void setBroadcastProfile(ZigBeeTransactionProfile profile); ZigBeeTransactionProfile getBroadcastProfile(); void sendTransaction(ZigBeeCommand command); Future<CommandResult> sendTransaction(ZigBeeCommand command, ZigBeeTransactionMatcher responseMatcher); ZigBeeCommand receive(final ZigBeeCommand command); void receiveCommandState(int transactionId, ZigBeeTransportProgressState state); ZigBeeTransactionQueue getQueue(IeeeAddress address); void removeNode(IeeeAddress address); @Override void nodeAdded(ZigBeeNode node); @Override void nodeUpdated(ZigBeeNode node); @Override void nodeRemoved(ZigBeeNode node); }
ZigBeeTransactionManager implements ZigBeeNetworkNodeListener { public void shutdown() { logger.debug("Transaction Manager: Shutdown"); isShutdown = true; executorService.shutdown(); networkManager.removeNetworkNodeListener(this); stopRequeueTimer(); broadcastQueue.shutdown(); multicastQueue.shutdown(); for (ZigBeeTransactionQueue queue : nodeQueue.values()) { queue.shutdown(); } nodeQueue.clear(); synchronized (outstandingTransactions) { for (final ZigBeeTransaction transaction : outstandingTransactions) { networkManager.getNotificationService().execute(new Runnable() { @Override public void run() { transaction.cancel(); } }); } } executorService.shutdownNow(); } ZigBeeTransactionManager(ZigBeeNetworkManager manager); void shutdown(); int getMaxOutstandingTransactions(); void setMaxOutstandingTransactions(int maxOutstandingTransactions); int getMaxSleepyTransactions(); void setMaxSleepyTransactions(int maxSleepyTransactions); void setDefaultProfile(ZigBeeTransactionProfile profile); ZigBeeTransactionProfile getDefaultProfile(); void setSleepyProfile(ZigBeeTransactionProfile profile); ZigBeeTransactionProfile getSleepyProfile(); void setMulticastProfile(ZigBeeTransactionProfile profile); ZigBeeTransactionProfile getMulticastProfile(); void setBroadcastProfile(ZigBeeTransactionProfile profile); ZigBeeTransactionProfile getBroadcastProfile(); void sendTransaction(ZigBeeCommand command); Future<CommandResult> sendTransaction(ZigBeeCommand command, ZigBeeTransactionMatcher responseMatcher); ZigBeeCommand receive(final ZigBeeCommand command); void receiveCommandState(int transactionId, ZigBeeTransportProgressState state); ZigBeeTransactionQueue getQueue(IeeeAddress address); void removeNode(IeeeAddress address); @Override void nodeAdded(ZigBeeNode node); @Override void nodeUpdated(ZigBeeNode node); @Override void nodeRemoved(ZigBeeNode node);  }