| /******************************************************************************* |
| * Copyright 2017 General Electric Company |
| * |
| * 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. |
| * |
| * SPDX-License-Identifier: Apache-2.0 |
| *******************************************************************************/ |
| |
| package com.ge.predix.controller.test; |
| |
| import static com.ge.predix.acs.commons.web.AcsApiUriTemplates.HEARTBEAT_URL; |
| import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; |
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; |
| import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; |
| |
| import org.springframework.beans.factory.annotation.Autowired; |
| import org.springframework.http.MediaType; |
| import org.springframework.test.context.ActiveProfiles; |
| import org.springframework.test.context.ContextConfiguration; |
| import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; |
| import org.springframework.test.context.web.WebAppConfiguration; |
| import org.springframework.test.web.servlet.MockMvc; |
| import org.springframework.test.web.servlet.setup.MockMvcBuilders; |
| import org.springframework.web.context.WebApplicationContext; |
| import org.testng.annotations.BeforeClass; |
| import org.testng.annotations.Test; |
| |
| import com.ge.predix.acs.testutils.TestActiveProfilesResolver; |
| |
| /* |
| * |
| * @author acs-engineers@ge.com |
| */ |
| @WebAppConfiguration |
| @ContextConfiguration("classpath:controller-tests-context.xml") |
| @ActiveProfiles(resolver = TestActiveProfilesResolver.class) |
| @Test |
| public class AcsMonitoringControllerIT extends AbstractTestNGSpringContextTests { |
| @Autowired |
| private WebApplicationContext wac; |
| |
| private MockMvc mockMvc; |
| |
| @BeforeClass |
| public void setup() { |
| this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build(); |
| } |
| |
| public void testMonitoringHeartBeat() throws Exception { |
| this.mockMvc.perform(get(HEARTBEAT_URL).accept(MediaType.TEXT_PLAIN_VALUE)).andExpect(status().isOk()) |
| .andExpect(content().contentType(MediaType.TEXT_PLAIN_VALUE + ";charset=UTF-8")) |
| .andExpect(content().string("alive")); |
| } |
| |
| } |