当前位置: 首页>>代码示例>>Java>>正文


Java LoggingEvent类代码示例

本文整理汇总了Java中uk.org.lidalia.slf4jtest.LoggingEvent的典型用法代码示例。如果您正苦于以下问题:Java LoggingEvent类的具体用法?Java LoggingEvent怎么用?Java LoggingEvent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


LoggingEvent类属于uk.org.lidalia.slf4jtest包,在下文中一共展示了LoggingEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkBadWriter

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@Test
public void checkBadWriter() throws NitfFormatException {
    NitfReader reader = new NitfInputStreamReader(new BufferedInputStream(getInputStream("/WithBE.ntf")));
    SlottedParseStrategy parseStrategy = new SlottedParseStrategy(SlottedParseStrategy.ALL_SEGMENT_DATA);
    HeapStrategyConfiguration heapStrategyConfiguration = new HeapStrategyConfiguration(length -> length > ABOUT_100K);
    HeapStrategy<ImageInputStream> imageDataStrategy = new ConfigurableHeapStrategy<>(heapStrategyConfiguration,
            file -> new FileImageInputStream(file), is -> new MemoryCacheImageInputStream(is));
    parseStrategy.setImageHeapStrategy(imageDataStrategy);
    NitfParser.parse(reader, parseStrategy);

    // Introduce deliberate issue
    // Introduce deliberate issue
    ImageSegment imageSegment = parseStrategy.getDataSource().getImageSegments().get(0);
    TargetId originalTargetId = imageSegment.getImageTargetId();
    TargetIdImpl newTargetId = new TargetIdImpl();
    newTargetId.setBasicEncyclopediaNumber(originalTargetId.getBasicEncyclopediaNumber());
    newTargetId.setOSuffix(originalTargetId.getOSuffix());
    newTargetId.setCountryCode(null);
    imageSegment.setImageTargetId(newTargetId);

    NitfWriter writer = new NitfFileWriter(parseStrategy.getDataSource(), "checkBadWriter.ntf");
    assertEquals(0, LOGGER.getLoggingEvents().size());
    writer.write();
    assertThat(LOGGER.getLoggingEvents(), is(Arrays.asList(LoggingEvent.error("Could not write", "Cannot generate string target identifier with null country code"))));
}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:26,代码来源:BasicWriterTest.java

示例2: checkBadStreamWriter

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@Test
public void checkBadStreamWriter() throws NitfFormatException, FileNotFoundException {
    OutputStream outputStream = new FileOutputStream("checkBadStreamWriter.ntf");
    NitfReader reader = new NitfInputStreamReader(new BufferedInputStream(getInputStream("/WithBE.ntf")));
    SlottedParseStrategy parseStrategy = new SlottedParseStrategy(SlottedParseStrategy.ALL_SEGMENT_DATA);
    HeapStrategyConfiguration heapStrategyConfiguration = new HeapStrategyConfiguration(length -> length > ABOUT_100K);
    HeapStrategy<ImageInputStream> imageDataStrategy = new ConfigurableHeapStrategy<>(heapStrategyConfiguration,
            file -> new FileImageInputStream(file), is -> new MemoryCacheImageInputStream(is));
    parseStrategy.setImageHeapStrategy(imageDataStrategy);
    NitfParser.parse(reader, parseStrategy);

    // Introduce deliberate issue
    ImageSegment imageSegment = parseStrategy.getDataSource().getImageSegments().get(0);
    TargetId originalTargetId = imageSegment.getImageTargetId();
    TargetIdImpl newTargetId = new TargetIdImpl();
    newTargetId.setBasicEncyclopediaNumber(originalTargetId.getBasicEncyclopediaNumber());
    newTargetId.setOSuffix(originalTargetId.getOSuffix());
    newTargetId.setCountryCode(null);
    imageSegment.setImageTargetId(newTargetId);

    NitfWriter writer = new NitfOutputStreamWriter(parseStrategy.getDataSource(), outputStream);
    assertEquals(0, LOGGER.getLoggingEvents().size());
    writer.write();
    assertThat(LOGGER.getLoggingEvents(), is(Arrays.asList(LoggingEvent.error("Could not write", "Cannot generate string target identifier with null country code"))));
}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:26,代码来源:BasicWriterTest.java

