Java Code Examples for org.apache.logging.log4j.util.Strings

The following examples show how to use org.apache.logging.log4j.util.Strings. These examples are extracted from open source projects. 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 Project: hadoop-ozone   Source File: CertificateSignRequest.java    License: Apache License 2.0 6 votes vote down vote up
public PKCS10CertificationRequest build() throws SCMSecurityException {
  Preconditions.checkNotNull(key, "KeyPair cannot be null");
  Preconditions.checkArgument(Strings.isNotBlank(subject), "Subject " +
      "cannot be blank");

  try {
    CertificateSignRequest csr = new CertificateSignRequest(subject, scmID,
        clusterID, key, config, createExtensions());
    return csr.generateCSR();
  } catch (IOException ioe) {
    throw new CertificateException(String.format("Unable to create " +
        "extension for certificate sign request for %s.", SecurityUtil
        .getDistinguishedName(subject, scmID, clusterID)), ioe.getCause());
  } catch (OperatorCreationException ex) {
    throw new CertificateException(String.format("Unable to create " +
        "certificate sign request for %s.", SecurityUtil
        .getDistinguishedName(subject, scmID, clusterID)),
        ex.getCause());
  }
}
 
Example 2
Source Project: logging-log4j2   Source File: MockTlsSyslogServer.java    License: Apache License 2.0 6 votes vote down vote up
private synchronized void processFrames() throws IOException {
    try {
        int count = 0;
        while (!shutdown) {
            String message = Strings.EMPTY;
            message = syslogReader.read();
            messageList.add(message);
            count++;
            if (isEndOfMessages(count)) {
                break;
            }
        }
        this.notify();
    }
    catch(final Exception e) {
        this.notify();
        throw new IOException(e);
    }
}
 
Example 3
Source Project: logging-log4j2   Source File: JdbcDatabaseManager.java    License: Apache License 2.0 6 votes vote down vote up
private void setFields(final MapMessage<?, ?> mapMessage) throws SQLException {
    final IndexedReadOnlyStringMap map = mapMessage.getIndexedReadOnlyStringMap();
    final String simpleName = statement.getClass().getName();
    int j = 1; // JDBC indices start at 1
    for (final ColumnMapping mapping : this.factoryData.columnMappings) {
        if (mapping.getLiteralValue() == null) {
            final String source = mapping.getSource();
            final String key = Strings.isEmpty(source) ? mapping.getName() : source;
            final Object value = map.getValue(key);
            if (logger().isTraceEnabled()) {
                final String valueStr = value instanceof String ? "\"" + value + "\""
                        : Objects.toString(value, null);
                logger().trace("{} setObject({}, {}) for key '{}' and mapping '{}'", simpleName, j, valueStr, key,
                        mapping.getName());
            }
            setStatementObject(j, mapping.getNameKey(), value);
            j++;
        }
    }
}
 
Example 4
Source Project: logging-log4j2   Source File: DataSourceConnectionSource.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Factory method for creating a connection source within the plugin manager.
 *
 * @param jndiName The full JNDI path where the data source is bound. Should start with java:/comp/env or
 *                 environment-equivalent.
 * @return the created connection source.
 */
@PluginFactory
public static DataSourceConnectionSource createConnectionSource(@PluginAttribute final String jndiName) {
    if (Strings.isEmpty(jndiName)) {
        LOGGER.error("No JNDI name provided.");
        return null;
    }

    try {
        final InitialContext context = new InitialContext();
        final DataSource dataSource = (DataSource) context.lookup(jndiName);
        if (dataSource == null) {
            LOGGER.error("No data source found with JNDI name [" + jndiName + "].");
            return null;
        }

        return new DataSourceConnectionSource(jndiName, dataSource);
    } catch (final NamingException e) {
        LOGGER.error(e.getMessage(), e);
        return null;
    }
}
 
Example 5
@NotNull
public static DriverCatalog createTestDriverCatalogEntry(@NotNull String gene) {
    return ImmutableDriverCatalog.builder()
            .gene(gene)
            .chromosome(Strings.EMPTY)
            .chromosomeBand(Strings.EMPTY)
            .category(DriverCategory.ONCO)
            .driver(DriverType.MUTATION)
            .likelihoodMethod(LikelihoodMethod.NONE)
            .driverLikelihood(0D)
            .dndsLikelihood(0D)
            .missense(0)
            .nonsense(0)
            .splice(0)
            .inframe(0)
            .frameshift(0)
            .biallelic(false)
            .minCopyNumber(0)
            .maxCopyNumber(0)
            .build();
}
 
