You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by se...@apache.org on 2010/01/06 17:59:19 UTC
svn commit: r896534 - in /cxf/trunk:
rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/
systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/
systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/
Author: sergeyb
Date: Wed Jan 6 16:59:18 2010
New Revision: 896534
URL: http://svn.apache.org/viewvc?rev=896534&view=rev
Log:
Another update to the atom pull logging test
Modified:
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPullHandler.java
cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPullServer.java
cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPullSpringTest.java
cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/beans.xml
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPullHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPullHandler.java?rev=896534&r1=896533&r2=896534&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPullHandler.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPullHandler.java Wed Jan 6 16:59:18 2010
@@ -37,8 +37,16 @@
@Override
public void publish(java.util.logging.LogRecord record) {
- LogRecord rec = LogRecord.fromJUL(record);
- engine.publish(rec);
+ if (LoggingThread.isSilent()) {
+ return;
+ }
+ LoggingThread.markSilent(true);
+ try {
+ LogRecord rec = LogRecord.fromJUL(record);
+ engine.publish(rec);
+ } finally {
+ LoggingThread.markSilent(false);
+ }
}
@Override
Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPullServer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPullServer.java?rev=896534&r1=896533&r2=896534&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPullServer.java (original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/ext/logging/atom/AtomPullServer.java Wed Jan 6 16:59:18 2010
@@ -119,7 +119,7 @@
}
if (page * (pageSize + 1) < records.size()) {
- feed.addLink(uri + "?page=" + (page + 2), "last");
+ feed.addLink(uri + "?page=" + (records.size() / pageSize + 1), "last");
}
if (page > 1) {
@@ -162,7 +162,7 @@
}
public void close() {
- // save records somehow
+
}
public void setPageSize(int size) {
Modified: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPullSpringTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPullSpringTest.java?rev=896534&r1=896533&r2=896534&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPullSpringTest.java (original)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPullSpringTest.java Wed Jan 6 16:59:18 2010
@@ -81,21 +81,20 @@
resetCounters();
for (Entry e : feed.getEntries()) {
- updateCounters(readLogRecord(e.getContent()), "Resource");
+ updateCounters(readLogRecord(e.getContent()), "Resource", "namedLogger");
}
verifyCounters();
}
@Test
- @Ignore("For some reasons two tests step on each other - fix it")
public void testPagedFeed() throws Exception {
WebClient wc = WebClient.create("http://localhost:9080/resource2/paged");
wc.path("/log").get();
Thread.sleep(3000);
- verifyPages("http://localhost:9080/atom/logs", "next", 3, 2);
- verifyPages("http://localhost:9080/atom/logs?page=3", "previous", 2, 3);
+ verifyPages("http://localhost:9080/atom2/logs", "next", 3, 2);
+ verifyPages("http://localhost:9080/atom2/logs?page=3", "previous", 2, 3);
}
private void verifyPages(String startAddress, String rel, int firstValue, int lastValue)
@@ -109,7 +108,7 @@
resetCounters();
for (Entry e : entries) {
- updateCounters(readLogRecord(e.getContent()), "Resource2");
+ updateCounters(readLogRecord(e.getContent()), "Resource2", "theNamedLogger");
}
verifyCounters();
}
@@ -146,7 +145,7 @@
@GET
@Path("/log")
public void doLogging() {
- doLog(LOG1, LOG2);
+ doLog(Resource.LOG1, Resource.LOG2);
}
}
@@ -155,12 +154,12 @@
@Path("/paged")
public static class Resource2 {
private static final Logger LOG1 = LogUtils.getL7dLogger(Resource2.class);
- private static final Logger LOG2 = LogUtils.getL7dLogger(Resource2.class, null, "namedLogger");
+ private static final Logger LOG2 = LogUtils.getL7dLogger(Resource2.class, null, "theNamedLogger");
@GET
@Path("/log")
public void doLogging() {
- doLog(LOG1, LOG2);
+ doLog(Resource2.LOG1, Resource2.LOG2);
}
}
@@ -186,6 +185,7 @@
l2.severe("severe message2");
l2.info("info message - should not pass!");
l2.finer("finer message - should not pass!");
+
}
private org.apache.cxf.jaxrs.ext.logging.LogRecord readLogRecord(String value) throws Exception {
@@ -194,12 +194,14 @@
}
- private void updateCounters(org.apache.cxf.jaxrs.ext.logging.LogRecord record, String clsName) {
+ private void updateCounters(org.apache.cxf.jaxrs.ext.logging.LogRecord record,
+ String clsName,
+ String namedLoggerName) {
String name = record.getLoggerName();
if (name != null && name.length() > 0) {
if (("org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$" + clsName).equals(name)) {
resourceLogger++;
- } else if ("namedLogger".equals(name)) {
+ } else if (namedLoggerName.equals(name)) {
namedLogger++;
} else if ("faky-logger".equals(name)) {
fakyLogger++;
Modified: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/beans.xml?rev=896534&r1=896533&r2=896534&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/beans.xml Wed Jan 6 16:59:18 2010
@@ -44,6 +44,16 @@
value="
org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource:ALL,
namedLogger:WARN" />
+ </bean>
+
+ <bean id = "atomPullServer2" class="org.apache.cxf.jaxrs.ext.logging.atom.AtomPullServer"
+ init-method="init">
+ <property name="loggers"
+ value="
+ org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource2:ALL,
+ theNamedLogger:WARN" />
+ <property name="pageSize" value="3"/>
+
</bean>
<bean id="feed" class="org.apache.cxf.jaxrs.provider.AtomFeedProvider">
@@ -58,6 +68,7 @@
<ref bean="feed" />
</jaxrs:providers>
</jaxrs:server>
+
<jaxrs:server id="resource2Server" address="/resource2">
<jaxrs:serviceBeans>
<bean class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource2"/>
@@ -76,6 +87,15 @@
<ref bean="feed" />
</jaxrs:providers>
</jaxrs:server>
+
+ <jaxrs:server id="atomServer2" address="/atom2">
+ <jaxrs:serviceBeans>
+ <ref bean="atomPullServer2"/>
+ </jaxrs:serviceBeans>
+ <jaxrs:providers>
+ <ref bean="feed" />
+ </jaxrs:providers>
+ </jaxrs:server>
</beans>
<!-- END SNIPPET: beans -->