示例3: testParseOfENCRYP

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@Test
public void testParseOfENCRYP() throws NitfFormatException {
    AbstractSegmentParser parser = mock(AbstractSegmentParser.class, CALLS_REAL_METHODS);

    NitfReader mockReader = mock(NitfReader.class);
    parser.reader = mockReader;
    when(mockReader.readBytes(1)).thenReturn("0");
    parser.readENCRYP();
    assertThat(LOGGER.getLoggingEvents().isEmpty(), is(true));

    try {
        when(mockReader.readBytes(1)).thenReturn("1");
        exception.expect(NitfFormatException.class);
        exception.expectMessage("Unexpected ENCRYP value");
        parser.readENCRYP();
    } finally {
        assertThat(LOGGER.getLoggingEvents(), is(Arrays.asList(LoggingEvent.warn("Mismatch while reading ENCRYP"))));
    }
}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:20,代码来源:AbstractParserTest.java

示例4: testWriteFixedLengthString

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@Test
public void testWriteFixedLengthString() throws Exception {
    DataOutput mockOutput = mock(DataOutput.class);
    AbstractSegmentWriter testWriter = new AbstractSegmentWriterImpl(mockOutput);
    testWriter.writeFixedLengthString("Test", 4);
    verify(mockOutput).writeBytes("Test");

    assertThat(LOGGER.getLoggingEvents().isEmpty(), is(true));
    testWriter.writeFixedLengthString("Too Long", 6);
    verify(mockOutput).writeBytes("Too Lo");
    assertThat(LOGGER.getLoggingEvents(), is(Arrays.asList(
            LoggingEvent.warn("Truncated string \"Too Long\", max length is 6"))));
    LOGGER.clear();

    testWriter.writeFixedLengthString("Short", 7);
    verify(mockOutput).writeBytes("Short  ");
    assertThat(LOGGER.getLoggingEvents().isEmpty(), is(true));

}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:20,代码来源:AbstractSegmentWriterTest.java

示例5: testWriteFixedLengthNumber

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@Test
public void testWriteFixedLengthNumber() throws Exception {
    DataOutput mockOutput = mock(DataOutput.class);
    AbstractSegmentWriter testWriter = new AbstractSegmentWriterImpl(mockOutput);
    assertThat(LOGGER.getLoggingEvents().isEmpty(), is(true));

    testWriter.writeFixedLengthNumber(3, 2);
    verify(mockOutput).writeBytes("03");
    assertThat(LOGGER.getLoggingEvents().isEmpty(), is(true));

    testWriter.writeFixedLengthNumber(23, 2);
    verify(mockOutput).writeBytes("23");
    assertThat(LOGGER.getLoggingEvents().isEmpty(), is(true));

    try {
        exception.expect(IllegalArgumentException.class);
        exception.expectMessage("Fixed length number 235 cannot fit into length 2");
        testWriter.writeFixedLengthNumber(235, 2);
    } finally {
        assertThat(LOGGER.getLoggingEvents(), is(Arrays.asList(
                LoggingEvent.error("Fixed length number 235 cannot fit into length 2"))));
    }
}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:24,代码来源:AbstractSegmentWriterTest.java

示例6: testIncorrectStringLengthWrite

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@Test
public void testIncorrectStringLengthWrite() throws Exception {
    DataOutput mockOutput = mock(DataOutput.class);
    AbstractSegmentWriter testWriter = new AbstractSegmentWriterImpl(mockOutput);
    assertThat(LOGGER.getLoggingEvents().isEmpty(), is(true));
    try {
        exception.expect(IllegalArgumentException.class);
        exception.expectMessage("String Too Long was not of expected length 6");
        testWriter.writeBytes("Too Long", 6);
    } finally {
        assertThat(LOGGER.getLoggingEvents(), is(Arrays.asList(
                LoggingEvent.error("String Too Long was not of expected length 6"))));
    }
    verify(mockOutput, never()).writeBytes(any());
    verify(mockOutput, never()).write(any());
}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:17,代码来源:AbstractSegmentWriterTest.java

示例7: testIncorrectByteArrayLengthWrite

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@Test
public void testIncorrectByteArrayLengthWrite() throws Exception {
    DataOutput mockOutput = mock(DataOutput.class);
    AbstractSegmentWriter testWriter = new AbstractSegmentWriterImpl(mockOutput);
    assertThat(LOGGER.getLoggingEvents().isEmpty(), is(true));
    try {
        exception.expect(IllegalArgumentException.class);
        exception.expectMessage("Array was length 5, and not expected length 6");
        testWriter.writeBytes(new byte[5], 6);
    } finally {
        assertThat(LOGGER.getLoggingEvents(), is(Arrays.asList(
                LoggingEvent.error("Array was length 5, and not expected length 6"))));
    }
    verify(mockOutput, never()).writeBytes(any());
    verify(mockOutput, never()).write(any());
}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:17,代码来源:AbstractSegmentWriterTest.java

