Search in sources :

Example 1 with AppenderBase

use of ch.qos.logback.core.AppenderBase in project jackrabbit-oak by apache.

the class RepositoryTest method largeMultiValueProperty.

@Test
public void largeMultiValueProperty() throws Exception {
    final List<String> logMessages = Lists.newArrayList();
    Appender<ILoggingEvent> a = new AppenderBase<ILoggingEvent>() {

        @Override
        protected void append(ILoggingEvent e) {
            if (Level.WARN.isGreaterOrEqual(e.getLevel())) {
                logMessages.add(e.getFormattedMessage());
            }
        }
    };
    a.start();
    rootLogger().addAppender(a);
    Session session = getAdminSession();
    Node node = session.getRootNode().addNode("largeMultiValueProperty", "nt:unstructured");
    //ItemImpl.MV_PROPERTY_WARN_THRESHOLD - 1000
    String[] largeArray = new String[1000 + 1];
    Arrays.fill(largeArray, "x");
    Property p = node.setProperty("fooProp", largeArray);
    Property p2 = node.setProperty("barProp", new String[] { "x" });
    p2.setValue(largeArray);
    session.save();
    rootLogger().detachAppender(a);
    a.stop();
    assertTrue(logMessages.size() >= 2);
    assertThat("Warn log message must contains a reference to the large array property path", logMessages.toString(), containsString(p.getPath()));
    assertThat("Warn log message must contains a reference to the large array property path", logMessages.toString(), containsString(p2.getPath()));
}
Also used : AppenderBase(ch.qos.logback.core.AppenderBase) JackrabbitNode(org.apache.jackrabbit.api.JackrabbitNode) Node(javax.jcr.Node) JUnitMatchers.containsString(org.junit.matchers.JUnitMatchers.containsString) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) Property(javax.jcr.Property) Session(javax.jcr.Session) Test(org.junit.Test)

Aggregations

ILoggingEvent (ch.qos.logback.classic.spi.ILoggingEvent)1 AppenderBase (ch.qos.logback.core.AppenderBase)1 Node (javax.jcr.Node)1 Property (javax.jcr.Property)1 Session (javax.jcr.Session)1 JackrabbitNode (org.apache.jackrabbit.api.JackrabbitNode)1 Test (org.junit.Test)1 JUnitMatchers.containsString (org.junit.matchers.JUnitMatchers.containsString)1