PageRenderTime 17ms CodeModel.GetById 13ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/opennms-alarms/http-northbounder/src/test/java/org/opennms/netmgt/alarmd/northbounder/http/HttpNorthBounderTest.java

https://github.com/ajakubo1/opennms
Java | 79 lines | 29 code | 12 blank | 38 comment | 0 complexity | e00ef1a320b2a31eda90a38c53d933bf MD5 | raw file
 1/*******************************************************************************
 2 * This file is part of OpenNMS(R).
 3 *
 4 * Copyright (C) 2011-2012 The OpenNMS Group, Inc.
 5 * OpenNMS(R) is Copyright (C) 1999-2012 The OpenNMS Group, Inc.
 6 *
 7 * OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
 8 *
 9 * OpenNMS(R) is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published
11 * by the Free Software Foundation, either version 3 of the License,
12 * or (at your option) any later version.
13 *
14 * OpenNMS(R) is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with OpenNMS(R).  If not, see:
21 *      http://www.gnu.org/licenses/
22 *
23 * For more information contact:
24 *     OpenNMS(R) Licensing <license@opennms.org>
25 *     http://www.opennms.org/
26 *     http://www.opennms.com/
27 *******************************************************************************/
28
29package org.opennms.netmgt.alarmd.northbounder.http;
30
31import org.junit.Test;
32import org.junit.runner.RunWith;
33import org.opennms.core.test.OpenNMSJUnit4ClassRunner;
34import org.opennms.core.test.http.annotations.JUnitHttpServer;
35import org.opennms.netmgt.alarmd.api.NorthboundAlarm;
36import org.opennms.netmgt.alarmd.northbounder.http.HttpNorthbounderConfig.HttpMethod;
37import org.opennms.netmgt.model.OnmsAlarm;
38import org.springframework.test.context.ContextConfiguration;
39
40/**
41 * Tests the HTTP North Bound Interface
42 * FIXME: This is far from completed
43 * 
44 * @author <a mailto:brozow@opennms.org>Matt Brozowski</a>
45 * @author <a mailto:david@opennms.org>David Hustace</a>
46 */
47@RunWith(OpenNMSJUnit4ClassRunner.class)
48// context not used but we this annotation is mandator
49@ContextConfiguration(locations="classpath:/test-context.xml")
50@JUnitHttpServer(port=10342)
51public class HttpNorthBounderTest {
52
53    @Test
54    public void testForwardAlarms() throws InterruptedException {
55        
56        HttpNorthbounder nb = new HttpNorthbounder();
57        HttpNorthbounderConfig config = new HttpNorthbounderConfig("localhost");
58        config.setMethod(HttpMethod.POST);
59        config.setPath("/jms/post");
60        config.setPort(Integer.valueOf(10342));
61        
62        nb.setConfig(config);
63        
64        OnmsAlarm alarm = new OnmsAlarm();
65        alarm.setId(1);
66        alarm.setUei("uei.opennms.org/test/httpNorthBounder");
67        
68        NorthboundAlarm a = new NorthboundAlarm(alarm);
69//        List<Alarm> alarms = Arrays.asList(a);
70//        
71//        nb.forwardAlarms(alarms);
72        
73        nb.onAlarm(a);
74        
75        Thread.sleep(10000);
76        
77    }
78
79}