List of usage examples for org.springframework.integration.mqtt.inbound MqttPahoMessageDrivenChannelAdapter stop
@Override
public final void stop()
From source file:org.springframework.integration.mqtt.MqttAdapterTests.java
@Test public void testStopActionDefault() throws Exception { final IMqttClient client = mock(IMqttClient.class); MqttPahoMessageDrivenChannelAdapter adapter = buildAdapter(client, null, null); adapter.start();/* w ww . j av a 2 s .com*/ adapter.stop(); verifyUnsubscribe(client); }
From source file:org.springframework.integration.mqtt.MqttAdapterTests.java
@Test public void testStopActionDefaultNotClean() throws Exception { final IMqttClient client = mock(IMqttClient.class); MqttPahoMessageDrivenChannelAdapter adapter = buildAdapter(client, false, null); adapter.start();/*from ww w . j a v a 2 s. c o m*/ adapter.stop(); verifyNotUnsubscribe(client); }
From source file:org.springframework.integration.mqtt.MqttAdapterTests.java
@Test public void testStopActionAlways() throws Exception { final IMqttClient client = mock(IMqttClient.class); MqttPahoMessageDrivenChannelAdapter adapter = buildAdapter(client, false, ConsumerStopAction.UNSUBSCRIBE_ALWAYS); adapter.start();//from w ww . java2 s. c o m adapter.stop(); verifyUnsubscribe(client); }
From source file:org.springframework.integration.mqtt.MqttAdapterTests.java
@Test public void testStopActionNever() throws Exception { final IMqttClient client = mock(IMqttClient.class); MqttPahoMessageDrivenChannelAdapter adapter = buildAdapter(client, null, ConsumerStopAction.UNSUBSCRIBE_NEVER); adapter.start();//from w w w. ja va 2s .c o m adapter.stop(); verifyNotUnsubscribe(client); }
From source file:org.springframework.integration.mqtt.MqttAdapterTests.java
@Test public void testReconnect() throws Exception { final IMqttClient client = mock(IMqttClient.class); MqttPahoMessageDrivenChannelAdapter adapter = buildAdapter(client, null, ConsumerStopAction.UNSUBSCRIBE_NEVER); adapter.setRecoveryInterval(10);//ww w . j a va 2 s.c o m Log logger = spy(TestUtils.getPropertyValue(adapter, "logger", Log.class)); new DirectFieldAccessor(adapter).setPropertyValue("logger", logger); given(logger.isDebugEnabled()).willReturn(true); final AtomicInteger attemptingReconnectCount = new AtomicInteger(); willAnswer(i -> { if (attemptingReconnectCount.getAndIncrement() == 0) { adapter.connectionLost(new RuntimeException("while schedule running")); } i.callRealMethod(); return null; }).given(logger).debug("Attempting reconnect"); ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler(); taskScheduler.initialize(); adapter.setTaskScheduler(taskScheduler); adapter.start(); adapter.connectionLost(new RuntimeException("initial")); Thread.sleep(1000); // the following assertion should be equalTo, but leq to protect against a slow CI server assertThat(attemptingReconnectCount.get(), lessThanOrEqualTo(2)); adapter.stop(); taskScheduler.destroy(); }