示例8: shouldLog4xxAsWarn

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("data")
void shouldLog4xxAsWarn(final Status status) {
    assumeTrue(status.getStatusCode() / 100 == 4);
    unit.create(status, new NoHandlerFoundException("GET", "/", new HttpHeaders()), mock(NativeWebRequest.class));

    final LoggingEvent event = getOnlyElement(log.getLoggingEvents());
    assertThat(event.getLevel(), is(Level.WARN));
    assertThat(event.getMessage(), is("{}: {}"));
    assertThat(event.getArguments(), contains(getReasonPhrase(status), "No handler found for GET /"));
    assertThat(event.getThrowable().orNull(), is(nullValue()));
}
 
开发者ID:zalando,项目名称:problem-spring-web,代码行数:13,代码来源:AdviceTraitLoggingTest.java

示例9: shouldLog5xxAsError

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@ParameterizedTest
@MethodSource("data")
void shouldLog5xxAsError(final Status status) {
    assumeTrue(status.getStatusCode() / 100 == 5);
    final IOException throwable = new IOException();
    unit.create(status, throwable, mock(NativeWebRequest.class));

    final LoggingEvent event = getOnlyElement(log.getLoggingEvents());
    assertThat(event.getLevel(), is(Level.ERROR));
    assertThat(event.getMessage(), is(getReasonPhrase(status)));
    assertThat(event.getArguments(), emptyIterable());
    assertThat(event.getThrowable().orNull(), is(throwable));
}
 
开发者ID:zalando,项目名称:problem-spring-web,代码行数:14,代码来源:AdviceTraitLoggingTest.java

示例10: testGettersAllSpaces

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@Test
public void testGettersAllSpaces() throws NitfFormatException {
    Tre tre = parseTRE(mAllSpaces, "PIAPEB");
    PIAPEB piapeb = new PIAPEB(tre);
    assertEquals("", piapeb.getLastName());
    assertEquals("", piapeb.getFirstName());
    assertEquals("", piapeb.getMiddleName());
    assertThat(LOGGER.getLoggingEvents().isEmpty(), is(true));
    assertEquals(null, piapeb.getBirthDate());
    assertThat(LOGGER.getLoggingEvents(), is(Arrays.asList(LoggingEvent.debug("Could not parse          as a local date: Text '        ' could not be parsed at index 0"))));
    assertEquals("  ", piapeb.getAssociatedCountryCode());
}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:13,代码来源:PIAPEB_WrapTest.java

示例11: testGettersAlternate

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@Test
public void testGettersAlternate() throws NitfFormatException, XMLStreamException, IOException {
    Tre tre = parseTRE(mAlternateData, "ACFTB ");
    ACFTB acftb = new ACFTB(tre);
    assertTrue(acftb.getValidity().isValid());
    assertEquals("NOT AVAILABLE", acftb.getAircraftMissionIdentification());
    assertEquals("", acftb.getAircraftTailNumber());
    assertThat(LOGGER.getLoggingEvents().isEmpty(), is(true));
    ZonedDateTime actualTakeOffTime = acftb.getAircraftTakeoff();
    assertNull(actualTakeOffTime);
    assertThat(LOGGER.getLoggingEvents(), is(Arrays.asList(LoggingEvent.debug("Could not parse              as a zoned date/time: Text '            ' could not be parsed at index 0"))));
    assertEquals("DPY-1", acftb.getSensorIdentification());
    // Likely a typo in the source data
    assertEquals("Lxyn Block 30 Radar", acftb.getSensorIdentificationDecoded());
    assertEquals("", acftb.getSceneSource());
    assertEquals("Not specified", acftb.getSceneSourceDecoded());
    assertEquals(5, acftb.getMissionPlanMode());
    assertEquals("Geo Strip", acftb.getMissionPlanModeDecoded());
    assertTrue(acftb.entryPointHasData());
    assertEquals(-33.36200000, acftb.getEntryLocationLatitude(), 0.00000001);
    assertEquals(-44.35100000, acftb.getEntryLocationLongitude(), 0.00000001);
    assertTrue(acftb.locationAccuracyIsKnown());
    assertEquals(30.0, acftb.getLocationAccuracy(), 0.01);
    assertEquals("m", acftb.getUnitOfElevation());
    assertEquals(-33.36500000, acftb.getExitLocationLatitude(), 0.00000001);
    assertEquals(-44.35200000, acftb.getExitLocationLongitude(), 0.00000001);
    assertTrue(acftb.rowSpacingIsKnown());
    assertTrue(acftb.columnSpacingIsKnown());
    assertEquals(12.0001, acftb.getRowSpacing(), 0.0001);
    assertEquals("f", acftb.getRowSpacingUnits());
    assertEquals(3.4567, acftb.getColumnSpacing(), 0.0001);
    assertEquals("m", acftb.getColumnSpacingUnits());
    assertTrue(acftb.focalLengthIsAvailable());
    assertEquals(123.45, acftb.getFocalLength(), 0.01);
    LocalDate expectedCalibrationDate = LocalDate.of(2016, 11, 3);
    LocalDate actualCalibrationDate = acftb.getCalibrationDate();
    assertEquals(expectedCalibrationDate, actualCalibrationDate);
    assertEquals(1234, acftb.getPatchTotal());
    assertEquals(321, acftb.getMTITotal());
}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:41,代码来源:ACFTB_WrapTest.java

