merge from master
This commit is contained in:
commit
94124f7412
|
@ -20,7 +20,7 @@ target/
|
|||
.idea/
|
||||
|
||||
# Mac filesystem dust
|
||||
/.DS_Store
|
||||
.DS_Store
|
||||
|
||||
# pmd
|
||||
.pmdruleset
|
||||
|
|
15
VERSION.txt
15
VERSION.txt
|
@ -16,6 +16,21 @@ jetty-8.0.4.v20111024 - 24 October 2011
|
|||
+ 361655 ExecutorThreadPool.isLowOnThreads() returns wrong value.
|
||||
+ JETTY-1444 start threadpool before selector manager
|
||||
|
||||
jetty-7.5.4.v20111024 - 24 October 2011
|
||||
+ 358263 JDBCSessionIdManager add setDatasource(DataSource) method
|
||||
+ 358649 Replace existing StdErrLog system properties for DEBUG/IGNORED with
|
||||
LEVEL instead.
|
||||
+ 360836 Accept parameters with bad UTF-8. Use replacement character
|
||||
+ 360912 CrossOriginFilter does not send Access-Control-Allow-Origin on
|
||||
responses. 355103 Make allowCredentials default to true in
|
||||
CrossOriginFilter.
|
||||
+ 360938 Connections closed after a while.
|
||||
+ 361319 Log initialization does not catch correct exceptions on all jvms
|
||||
+ 361325 359292 Allow KeyStore to be set
|
||||
+ 361456 release timer task on connection failed
|
||||
+ 361655 ExecutorThreadPool.isLowOnThreads() returns wrong value.
|
||||
+ JETTY-1444 start threadpool before selector manager
|
||||
|
||||
jetty-8.0.3.v20111011 - 11 October 2011
|
||||
+ 348978 migrate jetty-http-spi
|
||||
+ 358649 StdErrLog system properties for package/class logging LEVEL.
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<version>8.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.eclipse.jetty.aggregate</groupId>
|
||||
<artifactId>jetty-plus</artifactId>
|
||||
<name>Jetty :: Aggregate :: Plus Server</name>
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<version>8.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.eclipse.jetty.aggregate</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<name>Jetty :: Aggregate :: HTTP Server</name>
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<version>8.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.eclipse.jetty.aggregate</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<name>Jetty :: Aggregate :: Servlet Server</name>
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
<version>8.0.5-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.eclipse.jetty.aggregate</groupId>
|
||||
<artifactId>jetty-webapp</artifactId>
|
||||
<name>Jetty :: Aggregate :: WebApp Server</name>
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.eclipse.org/configure.dtd">
|
||||
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">
|
||||
|
||||
<!-- =============================================================== -->
|
||||
<!-- Configure the Jetty Server -->
|
||||
|
@ -85,7 +85,7 @@
|
|||
<Array type="org.eclipse.jetty.rewrite.handler.Rule">
|
||||
|
||||
<Item>
|
||||
<New id="" class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
|
||||
<New id="rewrite" class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
|
||||
<Set name="pattern">/*</Set>
|
||||
<Set name="replacement">/test</Set>
|
||||
</New>
|
||||
|
|
|
@ -43,15 +43,18 @@ public class StdErrLog implements Logger
|
|||
System.getProperty("org.eclipse.jetty.util.log.stderr.SOURCE","false")));
|
||||
private final static boolean __long = Boolean.parseBoolean(System.getProperty("org.eclipse.jetty.util.log.stderr.LONG","false"));
|
||||
|
||||
/**
|
||||
* Tracking for child loggers only.
|
||||
*/
|
||||
private final static ConcurrentMap<String, StdErrLog> __loggers = new ConcurrentHashMap<String, StdErrLog>();
|
||||
|
||||
static
|
||||
{
|
||||
String deprecatedProperites[] =
|
||||
String deprecatedProperties[] =
|
||||
{ "DEBUG", "org.eclipse.jetty.util.log.DEBUG", "org.eclipse.jetty.util.log.stderr.DEBUG" };
|
||||
|
||||
// Toss a message to users about deprecated system properties
|
||||
for (String deprecatedProp : deprecatedProperites)
|
||||
for (String deprecatedProp : deprecatedProperties)
|
||||
{
|
||||
if (System.getProperty(deprecatedProp) != null)
|
||||
{
|
||||
|
@ -91,14 +94,19 @@ public class StdErrLog implements Logger
|
|||
}
|
||||
|
||||
public StdErrLog(String name)
|
||||
{
|
||||
this(name,System.getProperties());
|
||||
}
|
||||
|
||||
public StdErrLog(String name, Properties props)
|
||||
{
|
||||
this._name = name == null?"":name;
|
||||
this._abbrevname = condensePackageString(this._name);
|
||||
this._level = getLoggingLevel(System.getProperties(),this._name);
|
||||
this._level = getLoggingLevel(props,this._name);
|
||||
|
||||
try
|
||||
{
|
||||
_source = Boolean.parseBoolean(System.getProperty(_name + ".SOURCE",Boolean.toString(_source)));
|
||||
_source = Boolean.parseBoolean(props.getProperty(_name + ".SOURCE",Boolean.toString(_source)));
|
||||
}
|
||||
catch (AccessControlException ace)
|
||||
{
|
||||
|
@ -126,34 +134,29 @@ public class StdErrLog implements Logger
|
|||
{
|
||||
String levelStr = props.getProperty(nameSegment + ".LEVEL");
|
||||
// System.err.printf("[StdErrLog.CONFIG] Checking for property [%s.LEVEL] = %s%n",nameSegment,levelStr);
|
||||
if (levelStr == null)
|
||||
int level = getLevelId(nameSegment + ".LEVEL",levelStr);
|
||||
if (level != (-1))
|
||||
{
|
||||
// Trim and try again.
|
||||
int idx = nameSegment.lastIndexOf('.');
|
||||
if (idx >= 0)
|
||||
{
|
||||
nameSegment = nameSegment.substring(0,idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
nameSegment = null;
|
||||
}
|
||||
return level;
|
||||
}
|
||||
|
||||
// Trim and try again.
|
||||
int idx = nameSegment.lastIndexOf('.');
|
||||
if (idx >= 0)
|
||||
{
|
||||
nameSegment = nameSegment.substring(0,idx);
|
||||
}
|
||||
else
|
||||
{
|
||||
int level = getLevelId(levelStr);
|
||||
if (level != (-1))
|
||||
{
|
||||
return level;
|
||||
}
|
||||
nameSegment = null;
|
||||
}
|
||||
}
|
||||
|
||||
// Default Logging Level
|
||||
return getLevelId(props.getProperty("log.LEVEL", "INFO"));
|
||||
return getLevelId("log.LEVEL",props.getProperty("log.LEVEL","INFO"));
|
||||
}
|
||||
|
||||
protected static int getLevelId(String levelName)
|
||||
|
||||
protected static int getLevelId(String levelSegment, String levelName)
|
||||
{
|
||||
if (levelName == null)
|
||||
{
|
||||
|
@ -177,7 +180,7 @@ public class StdErrLog implements Logger
|
|||
return LEVEL_WARN;
|
||||
}
|
||||
|
||||
System.err.println("Unknown StdErrLog level [" + levelStr + "], expecting only [ALL, DEBUG, INFO, WARN] as values.");
|
||||
System.err.println("Unknown StdErrLog level [" + levelSegment + "]=[" + levelStr + "], expecting only [ALL, DEBUG, INFO, WARN] as values.");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -312,7 +315,7 @@ public class StdErrLog implements Logger
|
|||
|
||||
public boolean isDebugEnabled()
|
||||
{
|
||||
return (_level >= LEVEL_DEBUG);
|
||||
return (_level <= LEVEL_DEBUG);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -543,16 +546,53 @@ public class StdErrLog implements Logger
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A more robust form of name blank test. Will return true for null names, and names that have only whitespace
|
||||
*
|
||||
* @param name
|
||||
* the name to test
|
||||
* @return true for null or blank name, false if any non-whitespace character is found.
|
||||
*/
|
||||
private static boolean isBlank(String name)
|
||||
{
|
||||
if (name == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
int size = name.length();
|
||||
char c;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
c = name.charAt(i);
|
||||
if (!Character.isWhitespace(c))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Child Logger relative to this Logger.
|
||||
*
|
||||
* @param name
|
||||
* the child name
|
||||
* @return the appropriate child logger (if name specified results in a new unique child)
|
||||
*/
|
||||
public Logger getLogger(String name)
|
||||
{
|
||||
String fullname = _name == null || _name.length() == 0?name:_name + "." + name;
|
||||
|
||||
if ((name == null && this._name == null) || fullname.equals(_name))
|
||||
if (isBlank(name))
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
StdErrLog logger = __loggers.get(name);
|
||||
String fullname = name;
|
||||
if (!isBlank(_name))
|
||||
{
|
||||
fullname = _name + "." + name;
|
||||
}
|
||||
|
||||
StdErrLog logger = __loggers.get(fullname);
|
||||
if (logger == null)
|
||||
{
|
||||
StdErrLog sel = new StdErrLog(fullname);
|
||||
|
|
|
@ -78,6 +78,30 @@ public class StdErrLogTest
|
|||
Assert.assertEquals("Default Logging Level",StdErrLog.LEVEL_INFO,StdErrLog.getLoggingLevel(props,StdErrLogTest.class.getName()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLoggingLevel_Bad()
|
||||
{
|
||||
Properties props = new Properties();
|
||||
props.setProperty("log.LEVEL", "WARN");
|
||||
props.setProperty("org.eclipse.jetty.bad.LEVEL","FRUIT");
|
||||
|
||||
// Default Level (because of bad level value)
|
||||
Assert.assertEquals("Bad Logging Level",StdErrLog.LEVEL_WARN,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty.bad"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLoggingLevel_Lowercase()
|
||||
{
|
||||
Properties props = new Properties();
|
||||
props.setProperty("log.LEVEL", "warn");
|
||||
props.setProperty("org.eclipse.jetty.util.LEVEL","info");
|
||||
|
||||
// Default Level
|
||||
Assert.assertEquals("Lowercase Level",StdErrLog.LEVEL_WARN,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty"));
|
||||
// Specific Level
|
||||
Assert.assertEquals("Lowercase Level",StdErrLog.LEVEL_INFO,StdErrLog.getLoggingLevel(props,"org.eclipse.jetty.util"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetLoggingLevel_Root()
|
||||
{
|
||||
|
@ -157,7 +181,7 @@ public class StdErrLogTest
|
|||
public void testWarnFiltering() throws UnsupportedEncodingException
|
||||
{
|
||||
StdErrLog log = new StdErrLog(StdErrLogTest.class.getName());
|
||||
log.setHideStacks(true);
|
||||
log.setHideStacks(false);
|
||||
|
||||
ByteArrayOutputStream test = new ByteArrayOutputStream();
|
||||
PrintStream err = new PrintStream(test);
|
||||
|
@ -174,12 +198,20 @@ public class StdErrLogTest
|
|||
log.setLevel(StdErrLog.LEVEL_WARN);
|
||||
log.warn("Cheer Me");
|
||||
|
||||
log.warn("<zoom>", new Throwable("out of focus"));
|
||||
log.warn(new Throwable("scene lost"));
|
||||
|
||||
// Validate Output
|
||||
String output = new String(test.toByteArray(),"UTF-8");
|
||||
System.err.print(output);
|
||||
// System.err.print(output);
|
||||
Assert.assertThat(output,containsString("See Me"));
|
||||
Assert.assertThat(output,containsString("Hear Me"));
|
||||
Assert.assertThat(output,containsString("Cheer Me"));
|
||||
|
||||
// Validate Stack Traces
|
||||
Assert.assertThat(output,containsString(".StdErrLogTest:<zoom>"));
|
||||
Assert.assertThat(output,containsString("java.lang.Throwable: out of focus"));
|
||||
Assert.assertThat(output,containsString("java.lang.Throwable: scene lost"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -191,7 +223,7 @@ public class StdErrLogTest
|
|||
public void testInfoFiltering() throws UnsupportedEncodingException
|
||||
{
|
||||
StdErrLog log = new StdErrLog(StdErrLogTest.class.getName());
|
||||
log.setHideStacks(true);
|
||||
log.setHideStacks(false);
|
||||
|
||||
ByteArrayOutputStream test = new ByteArrayOutputStream();
|
||||
PrintStream err = new PrintStream(test);
|
||||
|
@ -208,17 +240,29 @@ public class StdErrLogTest
|
|||
log.setLevel(StdErrLog.LEVEL_ALL);
|
||||
log.info("it is scratched.");
|
||||
|
||||
log.info("<zoom>", new Throwable("out of focus"));
|
||||
log.info(new Throwable("scene lost"));
|
||||
|
||||
// Level Warn
|
||||
log.setLevel(StdErrLog.LEVEL_WARN);
|
||||
log.info("sorry?");
|
||||
log.info("<spoken line>", new Throwable("on editing room floor"));
|
||||
|
||||
// Validate Output
|
||||
String output = new String(test.toByteArray(),"UTF-8");
|
||||
System.err.print(output);
|
||||
// System.err.print(output);
|
||||
Assert.assertThat(output,containsString("I will not buy"));
|
||||
Assert.assertThat(output,containsString("this record"));
|
||||
Assert.assertThat(output,containsString("it is scratched."));
|
||||
Assert.assertThat(output,not(containsString("sorry?")));
|
||||
|
||||
// Validate Stack Traces
|
||||
Assert.assertThat(output,not(containsString("<spoken line>")));
|
||||
Assert.assertThat(output,not(containsString("on editing room floor")));
|
||||
|
||||
Assert.assertThat(output,containsString(".StdErrLogTest:<zoom>"));
|
||||
Assert.assertThat(output,containsString("java.lang.Throwable: out of focus"));
|
||||
Assert.assertThat(output,containsString("java.lang.Throwable: scene lost"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -238,10 +282,14 @@ public class StdErrLogTest
|
|||
|
||||
// Normal/Default behavior
|
||||
log.debug("Tobacconist");
|
||||
log.debug("<spoken line>", new Throwable("on editing room floor"));
|
||||
|
||||
// Level Debug
|
||||
log.setLevel(StdErrLog.LEVEL_DEBUG);
|
||||
log.debug("my hovercraft is");
|
||||
|
||||
log.debug("<zoom>", new Throwable("out of focus"));
|
||||
log.debug(new Throwable("scene lost"));
|
||||
|
||||
// Level All
|
||||
log.setLevel(StdErrLog.LEVEL_ALL);
|
||||
|
@ -253,11 +301,19 @@ public class StdErrLogTest
|
|||
|
||||
// Validate Output
|
||||
String output = new String(test.toByteArray(),"UTF-8");
|
||||
System.err.print(output);
|
||||
// System.err.print(output);
|
||||
Assert.assertThat(output,not(containsString("Tobacconist")));
|
||||
Assert.assertThat(output,containsString("my hovercraft is"));
|
||||
Assert.assertThat(output,containsString("full of eels."));
|
||||
Assert.assertThat(output,not(containsString("what?")));
|
||||
|
||||
// Validate Stack Traces
|
||||
Assert.assertThat(output,not(containsString("<spoken line>")));
|
||||
Assert.assertThat(output,not(containsString("on editing room floor")));
|
||||
|
||||
Assert.assertThat(output,containsString(".StdErrLogTest:<zoom>"));
|
||||
Assert.assertThat(output,containsString("java.lang.Throwable: out of focus"));
|
||||
Assert.assertThat(output,containsString("java.lang.Throwable: scene lost"));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -281,16 +337,177 @@ public class StdErrLogTest
|
|||
// Show Ignored
|
||||
log.setLevel(StdErrLog.LEVEL_ALL);
|
||||
log.ignore(new Throwable("Don't ignore me"));
|
||||
|
||||
|
||||
// Set to Debug level
|
||||
log.setLevel(StdErrLog.LEVEL_DEBUG);
|
||||
log.ignore(new Throwable("Debug me"));
|
||||
|
||||
// Validate Output
|
||||
String output = new String(test.toByteArray(),"UTF-8");
|
||||
System.err.print(output);
|
||||
// System.err.print(output);
|
||||
Assert.assertThat(output,not(containsString("IGNORE ME")));
|
||||
Assert.assertThat(output,containsString("Don't ignore me"));
|
||||
Assert.assertThat(output,not(containsString("Debug me")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIsDebugEnabled() {
|
||||
StdErrLog log = new StdErrLog(StdErrLogTest.class.getName());
|
||||
log.setHideStacks(true);
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_ALL);
|
||||
Assert.assertThat("log.level(all).isDebugEnabled", log.isDebugEnabled(), is(true));
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_DEBUG);
|
||||
Assert.assertThat("log.level(debug).isDebugEnabled", log.isDebugEnabled(), is(true));
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_INFO);
|
||||
Assert.assertThat("log.level(info).isDebugEnabled", log.isDebugEnabled(), is(false));
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_WARN);
|
||||
Assert.assertThat("log.level(warn).isDebugEnabled", log.isDebugEnabled(), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetGetLevel()
|
||||
{
|
||||
StdErrLog log = new StdErrLog(StdErrLogTest.class.getName());
|
||||
log.setHideStacks(true);
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_ALL);
|
||||
Assert.assertThat("log.level(all).getLevel()", log.getLevel(), is(StdErrLog.LEVEL_ALL));
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_DEBUG);
|
||||
Assert.assertThat("log.level(debug).getLevel()", log.getLevel(), is(StdErrLog.LEVEL_DEBUG));
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_INFO);
|
||||
Assert.assertThat("log.level(info).getLevel()", log.getLevel(), is(StdErrLog.LEVEL_INFO));
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_WARN);
|
||||
Assert.assertThat("log.level(warn).getLevel()", log.getLevel(), is(StdErrLog.LEVEL_WARN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChildLogger_Simple()
|
||||
{
|
||||
String baseName = "jetty";
|
||||
StdErrLog log = new StdErrLog(baseName);
|
||||
log.setHideStacks(true);
|
||||
|
||||
Assert.assertThat("Logger.name", log.getName(), is("jetty"));
|
||||
|
||||
Logger log2 = log.getLogger("child");
|
||||
Assert.assertThat("Logger.child.name", log2.getName(), is("jetty.child"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChildLogger_Deep()
|
||||
{
|
||||
String baseName = "jetty";
|
||||
StdErrLog log = new StdErrLog(baseName);
|
||||
log.setHideStacks(true);
|
||||
|
||||
Assert.assertThat("Logger.name", log.getName(), is("jetty"));
|
||||
|
||||
Logger log2 = log.getLogger("child.of.the.sixties");
|
||||
Assert.assertThat("Logger.child.name", log2.getName(), is("jetty.child.of.the.sixties"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChildLogger_Null()
|
||||
{
|
||||
String baseName = "jetty";
|
||||
StdErrLog log = new StdErrLog(baseName);
|
||||
log.setHideStacks(true);
|
||||
|
||||
Assert.assertThat("Logger.name", log.getName(), is("jetty"));
|
||||
|
||||
// Pass null as child reference, should return parent logger
|
||||
Logger log2 = log.getLogger(null);
|
||||
Assert.assertThat("Logger.child.name", log2.getName(), is("jetty"));
|
||||
Assert.assertSame("Should have returned same logger", log2, log);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChildLogger_EmptyName()
|
||||
{
|
||||
String baseName = "jetty";
|
||||
StdErrLog log = new StdErrLog(baseName);
|
||||
log.setHideStacks(true);
|
||||
|
||||
Assert.assertThat("Logger.name", log.getName(), is("jetty"));
|
||||
|
||||
// Pass empty name as child reference, should return parent logger
|
||||
Logger log2 = log.getLogger("");
|
||||
Assert.assertThat("Logger.child.name", log2.getName(), is("jetty"));
|
||||
Assert.assertSame("Should have returned same logger", log2, log);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChildLogger_EmptyNameSpaces()
|
||||
{
|
||||
String baseName = "jetty";
|
||||
StdErrLog log = new StdErrLog(baseName);
|
||||
log.setHideStacks(true);
|
||||
|
||||
Assert.assertThat("Logger.name", log.getName(), is("jetty"));
|
||||
|
||||
// Pass empty name as child reference, should return parent logger
|
||||
Logger log2 = log.getLogger(" ");
|
||||
Assert.assertThat("Logger.child.name", log2.getName(), is("jetty"));
|
||||
Assert.assertSame("Should have returned same logger", log2, log);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetChildLogger_NullParent()
|
||||
{
|
||||
StdErrLog log = new StdErrLog(null);
|
||||
|
||||
Assert.assertThat("Logger.name", log.getName(), is(""));
|
||||
|
||||
Logger log2 = log.getLogger("jetty");
|
||||
Assert.assertThat("Logger.child.name", log2.getName(), is("jetty"));
|
||||
Assert.assertNotSame("Should have returned same logger", log2, log);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testToString()
|
||||
{
|
||||
StdErrLog log = new StdErrLog("jetty");
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_ALL);
|
||||
Assert.assertThat("Logger.toString", log.toString(), is("StdErrLog:jetty:LEVEL=ALL"));
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_DEBUG);
|
||||
Assert.assertThat("Logger.toString", log.toString(), is("StdErrLog:jetty:LEVEL=DEBUG"));
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_INFO);
|
||||
Assert.assertThat("Logger.toString", log.toString(), is("StdErrLog:jetty:LEVEL=INFO"));
|
||||
|
||||
log.setLevel(StdErrLog.LEVEL_WARN);
|
||||
Assert.assertThat("Logger.toString", log.toString(), is("StdErrLog:jetty:LEVEL=WARN"));
|
||||
|
||||
log.setLevel(99); // intentionally bogus level
|
||||
Assert.assertThat("Logger.toString", log.toString(), is("StdErrLog:jetty:LEVEL=?"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPrintSource() throws UnsupportedEncodingException
|
||||
{
|
||||
StdErrLog log = new StdErrLog("test");
|
||||
log.setLevel(StdErrLog.LEVEL_DEBUG);
|
||||
log.setSource(true);
|
||||
|
||||
ByteArrayOutputStream test = new ByteArrayOutputStream();
|
||||
PrintStream err = new PrintStream(test);
|
||||
log.setStdErrStream(err);
|
||||
|
||||
log.debug("Show me the source!");
|
||||
|
||||
String output = new String(test.toByteArray(),"UTF-8");
|
||||
// System.err.print(output);
|
||||
|
||||
Assert.assertThat(output, containsString(".StdErrLogTest#testPrintSource(StdErrLogTest.java:"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -209,5 +209,11 @@
|
|||
<version>2.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.servlet</groupId>
|
||||
<artifactId>jstl</artifactId>
|
||||
<version>1.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
Loading…
Reference in New Issue