-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix test cases for pull request #92:
Parse key=values even with whitespace around the equals sign. Prevent ArrayOutOfBounds exception. add TestAppender class to check for logged statements
- Loading branch information
Kay Roepke
committed
Oct 14, 2012
1 parent
a7553e9
commit 80e7b3a
Showing
2 changed files
with
65 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/** | ||
* Copyright 2012 Kay Roepke <[email protected]> | ||
* | ||
* This file is part of Graylog2. | ||
* | ||
* Graylog2 is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* Graylog2 is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with Graylog2. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
package org.graylog2; | ||
|
||
import com.google.common.collect.ImmutableList; | ||
import com.google.common.collect.Lists; | ||
import org.apache.log4j.AppenderSkeleton; | ||
import org.apache.log4j.spi.LoggingEvent; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* Appender which buffers all log statements, useful for testing that some class under test did actually log information. | ||
*/ | ||
public class TestAppender extends AppenderSkeleton { | ||
|
||
private final List<LoggingEvent> events = Lists.newArrayList(); | ||
|
||
@Override | ||
protected void append(LoggingEvent event) { | ||
events.add(event); | ||
} | ||
|
||
@Override | ||
public void close() { | ||
events.clear(); | ||
} | ||
|
||
@Override | ||
public boolean requiresLayout() { | ||
return false; | ||
} | ||
|
||
public List<LoggingEvent> getEvents() { | ||
return ImmutableList.copyOf(events); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters