001/**
002 * Logback: the reliable, generic, fast and flexible logging framework.
003 * Copyright (C) 1999-2015, QOS.ch. All rights reserved.
004 *
005 * This program and the accompanying materials are dual-licensed under
006 * either the terms of the Eclipse Public License v1.0 as published by
007 * the Eclipse Foundation
008 *
009 *   or (per the licensee's choosing)
010 *
011 * under the terms of the GNU Lesser General Public License version 2.1
012 * as published by the Free Software Foundation.
013 */
014package ch.qos.logback.core.read;
015
016import org.junit.Before;
017import org.junit.Test;
018
019import static org.junit.Assert.assertEquals;
020
021public class CyclicBufferAppenderTest {
022
023    private CyclicBufferAppender<String> cyclicBufferAppender;
024
025    @Before
026    public void before() {
027        cyclicBufferAppender = new CyclicBufferAppender<String>();
028        cyclicBufferAppender.start();
029    }
030
031    @Test
032    public void reset() {
033
034        cyclicBufferAppender.append("foobar");
035        assertEquals(1, cyclicBufferAppender.getLength());
036        cyclicBufferAppender.reset();
037        assertEquals(0, cyclicBufferAppender.getLength());
038    }
039
040    @Test
041    public void genericGet() {
042        cyclicBufferAppender.append("Some string");
043        // get() now has type information, assigning to String should work without cast.
044        String foo = cyclicBufferAppender.get(0);
045        assertEquals("Some string", foo);
046    }
047
048}