Example 6
Source Project: hugegraph   Source File: PostgresqlSerializer.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public BackendEntry writeIndex(HugeIndex index) {
    TableBackendEntry entry = newBackendEntry(index);
    /*
     * When field-values is null and elementIds size is 0, it is
     * meaningful for deletion of index data in secondary/range index.
     */
    if (index.fieldValues() == null && index.elementIds().size() == 0) {
        entry.column(HugeKeys.INDEX_LABEL_ID, index.indexLabel().longId());
    } else {
        Object value = index.fieldValues();
        if (value != null && "\u0000".equals(value)) {
            value = Strings.EMPTY;
        }
        entry.column(HugeKeys.FIELD_VALUES, value);
        entry.column(HugeKeys.INDEX_LABEL_ID, index.indexLabel().longId());
        entry.column(HugeKeys.ELEMENT_IDS,
                     IdUtil.writeStoredString(index.elementId()));
        entry.column(HugeKeys.EXPIRED_TIME, index.expiredTime());
        entry.subId(index.elementId());
    }
    return entry;
}
 
Example 7
Source Project: logging-log4j2   Source File: ColumnConfigTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testPatternColumn03() {
    final ColumnConfig config = ColumnConfig.newBuilder()
        .setName("col3")
        .setPattern("%X{id} %level")
        .setLiteral(Strings.EMPTY)
        .setEventTimestamp(false)
        .setUnicode(true)
        .setClob(false)
        .build();

    assertNotNull("The result should not be null.", config);
    assertEquals("The column name is not correct.", "col3", config.getColumnName());
    assertNotNull("The pattern should not be null.", config.getLayout());
    assertEquals("The pattern is not correct.", "%X{id} %level", config.getLayout().toString());
    assertNull("The literal value should be null.", config.getLiteralValue());
    assertFalse("The timestamp flag should be false.", config.isEventTimestamp());
    assertTrue("The unicode flag should be true.", config.isUnicode());
    assertFalse("The clob flag should be false.", config.isClob());
}
 
Example 8
Source Project: logging-log4j2   Source File: PatternSelectorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testJavaScriptPatternSelector() throws Exception {
    final org.apache.logging.log4j.Logger logger = LogManager.getLogger("TestJavaScriptPatternSelector");
    final org.apache.logging.log4j.Logger logger2 = LogManager.getLogger("JavascriptNoLocation");
    logger.traceEntry();
    logger.info("Hello World");
    logger2.info("No location information");
    logger.traceExit();
    final ListAppender app = (ListAppender) context.getRequiredAppender("List3");
    assertNotNull("No ListAppender", app);
    final List<String> messages = app.getMessages();
    assertNotNull("No Messages", messages);
    assertTrue("Incorrect number of messages. Expected 4, Actual " + messages.size() + ": " + messages, messages.size() == 4);
    String expect = "[TRACE] TestJavaScriptPatternSelector ====== " +
            "o.a.l.l.c.PatternSelectorTest.testJavaScriptPatternSelector:85 Enter ======" + Strings.LINE_SEPARATOR;
    assertEquals(expect, messages.get(0));
    expect = "[INFO ] TestJavaScriptPatternSelector " +
            "o.a.l.l.c.PatternSelectorTest.testJavaScriptPatternSelector.86 Hello World" + Strings.LINE_SEPARATOR;
    assertEquals(expect, messages.get(1));
    assertEquals("[INFO ] JavascriptNoLocation No location information" + Strings.LINE_SEPARATOR, messages.get(2));
    app.clear();
}
 
Example 9
Source Project: logging-log4j2   Source File: PatternSelectorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testMarkerPatternSelector() throws Exception {
    final org.apache.logging.log4j.Logger logger = LogManager.getLogger("TestMarkerPatternSelector");
    logger.traceEntry();
    logger.info("Hello World");
    logger.traceExit();
    final ListAppender app = (ListAppender) context.getRequiredAppender("List");
    assertNotNull("No ListAppender", app);
    final List<String> messages = app.getMessages();
    assertNotNull("No Messages", messages);
    assertTrue("Incorrect number of messages. Expected 3, Actual " + messages.size() + ": " + messages, messages.size() == 3);
    final String expect = String.format("[TRACE] TestMarkerPatternSelector ====== "
            + "o.a.l.l.c.PatternSelectorTest.testMarkerPatternSelector:43 Enter ======%n");
    assertEquals(expect, messages.get(0));
    assertEquals("[INFO ] TestMarkerPatternSelector Hello World" + Strings.LINE_SEPARATOR, messages.get(1));
    app.clear();
}
 
