blob: 0b7d98112ce8e637e8bd90088abecaa144299a79 [file] [log] [blame]
kmcpeake4fe18c82015-11-17 20:07:39 +00001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.faultmanagement.web;
17
18import com.sun.jersey.api.client.WebResource;
19import org.junit.Before;
20import org.junit.Test;
21
22import static org.hamcrest.MatcherAssert.assertThat;
23import static org.hamcrest.Matchers.containsString;
24import static org.hamcrest.Matchers.not;
25import org.junit.Ignore;
26import org.onlab.osgi.ServiceDirectory;
27import org.onlab.osgi.TestServiceDirectory;
28import org.onlab.rest.BaseResource;
29import org.onosproject.codec.CodecService;
30import org.onosproject.codec.impl.CodecManager;
31import org.onosproject.rest.ResourceTest;
32
33/**
34 * Test of the Fault Management Web REST API for Alarms.
35 */
36public class AlarmsWebResourceTest extends ResourceTest {
37
38 @Before
39 public void setUp() {
40
41 final CodecManager codecService = new CodecManager();
42 codecService.activate();
43
44 final ServiceDirectory testDirectory
45 = new TestServiceDirectory()
46 // Currently no alarms-service implemented
47 // .add(AlarmsService.class, alarmsService)
48 .add(CodecService.class, codecService);
49 BaseResource.setServiceDirectory(testDirectory);
50 }
51
52 @Test
53 @Ignore
54 public void getAllAlarms() {
55 final WebResource rs = resource();
56 final String response = rs.path("/alarms").get(String.class);
57 // Ensure hard-coded alarms returned okay
58 assertThat(response, containsString("\"NE is not reachable\","));
59 assertThat(response, containsString("\"Equipment Missing\","));
60 }
61
62 @Test
63 @Ignore
64 public void getAlarm() {
65 final WebResource rs = resource();
66 final String response = rs.path("/alarms/1").get(String.class);
67 // Ensure hard-coded alarms returned okay
68 assertThat(response, containsString("\"NE is not reachable\","));
69 assertThat(response, not(containsString("\"Equipment Missing\",")));
70 }
71
72}