blob: e07487ce96dbf38c67a6616bc4951346b39a5852 [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
kmcpeakea5404812015-12-08 11:52:50 +000044 final ServiceDirectory testDirectory = new TestServiceDirectory()
kmcpeake4fe18c82015-11-17 20:07:39 +000045 // Currently no alarms-service implemented
46 // .add(AlarmsService.class, alarmsService)
47 .add(CodecService.class, codecService);
48 BaseResource.setServiceDirectory(testDirectory);
49 }
50
51 @Test
52 @Ignore
53 public void getAllAlarms() {
54 final WebResource rs = resource();
55 final String response = rs.path("/alarms").get(String.class);
56 // Ensure hard-coded alarms returned okay
57 assertThat(response, containsString("\"NE is not reachable\","));
58 assertThat(response, containsString("\"Equipment Missing\","));
59 }
60
61 @Test
62 @Ignore
63 public void getAlarm() {
64 final WebResource rs = resource();
65 final String response = rs.path("/alarms/1").get(String.class);
66 // Ensure hard-coded alarms returned okay
67 assertThat(response, containsString("\"NE is not reachable\","));
68 assertThat(response, not(containsString("\"Equipment Missing\",")));
69 }
70
71}