From 890f37d9681ea7ef7e88391464c65b774df8a7e5 Mon Sep 17 00:00:00 2001 From: snoop Date: Fri, 13 Oct 2017 18:04:22 +0900 Subject: [PATCH] added test discovery --- .../discovery/service/DiscoveryService.java | 22 +++++++++++++++++++ .../service/NoAuthProbeServiceTest.java | 17 ++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/src/main/java/com/loafle/overflow/module/discovery/service/DiscoveryService.java b/src/main/java/com/loafle/overflow/module/discovery/service/DiscoveryService.java index cebcbe1..99576ef 100644 --- a/src/main/java/com/loafle/overflow/module/discovery/service/DiscoveryService.java +++ b/src/main/java/com/loafle/overflow/module/discovery/service/DiscoveryService.java @@ -2,6 +2,7 @@ package com.loafle.overflow.module.discovery.service; import com.loafle.overflow.commons.service.MessagePublisher; import com.loafle.overflow.module.discovery.model.DiscoveryStartInfo; +import com.loafle.overflow.module.domain.model.Domain; import org.codehaus.jackson.map.ObjectMapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -27,4 +28,25 @@ public class DiscoveryService { System.out.println(json); // this.messagePublisher.publishToProbe("/auth", noAuthProbe.getTempProbeKey(), "NoAuthProbeService.acceptNoAuthProbe", probe.getProbeKey()); } + + public boolean testDiscovery(int types, String obj) { + + Domain domain = new Domain(); + domain.setId(1); + + switch (types) { + case 1 : + messagePublisher.publishToDomain("/web", domain, "DiscoveryService.discoveryIngHost", obj); + break; + case 2 : + messagePublisher.publishToDomain("/web", domain, "DiscoveryService.discoveryIngPort", obj); + break; + case 3 : + messagePublisher.publishToDomain("/web", domain, "DiscoveryService.discoveryIngService", obj); + break; + } + + + return true; + } } diff --git a/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java b/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java index 534ea31..e9c80a8 100644 --- a/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java +++ b/src/test/java/com/loafle/overflow/module/noauthprobe/service/NoAuthProbeServiceTest.java @@ -1,5 +1,6 @@ package com.loafle.overflow.module.noauthprobe.service; +import com.loafle.overflow.commons.service.MessagePublisher; import com.loafle.overflow.module.domain.model.Domain; import com.loafle.overflow.module.meta.model.MetaNoAuthProbeStatus; import com.loafle.overflow.module.noauthprobe.model.NoAuthProbe; @@ -26,6 +27,9 @@ public class NoAuthProbeServiceTest { @Autowired private NoAuthProbeService noAuthProbeService; + @Autowired + private MessagePublisher messagePublisher; + @Ignore @Test public void regist() throws Exception { @@ -139,4 +143,17 @@ public class NoAuthProbeServiceTest { } + @Test + public void sendWeb() { + + Domain domain = new Domain(); + domain.setId(1); + + List probes = this.noAuthProbeService.readAllByDomain(domain); + + messagePublisher.publishToDomain("/web", domain, "NoAuthProbeService.regist", probes); + + } + + } \ No newline at end of file