mdc,
388 | // null, //final ThreadContext.ContextStack ndc,
389 | // TEST_THREAD_NAME, //final String threadName,
390 | // STACK_TRACE_ELEMENT, // final StackTraceElement location,
391 | // LOG_DATE.getTime()); //final long timestamp);
392 | //
393 | // String actualJSON = layout.toSerializable(event);
394 | // ObjectNode resultLayout = mapper.readValue(actualJSON, ObjectNode.class);
395 | //
396 | //
397 | // assertThat(resultLayout.has("Properties"), is(false));
398 | //
399 | //
400 | // }
401 | //
402 | // @Test
403 | // public void testPluginAttributeComplete() {
404 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
405 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
406 | // null, // @PluginAttribute("properties") final String properties,
407 | // null, // @PluginAttribute("complete") final String completeStr,
408 | // null, // @PluginAttribute("compact") final String compactStr,
409 | // null, // @PluginAttribute("newline") final String newlineStr,
410 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
411 | // null, // @PluginAttribute("charset") final String charsetName,
412 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
413 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
414 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
415 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
416 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
417 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
418 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
419 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
420 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
421 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
422 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
423 | // );
424 | // }
425 | //
426 | // @Test
427 | // public void testPluginAttributeCompact() {
428 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
429 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
430 | // null, // @PluginAttribute("properties") final String properties,
431 | // null, // @PluginAttribute("complete") final String completeStr,
432 | // null, // @PluginAttribute("compact") final String compactStr,
433 | // null, // @PluginAttribute("newline") final String newlineStr,
434 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
435 | // null, // @PluginAttribute("charset") final String charsetName,
436 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
437 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
438 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
439 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
440 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
441 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
442 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
443 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
444 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
445 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
446 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
447 | // );
448 | // }
449 | //
450 | // @Test
451 | // public void testPluginAttributeNewLine() {
452 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
453 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
454 | // null, // @PluginAttribute("properties") final String properties,
455 | // null, // @PluginAttribute("complete") final String completeStr,
456 | // null, // @PluginAttribute("compact") final String compactStr,
457 | // null, // @PluginAttribute("newline") final String newlineStr,
458 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
459 | // null, // @PluginAttribute("charset") final String charsetName,
460 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
461 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
462 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
463 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
464 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
465 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
466 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
467 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
468 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
469 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
470 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
471 | // );
472 | // }
473 | //
474 | // @Test
475 | // public void testPluginAttributeCommaAtEventEnd() {
476 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
477 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
478 | // null, // @PluginAttribute("properties") final String properties,
479 | // null, // @PluginAttribute("complete") final String completeStr,
480 | // null, // @PluginAttribute("compact") final String compactStr,
481 | // null, // @PluginAttribute("newline") final String newlineStr,
482 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
483 | // null, // @PluginAttribute("charset") final String charsetName,
484 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
485 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
486 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
487 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
488 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
489 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
490 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
491 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
492 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
493 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
494 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
495 | // );
496 | // }
497 | //
498 | // @Test
499 | // public void testPluginAttributeCharSet() {
500 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
501 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
502 | // null, // @PluginAttribute("properties") final String properties,
503 | // null, // @PluginAttribute("complete") final String completeStr,
504 | // null, // @PluginAttribute("compact") final String compactStr,
505 | // null, // @PluginAttribute("newline") final String newlineStr,
506 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
507 | // null, // @PluginAttribute("charset") final String charsetName,
508 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
509 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
510 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
511 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
512 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
513 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
514 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
515 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
516 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
517 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
518 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
519 | // );
520 | // }
521 | //
522 | // @Test
523 | // public void testPluginAttributeExcludeLogger() {
524 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
525 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
526 | // null, // @PluginAttribute("properties") final String properties,
527 | // null, // @PluginAttribute("complete") final String completeStr,
528 | // null, // @PluginAttribute("compact") final String compactStr,
529 | // null, // @PluginAttribute("newline") final String newlineStr,
530 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
531 | // null, // @PluginAttribute("charset") final String charsetName,
532 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
533 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
534 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
535 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
536 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
537 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
538 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
539 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
540 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
541 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
542 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
543 | // );
544 | // }
545 | //
546 | // @Test
547 | // public void testPluginAttributeExcludeLevel() {
548 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
549 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
550 | // null, // @PluginAttribute("properties") final String properties,
551 | // null, // @PluginAttribute("complete") final String completeStr,
552 | // null, // @PluginAttribute("compact") final String compactStr,
553 | // null, // @PluginAttribute("newline") final String newlineStr,
554 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
555 | // null, // @PluginAttribute("charset") final String charsetName,
556 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
557 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
558 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
559 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
560 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
561 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
562 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
563 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
564 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
565 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
566 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
567 | // );
568 | // }
569 | //
570 | // @Test
571 | // public void testPluginAttributeExcludeThread() {
572 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
573 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
574 | // null, // @PluginAttribute("properties") final String properties,
575 | // null, // @PluginAttribute("complete") final String completeStr,
576 | // null, // @PluginAttribute("compact") final String compactStr,
577 | // null, // @PluginAttribute("newline") final String newlineStr,
578 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
579 | // null, // @PluginAttribute("charset") final String charsetName,
580 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
581 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
582 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
583 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
584 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
585 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
586 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
587 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
588 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
589 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
590 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
591 | // );
592 | //
593 | // }
594 | //
595 | // @Test
596 | // public void testPluginAttributeMessage() {
597 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
598 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
599 | // null, // @PluginAttribute("properties") final String properties,
600 | // null, // @PluginAttribute("complete") final String completeStr,
601 | // null, // @PluginAttribute("compact") final String compactStr,
602 | // null, // @PluginAttribute("newline") final String newlineStr,
603 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
604 | // null, // @PluginAttribute("charset") final String charsetName,
605 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
606 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
607 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
608 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
609 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
610 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
611 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
612 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
613 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
614 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
615 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
616 | // );
617 | //
618 | // }
619 | //
620 | // @Test
621 | // public void testPluginAttributeNDC() {
622 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
623 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
624 | // null, // @PluginAttribute("properties") final String properties,
625 | // null, // @PluginAttribute("complete") final String completeStr,
626 | // null, // @PluginAttribute("compact") final String compactStr,
627 | // null, // @PluginAttribute("newline") final String newlineStr,
628 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
629 | // null, // @PluginAttribute("charset") final String charsetName,
630 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
631 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
632 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
633 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
634 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
635 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
636 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
637 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
638 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
639 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
640 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
641 | // );
642 | //
643 | // }
644 | //
645 | // @Test
646 | // public void testPluginAttributeThrown() {
647 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
648 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
649 | // null, // @PluginAttribute("properties") final String properties,
650 | // null, // @PluginAttribute("complete") final String completeStr,
651 | // null, // @PluginAttribute("compact") final String compactStr,
652 | // null, // @PluginAttribute("newline") final String newlineStr,
653 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
654 | // null, // @PluginAttribute("charset") final String charsetName,
655 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
656 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
657 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
658 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
659 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
660 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
661 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
662 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
663 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
664 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
665 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
666 | // );
667 | //
668 | // }
669 | //
670 | // @Test
671 | // public void testPluginAttributeSkipJSONSublayout() {
672 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
673 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
674 | // null, // @PluginAttribute("properties") final String properties,
675 | // null, // @PluginAttribute("complete") final String completeStr,
676 | // null, // @PluginAttribute("compact") final String compactStr,
677 | // null, // @PluginAttribute("newline") final String newlineStr,
678 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
679 | // null, // @PluginAttribute("charset") final String charsetName,
680 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
681 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
682 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
683 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
684 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
685 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
686 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
687 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
688 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
689 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
690 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
691 | // );
692 | //
693 | // }
694 | //
695 | // @Test
696 | // public void testPluginAttributeLayout() {
697 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
698 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
699 | // null, // @PluginAttribute("properties") final String properties,
700 | // null, // @PluginAttribute("complete") final String completeStr,
701 | // null, // @PluginAttribute("compact") final String compactStr,
702 | // null, // @PluginAttribute("newline") final String newlineStr,
703 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
704 | // null, // @PluginAttribute("charset") final String charsetName,
705 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
706 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
707 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
708 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
709 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
710 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
711 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
712 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
713 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
714 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
715 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
716 | // );
717 | // }
718 | //
719 | // @Test
720 | // public void testPluginAttributePairs() {
721 | // LogStashJSONLayout layout = LogStashJSONLayout.createLayout(
722 | // null, // @PluginAttribute("locationInfo") final String locationInfo,
723 | // null, // @PluginAttribute("properties") final String properties,
724 | // null, // @PluginAttribute("complete") final String completeStr,
725 | // null, // @PluginAttribute("compact") final String compactStr,
726 | // null, // @PluginAttribute("newline") final String newlineStr,
727 | // null, // @PluginAttribute("commaAtEventEnd") final String commaAtEventEndStr,
728 | // null, // @PluginAttribute("charset") final String charsetName,
729 | // null, // @PluginAttribute("excludeLogger") final String excludeLoggerStr,
730 | // null, // @PluginAttribute("excludeLevel") final String excludeLevelStr,
731 | // null, // @PluginAttribute("excludeThread") final String excludeThreadStr,
732 | // null, // @PluginAttribute("excludeMessage") final String excludeMessageStr,
733 | // null, // @PluginAttribute("excludeLog") final String excludeLogStr,
734 | // null, // @PluginAttribute("excludeNDC") final String excludeNDCStr,
735 | // null, // @PluginAttribute("excludeThrown") final String excludeThrownStr,
736 | // null, // @PluginAttribute("skipJsonEscapeSubLayout") final String skipJsonEscapeSubLayoutStr,
737 | // null, // @PluginAttribute("subLayoutAsElement") final String subLayoutAsElementStr,
738 | // null, // @PluginElement("Layout") Layout extends Serializable> subLayout,
739 | // null // @PluginElement("Pairs") final KeyValuePair[] pairs
740 | // );
741 | //
742 | // }
743 | //
744 | //
745 | // //TODO test variety of objects
746 | //
747 | // //TODO test all message types
748 | //
749 | // //TODO test markers
750 | //
751 | // //TODO demo expansion scenarios like audit log marker
752 | //
753 | // //TODO demo parameter object like audit
754 | //
755 | // //TODO test context
756 | //
757 | //
758 | // /**
759 | // * This test requires logstash (installed manually) and makes assumptions
760 | // * about both configuration and operating system...
761 | // *
762 | // * ... So, you probably ought not run it by default :)
763 | // */
764 | // @Test(groups = "integration")
765 | // public void LogToLogStashTest() {
766 | // System.out.println("&&&&&&&&&&&&&&&&&&&");
767 | // System.out.println("&&&&&&&&&&&&&&&&&&&");
768 | // System.out.println("&&&&&&&&&&&&&&&&&&&");
769 | // System.out.println("&&&&&&&&&&&&&&&&&&&");
770 | // logger.info("TEST IS WIRED");
771 | //
772 | // }
773 |
774 | }
775 |
--------------------------------------------------------------------------------
/src/test/java/org/apache/logging/log4j/core/layout/LogStashJSONLayoutJacksonIT.java:
--------------------------------------------------------------------------------
1 | package org.apache.logging.log4j.core.layout;
2 |
3 | import java.nio.charset.Charset;
4 | import java.util.HashMap;
5 | import java.util.Map;
6 |
7 | import com.fasterxml.jackson.databind.ObjectMapper;
8 | import org.apache.logging.log4j.Level;
9 | import org.apache.logging.log4j.LogManager;
10 | import org.apache.logging.log4j.Logger;
11 | import org.apache.logging.log4j.core.LogEvent;
12 | import org.apache.logging.log4j.core.impl.Log4jLogEvent;
13 | import org.apache.logging.log4j.core.util.KeyValuePair;
14 | import org.apache.logging.log4j.message.Message;
15 | import org.apache.logging.log4j.message.SimpleMessage;
16 | import org.testng.annotations.AfterTest;
17 | import org.testng.annotations.BeforeTest;
18 | import org.testng.annotations.DataProvider;
19 | import org.testng.annotations.Test;
20 |
21 | import static org.hamcrest.MatcherAssert.assertThat;
22 | import static uk.co.datumedge.hamcrest.json.SameJSONAs.sameJSONAs;
23 |
24 | public class LogStashJSONLayoutJacksonIT {
25 | public static final String LOCATION_INFO = "LocationInfo";
26 | private static Logger logger = LogManager.getLogger(LogStashJSONLayoutJacksonIT.class);
27 |
28 |
29 | @Test(enabled = false, dataProvider = "dp")
30 | public void f(Integer n, String s) {
31 | }
32 |
33 | @DataProvider
34 | public Object[][] dp() {
35 | return new Object[][]{
36 | new Object[]{1, "a"},
37 | new Object[]{2, "b"},
38 | };
39 | }
40 |
41 | @BeforeTest
42 | public void beforeTest() {
43 | }
44 |
45 | @AfterTest
46 | public void afterTest() {
47 | }
48 |
49 |
50 | ObjectMapper mapper = new ObjectMapper();
51 |
52 | String expectedBasicSimpleTestJSON = "{\"@version\":\"1\"," +
53 | // "\"@timestamp\":\"2015-07-28T11:31:18.492-07:00\",\"timeMillis\":1438108278492," +
54 | "\"thread\":\""+ Thread.currentThread().getName() +"\"," +
55 | "\"level\":\"DEBUG\"," +
56 | "\"loggerName\":\"org.apache.logging.log4j.core.layout.LogStashJSONLayoutJacksonIT\"," +
57 | "\"message\":\"Test Message\"," +
58 | "\"endOfBatch\":false," +
59 | "\"loggerFqcn\":\"org.apache.logging.log4j.core.layout.LogStashJSONLayoutJacksonIT\","+
60 | "\"contextMap\":[{\"key\":\"Foo\",\"value\":\"Bar\"},{\"key\":\"A\",\"value\":\"B\"}]}";
61 |
62 | @Test
63 | public void BasicSimpleTest() throws Exception {
64 | Message simpleMessage = new SimpleMessage("Test Message");
65 |
66 | Map mdc = new HashMap();
67 | mdc.put("A","B");//Already some threadcontext
68 |
69 | LogEvent event = new Log4jLogEvent(
70 | logger.getName(),
71 | null,
72 | this.getClass().getCanonicalName(),
73 | Level.DEBUG,
74 | simpleMessage,
75 | null,
76 | mdc,
77 | null,
78 | Thread.currentThread().getName(),
79 | null,
80 | System.currentTimeMillis()
81 | );
82 |
83 |
84 | AbstractJacksonLayout layout = LogStashJSONLayout.createLayout(
85 | true, //location
86 | true, //properties
87 | true, //complete
88 | false, //compact
89 | false, //eventEol
90 | Charset.defaultCharset(),
91 | new KeyValuePair[]{new KeyValuePair("Foo", "Bar")}
92 | );
93 |
94 | String actualJSON = layout.toSerializable(event);
95 | System.out.println(actualJSON);
96 | assertThat(actualJSON, sameJSONAs(expectedBasicSimpleTestJSON)
97 | .allowingExtraUnexpectedFields()
98 | .allowingAnyArrayOrdering());
99 |
100 | }
101 |
102 | }
103 |
--------------------------------------------------------------------------------
/src/test/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
--------------------------------------------------------------------------------