-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose ServiceRegistry, LoadBalancer- and RewriteMap-configuration fo…
…r info
- Loading branch information
1 parent
969d951
commit e7f8e21
Showing
5 changed files
with
106 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
...pache-bridge-it/src/test/java/eu/europa/ec/cc/zkapachebridge/rest/InfoControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package eu.europa.ec.cc.zkapachebridge.rest; | ||
|
||
import eu.europa.ec.cc.zkapachebridge.ZkApacheBridgeApplication; | ||
import eu.europa.ec.cc.zkapachebridge.test.CommonTestConfig; | ||
import org.hamcrest.core.StringContains; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
import org.springframework.boot.test.web.client.TestRestTemplate; | ||
import org.springframework.boot.web.server.LocalServerPort; | ||
import org.springframework.test.context.TestPropertySource; | ||
import org.springframework.test.context.junit4.SpringRunner; | ||
|
||
import java.util.Map; | ||
|
||
import static org.junit.Assert.assertThat; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
@SpringBootTest( | ||
classes = {CommonTestConfig.class, ZkApacheBridgeApplication.class}, | ||
webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) | ||
@RunWith(SpringRunner.class) | ||
@TestPropertySource(locations = "classpath:/application-test.properties") | ||
public class InfoControllerTest { | ||
|
||
|
||
@LocalServerPort | ||
int port; | ||
|
||
@Autowired | ||
TestRestTemplate restTemplate; | ||
|
||
@Test | ||
public void getServiceInformation() { | ||
assertTrue( | ||
"service info didn't return zk-apache-bridge itself as endpoint", | ||
this.restTemplate.getForObject("/api/info", Map.class).containsKey("zk-apache-bridge")); | ||
} | ||
|
||
@Test | ||
public void getLoadBalancerConfiguration() { | ||
assertThat( | ||
this.restTemplate.getForObject("/api/info/loadbalancer", String.class), | ||
new StringContains("ProxyPass /zk-apache-bridge")); | ||
} | ||
|
||
@Test | ||
public void getRewriteMapConfiguration() { | ||
assertThat( | ||
this.restTemplate.getForObject("/api/info/rewritemap", String.class), | ||
new StringContains("zk-apache-bridge")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
zk-apache-bridge/src/main/java/eu/europa/ec/cc/zkapachebridge/rest/InfoController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package eu.europa.ec.cc.zkapachebridge.rest; | ||
|
||
import eu.europa.ec.cc.zkapachebridge.apache.loadbalancer.LoadBalancerUpdater; | ||
import eu.europa.ec.cc.zkapachebridge.apache.rewritemap.RewriteMapUpdater; | ||
import eu.europa.ec.cc.zkapachebridge.serviceregistry.EndpointCollection; | ||
import eu.europa.ec.cc.zkapachebridge.serviceregistry.ServiceRegistry; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RequestMethod; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.Map; | ||
|
||
@RestController | ||
@RequestMapping("/api/info") | ||
public class InfoController { | ||
|
||
@Autowired | ||
ServiceRegistry serviceRegistry; | ||
|
||
@Autowired | ||
LoadBalancerUpdater loadBalancerUpdater; | ||
|
||
@Autowired | ||
RewriteMapUpdater rewriteMapUpdater; | ||
|
||
@RequestMapping(method = RequestMethod.GET) | ||
public Map<String, EndpointCollection> getServiceInformation() { | ||
return serviceRegistry.getServices(); | ||
} | ||
|
||
@RequestMapping(path="loadbalancer", method=RequestMethod.GET) | ||
public String getLoadBalancerConfiguration() throws Exception { | ||
return loadBalancerUpdater.getConfiguration(); | ||
} | ||
|
||
@RequestMapping(path="rewritemap", method=RequestMethod.GET) | ||
public String getRewriteMapConfiguration() { | ||
return rewriteMapUpdater.getConfiguration(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters