/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. package org.opennms.netmgt.alarmd.northbounder.http;
  29. import org.junit.Test;
  30. import org.junit.runner.RunWith;
  31. import org.opennms.core.test.OpenNMSJUnit4ClassRunner;
  32. import org.opennms.core.test.http.annotations.JUnitHttpServer;
  33. import org.opennms.netmgt.alarmd.api.NorthboundAlarm;
  34. import org.opennms.netmgt.alarmd.northbounder.http.HttpNorthbounderConfig.HttpMethod;
  35. import org.opennms.netmgt.model.OnmsAlarm;
  36. import org.springframework.test.context.ContextConfiguration;
  37. /**
  38. * Tests the HTTP North Bound Interface
  39. * FIXME: This is far from completed
  40. *
  41. * @author <a mailto:brozow@opennms.org>Matt Brozowski</a>
  42. * @author <a mailto:david@opennms.org>David Hustace</a>
  43. */
  44. @RunWith(OpenNMSJUnit4ClassRunner.class)
  45. // context not used but we this annotation is mandator
  46. @ContextConfiguration(locations="classpath:/test-context.xml")
  47. @JUnitHttpServer(port=10342)
  48. public class HttpNorthBounderTest {
  49. @Test
  50. public void testForwardAlarms() throws InterruptedException {
  51. HttpNorthbounder nb = new HttpNorthbounder();
  52. HttpNorthbounderConfig config = new HttpNorthbounderConfig("localhost");
  53. config.setMethod(HttpMethod.POST);
  54. config.setPath("/jms/post");
  55. config.setPort(Integer.valueOf(10342));
  56. nb.setConfig(config);
  57. OnmsAlarm alarm = new OnmsAlarm();
  58. alarm.setId(1);
  59. alarm.setUei("uei.opennms.org/test/httpNorthBounder");
  60. NorthboundAlarm a = new NorthboundAlarm(alarm);
  61. // List<Alarm> alarms = Arrays.asList(a);
  62. //
  63. // nb.forwardAlarms(alarms);
  64. nb.onAlarm(a);
  65. Thread.sleep(10000);
  66. }
  67. }