示例12: testGracefulRecovery

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@Test
public void testGracefulRecovery() throws NitfFormatException {
    LOGGER.clear();
    String treString = "ENGRDA00058LAIR                00113majorVersion00010001A1NA00000002AENGRDA00058LAIR                00112majorVersion00010001A1NA000000011";
    InputStream inputStream = new ByteArrayInputStream(treString.getBytes(StandardCharsets.ISO_8859_1));
    BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
    NitfReader nitfReader = new NitfInputStreamReader(bufferedInputStream);
    TreCollectionParser treCollectionParser = new TreCollectionParser();
    TreCollection treCollection = treCollectionParser.parse(nitfReader, 138, TreSource.ImageExtendedSubheaderData);
    assertEquals(2, treCollection.getTREs().size());

    Tre tre0 = treCollection.getTREs().get(0);
    assertNotNull(tre0.getName());
    assertEquals(0, tre0.getEntries().size());
    assertNotNull(tre0.getRawData());

    Tre tre1 = treCollection.getTREs().get(1);
    assertNotNull(tre1.getName());
    assertEquals(3, tre1.getEntries().size());
    assertNull(tre1.getRawData());
    com.google.common.collect.ImmutableList<LoggingEvent> loggingEvents = LOGGER.getLoggingEvents();
    assertEquals(2, loggingEvents.size());
    assertEquals(Level.WARN, loggingEvents.get(0).getLevel());
    assertEquals("Failed to parse TRE {}. See debug log for exception information.", loggingEvents.get(0).getMessage());
    assertEquals(1, loggingEvents.get(0).getArguments().size());
    assertEquals("ENGRDA", loggingEvents.get(0).getArguments().get(0));
    assertEquals(Level.DEBUG, loggingEvents.get(1).getLevel());
    assertEquals(NumberFormatException.class, loggingEvents.get(1).getThrowable().get().getClass());
}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:30,代码来源:TreCollectionTest.java

示例13: testWriteDateTimeLongLength

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
@Test
public void testWriteDateTimeLongLength() throws Exception {
    DataOutput mockOutput = mock(DataOutput.class);
    AbstractSegmentWriter testWriter = new AbstractSegmentWriterImpl(mockOutput);
    DateTimeImpl testDateTime = new DateTimeImpl();
    testDateTime.setSourceString("201603020211567");
    testWriter.writeDateTime(testDateTime);
    verify(mockOutput).writeBytes("--------------");
    assertThat(LOGGER.getLoggingEvents(), is(Arrays.asList(
            LoggingEvent.warn("Invalid date format \"201603020211567\""))));
}
 
开发者ID:codice,项目名称:imaging-nitf,代码行数:12,代码来源:AbstractSegmentWriterTest.java

示例14: getLogs

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
default List<String> getLogs() {
	return getLogger().getAllLoggingEvents()
			.stream()
			.map(LoggingEvent::getMessage)
			.collect(Collectors.toList());
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:7,代码来源:LoggerContract.java

示例15: assertSingleEvent

import uk.org.lidalia.slf4jtest.LoggingEvent; //导入依赖的package包/类
private void assertSingleEvent(Consumer<LoggingEvent> consumer) {
	ImmutableList<LoggingEvent> events = testLogger.getLoggingEvents();
	assertThat(events.size()).isEqualTo(1);
	consumer.accept(events.get(0));
	testLogger.clear();
}
 
开发者ID:SemanticRecord,项目名称:talaan,代码行数:7,代码来源:SemanticLoggerTest.java


注:本文中的uk.org.lidalia.slf4jtest.LoggingEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。