From bebe7c159f00e6d5a83bb786824d5f32e4de9270 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Sat, 24 Feb 2018 16:54:28 +0300 Subject: spring boot wip --- .../src/test/java/com/juick/xmpp/XMPPTests.java | 28 +++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'juick-xmpp-wip/src/test/java') diff --git a/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java b/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java index 1193f3a2..2cad5fb4 100644 --- a/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java +++ b/juick-xmpp-wip/src/test/java/com/juick/xmpp/XMPPTests.java @@ -21,8 +21,6 @@ import com.gargoylesoftware.htmlunit.WebClient; import com.juick.components.XMPPRouter; import com.juick.components.configuration.BotAppConfiguration; import com.juick.configuration.MockDataConfiguration; -import com.juick.server.XMPPConnection; -import com.juick.server.configuration.ApiAppConfiguration; import com.juick.service.MessengerService; import com.juick.service.PrivacyQueriesService; import com.juick.service.ShowQueriesService; @@ -60,7 +58,7 @@ import static org.hamcrest.Matchers.equalTo; public class XMPPTests { @Configuration @Import(value = { - BotAppConfiguration.class, ApiAppConfiguration.class, MockDataConfiguration.class + BotAppConfiguration.class, MockDataConfiguration.class }) static class Config { @Bean @@ -91,11 +89,9 @@ public class XMPPTests { @Inject XMPPRouter router; @Inject - XMPPConnection component; - @Inject ExecutorService service; @Test - public void routerHandshake() throws XmppException, InterruptedException { + public void routerHandshake() throws InterruptedException { XmppSessionConfiguration configuration = XmppSessionConfiguration.builder() .extensions(Extension.of(com.juick.Message.class)) .debugger(LogbackDebugger.class) @@ -108,23 +104,33 @@ public class XMPPTests { lock.countDown(); } }); + ExternalComponent routerClient2 = ExternalComponent.create("bot.localhost", + "secret", configuration, "localhost", 5347); + CountDownLatch lock2 = new CountDownLatch(1); + routerClient2.addConnectionListener(connectionEvent -> { + if (connectionEvent.equals(ConnectionEvent.Type.RECONNECTION_SUCCEEDED)) { + lock2.countDown(); + } + }); service.submit(() -> { try { Thread.sleep(3000); routerClient.connect(); + routerClient2.connect(); } catch (XmppException | InterruptedException e) { e.printStackTrace(); } lock.countDown(); + lock2.countDown(); }); lock.await(); - CountDownLatch lock2 = new CountDownLatch(2); - component.sendStanza(new Message(Jid.of("yoyo@test.localhost"), Message.Type.CHAT, "test" )); - component.sendStanza(new Message(Jid.of("yoyo@test.localhost"), Message.Type.CHAT, "test" )); + CountDownLatch lock3 = new CountDownLatch(2); + routerClient2.sendMessage(new Message(Jid.of("yoyo@test.localhost"), Message.Type.CHAT, "test" )); + routerClient2.sendMessage(new Message(Jid.of("yoyo@test.localhost"), Message.Type.CHAT, "test" )); routerClient.addInboundMessageListener(messageEvent -> { assertThat(messageEvent.getMessage().getBody(), equalTo("test")); - lock2.countDown(); + lock3.countDown(); }); - lock2.await(); + lock3.await(); } } -- cgit v1.2.3