diff options
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java b/src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java new file mode 100644 index 0000000..e9a6da5 --- /dev/null +++ b/src/test/java/org/onap/aai/modelloader/actuator/ActuatorTest.java @@ -0,0 +1,47 @@ +/** + * ============LICENSE_START======================================================= + * org.onap.aai + * ================================================================================ + * Copyright © 2024 Deutsche Telekom AG Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.aai.modelloader.actuator; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.boot.test.context.SpringBootTest.WebEnvironment; +import org.springframework.boot.test.web.server.LocalServerPort; +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.client.RestTemplate; + +@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) +public class ActuatorTest { + + @Autowired RestTemplate restTemplate; + @LocalServerPort + private int serverPort; + + @Test + public void thatLivenessEndpointReturnsOk() { + String url = String.format("http://localhost:%s/actuator/health", serverPort); + ResponseEntity<String> entity = restTemplate.getForEntity(url, String.class); + assertEquals(entity.getStatusCode(), HttpStatus.OK); + assertEquals(entity.getBody(), "{\"status\":\"UP\"}"); + } +} |