Example 10
@NotNull
static ModifiableVariantHotspotEvidence create(@NotNull final VariantHotspot hotspot) {
    return ModifiableVariantHotspotEvidence.create()
            .from(hotspot)
            .setRef(hotspot.ref())
            .setAlt(hotspot.alt())
            .setAltQuality(0)
            .setAltSupport(0)
            .setRefSupport(0)
            .setRefQuality(0)
            .setIndelSupport(0)
            .setReadDepth(0)
            .setAltMapQuality(0)
            .setAltMinQuality(0)
            .setAltDistanceFromRecordStart(0)
            .setAltMinDistanceFromAlignment(0)
            .setSubprimeReadDepth(0)
            .setReadContext(Strings.EMPTY)
            .setReadContextCount(0)
            .setReadContextCountOther(0);
}
 
Example 11
private void renderMicrosatelliteStabilityCharacteristic(@NotNull Document reportDocument) {
    boolean hasReliablePurity = patientReport.hasReliablePurity();
    double microSatelliteStability = patientReport.microsatelliteIndelsPerMb();
    String microSatelliteStabilityString = hasReliablePurity ? patientReport.microsatelliteStatus().display() + " "
            + DOUBLE_DECIMAL_FORMAT.format(patientReport.microsatelliteIndelsPerMb()) : DataUtil.NA_STRING;

    BarChart satelliteChart =
            new BarChart(microSatelliteStability, MicroSatelliteStatus.RANGE_MIN, MicroSatelliteStatus.RANGE_MAX, "MSS", "MSI", false);
    satelliteChart.enabled(hasReliablePurity);
    satelliteChart.scale(InlineBarChart.LOG10_SCALE);
    satelliteChart.setTickMarks(new double[] { MicroSatelliteStatus.RANGE_MIN, 10, MicroSatelliteStatus.RANGE_MAX },
            DOUBLE_DECIMAL_FORMAT);
    satelliteChart.enableUndershoot(NO_DECIMAL_FORMAT.format(0));
    satelliteChart.enableOvershoot(">" + NO_DECIMAL_FORMAT.format(satelliteChart.max()));
    satelliteChart.setIndicator(MicroSatelliteStatus.THRESHOLD,
            "Microsatellite \ninstability (" + DOUBLE_DECIMAL_FORMAT.format(MicroSatelliteStatus.THRESHOLD) + ")");
    reportDocument.add(createCharacteristicDiv("Microsatellite status",
            microSatelliteStabilityString,
            "The microsatellite stability score represents the number of somatic inserts and deletes in "
                    + "(short) repeat sections across the whole genome of the tumor per Mb. This metric can be "
                    + "considered as a good marker for instability in microsatellite repeat regions. Tumors with a "
                    + "score greater than 4.0 are considered microsatellite unstable (MSI).",
            satelliteChart,
            Strings.EMPTY,
            false));
}
 
Example 12
@NotNull
private static SampleReport createSkinMelanomaSampleReport(@NotNull String sample) {
    SampleMetadata sampleMetadata = ImmutableSampleMetadata.builder()
            .refSampleId(Strings.EMPTY)
            .refSampleBarcode("FR12123488")
            .tumorSampleId(sample)
            .tumorSampleBarcode("FR12345678")
            .build();

    return ImmutableSampleReport.builder()
            .sampleMetadata(sampleMetadata)
            .patientTumorLocation(ImmutablePatientTumorLocation.of(Strings.EMPTY, "Skin", "Melanoma"))
            .refArrivalDate(LocalDate.parse("01-Jan-2020", DATE_FORMATTER))
            .tumorArrivalDate(LocalDate.parse("05-Jan-2020", DATE_FORMATTER))
            .shallowSeqPurityString(Lims.NOT_PERFORMED_STRING)
            .labProcedures("PREP013V23-QC037V20-SEQ008V25")
            .cohort("TEST")
            .projectName("TEST-001-002")
            .submissionId("SUBM")
            .hospitalContactData(createTestHospitalContactData())
            .hospitalPatientId("HOSP1")
            .hospitalPathologySampleId("PA1")
            .build();
}
 
