use of org.graylog2.plugin.Version in project graylog2-server by Graylog2.
the class PluginVersionConstraintCheckerTest method checkConstraints.
@Test
public void checkConstraints() {
final TestPluginMetaData pluginMetaData = new TestPluginMetaData();
final PluginVersionConstraintChecker constraintChecker = new PluginVersionConstraintChecker(Collections.singleton(pluginMetaData));
final GraylogVersionConstraint graylogVersionConstraint = GraylogVersionConstraint.builder().version("^2.0.0").build();
final PluginVersionConstraint pluginVersionConstraint = PluginVersionConstraint.builder().pluginId("unique-id").version("^1.0.0").build();
final ImmutableSet<Constraint> requiredConstraints = ImmutableSet.of(graylogVersionConstraint, pluginVersionConstraint);
assertThat(constraintChecker.checkConstraints(requiredConstraints).stream().allMatch(c -> c.fulfilled())).isTrue();
}
use of org.graylog2.plugin.Version in project graylog2-server by Graylog2.
the class PluginVersionConstraintCheckerTest method checkConstraintsFails.
@Test
public void checkConstraintsFails() {
final TestPluginMetaData pluginMetaData = new TestPluginMetaData();
final PluginVersionConstraintChecker constraintChecker = new PluginVersionConstraintChecker(Collections.singleton(pluginMetaData));
final GraylogVersionConstraint graylogVersionConstraint = GraylogVersionConstraint.builder().version("^2.0.0").build();
final PluginVersionConstraint pluginVersionConstraint = PluginVersionConstraint.builder().pluginId("unique-id").version("^2.0.0").build();
final ImmutableSet<Constraint> requiredConstraints = ImmutableSet.of(graylogVersionConstraint, pluginVersionConstraint);
assertThat(constraintChecker.checkConstraints(requiredConstraints).stream().allMatch(c -> !c.fulfilled())).isTrue();
}
use of org.graylog2.plugin.Version in project graylog2-server by Graylog2.
the class SyslogCodecTest method testDecodeUnstructuredWithFullMessage.
@Test
public void testDecodeUnstructuredWithFullMessage() throws Exception {
when(configuration.getBoolean(SyslogCodec.CK_STORE_FULL_MESSAGE)).thenReturn(true);
final Message message = codec.decode(buildRawMessage(UNSTRUCTURED));
assertNotNull(message);
assertEquals("c4dc57ba1ebb syslog-ng[7208]: syslog-ng starting up; version='3.5.3'", message.getMessage());
assertEquals(new DateTime(YEAR + "-10-21T12:09:37"), message.getField("timestamp"));
assertEquals("c4dc57ba1ebb", message.getField("source"));
assertEquals(5, message.getField("level"));
assertEquals("syslogd", message.getField("facility"));
assertEquals(UNSTRUCTURED, message.getField("full_message"));
assertEquals(5, message.getField("facility_num"));
}
use of org.graylog2.plugin.Version in project graylog2-server by Graylog2.
the class GelfCodecTest method decodeFailsWithEmptyHost.
@Test
public void decodeFailsWithEmptyHost() throws Exception {
final String json = "{" + "\"version\": \"1.1\"," + "\"host\": \"\"," + "\"short_message\": \"A short message that helps you identify what is going on\"" + "}";
final RawMessage rawMessage = new RawMessage(json.getBytes(StandardCharsets.UTF_8));
assertThatIllegalArgumentException().isThrownBy(() -> codec.decode(rawMessage)).withNoCause().withMessageMatching("GELF message <[0-9a-f-]+> has empty mandatory \"host\" field.");
}
use of org.graylog2.plugin.Version in project graylog2-server by Graylog2.
the class GelfCodecTest method decodeFailsWithWrongTypeForHost.
@Test
public void decodeFailsWithWrongTypeForHost() throws Exception {
final String json = "{" + "\"version\": \"1.1\"," + "\"host\": 42," + "\"short_message\": \"A short message that helps you identify what is going on\"" + "}";
final RawMessage rawMessage = new RawMessage(json.getBytes(StandardCharsets.UTF_8));
assertThatIllegalArgumentException().isThrownBy(() -> codec.decode(rawMessage)).withNoCause().withMessageMatching("GELF message <[0-9a-f-]+> has invalid \"host\": 42");
}
Aggregations