예제 #1
0
        public void UnsupportedLogType()
        {
            var testWriterFactory = new TestWriterFactory();

            using (var plugin = new LogShark.Plugins.TabadminController.TabadminControllerPlugin())
            {
                plugin.Configure(testWriterFactory, null, _processingNotificationsCollectorMock.Object, new NullLoggerFactory());

                var someLogLine = new LogLine(
                    new ReadLogLineResult(123, "2020-09-28 17:47:01.730 -0500  pool-20-thread-1 : INFO  com.tableausoftware.tabadmin.webapp.asyncjobs.AsyncJobService - Running job 117 of type StartServerJob"),
                    TestLogFileInfo);
                Action wrongLogTypeAction = () => { plugin.ProcessLogLine(someLogLine, LogType.Apache); };
                wrongLogTypeAction.Should().Throw <LogSharkProgramLogicException>();

                plugin.CompleteProcessing();
            }

            testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1);
            _processingNotificationsCollectorMock.VerifyNoOtherCalls();
        }
예제 #2
0
        public void NotAJavaLine()
        {
            var testWriterFactory = new TestWriterFactory();
            var logLine           = new LogLine(new ReadLogLineResult(123, "Not a Java Log Line"), TestLogFileInfo);

            using (var plugin = new LogShark.Plugins.TabadminController.TabadminControllerPlugin())
            {
                plugin.Configure(testWriterFactory, null, _processingNotificationsCollectorMock.Object, new NullLoggerFactory());
                plugin.ProcessLogLine(logLine, LogType.TabadminControllerJava);
                plugin.CompleteProcessing();
            }

            testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1);
            _processingNotificationsCollectorMock.Verify(m => m.ReportError(
                                                             It.IsAny <string>(),
                                                             logLine,
                                                             nameof(LogShark.Plugins.TabadminController.TabadminControllerPlugin)),
                                                         Times.Once);
            _processingNotificationsCollectorMock.VerifyNoOtherCalls();
        }
예제 #3
0
        public void RunTestCases(string testName, string logLineText, DateTime timestamp, LogType logType, IDictionary <string, object> nonNullProps)
        {
            var testWriterFactory = new TestWriterFactory();
            var logLine           = new LogLine(new ReadLogLineResult(123, logLineText), TestLogFileInfo);
            SinglePluginExecutionResults processingResults;

            using (var plugin = new LogShark.Plugins.TabadminController.TabadminControllerPlugin())
            {
                plugin.Configure(testWriterFactory, null, _processingNotificationsCollectorMock.Object, new NullLoggerFactory());
                plugin.ProcessLogLine(logLine, logType);
                processingResults = plugin.CompleteProcessing();
            }

            _processingNotificationsCollectorMock.VerifyNoOtherCalls();

            processingResults.AdditionalTags.Should().BeEmpty();
            processingResults.HasAdditionalTags.Should().BeFalse();
            processingResults.WritersStatistics.Count.Should().Be(1);

            if (nonNullProps == null)
            {
                testWriterFactory.AssertAllWritersAreDisposedAndEmpty(1);
                processingResults.WritersStatistics[0].LinesPersisted.Should().Be(0);
                return;
            }

            processingResults.WritersStatistics[0].LinesPersisted.Should().Be(1);
            var testWriter = testWriterFactory.GetOneWriterAndVerifyOthersAreEmptyAndDisposed <TabadminControllerEvent>("TabadminControllerEvents", 1);

            testWriter.ReceivedObjects.Count.Should().Be(1);
            var result = testWriter.ReceivedObjects.FirstOrDefault() as TabadminControllerEvent;

            result.Should().NotBeNull();
            AssertMethods.AssertThatAllClassOwnPropsAreAtDefaultExpectFor(result, nonNullProps, testName);
            result.VerifyBaseEventProperties(timestamp, logLine);
        }