|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| This report was generated with an evaluation server license. Purchase Clover or configure your license. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| CombinedFormatLogEntryFormatTest | Line # 41 | 40 | 0% | 16 | 0 | 100% |
1.0
|
||||||||||||||||||||||||||||||||||||||||||||||||||||
| (30) | |||
| Result | |||
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentNotSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererNotSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostNotSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRefererNotSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRequestSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRequestSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenHostNotSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRequestSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenRequestSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentSpecified
|
1 PASS | |
|
0.071428575
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testParseWhenAgentNotSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentNotSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRequestSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRequestSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostNotSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererNotSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererNotSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRequestSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRequestSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostNotSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenHostSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testDateIsCorrectlyParsed
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testDateIsCorrectlyParsed
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentNotSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenAgentNotSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererSpecified
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testFormatWhenRefererSpecified
|
1 PASS | |
|
0.05357143
|
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testDateIsCorrectlyParsed
net.sourceforge.pebble.logging.CombinedFormatLogEntryFormatTest.testDateIsCorrectlyParsed
|
1 PASS | |
| 1 | /* | |
| 2 | * Copyright (c) 2003-2006, Simon Brown | |
| 3 | * All rights reserved. | |
| 4 | * | |
| 5 | * Redistribution and use in source and binary forms, with or without | |
| 6 | * modification, are permitted provided that the following conditions are met: | |
| 7 | * | |
| 8 | * - Redistributions of source code must retain the above copyright | |
| 9 | * notice, this list of conditions and the following disclaimer. | |
| 10 | * | |
| 11 | * - Redistributions in binary form must reproduce the above copyright | |
| 12 | * notice, this list of conditions and the following disclaimer in | |
| 13 | * the documentation and/or other materials provided with the | |
| 14 | * distribution. | |
| 15 | * | |
| 16 | * - Neither the name of Pebble nor the names of its contributors may | |
| 17 | * be used to endorse or promote products derived from this software | |
| 18 | * without specific prior written permission. | |
| 19 | * | |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | |
| 21 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
| 22 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
| 23 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | |
| 24 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
| 25 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
| 26 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | |
| 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | |
| 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
| 29 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |
| 30 | * POSSIBILITY OF SUCH DAMAGE. | |
| 31 | */ | |
| 32 | package net.sourceforge.pebble.logging; | |
| 33 | ||
| 34 | import net.sourceforge.pebble.domain.SingleBlogTestCase; | |
| 35 | ||
| 36 | /** | |
| 37 | * Tests for the CombinedFormatLogEntryFormat class. | |
| 38 | * | |
| 39 | * @author Simon Brown | |
| 40 | */ | |
| 41 | public class CombinedFormatLogEntryFormatTest extends SingleBlogTestCase { | |
| 42 | ||
| 43 | private CombinedFormatLogEntryFormat format; | |
| 44 | private LogEntry logEntry; | |
| 45 | private LogEntry parsedLogEntry; | |
| 46 | ||
| 47 | 30 |
protected void setUp() throws Exception { |
| 48 | 30 | super.setUp(); |
| 49 | ||
| 50 | 30 | this.format = new CombinedFormatLogEntryFormat(blog); |
| 51 | 30 | this.logEntry = new LogEntry(); |
| 52 | } | |
| 53 | ||
| 54 | 2 |
public void testFormatWhenHostNotSpecified() { |
| 55 | 2 | logEntry.setHost(null); |
| 56 | 2 | assertEquals("- - - " + format.dateFormatter.format(logEntry.getDate()) + " \"\" 200 - - -", format.format(logEntry)); |
| 57 | } | |
| 58 | ||
| 59 | 2 |
public void testFormatWhenHostSpecified() { |
| 60 | 2 | logEntry.setHost("127.0.0.1"); |
| 61 | 2 | assertEquals("127.0.0.1 - - " + format.dateFormatter.format(logEntry.getDate()) + " \"\" 200 - - -", format.format(logEntry)); |
| 62 | } | |
| 63 | ||
| 64 | 2 |
public void testFormatWhenRequestSpecified() { |
| 65 | 2 | logEntry.setRequest("GET /blog/index.jsp"); |
| 66 | 2 | assertEquals("- - - " + format.dateFormatter.format(logEntry.getDate()) + " \"GET /blog/index.jsp\" 200 - - -", format.format(logEntry)); |
| 67 | } | |
| 68 | ||
| 69 | 2 |
public void testFormatWhenRefererNotSpecified() { |
| 70 | 2 | logEntry.setReferer(null); |
| 71 | 2 | assertEquals("- - - " + format.dateFormatter.format(logEntry.getDate()) + " \"\" 200 - - -", format.format(logEntry)); |
| 72 | } | |
| 73 | ||
| 74 | 2 |
public void testFormatWhenRefererSpecified() { |
| 75 | 2 | logEntry.setReferer("http://www.google.com"); |
| 76 | 2 | assertEquals("- - - " + format.dateFormatter.format(logEntry.getDate()) + " \"\" 200 - \"http://www.google.com\" -", format.format(logEntry)); |
| 77 | } | |
| 78 | ||
| 79 | 2 |
public void testFormatWhenAgentNotSpecified() { |
| 80 | 2 | logEntry.setAgent(null); |
| 81 | 2 | assertEquals("- - - " + format.dateFormatter.format(logEntry.getDate()) + " \"\" 200 - - -", format.format(logEntry)); |
| 82 | } | |
| 83 | ||
| 84 | 2 |
public void testFormatWhenAgentSpecified() { |
| 85 | 2 | logEntry.setAgent("Some user agent"); |
| 86 | 2 | assertEquals("- - - " + format.dateFormatter.format(logEntry.getDate()) + " \"\" 200 - - \"Some user agent\"", format.format(logEntry)); |
| 87 | } | |
| 88 | ||
| 89 | 2 |
public void testParseWhenHostNotSpecified() { |
| 90 | 2 | logEntry.setHost(null); |
| 91 | 2 | parsedLogEntry = format.parse(format.format(logEntry)); |
| 92 | 2 | assertNull(parsedLogEntry.getHost()); |
| 93 | } | |
| 94 | ||
| 95 | 2 |
public void testParseWhenHostSpecified() { |
| 96 | 2 | logEntry.setHost("127.0.0.1"); |
| 97 | 2 | parsedLogEntry = format.parse(format.format(logEntry)); |
| 98 | 2 | assertEquals("127.0.0.1", parsedLogEntry.getHost()); |
| 99 | } | |
| 100 | ||
| 101 | 2 |
public void testDateIsCorrectlyParsed() { |
| 102 | 2 | parsedLogEntry = format.parse(format.format(logEntry)); |
| 103 | 2 | assertTrue(logEntry.getDate().getTime() - parsedLogEntry.getDate().getTime() <= 1000); |
| 104 | } | |
| 105 | ||
| 106 | 2 |
public void testParseWhenRequestSpecified() { |
| 107 | 2 | logEntry.setRequest("GET /blog/index.jsp"); |
| 108 | 2 | parsedLogEntry = format.parse(format.format(logEntry)); |
| 109 | 2 | assertEquals("GET /blog/index.jsp", parsedLogEntry.getRequest()); |
| 110 | } | |
| 111 | ||
| 112 | 2 |
public void testParseWhenRefererNotSpecified() { |
| 113 | 2 | logEntry.setReferer(null); |
| 114 | 2 | parsedLogEntry = format.parse(format.format(logEntry)); |
| 115 | 2 | assertNull(parsedLogEntry.getReferer()); |
| 116 | } | |
| 117 | ||
| 118 | 2 |
public void testParseWhenRefererSpecified() { |
| 119 | 2 | logEntry.setReferer("http://www.google.com"); |
| 120 | 2 | parsedLogEntry = format.parse(format.format(logEntry)); |
| 121 | 2 | assertEquals("http://www.google.com", parsedLogEntry.getReferer()); |
| 122 | } | |
| 123 | ||
| 124 | 2 |
public void testParseWhenAgentNotSpecified() { |
| 125 | 2 | logEntry.setAgent(null); |
| 126 | 2 | parsedLogEntry = format.parse(format.format(logEntry)); |
| 127 | 2 | assertNull(parsedLogEntry.getAgent()); |
| 128 | } | |
| 129 | ||
| 130 | 2 |
public void testParseWhenAgentSpecified() { |
| 131 | 2 | logEntry.setAgent("Some user agent"); |
| 132 | 2 | parsedLogEntry = format.parse(format.format(logEntry)); |
| 133 | 2 | assertEquals("Some user agent", parsedLogEntry.getAgent()); |
| 134 | } | |
| 135 | ||
| 136 | } | |
|
||||||||||||