当前位置: 首页>>代码示例>>Java>>正文


Java MessagePayload类代码示例

本文整理汇总了Java中com.googlecode.jsendnsca.MessagePayload的典型用法代码示例。如果您正苦于以下问题:Java MessagePayload类的具体用法?Java MessagePayload怎么用?Java MessagePayload使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MessagePayload类属于com.googlecode.jsendnsca包,在下文中一共展示了MessagePayload类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldConstructTwoNewMessagePayload

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void shouldConstructTwoNewMessagePayload() throws Exception {
    final MessagePayload messagePayload = new MessagePayloadBuilder()
        .withHostname("localhost")
        .withLevel(Level.OK)
        .withServiceName("test service")
        .withMessage("test message")
        .create();

    final MessagePayload messagePayload2 = new MessagePayloadBuilder()
        .withHostname("somehost")
        .withLevel(Level.WARNING)
        .withServiceName("foo service")
        .withMessage("foo message")
        .create();

    assertEquals("localhost", messagePayload.getHostname());
    assertEquals(Level.OK, messagePayload.getLevel());
    assertEquals("test service", messagePayload.getServiceName());
    assertEquals("test message", messagePayload.getMessage());

    assertEquals("somehost", messagePayload2.getHostname());
    assertEquals(Level.WARNING, messagePayload2.getLevel());
    assertEquals("foo service", messagePayload2.getServiceName());
    assertEquals("foo message", messagePayload2.getMessage());
}
 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:27,代码来源:MessagePayloadBuilderTest.java

示例2: shouldConstructPayloadWithoutUsingLocalHostname

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void shouldConstructPayloadWithoutUsingLocalHostname() {
    MessagePayload messagePayload = new MessagePayloadBuilder() {
        @Override
        MessagePayload createMessagePayload() {
            return new MessagePayload(false) {
                @Override
                public void useLocalHostname() {
                    throw new UnknownHostRuntimeException(new UnknownHostException());
                }
            };
        }
    }.create();

    assertEquals("UNKNOWN", messagePayload.getHostname());
    assertEquals(Level.UNKNOWN, messagePayload.getLevel());
    assertEquals("UNDEFINED", messagePayload.getServiceName());
    assertEquals(StringUtils.EMPTY, messagePayload.getMessage());
}
 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:20,代码来源:MessagePayloadBuilderTest.java

示例3: testSendToNagios

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void testSendToNagios() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(createRouteBuilder());

    MessagePayload expectedPayload = new MessagePayload("localhost", Level.OK, camelctx.getName(),  "Hello Nagios");

    MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(1);
    mock.allMessages().body().isInstanceOf(String.class);
    mock.expectedBodiesReceived("Hello Nagios");

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBody("direct:start", "Hello Nagios");

        mock.assertIsSatisfied();

        Mockito.verify(nagiosPassiveCheckSender, Mockito.times(1)).send(expectedPayload);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:26,代码来源:NagiosIntegrationTest.java

示例4: testSendToNagiosWarn

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void testSendToNagiosWarn() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(createRouteBuilder());

    MessagePayload expectedPayload1 = new MessagePayload("localhost", Level.WARNING, camelctx.getName(),  "Hello Nagios");

    MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("Hello Nagios");

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBodyAndHeader("direct:start", "Hello Nagios", NagiosConstants.LEVEL, Level.WARNING);

        mock.assertIsSatisfied();
        Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:24,代码来源:NagiosIntegrationTest.java

示例5: testSendToNagiosWarnAsText

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void testSendToNagiosWarnAsText() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(createRouteBuilder());

    MessagePayload expectedPayload1 = new MessagePayload("localhost", Level.WARNING, camelctx.getName(),  "Hello Nagios");

    MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("Hello Nagios");

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBodyAndHeader("direct:start", "Hello Nagios", NagiosConstants.LEVEL, "WARNING");

        mock.assertIsSatisfied();

        Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:25,代码来源:NagiosIntegrationTest.java

示例6: shouldConstructNewMessagePayload

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void shouldConstructNewMessagePayload() throws Exception {
    final MessagePayload messagePayload = new MessagePayloadBuilder()
        .withHostname("localhost")
        .withLevel(Level.CRITICAL)
        .withServiceName("test service")
        .withMessage("test message")
        .create();

    assertEquals("localhost", messagePayload.getHostname());
    assertEquals(Level.CRITICAL, messagePayload.getLevel());
    assertEquals("test service", messagePayload.getServiceName());
    assertEquals("test message", messagePayload.getMessage());
}
 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:15,代码来源:MessagePayloadBuilderTest.java

示例7: testSendTwoToNagios

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void testSendTwoToNagios() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(createRouteBuilder());

    MessagePayload expectedPayload1 = new MessagePayload("localhost", Level.OK, camelctx.getName(),  "Hello Nagios");
    MessagePayload expectedPayload2 = new MessagePayload("localhost", Level.OK, camelctx.getName(),  "Bye Nagios");

    MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(2);
    mock.allMessages().body().isInstanceOf(String.class);
    mock.expectedBodiesReceived("Hello Nagios", "Bye Nagios");

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBody("direct:start", "Hello Nagios");
        template.sendBody("direct:start", "Bye Nagios");

        mock.assertIsSatisfied();

        Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
        Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload2);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:29,代码来源:NagiosIntegrationTest.java

