Search in sources :

Example 6 with Parameter

use of org.opennms.netmgt.config.poller.Parameter in project opennms by OpenNMS.

the class PollerBackEndTest method addParameterToService.

private static void addParameterToService(Service pkgService, String key, String value) {
    Parameter param = new Parameter();
    param.setKey(key);
    param.setValue(value);
    pkgService.addParameter(param);
}
Also used : Parameter(org.opennms.netmgt.config.poller.Parameter)

Example 7 with Parameter

use of org.opennms.netmgt.config.poller.Parameter in project opennms by OpenNMS.

the class PollerBackEndTest method addParameter.

private void addParameter(Service service, String key, String value) {
    Parameter param = new Parameter();
    param.setKey(key);
    param.setValue(value);
    service.addParameter(param);
}
Also used : Parameter(org.opennms.netmgt.config.poller.Parameter)

Example 8 with Parameter

use of org.opennms.netmgt.config.poller.Parameter in project opennms by OpenNMS.

the class MockPollerConfig method addParameter.

public void addParameter(final String key, final String value) {
    final Parameter param = new Parameter();
    param.setKey(key);
    param.setValue(value);
    m_currentSvc.addParameter(param);
}
Also used : Parameter(org.opennms.netmgt.config.poller.Parameter)

Example 9 with Parameter

use of org.opennms.netmgt.config.poller.Parameter in project opennms by OpenNMS.

the class DefaultPollerBackEndTest method getParameterMapMarshallsPageSequenceParameters.

/**
     * Verifies that {@link PageSequence} type parameters are marshalled to XML.
     */
@Test
public void getParameterMapMarshallsPageSequenceParameters() {
    final PageSequence ps = new PageSequence();
    Page page = new Page();
    page.setMethod("GET");
    page.setHttpVersion("1.1");
    page.setScheme("http");
    page.setHost("${ipaddr}");
    page.setDisableSslVerification("true");
    page.setPort(7080);
    page.setPath("/Login.do");
    page.setSuccessMatch("w00t");
    page.setResponseRange("100-399");
    ps.addPage(page);
    Parameter paramWithPageSequenceValue = new Parameter();
    paramWithPageSequenceValue.setKey("psm");
    paramWithPageSequenceValue.setAnyObject(ps);
    Service svc = new Service();
    svc.setParameters(Lists.newArrayList(paramWithPageSequenceValue));
    Map<String, Object> params = DefaultPollerBackEnd.getParameterMap(svc);
    PageSequence unmarshalledPs = JaxbUtils.unmarshal(PageSequence.class, (String) params.get("psm"));
    assertEquals(ps, unmarshalledPs);
}
Also used : PageSequence(org.opennms.netmgt.config.pagesequence.PageSequence) Parameter(org.opennms.netmgt.config.poller.Parameter) Service(org.opennms.netmgt.config.poller.Service) Page(org.opennms.netmgt.config.pagesequence.Page) Test(org.junit.Test)

Example 10 with Parameter

use of org.opennms.netmgt.config.poller.Parameter in project opennms by OpenNMS.

the class DefaultPollerBackEndTest method canConvertServiceParametersToSerializableMap.

/**
     * Verifies that the parameter map generated for a given
     * service is serializable. 
     */
@Test
public void canConvertServiceParametersToSerializableMap() {
    Parameter paramWithStringValue = new Parameter();
    paramWithStringValue.setKey("a");
    paramWithStringValue.setValue("test");
    Parameter paramWithNullValue = new Parameter();
    paramWithNullValue.setKey("b");
    paramWithNullValue.setAnyObject(null);
    Parameter paramWithNonSerializableObject = new Parameter();
    paramWithNonSerializableObject.setKey("c");
    // This can be any object, provided that it does not implement the Serializable interface
    paramWithNonSerializableObject.setAnyObject(new DefaultPollerBackEndTest());
    Service svc = new Service();
    svc.setParameters(Lists.newArrayList(paramWithStringValue, paramWithNullValue, paramWithNonSerializableObject));
    // Expect no exception to be thrown
    SerializationUtils.serialize(DefaultPollerBackEnd.getParameterMap(svc));
}
Also used : Parameter(org.opennms.netmgt.config.poller.Parameter) Service(org.opennms.netmgt.config.poller.Service) Test(org.junit.Test)

Aggregations

Parameter (org.opennms.netmgt.config.poller.Parameter)13 Test (org.junit.Test)7 PollStatus (org.opennms.netmgt.poller.PollStatus)6 ServiceMonitor (org.opennms.netmgt.poller.ServiceMonitor)6 ConcurrentSkipListMap (java.util.concurrent.ConcurrentSkipListMap)5 MonitoredService (org.opennms.netmgt.poller.MonitoredService)5 Service (org.opennms.netmgt.config.poller.Service)4 InetAddress (java.net.InetAddress)2 HashMap (java.util.HashMap)2 JUnitHttpServer (org.opennms.core.test.http.annotations.JUnitHttpServer)2 PageSequence (org.opennms.netmgt.config.pagesequence.PageSequence)2 MockMonitoredService (org.opennms.netmgt.poller.mock.MockMonitoredService)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 PollerConfig (org.opennms.netmgt.config.PollerConfig)1 Page (org.opennms.netmgt.config.pagesequence.Page)1 Package (org.opennms.netmgt.config.poller.Package)1