Package com.splunk.logging

Examples of com.splunk.logging.SplunkCimLogEvent


        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=129.32\"", event.toString());
    }

    @Test
    public void addFieldWithBooleanValue() {
        SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");
        event.addField("key", true);

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=true\"", event.toString());
    }
View Full Code Here


        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=true\"", event.toString());
    }

    @Test
    public void addFieldWithStringValue() {
        SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");
        event.addField("key", "some \u4406\u4261");

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=some \u4406\u4261\"", event.toString());
    }
View Full Code Here

    }

    @Test
    public void addFieldWithObjectValue() {
        final String valueString = "Hello world \u4406!";
        SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");
        event.addField("key", new Object() {
            public String toString() {
                return valueString;
            }
        });

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=" + valueString + "\"", event.toString());
    }
View Full Code Here

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=" + valueString + "\"", event.toString());
    }

    @Test
    public void addFieldWithStringValueContainingDoubleQuotes() {
        SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");
        event.addField("key", "I contain \" double quotes");

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=I contain \\\" double quotes\"", event.toString());
    }
View Full Code Here

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=I contain \\\" double quotes\"", event.toString());
    }

    @Test
    public void addThrowableWorks() {
        SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");

        try {
           throw new Exception("This is a test of the Java emergency broadcast system.");
        } catch (Exception e) {
            event.addThrowableWithStacktrace(e);
        }

        String expectedString = "\"name=name\" \"event_id=event-id\" " +
                "\"throwable_class=java.lang.Exception\" \"throwable_message=This is a test of the Java " +
                "emergency broadcast system.\" \"stacktrace_elements=SplunkCimLogEventUnitTest." +
                "addThrowableWorks(SplunkCimLogEventUnitTest.java:???),";
        String foundString = event.toString();
        foundString = foundString.replaceAll(":\\d+\\)", ":???)"); // Get rid of line numbers.

        Assert.assertEquals(expectedString, foundString.substring(0, expectedString.length()));

    }
View Full Code Here

    }

    @Test
    public void addThrowableWorksWithDepth() {
        SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");

        try {
            throw new Exception("This is a test of the Java emergency broadcast system.");
        } catch (Exception e) {
            event.addThrowableWithStacktrace(e, 1);
        }

        String expected = "\"name=name\" \"event_id=event-id\" " +
                "\"throwable_class=java.lang.Exception\" \"throwable_message=This is a test of the Java " +
                "emergency broadcast system.\" \"stacktrace_elements=SplunkCimLogEventUnitTest." +
                "addThrowableWorksWithDepth(SplunkCimLogEventUnitTest.java:???)\"";
        Assert.assertEquals(expected, event.toString().replaceAll(":\\d+\\)", ":???)"));
    }
View Full Code Here

* Check that SplunkCimLogEvent produces what we expect it to.
*/
public class SplunkCimLogEventUnitTest {
    @Test
    public void addFieldWithCharValue() {
        SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");
        event.addField("key", '\u4126');

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=\u4126\"", event.toString());
    }
View Full Code Here

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=\u4126\"", event.toString());
    }

    @Test
    public void addFieldWithByteValue() {
        SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");
        event.addField("key", (byte)125);

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=125\"", event.toString());
    }
View Full Code Here

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=125\"", event.toString());
    }

    @Test
    public void addFieldWithShortValue() {
        SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");
        event.addField("key", (short)129);

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=129\"", event.toString());
    }
View Full Code Here

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=129\"", event.toString());
    }

    @Test
    public void addFieldWithIntValue() {
        SplunkCimLogEvent event = new SplunkCimLogEvent("name", "event-id");
        event.addField("key", (int)129);

        Assert.assertEquals("\"name=name\" \"event_id=event-id\" \"key=129\"", event.toString());
    }
View Full Code Here

TOP

Related Classes of com.splunk.logging.SplunkCimLogEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.