Example 13
Source Project: zstack   Source File: KVMHost.java    License: Apache License 2.0 6 votes vote down vote up
private void handle(GetKVMHostDownloadCredentialMsg msg) {
    final GetKVMHostDownloadCredentialReply reply = new GetKVMHostDownloadCredentialReply();

    String key = asf.getPrivateKey();

    String hostname = null;
    if (Strings.isNotEmpty(msg.getDataNetworkCidr())) {
        String dataNetworkAddress = getDataNetworkAddress(self.getUuid(), msg.getDataNetworkCidr());

        if (dataNetworkAddress != null) {
            hostname = dataNetworkAddress;
        }
    }

    reply.setHostname(hostname == null ? getSelf().getManagementIp() : hostname);
    reply.setUsername(getSelf().getUsername());
    reply.setSshPort(getSelf().getPort());
    reply.setSshKey(key);
    bus.reply(msg, reply);
}
 
Example 14
@NotNull
public static ImmutableGermlineVariant.Builder createTestGermlineVariantBuilder() {
    return ImmutableGermlineVariant.builder()
            .passFilter(true)
            .gene(Strings.EMPTY)
            .ref(Strings.EMPTY)
            .alt(Strings.EMPTY)
            .codingEffect(CodingEffect.UNDEFINED)
            .chromosome(Strings.EMPTY)
            .position(0)
            .hgvsCodingImpact(Strings.EMPTY)
            .hgvsProteinImpact(Strings.EMPTY)
            .totalReadCount(0)
            .alleleReadCount(0)
            .adjustedCopyNumber(0)
            .adjustedVAF(0)
            .biallelic(false);
}
 
Example 15
@NotNull
public static ImmutableReportableVariant.Builder createTestReportableVariantBuilder() {
    return ImmutableReportableVariant.builder()
            .gene(Strings.EMPTY)
            .position(0)
            .chromosome(Strings.EMPTY)
            .ref(Strings.EMPTY)
            .alt(Strings.EMPTY)
            .canonicalCodingEffect(CodingEffect.UNDEFINED)
            .canonicalHgvsCodingImpact(Strings.EMPTY)
            .canonicalHgvsProteinImpact(Strings.EMPTY)
            .gDNA(Strings.EMPTY)
            .hotspot(Hotspot.HOTSPOT)
            .clonalLikelihood(1D)
            .alleleReadCount(0)
            .totalReadCount(0)
            .allelePloidy(0D)
            .totalPloidy(0)
            .biallelic(false)
            .driverCategory(DriverCategory.ONCO)
            .driverLikelihood(0D)
            .notifyClinicalGeneticist(false);
}
 
Example 16
@NotNull
private static List<ClinicalTrial> createCOLO829ClinicalTrials() {
    List<ClinicalTrial> trials = Lists.newArrayList();
    ImmutableClinicalTrial.Builder iclusionBuilder =
            ImmutableClinicalTrial.builder().cancerType(Strings.EMPTY).isOnLabel(true).source(ActionabilitySource.ICLUSION);

    trials.add(iclusionBuilder.event("BRAF p.Val600Glu")
            .scope(EvidenceScope.GENE_LEVEL)
            .acronym("CLXH254X2101")
            .reference("EXT10453 (NL55506.078.15)")
            .build());
    trials.add(iclusionBuilder.event("BRAF p.Val600Glu")
            .scope(EvidenceScope.SPECIFIC)
            .acronym("COWBOY")
            .reference("EXT12301 (NL71732.091.19)")
            .build());
    trials.add(iclusionBuilder.event("BRAF p.Val600Glu")
            .scope(EvidenceScope.GENE_LEVEL)
            .acronym("DRUP")
            .reference("EXT10299 (NL54757.031.16)")
            .build());
    trials.add(iclusionBuilder.event("BRAF p.Val600Glu")
            .scope(EvidenceScope.GENE_LEVEL)
            .acronym("EBIN (EORTC-1612-MG)")
            .reference("EXT11284 (NL67202.031.18)")
            .build());
    trials.add(iclusionBuilder.event("BRAF p.Val600Glu")
            .scope(EvidenceScope.GENE_LEVEL)
            .acronym("POLARIS")
            .reference("EXT11388 (NL69569.028.19)")
            .build());
    trials.add(iclusionBuilder.event("CDKN2A p.Ala68fs")
            .scope(EvidenceScope.GENE_LEVEL)
            .acronym("DRUP")
            .reference("EXT10299 (NL54757.031.16)")
            .build());

    return trials;
}
 
Example 17
Source Project: logging-log4j2   Source File: LoggerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void mdc() {

    MDC.put("TestYear", "2010");
    logger.debug("Debug message");
    verify("List", "o.a.l.s.LoggerTest Debug message MDC{TestYear=2010}" + Strings.LINE_SEPARATOR);
    MDC.clear();
    logger.debug("Debug message");
    verify("List", "o.a.l.s.LoggerTest Debug message MDC{}" + Strings.LINE_SEPARATOR);
}
 
