mirror of
https://github.com/corda/corda.git
synced 2024-12-28 00:38:55 +00:00
Fix broken network management server status endpoint (#397)
* add missing Path annotation and test * Address PR issue
This commit is contained in:
parent
55385613ac
commit
45b23737c7
@ -8,9 +8,9 @@ import javax.ws.rs.Produces
|
||||
import javax.ws.rs.core.MediaType
|
||||
import javax.ws.rs.core.Response
|
||||
|
||||
@Path("/status")
|
||||
class MonitoringWebService(private val serverStatus: NetworkManagementServerStatus) {
|
||||
@GET
|
||||
@Path("status")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
fun status(): Response {
|
||||
return Response.ok(ObjectMapper().writeValueAsString(serverStatus)).build()
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.r3.corda.networkmanage.doorman.webservice
|
||||
|
||||
import com.r3.corda.networkmanage.doorman.NetworkManagementServerStatus
|
||||
import com.r3.corda.networkmanage.doorman.NetworkManagementWebServer
|
||||
import net.corda.core.internal.openHttpConnection
|
||||
import net.corda.core.utilities.NetworkHostAndPort
|
||||
import org.codehaus.jackson.map.ObjectMapper
|
||||
import org.junit.Test
|
||||
import java.net.URL
|
||||
import kotlin.test.assertEquals
|
||||
|
||||
class MonitoringWebServiceTest {
|
||||
@Test
|
||||
fun `get server status`() {
|
||||
val status = NetworkManagementServerStatus()
|
||||
val jsonStatus = ObjectMapper().writeValueAsString(status)
|
||||
NetworkManagementWebServer(NetworkHostAndPort("localhost", 0), MonitoringWebService(status)).use {
|
||||
it.start()
|
||||
val conn = URL("http://${it.hostAndPort}/status").openHttpConnection()
|
||||
assertEquals(200, conn.responseCode)
|
||||
assertEquals(jsonStatus, conn.inputStream.bufferedReader().readLine())
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user