org.elasticsearch.common.xcontent.yaml.YamlXContent Java Examples

The following examples show how to use org.elasticsearch.common.xcontent.yaml.YamlXContent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KafkaSinkTest.java    From deprecated-security-advanced-modules with Apache License 2.0 6 votes vote down vote up
@Test
public void testKafka() throws Exception {
    String configYml = FileHelper.loadFile("auditlog/endpoints/sink/configuration_kafka.yml");
	configYml = configYml.replace("_RPLC_BOOTSTRAP_SERVERS_",embeddedKafka.getEmbeddedKafka().getBrokersAsString());
	Settings.Builder settingsBuilder = Settings.builder().loadFromSource(configYml, YamlXContent.yamlXContent.type());
	try(KafkaConsumer<Long, String> consumer = createConsumer()) {
	    consumer.subscribe(Arrays.asList("compliance"));

        Settings settings = settingsBuilder.put("path.home", ".").build();
        SinkProvider provider = new SinkProvider(settings, null, null, null);
        AuditLogSink sink = provider.getDefaultSink();
        try {
            Assert.assertEquals(KafkaSink.class, sink.getClass());
   	        boolean success = sink.doStore(MockAuditMessageFactory.validAuditMessage(Category.MISSING_PRIVILEGES));
   	        Assert.assertTrue(success);
   	        ConsumerRecords<Long, String> records = consumer.poll(Duration.ofSeconds(10));
   	        Assert.assertEquals(1, records.count());
        } finally {
            sink.close();
        }
	}

}
 
Example #2
Source File: XContentFactory.java    From Elasticsearch with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a binary content builder for the provided content type.
 */
public static XContentBuilder contentBuilder(XContentType type) throws IOException {
    if (type == XContentType.JSON) {
        return JsonXContent.contentBuilder();
    } else if (type == XContentType.SMILE) {
        return SmileXContent.contentBuilder();
    } else if (type == XContentType.YAML) {
        return YamlXContent.contentBuilder();
    } else if (type == XContentType.CBOR) {
        return CborXContent.contentBuilder();
    }
    throw new IllegalArgumentException("No matching content type for " + type);
}
 
Example #3
Source File: XContentFactory.java    From crate with Apache License 2.0 5 votes vote down vote up
/**
 * Returns a binary content builder for the provided content type.
 */
public static XContentBuilder contentBuilder(XContentType type) throws IOException {
    if (type == XContentType.JSON) {
        return JsonXContent.contentBuilder();
    } else if (type == XContentType.SMILE) {
        return SmileXContent.contentBuilder();
    } else if (type == XContentType.YAML) {
        return YamlXContent.contentBuilder();
    }
    throw new IllegalArgumentException("No matching content type for " + type);
}
 
Example #4
Source File: XContentFactory.java    From Elasticsearch with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a new yaml builder that will output the result into the provided output stream.
 */
public static XContentBuilder yamlBuilder(OutputStream os) throws IOException {
    return new XContentBuilder(YamlXContent.yamlXContent, os);
}
 
Example #5
Source File: XmlXContentFactory.java    From elasticsearch-xml with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a new yaml builder that will output the result into the provided output stream.
 */
public static XmlXContentBuilder yamlBuilder(OutputStream os) throws IOException {
    return new XmlXContentBuilder(YamlXContent.yamlXContent, os);
}
 
Example #6
Source File: XContentFactory.java    From crate with Apache License 2.0 4 votes vote down vote up
/**
 * Constructs a new yaml builder that will output the result into the provided output stream.
 */
public static XContentBuilder yamlBuilder(OutputStream os) throws IOException {
    return new XContentBuilder(YamlXContent.YAML_XCONTENT, os);
}