Example 18
Source Project: we-cmdb   Source File: OperationLogAspect.java    License: Apache License 2.0 5 votes vote down vote up
private String getRequestUrl(){
    HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest();
    if(request == null){
        return Strings.EMPTY;
    }

    return request.getRequestURL().toString();
}
 
Example 19
Source Project: moon-api-gateway   Source File: ExceptionAdvice.java    License: MIT License 5 votes vote down vote up
@ExceptionHandler(GeneralException.class)
public ResponseEntity generalException(GeneralException e, HttpServletRequest request) {
    log.error("{}", getStackTrace(e));
    ExceptionType exceptionType = e.getExceptionType();
    setHttpResponseErrorCode(request, exceptionType.getCode());
    String message = messageManager.getProperty(exceptionType.getCode());
    if (Strings.isNotEmpty(e.getMessage())) message = String.format("%s %s", message, e.getMessage());
    CommonResponseEntity response = CommonResponseEntity.generateException(e.getExceptionType().getCode(), message);
    return HttpHelper.newResponseEntityWithId(e.getExceptionType().getHttpStatus(), response);
}
 
Example 20
Source Project: we-cmdb   Source File: OperationLogAspect.java    License: Apache License 2.0 5 votes vote down vote up
private List<String> getGuidFromMapList(List value) {
    List<String> guids;
    guids = (List<String>) value.stream().map(e -> {
        if (e instanceof Map) {
            return (String) ((Map) e).get("guid");
        } else {
            return Strings.EMPTY;
        }
    }).collect(Collectors.toList());
    return guids;
}
 
Example 21
Source Project: zstack   Source File: LogSafeGson.java    License: Apache License 2.0 5 votes vote down vote up
public static Map<String, String> getValuesToMask(Object o) {
    Map<String, String> results = new HashMap<>();
    maskFields.getOrDefault(o.getClass(), Collections.emptySet()).forEach(f -> {
        Object obj = f.getValue(o);
        if (obj instanceof Collection) {
            ((Collection<?>) obj).forEach(v -> results.put(v.toString(), f.getMaskedValue(v.toString())));
        } else if (obj != null) {
            results.put(obj.toString(), f.getMaskedValue(obj.toString()));
        }
    });

    autoFields.getOrDefault(o.getClass(), Collections.emptySet()).forEach(f -> {
        Object si = f.getValue(o);
        if (mayHasSensitiveInfo(si)) {
            results.putAll(getValuesToMask(si));
        } else if (si instanceof Collection) {
            ((Collection<?>) si).forEach(v -> {
                if (mayHasSensitiveInfo(v)) {
                    results.put(v.toString(), f.getMaskedValue(v.toString()));
                }
            });
        }
    });

    results.remove(Strings.EMPTY);
    return results;
}
 
Example 22
Source Project: hmftools   Source File: IndexedBasesTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testBothCentreMatches() {
    ReadContext victim1 = new ReadContext(Strings.EMPTY, 1000, 4, 4, 4, 4, "AAAATGGGG".getBytes(), Strings.EMPTY);
    ReadContext victim2 = new ReadContext(Strings.EMPTY, 1005, 5, 5, 5, 4,     "TGGGGACCCC".getBytes(), Strings.EMPTY);
    assertFalse(victim1.phased(-5, victim2));
    assertFalse(victim2.phased(5, victim1));
}
 
Example 23
Source Project: oxAuth   Source File: AuthorizeAction.java    License: MIT License 5 votes vote down vote up
public String getBindingMessage() {
    String bindingMessage = null;

    if (Strings.isNotBlank(getAuthReqId())) {
        final CibaRequestCacheControl cibaRequestCacheControl = cibaRequestService.getCibaRequest(authReqId);

        if (cibaRequestCacheControl != null) {
            bindingMessage = cibaRequestCacheControl.getBindingMessage();
        }
    }

    return bindingMessage;
}
 
Example 24
Source Project: hmftools   Source File: IndexedBasesTest.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Test
public void testPhasedMNV() {
    ReadContext victim1 = new ReadContext(Strings.EMPTY, 1000, 4, 4, 4, 4, "GATCTTGAT".getBytes(), Strings.EMPTY);
    ReadContext victim2 = new ReadContext(Strings.EMPTY, 1001, 5, 5, 5, 4, "GATCTTGATC".getBytes(), Strings.EMPTY);

    assertTrue(victim1.phased(-1, victim2));
    assertTrue(victim2.phased(1, victim1));
}
 
