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 2016/12/23 10:40:40 UTC
cxf git commit: [CXF-7192] Removing rt-management-web tests
Repository: cxf
Updated Branches:
refs/heads/master 707fa4f3c -> 69891e8bd
[CXF-7192] Removing rt-management-web tests
Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/69891e8b
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/69891e8b
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/69891e8b
Branch: refs/heads/master
Commit: 69891e8bdb65fda1caa03810cdc3853a3f357cd1
Parents: 707fa4f
Author: Sergey Beryozkin <sb...@gmail.com>
Authored: Fri Dec 23 10:40:07 2016 +0000
Committer: Sergey Beryozkin <sb...@gmail.com>
Committed: Fri Dec 23 10:40:07 2016 +0000
----------------------------------------------------------------------
systests/jaxrs/pom.xml | 6 -
.../jaxrs/JAXRSLoggingAtomPullSpringTest.java | 615 -------------------
.../jaxrs/JAXRSLoggingAtomPushSpringTest.java | 446 --------------
.../systest/jaxrs/JAXRSLoggingAtomPushTest.java | 266 --------
.../jaxrs_logging_atompull/WEB-INF/beans.xml | 162 -----
.../jaxrs_logging_atompull/WEB-INF/web.xml | 45 --
.../jaxrs_logging_atompush/WEB-INF/beans.xml | 126 ----
.../jaxrs_logging_atompush/WEB-INF/web.xml | 45 --
8 files changed, 1711 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cxf/blob/69891e8b/systests/jaxrs/pom.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/pom.xml b/systests/jaxrs/pom.xml
index 7dbb2f7..15910bd 100644
--- a/systests/jaxrs/pom.xml
+++ b/systests/jaxrs/pom.xml
@@ -317,12 +317,6 @@
</dependency>
<dependency>
<groupId>org.apache.cxf</groupId>
- <artifactId>cxf-rt-management-web</artifactId>
- <version>${project.version}</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-extension-providers</artifactId>
<version>${project.version}</version>
</dependency>
http://git-wip-us.apache.org/repos/asf/cxf/blob/69891e8b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPullSpringTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPullSpringTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPullSpringTest.java
deleted file mode 100644
index 23d05b2..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPullSpringTest.java
+++ /dev/null
@@ -1,615 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.systest.jaxrs;
-
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.xml.bind.JAXBContext;
-
-import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.Feed;
-import org.apache.abdera.model.Link;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.jaxrs.ext.search.SearchCondition;
-import org.apache.cxf.jaxrs.provider.atom.AtomEntryProvider;
-import org.apache.cxf.jaxrs.provider.atom.AtomFeedProvider;
-import org.apache.cxf.management.web.logging.LogLevel;
-import org.apache.cxf.management.web.logging.ReadWriteLogStorage;
-import org.apache.cxf.management.web.logging.ReadableLogStorage;
-import org.apache.cxf.management.web.logging.atom.AtomPullServer;
-import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class JAXRSLoggingAtomPullSpringTest extends AbstractBusClientServerTestBase {
- public static final int PORT = SpringServer.PORT;
-
- private static JAXBContext context;
- private int fakyLogger;
- private int namedLogger;
- private int resourceLogger;
- private int throwables;
- private int errorLevels;
- private int traceLevels;
- private int infoLevels;
- private int debugLevels;
- private int warningLevels;
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- //make sure the Resource things have their static initializers called
- //to make sure the Loggers are created. Otherwise, the Loggers that the server
- //sets the handler into could be garbage collected before the init is called
- new Resource();
- new Resource2();
- new Resource3();
- // must be 'in-process' to communicate with inner class in single JVM
- // and to spawn class SpringServer w/o using main() method
- String resourceDir =
- JAXRSLoggingAtomPullSpringTest.class.getResource("resources").toURI().getPath();
- System.setProperty("systemtests.jaxrs.logs.folder", resourceDir);
- launchServer(SpringServer.class, true);
- context = JAXBContext.newInstance(org.apache.cxf.management.web.logging.LogRecord.class);
- createStaticBus();
- System.clearProperty("systemtests.jaxrs.logs.folder");
- }
-
- @Ignore
- public static class SpringServer extends AbstractSpringServer {
- public static final int PORT = allocatePortAsInt(SpringServer.class);
- public SpringServer() {
- super("/jaxrs_logging_atompull", PORT);
- }
- }
-
- @Before
- public void before() throws Exception {
- Storage.clearRecords();
- }
-
- @Test
- public void testFeed() throws Exception {
- String listing = WebClient.create("http://localhost:" + PORT + "/services").get(String.class);
- assertTrue(listing, listing.contains("http://localhost:" + PORT + "/atom/logs"));
- WebClient wc = WebClient.create("http://localhost:" + PORT + "/resource/root");
- wc.path("/log").get();
- Thread.sleep(3000);
-
- checkSimpleFeed(getFeed("http://localhost:" + PORT + "/atom/logs").getEntries());
- checkSimpleFeed(getFeed("http://localhost:" + PORT + "/atom/logs").getEntries());
-
- List<Entry> entries = new LinkedList<Entry>();
- WebClient wcEntry = WebClient.create("http://localhost:" + PORT + "/atom/logs",
- Collections.singletonList(new AtomEntryProvider()))
- .accept("application/atom+xml;type=entry");
- for (int i = 0; i < 8; i++) {
- Entry entry = wcEntry.path("entry/" + i).get(Entry.class);
- entry.toString();
- entries.add(entry);
- wcEntry.back(true);
- }
- checkSimpleFeed(entries);
- }
-
- private void checkSimpleFeed(List<Entry> entries) throws Exception {
- assertEquals(8, entries.size());
-
- resetCounters();
- for (Entry e : entries) {
- updateCounters(readLogRecord(e.getContent()), "Resource", "namedLogger");
- }
-
- verifyCounters();
- }
-
- @Test
- public void testPagedFeed() throws Exception {
- WebClient wcReset = WebClient.create("http://localhost:" + PORT + "/reset");
- wcReset.post(null);
-
- WebClient wc = WebClient.create("http://localhost:" + PORT + "/resource2/paged");
- wc.path("/log").get();
- Thread.sleep(3000);
-
- verifyPages("http://localhost:" + PORT + "/atom2/logs", "next", 3, 2, "theNamedLogger");
- verifyPages("http://localhost:" + PORT + "/atom2/logs/3", "previous", 2, 3, "theNamedLogger");
- }
-
- @Test
- public void testPagedFeedWithQuery() throws Exception {
- WebClient wcReset = WebClient.create("http://localhost:" + PORT + "/reset");
- wcReset.post(null);
-
- WebClient wc = WebClient.create("http://localhost:" + PORT + "/resource2/paged/log");
- wc.get();
- Thread.sleep(3000);
-
- String address = "http://localhost:" + PORT + "/atom2/logs"
- + "?_s=level==INFO,level==ERROR,level==WARN";
- verifyPagesWithQuery(address, "next", 3, 2, "Resource2", "theNamedLogger");
- verifyPagesWithQuery(address, "next", 3, 2, "Resource2", "theNamedLogger");
- }
-
-
- @Test
- public void testPagedFeedWithReadWriteStorage() throws Exception {
- WebClient wc = WebClient.create("http://localhost:" + PORT + "/resource3/storage");
- wc.path("/log").get();
- Thread.sleep(3000);
-
- verifyStoragePages("http://localhost:"
- + PORT + "/atom3/logs", "next", "Resource3", "theStorageLogger", false);
- List<org.apache.cxf.management.web.logging.LogRecord> list = Storage.getRecords();
- assertEquals(4, list.size());
- verifyStoragePages("http://localhost:"
- + PORT + "/atom3/logs", "next", "Resource3", "theStorageLogger", false);
- verifyStoragePages("http://localhost:" + PORT + "/atom3/logs/2", "previous", "Resource3",
- "theStorageLogger", false);
- }
-
- @Test
- public void testPagedFeedWithReadOnlyStorage() throws Exception {
- verifyStoragePages("http://localhost:"
- + PORT + "/atom4/logs", "next", "Resource4", "readOnlyStorageLogger", true);
- verifyStoragePages("http://localhost:" + PORT + "/atom4/logs/2", "previous", "Resource4",
- "readOnlyStorageLogger", true);
- }
-
- @Test
- public void testPagedFeedWithReadonlyStorageAngQuery() throws Exception {
- checkInfoLevelOnly();
- checkDebugLevelOnly();
- checkInfoLevelOnly();
- checkDebugLevelOnly();
- checkInfoOrDebugLevel();
- }
-
- private void checkInfoLevelOnly() throws Exception {
- String address = "http://localhost:" + PORT + "/atom5/logs"
- + "?_s=level==INFO";
- List<Entry> entries = new ArrayList<Entry>();
- String href1 = fillPagedEntries(entries, address, 1, "next", true);
- resetCounters();
- for (Entry e : entries) {
- updateCounters(readLogRecord(e.getContent()), "", "");
- }
- assertEquals(0, errorLevels);
- assertEquals(1, infoLevels);
- assertEquals(0, debugLevels);
- assertEquals(0, traceLevels);
- assertEquals(0, warningLevels);
-
- entries.clear();
- fillPagedEntries(entries, href1, 0, "next", false);
- }
-
- private void checkInfoOrDebugLevel() throws Exception {
- String address = "http://localhost:" + PORT + "/atom5/logs"
- + "?_s=level==INFO,level==DEBUG";
- List<Entry> entries = new ArrayList<Entry>();
- String href1 = fillPagedEntries(entries, address, 1, "next", true);
- resetCounters();
- for (Entry e : entries) {
- updateCounters(readLogRecord(e.getContent()), "", "");
- }
- assertEquals(0, errorLevels);
- assertEquals(1, infoLevels);
- assertEquals(0, debugLevels);
- assertEquals(0, traceLevels);
- assertEquals(0, warningLevels);
-
- entries.clear();
- String href2 = fillPagedEntries(entries, href1, 1, "next", true);
- resetCounters();
- for (Entry e : entries) {
- updateCounters(readLogRecord(e.getContent()), "", "");
- }
- assertEquals(0, errorLevels);
- assertEquals(0, infoLevels);
- assertEquals(1, debugLevels);
- assertEquals(0, traceLevels);
- assertEquals(0, warningLevels);
-
- entries.clear();
- fillPagedEntries(entries, href2, 0, "next", false);
- }
-
- private void checkDebugLevelOnly() throws Exception {
- String address = "http://localhost:" + PORT + "/atom5/logs"
- + "?_s=level==DEBUG";
- List<Entry> entries = new ArrayList<Entry>();
- String href1 = fillPagedEntries(entries, address, 1, "next", true);
- resetCounters();
- for (Entry e : entries) {
- updateCounters(readLogRecord(e.getContent()), "", "");
- }
- assertEquals(0, errorLevels);
- assertEquals(0, infoLevels);
- assertEquals(1, debugLevels);
- assertEquals(0, traceLevels);
- assertEquals(0, warningLevels);
-
- entries.clear();
- fillPagedEntries(entries, href1, 0, "next", false);
- }
-
- private void verifyStoragePages(String startAddress, String rel,
- String resourceName, String nLogger,
- boolean readOnly)
- throws Exception {
- List<Entry> entries = new ArrayList<Entry>();
- String href1 = fillPagedEntries(entries, startAddress, 4, rel, true);
- fillPagedEntries(entries, href1, 4, rel, "next".equals(rel) && readOnly ? true : false);
- assertEquals(8, entries.size());
-
- resetCounters();
- for (Entry e : entries) {
- updateCounters(readLogRecord(e.getContent()), resourceName, nLogger);
- }
- if ("Resource4".equals(resourceName)) {
- assertEquals(1, throwables);
- assertEquals(6, resourceLogger);
- assertEquals(2, namedLogger);
- assertEquals(0, fakyLogger);
- } else {
- verifyCounters();
- }
- }
-
- private void verifyPages(String startAddress, String rel,
- int firstValue, int lastValue, String nLogger)
- throws Exception {
- List<Entry> entries = new ArrayList<Entry>();
- String href1 = fillPagedEntries(entries, startAddress,
- firstValue, rel, true);
- String href2 = fillPagedEntries(entries, href1, 3, rel, true);
- fillPagedEntries(entries, href2, lastValue, rel, false);
- assertEquals(8, entries.size());
-
- resetCounters();
- for (Entry e : entries) {
- updateCounters(readLogRecord(e.getContent()), "Resource2", nLogger);
- }
- verifyCounters();
- }
-
- private void verifyPagesWithQuery(String startAddress, String rel,
- int firstValue, int lastValue, String resourceName, String nLogger)
- throws Exception {
- List<Entry> entries = new ArrayList<Entry>();
- String hrefRel = fillPagedEntries(entries, startAddress,
- firstValue, rel, true);
- hrefRel = fillPagedEntries(entries, hrefRel, lastValue, rel, false);
- assertEquals(firstValue + lastValue, entries.size());
-
- resetCounters();
- for (Entry e : entries) {
- updateCounters(readLogRecord(e.getContent()), "Resource2", nLogger);
- }
- assertEquals(3, errorLevels);
- assertEquals(1, infoLevels);
- assertEquals(0, debugLevels);
- assertEquals(0, traceLevels);
- assertEquals(1, warningLevels);
- }
-
- private String fillPagedEntries(List<Entry> entries, String href, int expected,
- String rel, boolean relExpected) {
- Feed feed = getFeed(href);
-
- assertEquals(expected, feed.getEntries().size());
- entries.addAll(feed.getEntries());
-
- Link link = feed.getLink(rel);
- if (relExpected) {
- assertNotNull(link);
- return link.getHref().toString();
- } else {
- assertNull(link);
- return null;
- }
- }
-
- private Feed getFeed(String address) {
- WebClient wc = WebClient.create(address,
- Collections.singletonList(new AtomFeedProvider()));
- WebClient.getConfig(wc).getHttpConduit().getClient().setReceiveTimeout(10000000);
-
- Feed feed = wc.accept("application/atom+xml").get(Feed.class);
- feed.toString();
- return feed;
- }
-
- @Ignore
- @Path("/root")
- public static class Resource {
- private static final Logger LOG1 = LogUtils.getL7dLogger(Resource.class);
- private static final Logger LOG2 = LogUtils.getL7dLogger(Resource.class, null, "namedLogger");
-
- @GET
- @Path("/log")
- public void doLogging() {
- doLog(Resource.LOG1, Resource.LOG2);
- }
-
- }
-
- @Ignore
- @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, "theNamedLogger");
-
- @GET
- @Path("/log")
- public void doLogging() {
- doLog(Resource2.LOG1, Resource2.LOG2);
- }
-
- }
-
- @Ignore
- @Path("/storage")
- public static class Resource3 {
- private static final Logger LOG1 = LogUtils.getL7dLogger(Resource3.class);
- private static final Logger LOG2 = LogUtils.getL7dLogger(Resource3.class, null, "theStorageLogger");
-
- @GET
- @Path("/log")
- public void doLogging() {
- doLog(Resource3.LOG1, Resource3.LOG2);
- }
-
- }
-
- @Path("/")
- public static class AtomServerReset {
-
- private AtomPullServer server;
-
- public void setServer(AtomPullServer s) {
- this.server = s;
- }
-
-
- @POST
- public void reset() {
- server.reset();
- }
-
- }
-
- @Ignore
- public static class ExternalStorage implements ReadableLogStorage {
-
- private List<org.apache.cxf.management.web.logging.LogRecord> records =
- new LinkedList<org.apache.cxf.management.web.logging.LogRecord>();
-
- public ExternalStorage() {
- addRecord("org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource4",
- Level.SEVERE, null);
- addRecord("org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource4",
- Level.WARNING, null);
- addRecord("org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource4",
- Level.INFO, null);
- addRecord("org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource4",
- Level.FINE, new IllegalArgumentException());
- addRecord("org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource4",
- Level.FINEST, null);
- addRecord("org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource4",
- Level.FINER, null);
- addRecord("readOnlyStorageLogger", Level.SEVERE, null);
- addRecord("readOnlyStorageLogger", Level.SEVERE, null);
- }
-
- private void addRecord(String loggerName, Level level, Throwable t) {
- org.apache.cxf.management.web.logging.LogRecord lr =
- new org.apache.cxf.management.web.logging.LogRecord();
- lr.setLoggerName(loggerName);
- lr.setLevel(LogLevel.fromJUL(level));
- if (t != null) {
- StringWriter sw = new StringWriter();
- t.printStackTrace(new PrintWriter(sw));
- lr.setThrowable(sw.getBuffer().toString());
- }
- records.add(lr);
- }
-
- public void close() {
- // TODO Auto-generated method stub
-
- }
-
- public int getSize() {
- // this storage is getting the records from a file log entries are added to
- return -1;
- }
-
- public int load(List<org.apache.cxf.management.web.logging.LogRecord> list,
- SearchCondition<org.apache.cxf.management.web.logging.LogRecord> condition,
- int pageNumber,
- int pageSize) {
- int loadFrom = pageNumber == 1 ? 0 : pageSize * (pageNumber - 1);
- for (int i = loadFrom; i < loadFrom + pageSize; i++) {
- if (condition.isMet(records.get(i))) {
- list.add(records.get(i));
- }
- }
- return pageNumber;
- }
-
- }
-
- @Ignore
- public static class Storage implements ReadWriteLogStorage {
- private static List<org.apache.cxf.management.web.logging.LogRecord> records =
- new LinkedList<org.apache.cxf.management.web.logging.LogRecord>();
-
- public int load(List<org.apache.cxf.management.web.logging.LogRecord> list,
- SearchCondition<org.apache.cxf.management.web.logging.LogRecord> sc,
- int pageNumber, int pageSize) {
-
- int loadFrom = pageNumber == 1 ? 0 : pageSize * (pageNumber - 1);
- if (loadFrom + pageSize <= records.size()) {
- list.addAll(records.subList(loadFrom, loadFrom + pageSize));
- }
- return pageNumber;
- }
-
- public void save(List<org.apache.cxf.management.web.logging.LogRecord> list) {
- records.addAll(list);
- }
-
- public void clear() {
- }
-
- public void close() {
- }
-
- public int getSize() {
- return records.size();
- }
-
- public static List<org.apache.cxf.management.web.logging.LogRecord> getRecords() {
- return records;
- }
-
- public static void clearRecords() {
- records.clear();
- }
- }
-
-
- private static void doLog(Logger l1, Logger l2) {
-
- // 3 severe, 1 warning, 1 info and 3 debug messages
-
- // 1
- l1.severe("severe message");
- // 2
- l1.warning("warning message");
- // 3
- l1.info("info message");
- LogRecord r = new LogRecord(Level.FINE, "fine message");
- if ("Resource4".equals(l1.getName())) {
- r.setLoggerName(l1.getName());
- }
- r.setThrown(new IllegalArgumentException("tadaam"));
- // 4
- l1.log(r);
- r = new LogRecord(Level.FINER, "finer message with {0} and {1}");
- r.setParameters(new Object[] {
- "param1", "param2"
- });
- r.setLoggerName("faky-logger");
- // 5
- l1.log(r);
- // 6
- l1.finest("finest message");
-
- // for LOG2 only 'warning' and above messages should be logged
- // 7
- l2.severe("severe message");
- // 8
- l2.severe("severe message2");
- l2.info("info message - should not pass!");
- l2.finer("finer message - should not pass!");
-
- }
-
- private org.apache.cxf.management.web.logging.LogRecord readLogRecord(String value) throws Exception {
- return (org.apache.cxf.management.web.logging.LogRecord)
- context.createUnmarshaller().unmarshal(new StringReader(value));
- }
-
-
- private void updateCounters(org.apache.cxf.management.web.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 (namedLoggerName.equals(name)) {
- namedLogger++;
- } else if ("faky-logger".equals(name)) {
- fakyLogger++;
- }
- }
-
- if (record.getThrowable().length() > 0) {
- throwables++;
- }
-
- LogLevel level = record.getLevel();
- if (level == LogLevel.ERROR) {
- errorLevels++;
- } else if (level == LogLevel.DEBUG) {
- debugLevels++;
- } else if (level == LogLevel.TRACE) {
- traceLevels++;
- } else if (level == LogLevel.INFO) {
- infoLevels++;
- } else {
- warningLevels++;
- }
- }
-
- private void resetCounters() {
- fakyLogger = 0;
- namedLogger = 0;
- resourceLogger = 0;
- throwables = 0;
-
- errorLevels = 0;
- infoLevels = 0;
- debugLevels = 0;
- traceLevels = 0;
- warningLevels = 0;
- }
-
- private void verifyCounters() {
- assertEquals(1, throwables);
- assertEquals(4, resourceLogger);
- assertEquals(2, namedLogger);
- assertEquals(1, fakyLogger);
-
- assertEquals(3, errorLevels);
- assertEquals(1, infoLevels);
- assertEquals(2, debugLevels);
- assertEquals(1, traceLevels);
- assertEquals(1, warningLevels);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69891e8b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushSpringTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushSpringTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushSpringTest.java
deleted file mode 100644
index bf144214..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushSpringTest.java
+++ /dev/null
@@ -1,446 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.systest.jaxrs;
-
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.xml.bind.JAXBContext;
-import javax.xml.namespace.QName;
-
-import org.apache.abdera.model.Element;
-import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.ExtensibleElement;
-import org.apache.abdera.model.Feed;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.jaxrs.client.WebClient;
-import org.apache.cxf.management.web.logging.LogRecords;
-import org.apache.cxf.testutil.common.AbstractClientServerTestBase;
-
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class JAXRSLoggingAtomPushSpringTest extends AbstractClientServerTestBase {
- public static final int PORT = SpringServer.PORT;
-
- private JAXBContext context;
- private int fakyLogger;
- private int namedLogger;
- private int resourceLogger;
- private int throwables;
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- // must be 'in-process' to communicate with inner class in single JVM
- // and to spawn class SpringServer w/o using main() method
- launchServer(SpringServer.class, true);
- }
-
- @Ignore
- public static class SpringServer extends AbstractSpringServer {
- public static final int PORT = allocatePortAsInt(SpringServer.class);
- public SpringServer() {
- super("/jaxrs_logging_atompush", PORT);
- }
- }
-
- @Before
- public void before() throws Exception {
- Resource.clear();
- Resource2.clear();
- Resource3.clear();
- Resource4.clear();
- Resource5.clear();
- context = JAXBContext.newInstance(LogRecords.class,
- org.apache.cxf.management.web.logging.LogRecord.class);
- }
-
- @Test
- public void testFeedsWithLogRecordsOneEntry() throws Exception {
- WebClient wc = WebClient.create("http://localhost:" + PORT + "/root");
- try {
- wc.path("/log").get();
- } catch (Exception ex) {
- //ignore
- }
- Thread.sleep(3000);
- List<Feed> elements = Resource.getElements();
- assertEquals(8, elements.size());
-
- resetCounters();
- for (Feed feed : elements) {
- List<Entry> entries = feed.getEntries();
- assertEquals(1, entries.size());
- Entry e = entries.get(0);
- LogRecords records = readLogRecords(e.getContent());
- List<org.apache.cxf.management.web.logging.LogRecord> list = records.getLogRecords();
- assertNotNull(list);
- assertEquals(1, list.size());
- updateCounters(list.get(0), "Resource");
- }
-
- verifyCounters();
- }
-
- @Test
- public void testFeedsWithBatchLogRecordsOneEntry() throws Exception {
- WebClient wc = WebClient.create("http://localhost:" + PORT + "/batch");
- wc.path("/log").get();
- Thread.sleep(3000);
- List<Feed> elements = Resource2.getElements();
- assertEquals(2, elements.size());
-
- resetCounters();
- for (Feed feed : elements) {
- List<Entry> entries = feed.getEntries();
- assertEquals(4, entries.size());
-
- for (Entry e : entries) {
- updateCounters(readLogRecord(e.getContent()), "Resource2");
- }
- }
-
- verifyCounters();
-
- }
-
- @Test
- public void testEntriesWithLogRecordsOneEntry() throws Exception {
- WebClient wc = WebClient.create("http://localhost:" + PORT + "/entries");
- wc.path("/log").get();
- Thread.sleep(3000);
- List<Entry> elements = Resource3.getElements();
- assertEquals(8, elements.size());
-
- resetCounters();
-
- for (Entry e : elements) {
- updateCounters(readLogRecord(e.getContent()), "Resource3");
- }
-
- verifyCounters();
-
- }
-
- @Test
- public void testManyEntries() throws Exception {
- WebClient wc = WebClient.create("http://localhost:" + PORT + "/entriesMany");
- wc.path("/log").get();
- Thread.sleep(3000);
- List<Entry> elements = Resource4.getElements();
- assertEquals(4, elements.size());
-
- resetCounters();
-
- for (Entry e : elements) {
- LogRecords records = readLogRecords(e.getContent());
- List<org.apache.cxf.management.web.logging.LogRecord> list = records.getLogRecords();
- assertNotNull(list);
- assertEquals(2, list.size());
- for (org.apache.cxf.management.web.logging.LogRecord record : list) {
- updateCounters(record, "Resource4");
- }
-
- }
- verifyCounters();
- }
-
- @Test
- public void testFeedsWithLogRecordsExtension() throws Exception {
- WebClient wc = WebClient.create("http://localhost:" + PORT + "/extensions");
- wc.path("/log").get();
- Thread.sleep(3000);
- List<Feed> elements = Resource5.getElements();
- assertEquals(8, elements.size());
-
- resetCounters();
- for (Feed feed : elements) {
- List<Entry> entries = feed.getEntries();
- assertEquals(1, entries.size());
- Entry e = entries.get(0);
- LogRecords records = readLogRecordsExtension(e);
- List<org.apache.cxf.management.web.logging.LogRecord> list = records.getLogRecords();
- assertNotNull(list);
- assertEquals(1, list.size());
- updateCounters(list.get(0), "Resource5");
- }
-
- verifyCounters();
- }
-
- @Ignore
- @Path("/root")
- public static class Resource {
- private static final Logger LOG1;
- private static final Logger LOG2;
-
- static {
- System.gc();
- LOG1 = LogUtils.getL7dLogger(Resource.class);
- LOG2 = LogUtils.getL7dLogger(Resource.class, null, "namedLogger");
- }
-
- private static List<Feed> feeds = new ArrayList<Feed>();
-
- @GET
- @Path("/log")
- public void doLogging() {
- doLog(LOG1, LOG2);
- }
-
- @POST
- @Path("/feeds")
- public void consume(Feed feed) {
- feed.toString();
- synchronized (Resource.class) {
- feeds.add(feed);
- }
- }
-
- public static void clear() {
- feeds.clear();
- }
-
- public static synchronized List<Feed> getElements() {
- return new ArrayList<Feed>(feeds);
- }
- }
-
- @Ignore
- @Path("/batch")
- 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 List<Feed> feeds = new ArrayList<Feed>();
-
- @GET
- @Path("/log")
- public void doLogging() {
- doLog(LOG1, LOG2);
- }
-
- @POST
- @Path("/feeds")
- public void consume(Feed feed) {
- feed.toString();
- synchronized (Resource2.class) {
- feeds.add(feed);
- }
- }
-
- public static void clear() {
- feeds.clear();
- }
-
- public static synchronized List<Feed> getElements() {
- return new ArrayList<Feed>(feeds);
- }
- }
-
- @Ignore
- @Path("/entries")
- public static class Resource3 {
- private static final Logger LOG1 = LogUtils.getL7dLogger(Resource3.class);
- private static final Logger LOG2 = LogUtils.getL7dLogger(Resource3.class, null, "namedLogger");
-
- private static List<Entry> entries = new ArrayList<Entry>();
-
- @GET
- @Path("/log")
- public void doLogging() {
- doLog(LOG1, LOG2);
- }
-
- @POST
- @Path("/entries")
- public void consume(Entry entry) {
- entry.toString();
- synchronized (Resource3.class) {
- entries.add(entry);
- }
- }
-
- public static void clear() {
- entries.clear();
- }
-
- public static synchronized List<Entry> getElements() {
- return new ArrayList<Entry>(entries);
- }
- }
-
- @Ignore
- @Path("/entriesMany")
- public static class Resource4 {
- private static final Logger LOG1 = LogUtils.getL7dLogger(Resource4.class);
- private static final Logger LOG2 = LogUtils.getL7dLogger(Resource4.class, null, "namedLogger");
-
- private static List<Entry> entries = new ArrayList<Entry>();
-
- @GET
- @Path("/log")
- public void doLogging() {
- doLog(LOG1, LOG2);
- }
-
- @POST
- @Path("/entries")
- public void consume(Entry entry) {
- entry.toString();
- synchronized (Resource4.class) {
- entries.add(entry);
- }
- }
-
- public static void clear() {
- entries.clear();
- }
-
- public static synchronized List<Entry> getElements() {
- return new ArrayList<Entry>(entries);
- }
- }
-
- @Ignore
- @Path("/extensions")
- public static class Resource5 {
- private static final Logger LOG1 = LogUtils.getL7dLogger(Resource5.class);
- private static final Logger LOG2 = LogUtils.getL7dLogger(Resource5.class, null, "namedLogger");
-
- private static List<Feed> feeds = new ArrayList<Feed>();
-
- @GET
- @Path("/log")
- public void doLogging() {
- doLog(LOG1, LOG2);
- }
-
- @POST
- @Path("/feeds")
- public void consume(Feed feed) {
- feed.toString();
- synchronized (Resource5.class) {
- feeds.add(feed);
- }
- }
-
- public static void clear() {
- feeds.clear();
- }
-
- public static List<Feed> getElements() {
- return new ArrayList<Feed>(feeds);
- }
- }
-
- private static void doLog(Logger l1, Logger l2) {
- l1.severe("severe message");
- l1.warning("warning message");
- l1.info("info message");
- LogRecord r = new LogRecord(Level.FINE, "fine message");
- r.setThrown(new IllegalArgumentException("tadaam"));
- l1.log(r);
- r = new LogRecord(Level.FINER, "finer message with {0} and {1}");
- r.setParameters(new Object[] {
- "param1", "param2"
- });
- r.setLoggerName("faky-logger");
- l1.log(r);
- l1.finest("finest message");
-
- // for LOG2 only 'warning' and above messages should be logged
- l2.severe("severe message");
- l2.severe("severe message2");
- l2.info("info message - should not pass!");
- l2.finer("finer message - should not pass!");
- }
-
- private LogRecords readLogRecords(String value) throws Exception {
- return (LogRecords)context.createUnmarshaller().unmarshal(new StringReader(value));
- }
-
- private org.apache.cxf.management.web.logging.LogRecord readLogRecord(String value) throws Exception {
- return (org.apache.cxf.management.web.logging.LogRecord)
- context.createUnmarshaller().unmarshal(new StringReader(value));
- }
-
- private LogRecords readLogRecordsExtension(Entry e) throws Exception {
- ExtensibleElement el = e.getExtension(new QName("http://cxf.apache.org/log", "logRecords", "log"));
- LogRecords records = new LogRecords();
- List<org.apache.cxf.management.web.logging.LogRecord> list =
- new ArrayList<org.apache.cxf.management.web.logging.LogRecord>();
- for (Element element : el.getElements()) {
- org.apache.cxf.management.web.logging.LogRecord record =
- new org.apache.cxf.management.web.logging.LogRecord();
- Element loggerName = element.getFirstChild(
- new QName("http://cxf.apache.org/log", "loggerName", "log"));
- if (loggerName != null) {
- record.setLoggerName(loggerName.getText());
- }
- Element throwable = element.getFirstChild(
- new QName("http://cxf.apache.org/log", "throwable", "log"));
- if (throwable != null) {
- record.setThrowable(throwable.getText());
- }
- list.add(record);
- }
- records.setLogRecords(list);
- return records;
- }
-
- private void updateCounters(org.apache.cxf.management.web.logging.LogRecord record, String clsName) {
- String name = record.getLoggerName();
- if (name != null && name.length() > 0) {
- if (("org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest$" + clsName).equals(name)) {
- resourceLogger++;
- } else if ("namedLogger".equals(name)) {
- namedLogger++;
- } else if ("faky-logger".equals(name)) {
- fakyLogger++;
- }
- } else {
- assertNotNull(record.getThrowable());
- throwables++;
- }
- }
-
- private void resetCounters() {
- fakyLogger = 0;
- namedLogger = 0;
- resourceLogger = 0;
- throwables = 0;
- }
-
- private void verifyCounters() {
- assertEquals(1, throwables);
- assertEquals(4, resourceLogger);
- assertEquals(2, namedLogger);
- assertEquals(1, fakyLogger);
- }
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69891e8b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java
deleted file mode 100644
index 0ea788a..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSLoggingAtomPushTest.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cxf.systest.jaxrs;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Queue;
-import java.util.concurrent.ConcurrentLinkedQueue;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogManager;
-import java.util.logging.LogRecord;
-import java.util.logging.Logger;
-
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-
-import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.Feed;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.endpoint.Server;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.jaxrs.JAXRSServerFactoryBean;
-import org.apache.cxf.jaxrs.provider.atom.AbstractEntryBuilder;
-import org.apache.cxf.jaxrs.provider.atom.AbstractFeedBuilder;
-import org.apache.cxf.jaxrs.provider.atom.AtomEntryProvider;
-import org.apache.cxf.jaxrs.provider.atom.AtomFeedProvider;
-import org.apache.cxf.management.web.logging.atom.AtomPushHandler;
-import org.apache.cxf.management.web.logging.atom.converter.Converter;
-import org.apache.cxf.management.web.logging.atom.converter.StandardConverter;
-import org.apache.cxf.management.web.logging.atom.converter.StandardConverter.Format;
-import org.apache.cxf.management.web.logging.atom.converter.StandardConverter.Multiplicity;
-import org.apache.cxf.management.web.logging.atom.converter.StandardConverter.Output;
-import org.apache.cxf.management.web.logging.atom.deliverer.Deliverer;
-import org.apache.cxf.management.web.logging.atom.deliverer.WebClientDeliverer;
-import org.apache.cxf.testutil.common.TestUtil;
-
-import org.junit.AfterClass;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class JAXRSLoggingAtomPushTest extends Assert {
- public static final String PORT = TestUtil.getPortNumber(JAXRSLoggingAtomPushTest.class);
- public static final Logger LOG = LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class);
-
- private static Server server;
-
- @BeforeClass
- public static void beforeClass() throws Exception {
- // disable logging for server startup
- configureLogging("resources/logging_atompush_disabled.properties");
-
- JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
- sf.setResourceClasses(JAXRSLoggingAtomPushTest.Resource.class);
- sf.setAddress("http://localhost:" + PORT + "/");
- sf.setProviders(Arrays.asList(new AtomFeedProvider(), new AtomEntryProvider()));
- server = sf.create();
- server.start();
- }
-
- /** Configures global logging */
- private static void configureLogging(String propFile) throws Exception {
- LogManager lm = LogManager.getLogManager();
- InputStream ins = JAXRSLoggingAtomPushTest.class.getResourceAsStream(propFile);
- String s = IOUtils.readStringFromStream(ins);
- ins.close();
- s = s.replaceAll("9080", PORT);
- lm.readConfiguration(new ByteArrayInputStream(s.getBytes(StandardCharsets.UTF_8)));
-
- for (Handler h : LOG.getHandlers()) {
- LOG.removeHandler(h);
- h.close();
- }
- if (lm.getProperty(JAXRSLoggingAtomPushTest.class.getName() + ".handlers") != null) {
- LOG.addHandler(new AtomPushHandler());
- }
- LOG.setUseParentHandlers(false);
- }
-
- private static void logSixEvents(Logger log) {
- log.severe("severe message");
- log.warning("warning message");
- log.info("info message");
- LogRecord r = new LogRecord(Level.FINE, "fine message");
- r.setThrown(new IllegalArgumentException("tadaam"));
- log.log(r);
- r = new LogRecord(Level.FINER, "finer message with {0} and {1}");
- r.setParameters(new Object[] {
- "param1", "param2"
- });
- r.setLoggerName("faky-logger");
- log.log(r);
- log.finest("finest message");
- }
-
- @AfterClass
- public static void afterClass() throws Exception {
- LogManager lm = LogManager.getLogManager();
- try {
- lm.reset();
- // restoring original configuration to not use tested logging handlers
- lm.readConfiguration();
- } catch (Exception e) {
- // ignore missing config file
- }
- if (server != null) {
- server.destroy();
- }
- }
-
- @Before
- public void before() throws Exception {
- Resource.clear();
- }
-
- private void waitForFeeds(Collection<?> c, int count) throws Exception {
- int iter = 0;
- while (c.size() < count) {
- Thread.sleep(100);
- iter++;
- if (iter > 30) {
- return;
- }
- }
- }
-
- @Test
- public void testPrivateLogger() throws Exception {
- configureLogging("resources/logging_atompush_disabled.properties");
- Logger log = LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class, null, "private-log");
- Converter c = new StandardConverter(Output.FEED, Multiplicity.ONE, Format.CONTENT);
- Deliverer d = new WebClientDeliverer("http://localhost:" + PORT);
- Handler h = new AtomPushHandler(2, c, d);
- log.addHandler(h);
- log.setLevel(Level.ALL);
- logSixEvents(log);
- // need to wait: multithreaded and client-server journey
- waitForFeeds(Resource.feeds, 3);
- // 6 events / 2 element batch = 3 feeds expected
- assertEquals("Different logged events count;", 3, Resource.feeds.size());
- }
-
- @Test
- public void testPrivateLoggerCustomBuilders() throws Exception {
- configureLogging("resources/logging_atompush_disabled.properties");
- Logger log = LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class, null, "private-log");
- AbstractFeedBuilder<List<org.apache.cxf.management.web.logging.LogRecord>> fb =
- createCustomFeedBuilder();
- AbstractEntryBuilder<List<org.apache.cxf.management.web.logging.LogRecord>> eb =
- createCustomEntryBuilder();
- Converter c = new StandardConverter(Output.FEED, Multiplicity.ONE, Format.CONTENT, fb, eb);
- Deliverer d = new WebClientDeliverer("http://localhost:" + PORT);
- Handler h = new AtomPushHandler(2, c, d);
- log.addHandler(h);
- log.setLevel(Level.ALL);
- logSixEvents(log);
- // need to wait: multithreaded and client-server journey
- waitForFeeds(Resource.feeds, 3);
- // 6 events / 2 element batch = 3 feeds expected
- assertEquals("Different logged events count;", 3, Resource.feeds.size());
- }
-
- @Test
- public void testOneElementBatch() throws Exception {
- configureLogging("resources/logging_atompush.properties");
- logSixEvents(LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class));
- // need to wait: multithreaded and client-server journey
- waitForFeeds(Resource.feeds, 6);
- assertEquals("Different logged events count;", 6, Resource.feeds.size());
- }
-
- @Test
- public void testMultiElementBatch() throws Exception {
- configureLogging("resources/logging_atompush_batch.properties");
- logSixEvents(LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class));
- // need to wait: multithreaded and client-server journey
- waitForFeeds(Resource.feeds, 2);
- // 6 events / 3 element batch = 2 feeds expected
- assertEquals("Different logged events count;", 2, Resource.feeds.size());
- }
-
-
-
- @Ignore
- private AbstractFeedBuilder<List<org.apache.cxf.management.web.logging.LogRecord>> createCustomFeedBuilder() {
-
- AbstractFeedBuilder<List<org.apache.cxf.management.web.logging.LogRecord>> fb =
- new AbstractFeedBuilder<List<org.apache.cxf.management.web.logging.LogRecord>>() {
- @Override
- public String getAuthor(List<org.apache.cxf.management.web.logging.LogRecord> pojo) {
- return "custom author";
- }
- };
- return fb;
- }
-
- @Ignore
- private AbstractEntryBuilder<List<org.apache.cxf.management.web.logging.LogRecord>> createCustomEntryBuilder() {
- AbstractEntryBuilder<List<org.apache.cxf.management.web.logging.LogRecord>> eb =
- new AbstractEntryBuilder<List<org.apache.cxf.management.web.logging.LogRecord>>() {
- @Override
- public String getSummary(List<org.apache.cxf.management.web.logging.LogRecord> pojo) {
- return "custom summary";
- }
- };
- return eb;
- }
-
- @Test
- public void testAtomPubEntries() throws Exception {
- configureLogging("resources/logging_atompush_atompub.properties");
- logSixEvents(LogUtils.getL7dLogger(JAXRSLoggingAtomPushTest.class));
- // need to wait: multithreaded and client-server journey
- waitForFeeds(Resource.entries, 6);
- // 6 events logged as entries
- assertEquals("Different logged events count;", 6, Resource.entries.size());
- }
-
- @Ignore
- @Path("/")
- public static class Resource {
-
- private static Queue<Feed> feeds = new ConcurrentLinkedQueue<Feed>();
- private static Queue<Entry> entries = new ConcurrentLinkedQueue<Entry>();
-
- @POST
- public void consume(Feed feed) {
- feeds.add(feed);
- }
-
- @POST
- @Path("/atomPub")
- public void consume(Entry entry) {
- entries.add(entry);
- }
-
- public static void clear() {
- feeds.clear();
- entries.clear();
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/cxf/blob/69891e8b/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/beans.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/beans.xml
deleted file mode 100644
index 7d55a72..0000000
--- a/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/beans.xml
+++ /dev/null
@@ -1,162 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to you under the Apache License, Version
- 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0 Unless required by
- applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the
- License.
- -->
-<!-- START SNIPPET: beans -->
-<!--
- beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:simple="http://cxf.apache.org/simple" xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
- http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd"
- -->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd">
- <import resource="classpath:META-INF/cxf/cxf.xml"/>
- <bean id="atomPullServer" class="org.apache.cxf.management.web.logging.atom.AtomPullServer" init-method="init">
- <property name="loggers" value=" org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource:ALL, namedLogger:WARN"/>
- <property name="bus">
- <ref bean="cxf"/>
- </property>
- <property name="endpointAddress" value="/resource"/>
- <property name="serverAddress" value="/atom"/>
- </bean>
- <bean id="atomPullServer2" class="org.apache.cxf.management.web.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="atomPullServer3" class="org.apache.cxf.management.web.logging.atom.AtomPullServer" init-method="init">
- <property name="loggers" value=" org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource3:ALL, theStorageLogger:WARN"/>
- <property name="pageSize" value="4"/>
- <property name="maxInMemorySize" value="4"/>
- <property name="storage">
- <ref bean="storage"/>
- </property>
- </bean>
- <bean id="atomPullServer4" class="org.apache.cxf.management.web.logging.atom.AtomPullServer" init-method="init">
- <property name="loggers" value=" org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource4:ALL, readOnlyStorageLogger:WARN"/>
- <property name="pageSize" value="4"/>
- <property name="storage">
- <ref bean="storage2"/>
- </property>
- </bean>
- <bean id="atomPullServer5" class="org.apache.cxf.management.web.logging.atom.AtomPullServer" init-method="init">
- <property name="pageSize" value="1"/>
- <property name="storage">
- <ref bean="storage3"/>
- </property>
- </bean>
- <bean id="storage" class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Storage"/>
- <bean id="storage2" class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$ExternalStorage"/>
- <bean id="storage3" class="org.apache.cxf.management.web.logging.ReadOnlyFileStorage">
- <property name="logLocation" value="{systemtests.jaxrs.logs.folder}/log.txt"/>
- <property name="numberOfColumns" value="2"/>
- <property name="columnsMap">
- <map>
- <entry key="1" value="level"/>
- <entry key="2" value="message"/>
- </map>
- </property>
- </bean>
- <bean id="feed" class="org.apache.cxf.jaxrs.provider.atom.AtomFeedProvider">
- <property name="formattedOutput" value="true"/>
- </bean>
- <bean id="entry" class="org.apache.cxf.jaxrs.provider.atom.AtomEntryProvider">
- <property name="formattedOutput" value="true"/>
- </bean>
- <jaxrs:server id="resourceServer" address="/resource">
- <jaxrs:serviceBeans>
- <bean class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <bean class="org.apache.cxf.jaxrs.ext.search.SearchContextProvider"/>
- </jaxrs:providers>
- </jaxrs:server>
- <jaxrs:server id="resource2Server" address="/resource2">
- <jaxrs:serviceBeans>
- <bean class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource2"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <bean class="org.apache.cxf.jaxrs.ext.search.SearchContextProvider"/>
- </jaxrs:providers>
- </jaxrs:server>
- <jaxrs:server id="resource3Server" address="/resource3">
- <jaxrs:serviceBeans>
- <bean class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$Resource3"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <bean class="org.apache.cxf.jaxrs.ext.search.SearchContextProvider"/>
- </jaxrs:providers>
- </jaxrs:server>
- <jaxrs:server id="atomServer" address="/atom">
- <jaxrs:serviceBeans>
- <ref bean="atomPullServer"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <ref bean="entry"/>
- <bean class="org.apache.cxf.jaxrs.ext.search.SearchContextProvider"/>
- </jaxrs:providers>
- </jaxrs:server>
- <jaxrs:server id="atomServer2" address="/atom2">
- <jaxrs:serviceBeans>
- <ref bean="atomPullServer2"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <bean class="org.apache.cxf.jaxrs.ext.search.SearchContextProvider"/>
- </jaxrs:providers>
- </jaxrs:server>
- <jaxrs:server id="atomServer3" address="/atom3">
- <jaxrs:serviceBeans>
- <ref bean="atomPullServer3"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <bean class="org.apache.cxf.jaxrs.ext.search.SearchContextProvider"/>
- </jaxrs:providers>
- </jaxrs:server>
- <jaxrs:server id="atomServer4" address="/atom4">
- <jaxrs:serviceBeans>
- <ref bean="atomPullServer4"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <bean class="org.apache.cxf.jaxrs.ext.search.SearchContextProvider"/>
- </jaxrs:providers>
- </jaxrs:server>
- <jaxrs:server id="atomServer5" address="/atom5">
- <jaxrs:serviceBeans>
- <ref bean="atomPullServer5"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <bean class="org.apache.cxf.jaxrs.ext.search.SearchContextProvider"/>
- </jaxrs:providers>
- </jaxrs:server>
- <jaxrs:server id="atomReset" address="/reset">
- <jaxrs:serviceBeans>
- <ref bean="atomServerReset"/>
- <bean class="org.apache.cxf.jaxrs.ext.search.SearchContextProvider"/>
- </jaxrs:serviceBeans>
- </jaxrs:server>
- <bean id="atomServerReset" class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPullSpringTest$AtomServerReset">
- <property name="server" ref="atomPullServer2"/>
- </bean>
-</beans>
-<!-- END SNIPPET: beans -->
http://git-wip-us.apache.org/repos/asf/cxf/blob/69891e8b/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/web.xml b/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/web.xml
deleted file mode 100644
index a8cae3f..0000000
--- a/systests/jaxrs/src/test/resources/jaxrs_logging_atompull/WEB-INF/web.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<!-- START SNIPPET: webxml -->
-<web-app>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>WEB-INF/beans.xml</param-value>
- </context-param>
- <listener>
- <listener-class>
- org.springframework.web.context.ContextLoaderListener
- </listener-class>
- </listener>
- <servlet>
- <servlet-name>CXFServlet</servlet-name>
- <display-name>CXF Servlet</display-name>
- <servlet-class>
- org.apache.cxf.transport.servlet.CXFServlet
- </servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>CXFServlet</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-</web-app>
-<!-- END SNIPPET: webxml -->
http://git-wip-us.apache.org/repos/asf/cxf/blob/69891e8b/systests/jaxrs/src/test/resources/jaxrs_logging_atompush/WEB-INF/beans.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_logging_atompush/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs_logging_atompush/WEB-INF/beans.xml
deleted file mode 100644
index 6e9867b..0000000
--- a/systests/jaxrs/src/test/resources/jaxrs_logging_atompush/WEB-INF/beans.xml
+++ /dev/null
@@ -1,126 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to you under the Apache License, Version
- 2.0 (the "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0 Unless required by
- applicable law or agreed to in writing, software distributed under the
- License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
- CONDITIONS OF ANY KIND, either express or implied. See the License for
- the specific language governing permissions and limitations under the
- License.
- -->
-<!-- START SNIPPET: beans -->
-<!--
- beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:simple="http://cxf.apache.org/simple" xsi:schemaLocation="
- http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
- http://cxf.apache.org/simple http://cxf.apache.org/schemas/simple.xsd"
- -->
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:util="http://www.springframework.org/schema/util" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.3.xsd">
- <import resource="classpath:META-INF/cxf/cxf.xml"/>
- <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
- <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>
- <jaxrs:server id="atomserver" address="/">
- <jaxrs:serviceBeans>
- <bean class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest$Resource"/>
- <bean class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest$Resource2"/>
- <bean class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest$Resource3"/>
- <bean class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest$Resource4"/>
- <bean class="org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest$Resource5"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <ref bean="entry"/>
- </jaxrs:providers>
- </jaxrs:server>
- <bean class="org.apache.cxf.management.web.logging.atom.AtomPushBean" init-method="init">
- <property name="multiplicity" value="one"/>
- <property name="loggers" value=" org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest$Resource:ALL, namedLogger:WARN"/>
- <property name="deliverer">
- <ref bean="webDeliverer"/>
- </property>
- </bean>
- <bean id="webDeliverer" class="org.apache.cxf.management.web.logging.atom.deliverer.WebClientDeliverer">
- <constructor-arg ref="webClient"/>
- </bean>
- <bean id="webClient" class="org.apache.cxf.jaxrs.client.WebClient" factory-method="create">
- <constructor-arg type="java.lang.String" value="http://localhost:${testutil.ports.SpringServer}/root/feeds"/>
- <constructor-arg ref="feedProvider"/>
- </bean>
- <bean class="org.apache.cxf.management.web.logging.atom.AtomPushBean" init-method="init">
- <property name="batchSize" value="4"/>
- <property name="loggers" value=" org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest$Resource2:ALL, namedLogger:WARN"/>
- <property name="url" value="http://localhost:${testutil.ports.SpringServer}/batch/feeds"/>
- </bean>
- <bean class="org.apache.cxf.management.web.logging.atom.AtomPushBean" init-method="init">
- <property name="output" value="entry"/>
- <property name="loggers" value=" org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest$Resource3:ALL, namedLogger:WARN"/>
- <property name="deliverer">
- <ref bean="webDeliverer3"/>
- </property>
- </bean>
- <bean id="webDeliverer3" class="org.apache.cxf.management.web.logging.atom.deliverer.WebClientDeliverer">
- <constructor-arg ref="webClient3"/>
- </bean>
- <bean id="webClient3" class="org.apache.cxf.jaxrs.client.WebClient" factory-method="create">
- <constructor-arg type="java.lang.String" value="http://localhost:${testutil.ports.SpringServer}/entries/entries"/>
- <constructor-arg ref="entryProvider"/>
- </bean>
- <bean class="org.apache.cxf.management.web.logging.atom.AtomPushBean" init-method="init">
- <property name="output" value="entry"/>
- <property name="multiplicity" value="many"/>
- <property name="batchSize" value="2"/>
- <property name="loggers" value=" org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest$Resource4:ALL, namedLogger:WARN"/>
- <property name="url" value="http://localhost:${testutil.ports.SpringServer}/entriesMany/entries"/>
- </bean>
- <bean class="org.apache.cxf.management.web.logging.atom.AtomPushBean" init-method="init">
- <property name="multiplicity" value="one"/>
- <property name="format" value="extension"/>
- <property name="loggers" value=" org.apache.cxf.systest.jaxrs.JAXRSLoggingAtomPushSpringTest$Resource5:ALL, namedLogger:WARN"/>
- <property name="url" value="http://localhost:${testutil.ports.SpringServer}/extensions/feeds"/>
- </bean>
- <util:list id="feedProvider">
- <ref bean="feed"/>
- </util:list>
- <util:list id="entryProvider">
- <ref bean="entry"/>
- </util:list>
- <bean id="feed" class="org.apache.cxf.jaxrs.provider.atom.AtomFeedProvider">
- <property name="formattedOutput" value="true"/>
- </bean>
- <bean id="entry" class="org.apache.cxf.jaxrs.provider.atom.AtomEntryProvider">
- <property name="formattedOutput" value="true"/>
- </bean>
- <!--
- Other config samples:
-
- <bean class="org.apache.cxf.management.web.logging.atom.AtomPushBean"
- init-method="init">
-
- <property name="url" value="http://localhost:${testutil.ports.SpringServer}/feed" />
- <property name="level" value="ALL" />
- </bean>
-
- <bean id="soapDeliverer" ... />
- <bean class="org.apache.cxf.management.web.logging.atom.AtomPushBean"
- init-method="init">
- <property name="deliverer">
- <ref bean="soapDeliverer" />
- </property>
- <property name="loggers"
- value="
- org.apache.cxf:DEBUG,
- org.apache.cxf.jaxrs:ALL,
- org.apache.cxf.bus:WARNING" />
- <property name="batchSize" value="10" />
- </bean>
- -->
-</beans>
-<!-- END SNIPPET: beans -->
http://git-wip-us.apache.org/repos/asf/cxf/blob/69891e8b/systests/jaxrs/src/test/resources/jaxrs_logging_atompush/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/systests/jaxrs/src/test/resources/jaxrs_logging_atompush/WEB-INF/web.xml b/systests/jaxrs/src/test/resources/jaxrs_logging_atompush/WEB-INF/web.xml
deleted file mode 100644
index a8cae3f..0000000
--- a/systests/jaxrs/src/test/resources/jaxrs_logging_atompush/WEB-INF/web.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<!-- START SNIPPET: webxml -->
-<web-app>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>WEB-INF/beans.xml</param-value>
- </context-param>
- <listener>
- <listener-class>
- org.springframework.web.context.ContextLoaderListener
- </listener-class>
- </listener>
- <servlet>
- <servlet-name>CXFServlet</servlet-name>
- <display-name>CXF Servlet</display-name>
- <servlet-class>
- org.apache.cxf.transport.servlet.CXFServlet
- </servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
- <servlet-mapping>
- <servlet-name>CXFServlet</servlet-name>
- <url-pattern>/*</url-pattern>
- </servlet-mapping>
-</web-app>
-<!-- END SNIPPET: webxml -->