示例8: testSendToNagiosMultiHeaders

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Test
public void testSendToNagiosMultiHeaders() throws Exception {

    CamelContext camelctx = new DefaultCamelContext();
    camelctx.addRoutes(createRouteBuilder());

    MessagePayload expectedPayload1 = new MessagePayload("myHost", Level.CRITICAL, "myService",  "Hello Nagios");

    MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(1);
    mock.expectedBodiesReceived("Hello Nagios");

    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put(NagiosConstants.LEVEL, "CRITICAL");
    headers.put(NagiosConstants.HOST_NAME, "myHost");
    headers.put(NagiosConstants.SERVICE_NAME, "myService");

    camelctx.start();
    try {
        ProducerTemplate template = camelctx.createProducerTemplate();
        template.sendBodyAndHeaders("direct:start", "Hello Nagios", headers);

        mock.assertIsSatisfied();
        Mockito.verify(nagiosPassiveCheckSender).send(expectedPayload1);
    } finally {
        camelctx.stop();
    }
}
 
开发者ID:wildfly-extras,项目名称:wildfly-camel,代码行数:29,代码来源:NagiosIntegrationTest.java

示例9: NscaCollector

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
public NscaCollector(PropertiesConfiguration properties) {
	super(properties, ActivecheckCollectorType.REPORTING);
	messageQueue = new LinkedList<MessagePayload>();

	// initialize what has not been initialized
	collectorInit();
}
 
开发者ID:frederikhappel,项目名称:activecheck,代码行数:8,代码来源:NscaCollector.java

示例10: sendImpl

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
@Override
public synchronized void sendImpl(NagiosServiceReport report) {
	String message = report.getMessageWithPerformancedata().replace("\n",
			"\\n");
	MessagePayload payload = new MessagePayloadBuilder().withHostname(report.getServiceHost()).withLevel(status2level.get(report.getStatus())).withMessage(message).create();
	String serviceName = report.getServiceName();
	if (serviceName != null) {
		payload.setServiceName(report.getServiceName());
	}
	messageQueue.add(payload);
	logger.trace(message);
}
 
开发者ID:frederikhappel,项目名称:activecheck,代码行数:13,代码来源:NscaCollector.java

示例11: send

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
public void send(Level level, String serviceName, String message)
		throws NagiosException, IOException {
	message = message.replace("\n", "\\n");
	MessagePayload payload = new MessagePayloadBuilder()
			.withHostname(senderHostName).withLevel(level)
			.withServiceName(serviceName).withMessage(message).create();

	sender.send(payload);
}
 
开发者ID:frederikhappel,项目名称:graylog2-plugin-alarmcallback-nsca,代码行数:10,代码来源:NscaHost.java

示例12: createMessagePayload

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
MessagePayload createMessagePayload() {
    return new MessagePayload(false);
}
 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:4,代码来源:MessagePayloadBuilder.java

示例13: create

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
/**
 * Return the built {@link MessagePayload}
 *
 * @return the built {@link MessagePayload}
 */
public MessagePayload create() {
    return payload;
}
 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:9,代码来源:MessagePayloadBuilder.java

示例14: getMessagePayloadList

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
public List<MessagePayload> getMessagePayloadList() {
        return messagePayloads;
    } 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:4,代码来源:NagiosNscaStub.java

示例15: parsePayload

import com.googlecode.jsendnsca.MessagePayload; //导入依赖的package包/类
private MessagePayload parsePayload(InputStream inputStream, byte[] initVector) throws IOException {
            DataInputStream stream = new DataInputStream(inputStream);

            byte[] bytes = new byte[16 + 64 + 128 + maxMessageSizeInChars];
            stream.readFully(bytes);

            decrypt(bytes, initVector);

            stream = new DataInputStream(new ByteArrayInputStream(bytes));

            int amountToSkip = 12;
            skipBytes(stream, amountToSkip);

            short level = stream.readShort();
            byte[] hostNameBytes = new byte[64];
            stream.readFully(hostNameBytes);
            String hostName = new String(hostNameBytes).trim();
            byte[] serviceNameBytes = new byte[128];
            stream.readFully(serviceNameBytes);
            String serviceName = new String(serviceNameBytes).trim();

            byte[] messageBytes = new byte[maxMessageSizeInChars];
            stream.readFully(messageBytes);
            String message = new String(messageBytes).trim();
            return new MessagePayloadBuilder().withHostname(hostName).withLevel(level).withServiceName(serviceName).withMessage(message).create();
        } 
开发者ID:jsendnsca,项目名称:jsendnsca,代码行数:27,代码来源:NagiosNscaStub.java


注:本文中的com.googlecode.jsendnsca.MessagePayload类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。