Example 25
Source Project: logging-log4j2   Source File: ThrowableProxyRenderer.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Formats the stack trace including packaging information.
 *
 * @param src            ThrowableProxy instance to format
 * @param sb             Destination.
 * @param ignorePackages List of packages to be ignored in the trace.
 * @param textRenderer   The message renderer.
 * @param suffix         Append this to the end of each stack frame.
 * @param lineSeparator  The end-of-line separator.
 */
static void formatExtendedStackTraceTo(ThrowableProxy src, final StringBuilder sb, final List<String> ignorePackages, final TextRenderer textRenderer, final String suffix, final String lineSeparator) {
    textRenderer.render(src.getName(), sb, "Name");
    textRenderer.render(": ", sb, "NameMessageSeparator");
    textRenderer.render(src.getMessage(), sb, "Message");
    renderSuffix(suffix, sb, textRenderer);
    textRenderer.render(lineSeparator, sb, "Text");
    final StackTraceElement[] causedTrace = src.getThrowable() != null ? src.getThrowable().getStackTrace() : null;
    formatElements(sb, Strings.EMPTY, 0, causedTrace, src.getExtendedStackTrace(), ignorePackages, textRenderer, suffix, lineSeparator);
    formatSuppressed(sb, TAB, src.getSuppressedProxies(), ignorePackages, textRenderer, suffix, lineSeparator);
    formatCause(sb, Strings.EMPTY, src.getCauseProxy(), ignorePackages, textRenderer, suffix, lineSeparator);
}
 
Example 26
Source Project: hmftools   Source File: KataegisEnrichment.java    License: GNU General Public License v3.0 5 votes vote down vote up
private static boolean isForwardCandidate(@NotNull final VariantContext context) {
    final boolean altMatch =
            context.getAlternateAlleles().stream().anyMatch(x -> x.getBaseString().equals("T") || x.getBaseString().equals("G"));

    final String triContext = context.getAttributeAsString(SomaticRefContextEnrichment.TRINUCLEOTIDE_FLAG, Strings.EMPTY);
    final boolean triMatch = triContext.startsWith("TC");

    return isNotFiltered(context) && triMatch && altMatch;
}
 
Example 27
Source Project: sofa-common-tools   Source File: LogEnvUtilsTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void test() {
    Assert.assertEquals(".dev", LogEnvUtils.getLogConfEnvSuffix("app"));
    Assert.assertEquals(".test", LogEnvUtils.getLogConfEnvSuffix("app2"));
    Assert.assertEquals(Strings.EMPTY, LogEnvUtils.getLogConfEnvSuffix("app3"));
    Assert.assertEquals(Strings.EMPTY, LogEnvUtils.getLogConfEnvSuffix("app4"));
}
 
Example 28
Source Project: logging-log4j2   Source File: LoggerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void basicFlow() {
    xlogger.entry();
    verify("List", "o.a.l.s.LoggerTest entry MDC{}" + Strings.LINE_SEPARATOR);
    xlogger.exit();
    verify("List", "o.a.l.s.LoggerTest exit MDC{}" + Strings.LINE_SEPARATOR);
}
 
Example 29
Source Project: logging-log4j2   Source File: InstantAttributeConverter.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public Instant convertToEntityAttribute(final String s) {
    if (Strings.isEmpty(s)) {
        return null;
    }

    int pos = s.indexOf(",");
    long epochSecond = Long.parseLong(s.substring(0, pos));
    int nanos = Integer.parseInt(s.substring(pos + 1, s.length()));

    MutableInstant result = new MutableInstant();
    result.initFromEpochSecond(epochSecond, nanos);
    return result;
}
 
Example 30
Source Project: logging-log4j2   Source File: LoggerTest.java    License: Apache License 2.0 5 votes vote down vote up
@Test
public void debugNoParms() {
    logger.debug("Debug message {}");
    verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Strings.LINE_SEPARATOR);
    logger.debug("Debug message {}", (Object[]) null);
    verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Strings.LINE_SEPARATOR);
    ((LocationAwareLogger)logger).log(null, Log4jLogger.class.getName(), LocationAwareLogger.DEBUG_INT,
        "Debug message {}", null, null);
    verify("List", "o.a.l.s.LoggerTest Debug message {} MDC{}" + Strings.LINE_SEPARATOR);
}