You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2022/01/21 10:08:55 UTC
[cxf] branch master updated: Initial removal of Abdera (#894)
This is an automated email from the ASF dual-hosted git repository.
coheigea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cxf.git
The following commit(s) were added to refs/heads/master by this push:
new b740e0a Initial removal of Abdera (#894)
b740e0a is described below
commit b740e0a7f606d9e5acb8c27dfb3a671708bb19db
Author: Colm O hEigeartaigh <co...@users.noreply.github.com>
AuthorDate: Fri Jan 21 10:08:49 2022 +0000
Initial removal of Abdera (#894)
* Initial removal of Abdera
* Removed Abdera usage from the CDI system tests
Co-authored-by: Andriy Redko <dr...@gmail.com>
---
distribution/javadoc/pom.xml | 12 -
distribution/manifest/pom.xml | 15 -
osgi/bundle/compatible/pom.xml | 1 -
.../karaf/features/src/main/resources/features.xml | 14 -
parent/pom.xml | 107 ----
rt/rs/extensions/providers/pom.xml | 18 -
.../provider/atom/AbstractAtomElementBuilder.java | 120 ----
.../jaxrs/provider/atom/AbstractAtomProvider.java | 108 ----
.../jaxrs/provider/atom/AbstractEntryBuilder.java | 54 --
.../jaxrs/provider/atom/AbstractFeedBuilder.java | 48 --
.../cxf/jaxrs/provider/atom/AtomElementReader.java | 37 --
.../cxf/jaxrs/provider/atom/AtomElementWriter.java | 37 --
.../cxf/jaxrs/provider/atom/AtomEntryProvider.java | 45 --
.../cxf/jaxrs/provider/atom/AtomFeedProvider.java | 43 --
.../cxf/jaxrs/provider/atom/AtomPojoProvider.java | 681 ---------------------
.../cxf/jaxrs/provider/ProviderFactoryAllTest.java | 21 -
.../jaxrs/provider/atom/AtomEntryProviderTest.java | 103 ----
.../jaxrs/provider/atom/AtomFeedProviderTest.java | 98 ---
.../jaxrs/provider/atom/AtomPojoProviderTest.java | 408 ------------
.../apache/cxf/jaxrs/provider/atom/atomEntry.xml | 8 -
.../apache/cxf/jaxrs/provider/atom/atomFeed.xml | 17 -
.../org/apache/cxf/jaxrs/provider/atom/servers.xml | 72 ---
.../apache/cxf/systests/cdi/base/AtomFeed.java} | 53 +-
.../cxf/systests/cdi/base/AtomFeedEntry.java} | 24 +-
.../cxf/systests/cdi/base/AtomFeedProvider.java | 83 +++
systests/cdi/cdi-owb/cdi-producers-owb/pom.xml | 8 -
.../cxf/systest/jaxrs/cdi/BookStoreFeed.java | 11 +-
.../cxf/systest/jaxrs/cdi/SampleFeature.java | 2 +-
systests/cdi/cdi-weld/cdi-producers-weld/pom.xml | 8 -
.../cxf/systest/jaxrs/cdi/BookStoreFeed.java | 11 +-
.../cxf/systest/jaxrs/cdi/SampleFeature.java | 2 +-
systests/jaxrs/pom.xml | 12 -
.../apache/cxf/systest/jaxrs/AtomBookServer.java | 41 --
.../apache/cxf/systest/jaxrs/AtomBookStore.java | 210 -------
.../apache/cxf/systest/jaxrs/AtomBookStore2.java | 50 --
.../org/apache/cxf/systest/jaxrs/AtomUtils.java | 66 --
.../cxf/systest/jaxrs/CustomAtomFeedProvider.java | 47 --
.../cxf/systest/jaxrs/JAXRSAtomBookTest.java | 267 --------
.../test/resources/jaxrs_atom/WEB-INF/beans.xml | 94 ---
.../src/test/resources/jaxrs_atom/WEB-INF/web.xml | 50 --
40 files changed, 135 insertions(+), 2971 deletions(-)
diff --git a/distribution/javadoc/pom.xml b/distribution/javadoc/pom.xml
index 848be98..2b6b939 100644
--- a/distribution/javadoc/pom.xml
+++ b/distribution/javadoc/pom.xml
@@ -390,18 +390,6 @@
<artifactId>jettison</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-parser</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-extensions-json</artifactId>
- </dependency>
- <dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope>
diff --git a/distribution/manifest/pom.xml b/distribution/manifest/pom.xml
index 0d3b281..434ee6a 100644
--- a/distribution/manifest/pom.xml
+++ b/distribution/manifest/pom.xml
@@ -318,21 +318,6 @@
<artifactId>FastInfoset</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-core</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-parser</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-extensions-json</artifactId>
- <optional>true</optional>
- </dependency>
- <dependency>
<groupId>jakarta.xml.ws</groupId>
<artifactId>jakarta.xml.ws-api</artifactId>
<version>2.3.3</version>
diff --git a/osgi/bundle/compatible/pom.xml b/osgi/bundle/compatible/pom.xml
index 19154a4..86ee400 100644
--- a/osgi/bundle/compatible/pom.xml
+++ b/osgi/bundle/compatible/pom.xml
@@ -162,7 +162,6 @@
javax.xml.soap,
junit.framework*;resolution:=optional,
net.sf.cglib*;resolution:=optional;version="${cxf.cglib.osgi.version}",
- org.apache.abdera*;resolution:=optional;version="[1.0,2)",
org.apache.aries*;resolution:=optional;version="${cxf.aries.version.range}",
org.apache.commons.lang3*;resolution:=optional;version="[3,4)",
org.apache.commons.codec*;resolution:=optional,
diff --git a/osgi/karaf/features/src/main/resources/features.xml b/osgi/karaf/features/src/main/resources/features.xml
index 4232bc7..61672ae 100644
--- a/osgi/karaf/features/src/main/resources/features.xml
+++ b/osgi/karaf/features/src/main/resources/features.xml
@@ -44,20 +44,6 @@
<bundle start-level="20">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-xjc/${cxf.jaxb.bundle.version}</bundle>
<bundle start-level="20">mvn:com.sun.istack/istack-commons-runtime/${cxf.istack.bundle.version}</bundle>
</feature>
- <!-- Current the abdera bundle is not working as we expect -->
- <feature name="cxf-abdera" version="${project.version}">
- <feature version="${project.version}">cxf-specs</feature>
- <bundle start-level="25" dependency="true">mvn:commons-codec/commons-codec/${cxf.commons-codec.version}</bundle>
- <bundle start-level="35">mvn:org.apache.abdera/abdera-core/${cxf.abdera.version}</bundle>
- <bundle start-level="35">mvn:org.apache.abdera/abdera-extensions-main/${cxf.abdera.version}</bundle>
- <bundle start-level="35">mvn:org.apache.abdera/abdera-i18n/${cxf.abdera.version}</bundle>
- <bundle start-level="35">mvn:org.apache.james/apache-mime4j-core/${cxf.james.mim4j.version}</bundle>
- <bundle start-level="35">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.abdera-parser/${cxf.abdera.osgi.version}</bundle>
- <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.jdom/${cxf.jdom.bundle.version}</bundle>
- <bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.dom4j/${cxf.dom4j.bundle.version}</bundle>
- <!--bundle start-level='35'>mvn:org.apache.abdera/abdera-extensions-html/${cxf.abdera.version}</bundle>
- <bundle start-level='35'>mvn:org.apache.abdera/abdera-extensions-json/${cxf.abdera.version}</bundle>-->
- </feature>
<feature name="saaj-impl" version="${cxf.saaj-impl.version}">
<bundle start-level="25">mvn:org.jvnet.staxex/stax-ex/${cxf.stax-ex.version}</bundle>
<bundle start-level="25">mvn:com.sun.xml.messaging.saaj/saaj-impl/${cxf.saaj-impl.version}</bundle>
diff --git a/parent/pom.xml b/parent/pom.xml
index 54a228d..0ca6bc3 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -76,8 +76,6 @@
<cxf.osgi.javax.xml.ws.version>[0,3)</cxf.osgi.javax.xml.ws.version>
<!-- please maintain alphabetical order here -->
- <cxf.abdera.osgi.version>1.1.3_2</cxf.abdera.osgi.version>
- <cxf.abdera.version>1.1.3</cxf.abdera.version>
<cxf.activemq.version>5.16.3</cxf.activemq.version>
<cxf.ahc.version>2.12.3</cxf.ahc.version>
<cxf.apacheds.version>2.0.0.AM26</cxf.apacheds.version>
@@ -1741,111 +1739,6 @@
<version>${cxf.bcprov.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-core</artifactId>
- <version>${cxf.abdera.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.woodstox</groupId>
- <artifactId>woodstox-core-asl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-activation_1.0.2_spec</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-stax-api_1.0_spec</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-extensions-json</artifactId>
- <version>${cxf.abdera.version}</version>
- <exclusions>
- <exclusion>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-client</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-server</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-extensions-html</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-activation_1.0.2_spec</artifactId>
- </exclusion>
- <exclusion>
- <groupId>stax</groupId>
- <artifactId>stax-api</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-parser</artifactId>
- <version>${cxf.abdera.version}</version>
- <exclusions>
- <exclusion>
- <groupId>org.codehaus.woodstox</groupId>
- <artifactId>woodstox-core-asl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-activation_1.1_spec</artifactId>
- </exclusion>
- <exclusion>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-stax-api_1.0_spec</artifactId>
- </exclusion>
- <exclusion>
- <groupId>javax.mail</groupId>
- <artifactId>mail</artifactId>
- </exclusion>
- <exclusion>
- <groupId>xml-apis</groupId>
- <artifactId>xml-apis</artifactId>
- </exclusion>
- <exclusion>
- <groupId>stax</groupId>
- <artifactId>stax-api</artifactId>
- </exclusion>
- <exclusion>
- <artifactId>xmlParserAPIs</artifactId>
- <groupId>xerces</groupId>
- </exclusion>
- <exclusion>
- <artifactId>xercesImpl</artifactId>
- <groupId>xerces</groupId>
- </exclusion>
- <exclusion>
- <artifactId>xom</artifactId>
- <groupId>xom</groupId>
- </exclusion>
- <exclusion>
- <artifactId>xalan</artifactId>
- <groupId>xalan</groupId>
- </exclusion>
- <exclusion>
- <artifactId>xml-apis</artifactId>
- <groupId>xml-apis</groupId>
- </exclusion>
- <exclusion>
- <groupId>org.codehaus.woodstox</groupId>
- <artifactId>wstx-asl</artifactId>
- </exclusion>
- </exclusions>
- </dependency>
- <dependency>
<groupId>jaxen</groupId>
<artifactId>jaxen</artifactId>
<version>${cxf.jaxen.version}</version>
diff --git a/rt/rs/extensions/providers/pom.xml b/rt/rs/extensions/providers/pom.xml
index 689e2d2..61e780a 100644
--- a/rt/rs/extensions/providers/pom.xml
+++ b/rt/rs/extensions/providers/pom.xml
@@ -93,24 +93,6 @@
<optional>true</optional>
</dependency>
<dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-core</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-parser</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-extensions-json</artifactId>
- <scope>provided</scope>
- <optional>true</optional>
- </dependency>
- <dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<optional>true</optional>
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractAtomElementBuilder.java b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractAtomElementBuilder.java
deleted file mode 100644
index 068f1c1..0000000
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractAtomElementBuilder.java
+++ /dev/null
@@ -1,120 +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.jaxrs.provider.atom;
-
-import java.util.List;
-import java.util.Map;
-
-import org.apache.cxf.jaxrs.ext.MessageContext;
-
-/**
- * A callback-style provider which can be used to map an object to Atom Feed or Entry
- * without having to deal directly with types representing Atom feeds or entries
- *
- * @param <T> Type of objects which will be mapped to feeds or entries
- */
-public abstract class AbstractAtomElementBuilder<T> {
-
- private MessageContext mc;
-
- /**
- * Sets MessageContext
- * @param context message context
- */
- public void setMessageContext(MessageContext context) {
- mc = context;
- }
-
- /**
- * returns MessageContext
- * @return message context
- */
- public MessageContext getMessageContext() {
- return mc;
- }
-
- /**
- *
- * @param pojo Object which is being mapped
- * @return element title
- */
- public String getTitle(T pojo) {
- return null;
- }
-
- /**
- *
- * @param pojo Object which is being mapped
- * @return element author
- */
- public String getAuthor(T pojo) {
- return null;
- }
-
- /**
- *
- * @param pojo Object which is being mapped
- * @return element id
- */
- public String getId(T pojo) {
- return null;
- }
-
- /**
- *
- * @param pojo Object which is being mapped
- * @return base uri
- */
- public String getBaseUri(T pojo) {
- return null;
- }
-
- /**
- *
- * @param pojo Object which is being mapped
- * @return element updated date
- */
- public String getUpdated(T pojo) {
- return null;
- }
-
-
- /**
- *
- * @param pojo Object which is being mapped
- * @return element categories
- */
- public List<String> getCategories(T pojo) {
- return null;
- }
-
-
- //CHECKSTYLE:OFF
- /**
- * Returns a map of link URI to link relations type pairs
- * See {@link <a href="http://www.iana.org/assignments/link-relations/link-relations.xml">Atom Link Relations</a>}.
- *
- * @param pojo Object which is being mapped
- * @return the map of link URI to link relations type pairs
- */
- //CHECKSTYLE:ON
- public Map<String, String> getLinks(T pojo) {
- return null;
- }
-}
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractAtomProvider.java b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractAtomProvider.java
deleted file mode 100644
index 142621d..0000000
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractAtomProvider.java
+++ /dev/null
@@ -1,108 +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.jaxrs.provider.atom;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-import java.util.logging.Logger;
-
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.MessageBodyReader;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.abdera.Abdera;
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Element;
-import org.apache.abdera.parser.Parser;
-import org.apache.abdera.parser.ParserOptions;
-import org.apache.abdera.writer.Writer;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.jaxrs.utils.ExceptionUtils;
-import org.apache.cxf.staxutils.StaxUtils;
-
-public abstract class AbstractAtomProvider<T extends Element>
- implements MessageBodyWriter<T>, MessageBodyReader<T> {
-
- private static final Logger LOG = LogUtils.getL7dLogger(AbstractAtomProvider.class);
- private static final Abdera ATOM_ENGINE = new Abdera();
- private boolean autodetectCharset;
- private boolean formattedOutput;
-
- public long getSize(T element, Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
- return -1;
- }
-
- public void writeTo(T element, Class<?> clazz, Type type, Annotation[] a,
- MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os)
- throws IOException {
- if (MediaType.APPLICATION_JSON_TYPE.isCompatible(mt)) {
- Writer w = createWriter("json");
- if (w == null) {
- throw ExceptionUtils.toNotSupportedException(null, null);
- }
- element.writeTo(w, os);
- } else if (formattedOutput) {
- Writer w = createWriter("prettyxml");
- if (w != null) {
- element.writeTo(w, os);
- } else {
- element.writeTo(os);
- }
- } else {
- element.writeTo(os);
- }
- }
-
- protected Writer createWriter(String writerName) {
- Writer w = ATOM_ENGINE.getWriterFactory().getWriter(writerName);
- if (w == null) {
- LOG.fine("Atom writer \"" + writerName + "\" is not available");
- }
- return w;
- }
-
- public T readFrom(Class<T> clazz, Type t, Annotation[] a, MediaType mt,
- MultivaluedMap<String, String> headers, InputStream is)
- throws IOException {
- Parser parser = ATOM_ENGINE.getParser();
- synchronized (parser) {
- ParserOptions options = parser.getDefaultParserOptions();
- if (options != null) {
- options.setAutodetectCharset(autodetectCharset);
- }
- }
- XMLStreamReader reader = StaxUtils.createXMLStreamReader(is);
- Document<T> doc = parser.parse(reader);
- return doc.getRoot();
- }
-
- public void setFormattedOutput(boolean formattedOutput) {
- this.formattedOutput = formattedOutput;
- }
-
- public void setAutodetectCharset(boolean autodetectCharset) {
- this.autodetectCharset = autodetectCharset;
- }
-}
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractEntryBuilder.java b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractEntryBuilder.java
deleted file mode 100644
index 365288b..0000000
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractEntryBuilder.java
+++ /dev/null
@@ -1,54 +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.jaxrs.provider.atom;
-
-/**
- * A callback-style provider which can be used to map an object to Atom Entry
- * without having to deal directly with types representing Atom entries
- *
- * @param <T> Type of objects which will be mapped to entries
- */
-public abstract class AbstractEntryBuilder<T> extends AbstractAtomElementBuilder<T> {
- /**
- *
- * @param pojo Object which is being mapped
- * @return element publication date
- */
- public String getPublished(T pojo) {
- return null;
- }
-
- /**
- *
- * @param pojo Object which is being mapped
- * @return element summary
- */
- public String getSummary(T pojo) {
- return null;
- }
-
- /**
- *
- * @param pojo Object which is being mapped
- * @return entry content
- */
- public String getContent(T pojo) {
- return null;
- }
-}
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractFeedBuilder.java b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractFeedBuilder.java
deleted file mode 100644
index 64674ee..0000000
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AbstractFeedBuilder.java
+++ /dev/null
@@ -1,48 +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.jaxrs.provider.atom;
-
-/**
- * A callback-style provider which can be used to map an object to Atom Feed
- * without having to deal directly with types representing Atom feeds
- *
- * @param <T> Type of objects which will be mapped to feeds or entries
- */
-public abstract class AbstractFeedBuilder<T> extends AbstractAtomElementBuilder<T> {
-
- /**
- *
- * @param pojo Object which is being mapped
- * @return feed icon uri
- */
- public String getIcon(T pojo) {
- return null;
- }
-
- /**
- *
- * @param pojo Object which is being mapped
- * @return feed logo uri
- */
- public String getLogo(T pojo) {
- return null;
- }
-
-
-}
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomElementReader.java b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomElementReader.java
deleted file mode 100644
index 2d998dc..0000000
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomElementReader.java
+++ /dev/null
@@ -1,37 +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.jaxrs.provider.atom;
-
-import org.apache.abdera.model.Element;
-
-/**
- * A callback-style interface which can be used to deserialize an Atom Feed or Entry into a custom object
- * without having to introduce direct dependencies on Abdera API in the 'main' service code
- *
- * @param <T> Type of Atom element, Feed or Entry
- * @param <E> Type of objects which will be deseriaized from feed or entry
- *
- */
-public interface AtomElementReader<T extends Element, E> {
- /**
- * @param element Feed or Entry instance
- * @return pojoElement
- */
- E readFrom(T element);
-}
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomElementWriter.java b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomElementWriter.java
deleted file mode 100644
index 48dc204..0000000
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomElementWriter.java
+++ /dev/null
@@ -1,37 +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.jaxrs.provider.atom;
-
-import org.apache.abdera.model.Element;
-
-/**
- * A callback-style interface which can be used to map an object to an Atom Feed or Entry
- * without having to introduce direct dependencies on Abdera API in the 'main' service code
- *
- * @param <T> Type of Atom element, Feed or Entry
- * @param <E> Type of objects which will be mapped to feed or entry
- *
- */
-public interface AtomElementWriter<T extends Element, E> {
- /**
- * @param element Feed or Entry instance
- * @param pojoElement An object which needs to be mapped to the feed or entry
- */
- void writeTo(T element, E pojoElement);
-}
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomEntryProvider.java b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomEntryProvider.java
deleted file mode 100644
index 2f158c6..0000000
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomEntryProvider.java
+++ /dev/null
@@ -1,45 +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.jaxrs.provider.atom;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.ext.Provider;
-
-import org.apache.abdera.model.Entry;
-
-@Produces({"application/atom+xml", "application/atom+xml;type=entry", "application/json" })
-@Consumes({"application/atom+xml", "application/atom+xml;type=entry" })
-@Provider
-public class AtomEntryProvider extends AbstractAtomProvider<Entry> {
-
- public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
- return Entry.class.isAssignableFrom(type);
- }
-
- public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
- return Entry.class.isAssignableFrom(type);
- }
-
-}
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomFeedProvider.java b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomFeedProvider.java
deleted file mode 100644
index ce311cc..0000000
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomFeedProvider.java
+++ /dev/null
@@ -1,43 +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.jaxrs.provider.atom;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.ext.Provider;
-
-import org.apache.abdera.model.Feed;
-
-@Produces({"application/atom+xml", "application/atom+xml;type=feed", "application/json" })
-@Consumes({"application/atom+xml", "application/atom+xml;type=feed" })
-@Provider
-public class AtomFeedProvider extends AbstractAtomProvider<Feed> {
- public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
- return Feed.class.isAssignableFrom(type);
- }
-
- public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
- return Feed.class.isAssignableFrom(type);
- }
-}
diff --git a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java b/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java
deleted file mode 100644
index cb48557..0000000
--- a/rt/rs/extensions/providers/src/main/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProvider.java
+++ /dev/null
@@ -1,681 +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.jaxrs.provider.atom;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.StringReader;
-import java.io.StringWriter;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.lang.reflect.Type;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.UUID;
-import java.util.logging.Logger;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.ext.MessageBodyReader;
-import javax.ws.rs.ext.MessageBodyWriter;
-import javax.ws.rs.ext.Provider;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-
-import org.apache.abdera.Abdera;
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Content;
-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.abdera.writer.Writer;
-import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.jaxrs.ext.MessageContext;
-import org.apache.cxf.jaxrs.provider.AbstractConfigurableProvider;
-import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
-import org.apache.cxf.jaxrs.utils.ExceptionUtils;
-import org.apache.cxf.jaxrs.utils.InjectionUtils;
-import org.apache.cxf.jaxrs.utils.JAXRSUtils;
-import org.apache.cxf.staxutils.StaxUtils;
-
-@Produces({"application/atom+xml", "application/atom+xml;type=feed", "application/atom+xml;type=entry" })
-@Consumes({"application/atom+xml", "application/atom+xml;type=feed", "application/atom+xml;type=entry" })
-@Provider
-public class AtomPojoProvider extends AbstractConfigurableProvider
- implements MessageBodyWriter<Object>, MessageBodyReader<Object> {
-
- private static final Logger LOG = LogUtils.getL7dLogger(AtomPojoProvider.class);
- private static final Abdera ATOM_ENGINE = new Abdera();
- private static final String DEFAULT_ENTRY_CONTENT_METHOD = "getContent";
-
- private JAXBElementProvider<Object> jaxbProvider = new JAXBElementProvider<>();
- private Map<String, String> collectionGetters = Collections.emptyMap();
- private Map<String, String> collectionSetters = Collections.emptyMap();
-
- private Map<Class<?>, AtomElementWriter<?, ?>> atomClassWriters = Collections.emptyMap();
- private Map<Class<?>, AtomElementReader<?, ?>> atomClassReaders = Collections.emptyMap();
- private Map<Class<?>, AbstractAtomElementBuilder<?>> atomClassBuilders = Collections.emptyMap();
-
- //Consider deprecating String based maps
- private Map<String, AtomElementWriter<?, ?>> atomWriters = Collections.emptyMap();
- private Map<String, AtomElementReader<?, ?>> atomReaders = Collections.emptyMap();
- private Map<String, AbstractAtomElementBuilder<?>> atomBuilders = Collections.emptyMap();
-
- private MessageContext mc;
- private boolean formattedOutput;
- private boolean useJaxbForContent = true;
- private boolean autodetectCharset;
- private String entryContentMethodName = DEFAULT_ENTRY_CONTENT_METHOD;
-
- public void setUseJaxbForContent(boolean use) {
- this.useJaxbForContent = use;
- }
-
- public void setEntryContentMethodName(String name) {
- this.entryContentMethodName = name;
- }
-
- @Context
- public void setMessageContext(MessageContext context) {
- mc = context;
- for (AbstractAtomElementBuilder<?> builder : atomClassBuilders.values()) {
- builder.setMessageContext(context);
- }
- for (AtomElementWriter<?, ?> writer : atomClassWriters.values()) {
- tryInjectMessageContext(writer);
- }
- for (AtomElementReader<?, ?> reader : atomClassReaders.values()) {
- tryInjectMessageContext(reader);
- }
- for (AbstractAtomElementBuilder<?> builder : atomBuilders.values()) {
- builder.setMessageContext(context);
- }
- for (AtomElementWriter<?, ?> writer : atomWriters.values()) {
- tryInjectMessageContext(writer);
- }
- for (AtomElementReader<?, ?> reader : atomReaders.values()) {
- tryInjectMessageContext(reader);
- }
- }
-
- protected void tryInjectMessageContext(Object handler) {
- final Method m;
- try {
- m = handler.getClass().getMethod("setMessageContext", new Class[]{MessageContext.class});
- } catch (Throwable t) {
- return;
- }
- try {
- InjectionUtils.injectThroughMethod(handler, m, mc);
- } catch (Throwable t) {
- LOG.warning("Message context can not be injected into " + handler.getClass().getName()
- + " : " + t.getMessage());
- }
- }
-
- public long getSize(Object t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
- return -1;
- }
-
- public void setCollectionGetters(Map<String, String> methods) {
- collectionGetters = methods;
- }
-
- public void setCollectionSetters(Map<String, String> methods) {
- collectionSetters = methods;
- }
-
- public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
- return !Feed.class.isAssignableFrom(type) && !Entry.class.isAssignableFrom(type);
- }
-
- public void writeTo(Object o, Class<?> cls, Type genericType, Annotation[] annotations,
- MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os)
- throws IOException {
- boolean isFeed = isFeedRequested(mt);
- boolean isCollection = InjectionUtils.isSupportedCollectionOrArray(cls);
-
-
- if (isFeed && isCollection) {
- reportError("Atom feed can only be created from a collection wrapper", null);
- } else if (!isFeed && isCollection) {
- reportError("Atom entry can only be created from a single object", null);
- }
- Factory factory = Abdera.getNewFactory();
-
- Element atomElement = null;
- try {
- if (isFeed && !isCollection) {
- atomElement = createFeedFromCollectionWrapper(factory, o, cls);
- } else if (!isFeed && !isCollection) {
- atomElement = createEntryFromObject(factory, o, cls);
- }
- } catch (Exception ex) {
- throw ExceptionUtils.toInternalServerErrorException(ex, null);
- }
-
- try {
- writeAtomElement(atomElement, os);
- } catch (IOException ex) {
- reportError("Atom element can not be serialized", ex);
- }
- }
-
- private void writeAtomElement(Element atomElement, OutputStream os) throws IOException {
- Writer w = formattedOutput ? createWriter("prettyxml") : null;
- if (w != null) {
- atomElement.writeTo(w, os);
- } else {
- atomElement.writeTo(os);
- }
- }
-
- protected Writer createWriter(String writerName) {
- return ATOM_ENGINE.getWriterFactory().getWriter(writerName);
- }
-
- public void setFormattedOutput(boolean formattedOutput) {
- this.formattedOutput = formattedOutput;
- }
-
- protected Feed createFeedFromCollectionWrapper(Factory factory, Object o, Class<?> pojoClass)
- throws Exception {
-
- Feed feed = factory.newFeed();
-
- boolean writerUsed = buildFeed(feed, o, pojoClass);
-
- if (feed.getEntries().size() > 0) {
- return feed;
- }
-
- String methodName = getCollectionMethod(o.getClass(), true);
- Object collection = null;
- Method m = null;
- try {
- m = o.getClass().getMethod(methodName, new Class[]{});
- collection = m.invoke(o, new Object[]{});
- } catch (Exception ex) {
- reportError("Collection for " + o.getClass().getName() + " can not be retrieved", ex);
- }
-
- setFeedFromCollection(factory, feed, o, pojoClass, collection, m.getReturnType(),
- m.getGenericReturnType(), writerUsed);
- return feed;
- }
-
- private String getCollectionMethod(Class<?> cls, boolean getter) {
- Map<String, String> map = getter ? collectionGetters : collectionSetters;
- String methodName = getCollectionMethod(map, cls);
- if (methodName == null) {
- try {
- methodName = (getter ? "get" : "set") + cls.getSimpleName();
- Class<?>[] params = getter ? new Class[]{} : new Class[]{List.class};
- cls.getMethod(methodName, params);
- } catch (Exception ex) {
- String type = getter ? "getter" : "setter";
- reportError("Collection " + type + " method for " + cls.getName()
- + " has not been specified and no default " + methodName + " is available", null);
- }
- }
- return methodName;
- }
-
- private String getCollectionMethod(Map<String, String> map, Class<?> pojoClass) {
- if (pojoClass == Object.class) {
- return null;
- }
- String method = map.get(pojoClass.getName());
- if (method != null) {
- return method;
- }
- return getCollectionMethod(map, pojoClass.getSuperclass());
- }
-
- @SuppressWarnings("unchecked")
- protected <X> boolean buildFeed(Feed feed, X o, Class<?> pojoClass) {
- AtomElementWriter<?, ?> builder = getAtomWriter(pojoClass);
- if (builder != null) {
- ((AtomElementWriter<Feed, X>)builder).writeTo(feed, o);
- return true;
- }
- return false;
- }
-
- protected AtomElementWriter<?, ?> getAtomWriter(Class<?> pojoClass) {
- AtomElementWriter<?, ?> writer = getAtomClassElementHandler(atomClassWriters, pojoClass);
- return writer == null && atomWriters != null
- ? getAtomElementHandler(atomWriters, pojoClass) : writer;
- }
-
- protected AtomElementReader<?, ?> getAtomReader(Class<?> pojoClass) {
- AtomElementReader<?, ?> reader = getAtomClassElementHandler(atomClassReaders, pojoClass);
- return reader == null && atomReaders != null
- ? getAtomElementHandler(atomReaders, pojoClass) : reader;
- }
-
- private <T> T getAtomClassElementHandler(Map<Class<?>, T> handlers, Class<?> pojoClass) {
- for (Map.Entry<Class<?>, T> entry : handlers.entrySet()) {
- if (entry.getKey().isAssignableFrom(pojoClass)) {
- return entry.getValue();
- }
- }
- return null;
- }
-
- protected <T> T getAtomElementHandler(Map<String, T> handlers, Class<?> pojoClass) {
- T handler = getAtomElementHandlerSuperClass(handlers, pojoClass);
- if (handler == null) {
- Class<?>[] interfaces = pojoClass.getInterfaces();
- for (Class<?> inter : interfaces) {
- handler = handlers.get(inter.getName());
- if (handler != null) {
- break;
- }
- }
- }
- return handler;
- }
-
- private <T> T getAtomElementHandlerSuperClass(Map<String, T> handlers, Class<?> pojoClass) {
- if (pojoClass == null || pojoClass == Object.class) {
- return null;
- }
- T handler = handlers.get(pojoClass.getName());
- if (handler != null) {
- return handler;
- }
- return getAtomElementHandlerSuperClass(handlers, pojoClass.getSuperclass());
- }
-
- //CHECKSTYLE:OFF
- protected void setFeedFromCollection(Factory factory,
- Feed feed,
- Object wrapper,
- Class<?> wrapperCls,
- Object collection,
- Class<?> collectionCls,
- Type collectionType,
- boolean writerUsed) throws Exception {
- //CHECKSTYLE:ON
- Object[] arr = collectionCls.isArray() ? (Object[])collection : ((Collection<?>)collection).toArray();
- Class<?> memberClass = InjectionUtils.getActualType(collectionType);
-
- for (Object o : arr) {
- Entry entry = createEntryFromObject(factory, o, memberClass);
- feed.addEntry(entry);
- }
- if (!writerUsed) {
- setFeedProperties(factory, feed, wrapper, wrapperCls, collection, collectionCls, collectionType);
- }
- }
-
- protected AbstractAtomElementBuilder<?> getAtomBuilder(Class<?> pojoClass) {
- AbstractAtomElementBuilder<?> builder = getAtomClassElementHandler(atomClassBuilders, pojoClass);
- return builder == null && atomBuilders != null
- ? getAtomElementHandler(atomBuilders, pojoClass) : builder;
- }
-
- @SuppressWarnings("unchecked")
- protected void setFeedProperties(Factory factory,
- Feed feed,
- Object wrapper,
- Class<?> wrapperCls,
- Object collection,
- Class<?> collectionCls,
- Type collectionType) {
-
- AbstractAtomElementBuilder<Object> builder =
- (AbstractAtomElementBuilder<Object>)getAtomBuilder(wrapperCls);
- if (builder == null) {
- return;
- }
- setCommonElementProperties(factory, feed, builder, wrapper);
-
- AbstractFeedBuilder<Object> theBuilder = (AbstractFeedBuilder<Object>)builder;
-
- // the hierarchy is a bit broken in that we can not set author/title.etc on some
- // common Feed/Entry super type
-
- String author = theBuilder.getAuthor(wrapper);
- if (author != null) {
- feed.addAuthor(author);
- } else {
- feed.addAuthor("CXF JAX-RS");
- }
- String title = theBuilder.getTitle(wrapper);
- if (title != null) {
- feed.setTitle(title);
- } else {
- feed.setTitle(String.format(wrapper.getClass().getSimpleName()
- + " collection with %d entry(ies)", feed.getEntries().size()));
- }
-
- String id = theBuilder.getId(wrapper);
- if (id != null) {
- feed.setId(id);
- } else {
- feed.setId("uuid:" + UUID.randomUUID().toString());
- }
- String updated = theBuilder.getUpdated(wrapper);
- if (updated != null) {
- feed.setUpdated(updated);
- } else {
- feed.setUpdated(new Date());
- }
-
-
- Map<String, String> links = theBuilder.getLinks(wrapper);
- if (links != null) {
- for (Map.Entry<String, String> entry : links.entrySet()) {
- feed.addLink(entry.getKey(), entry.getValue());
- }
- }
- List<String> terms = theBuilder.getCategories(wrapper);
- if (terms != null) {
- for (String term : terms) {
- feed.addCategory(term);
- }
- }
-
-
- // feed specific
-
- String logo = theBuilder.getLogo(wrapper);
- if (logo != null) {
- feed.setLogo(logo);
- }
- String icon = theBuilder.getLogo(wrapper);
- if (icon != null) {
- feed.setIcon(icon);
- }
-
- }
-
-
-
- protected Entry createEntryFromObject(Factory factory, Object o, Class<?> cls) throws Exception {
- Entry entry = factory.getAbdera().newEntry();
-
- if (!buildEntry(entry, o, cls)) {
- setEntryProperties(factory, entry, o, cls);
- }
-
- if (entry.getContentElement() == null
- && entry.getExtensions().isEmpty()) {
- createEntryContent(factory, entry, o, cls);
- }
- return entry;
-
- }
-
- @SuppressWarnings("unchecked")
- protected boolean buildEntry(Entry entry, Object o, Class<?> pojoClass) {
- AtomElementWriter<?, ?> builder = getAtomWriter(pojoClass);
- if (builder != null) {
- ((AtomElementWriter<Entry, Object>)builder).writeTo(entry, o);
- return true;
- }
- return false;
- }
-
- protected void createEntryContent(Factory factory, Entry e, Object o, Class<?> cls) throws Exception {
-
- final String content;
-
- if (useJaxbForContent) {
- JAXBContext jc = jaxbProvider.getJAXBContext(cls, cls);
- StringWriter writer = new StringWriter();
- jc.createMarshaller().marshal(o, writer);
- content = writer.toString();
- } else {
- Method m = cls.getMethod(entryContentMethodName, new Class[]{});
- content = (String)m.invoke(o, new Object[]{});
- }
-
- setEntryContent(factory, e, content);
-
- }
-
- protected void setEntryContent(Factory factory, Entry e, String content) {
- Content ct = factory.newContent(Content.Type.XML);
- ct.setValue(content);
- e.setContentElement(ct);
- }
-
- protected void setEntryProperties(Factory factory, Entry entry,
- Object o, Class<?> cls) {
- @SuppressWarnings("unchecked")
- AbstractAtomElementBuilder<Object> builder
- = (AbstractAtomElementBuilder<Object>)getAtomBuilder(cls);
- if (builder == null) {
- return;
- }
-
- setCommonElementProperties(factory, entry, builder, o);
-
- AbstractEntryBuilder<Object> theBuilder = (AbstractEntryBuilder<Object>)builder;
- String author = theBuilder.getAuthor(o);
- if (author != null) {
- entry.addAuthor(author);
- } else {
- entry.addAuthor("CXF JAX-RS");
- }
- String title = theBuilder.getTitle(o);
- if (title != null) {
- entry.setTitle(title);
- } else {
- entry.setTitle(o.getClass().getSimpleName());
- }
-
- String id = theBuilder.getId(o);
- if (id != null) {
- entry.setId(id);
- } else {
- entry.setId("uuid:" + UUID.randomUUID().toString());
- }
- String updated = theBuilder.getUpdated(o);
- if (updated != null) {
- entry.setUpdated(updated);
- } else {
- entry.setUpdated(new Date());
- }
-
- Map<String, String> links = theBuilder.getLinks(o);
- if (links != null) {
- for (Map.Entry<String, String> e : links.entrySet()) {
- entry.addLink(e.getKey(), e.getValue());
- }
- }
-
- // entry specific
-
- String published = theBuilder.getPublished(o);
- if (published != null) {
- entry.setPublished(published);
- }
-
- String summary = theBuilder.getSummary(o);
- if (summary != null) {
- entry.setSummary(summary);
- }
-
- List<String> terms = theBuilder.getCategories(o);
- if (terms != null) {
- for (String term : terms) {
- entry.addCategory(term);
- }
- }
-
- String content = theBuilder.getContent(o);
- if (content != null) {
- setEntryContent(factory, entry, content);
- }
-
- }
-
- private void setCommonElementProperties(Factory factory, ExtensibleElement element,
- AbstractAtomElementBuilder<Object> builder,
- Object o) {
- String baseUri = builder.getBaseUri(o);
- if (baseUri != null) {
- element.setBaseUri(baseUri);
- }
-
- }
- private void reportError(String message, Exception ex, int status) {
- LOG.warning(message);
- Response response = JAXRSUtils.toResponseBuilder(status).type("text/plain").entity(message).build();
- throw ExceptionUtils.toHttpException(ex, response);
- }
- private void reportError(String message, Exception ex) {
- reportError(message, ex, 500);
- }
-
- protected boolean isFeedRequested(MediaType mt) {
- return !"entry".equalsIgnoreCase(mt.getParameters().get("type"));
- }
-
- public void setAtomWriters(Map<String, AtomElementWriter<?, ?>> writers) {
- this.atomWriters = writers;
- }
-
- public void setAtomReaders(Map<String, AtomElementReader<?, ?>> readers) {
- this.atomReaders = readers;
- }
-
- public void setAtomBuilders(Map<String, AbstractAtomElementBuilder<?>> builders) {
- this.atomBuilders = builders;
- }
-
- public void setAtomClassWriters(Map<Class<?>, AtomElementWriter<?, ?>> writers) {
- this.atomClassWriters = writers;
- }
-
- public void setAtomClassReaders(Map<Class<?>, AtomElementReader<?, ?>> readers) {
- this.atomClassReaders = readers;
- }
-
- public void setAtomClassBuilders(Map<Class<?>, AbstractAtomElementBuilder<?>> builders) {
- this.atomClassBuilders = builders;
- }
-
- public boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations,
- MediaType mediaType) {
- return true;
- }
-
- public Object readFrom(Class<Object> cls, Type type, Annotation[] anns, MediaType mt,
- MultivaluedMap<String, String> headers, InputStream is)
- throws IOException, WebApplicationException {
- boolean isFeed = isFeedRequested(mt);
-
- if (isFeed) {
- return readFromFeedOrEntry(cls, mt, headers, is);
- }
- AtomEntryProvider p = new AtomEntryProvider();
- p.setAutodetectCharset(autodetectCharset);
- Entry entry = p.readFrom(Entry.class, Entry.class,
- new Annotation[]{}, mt, headers, is);
- return readFromEntry(entry, cls);
- }
-
- @SuppressWarnings("unchecked")
- private Object readFromFeedOrEntry(Class<Object> cls, MediaType mt,
- MultivaluedMap<String, String> headers, InputStream is)
- throws IOException {
-
- AtomFeedProvider p = new AtomFeedProvider();
- p.setAutodetectCharset(autodetectCharset);
- Object atomObject = p.readFrom(Feed.class, Feed.class, new Annotation[]{}, mt, headers, is);
- if (atomObject instanceof Entry) {
- return this.readFromEntry((Entry)atomObject, cls);
- }
-
- Feed feed = (Feed)atomObject;
- AtomElementReader<?, ?> reader = getAtomReader(cls);
- if (reader != null) {
- return ((AtomElementReader<Feed, Object>)reader).readFrom(feed);
- }
- Object instance = null;
- try {
- String methodName = getCollectionMethod(cls, false);
- Method m = cls.getMethod(methodName, new Class[]{List.class});
- Class<Object> realCls
- = (Class<Object>)InjectionUtils.getActualType(m.getGenericParameterTypes()[0]);
- List<Object> objects = new ArrayList<>();
- for (Entry e : feed.getEntries()) {
- objects.add(readFromEntry(e, realCls));
- }
- instance = cls.newInstance();
- m.invoke(instance, new Object[]{objects});
-
- } catch (Exception ex) {
- reportError("Object of type " + cls.getName() + " can not be deserialized from Feed", ex, 400);
- }
- return instance;
- }
-
- @SuppressWarnings("unchecked")
- private Object readFromEntry(Entry entry, Class<Object> cls)
- throws IOException {
-
- AtomElementReader<?, ?> reader = getAtomReader(cls);
- if (reader != null) {
- return ((AtomElementReader<Entry, Object>)reader).readFrom(entry);
- }
- String entryContent = entry.getContent();
- if (entryContent != null) {
- XMLStreamReader xreader = StaxUtils.createXMLStreamReader(new StringReader(entryContent));
- try {
- Unmarshaller um =
- jaxbProvider.getJAXBContext(cls, cls).createUnmarshaller();
- return cls.cast(um.unmarshal(xreader));
- } catch (Exception ex) {
- reportError("Object of type " + cls.getName() + " can not be deserialized from Entry", ex, 400);
- } finally {
- try {
- StaxUtils.close(xreader);
- } catch (XMLStreamException e) {
- //ignore
- }
- }
- }
- return null;
- }
-
- public void setAutodetectCharset(boolean autodetectCharset) {
- this.autodetectCharset = autodetectCharset;
- }
-
-
-}
diff --git a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryAllTest.java b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryAllTest.java
index 0e83ae7..8f02119 100644
--- a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryAllTest.java
+++ b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/ProviderFactoryAllTest.java
@@ -23,10 +23,8 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.MessageBodyReader;
import javax.ws.rs.ext.MessageBodyWriter;
-import org.apache.cxf.jaxrs.provider.atom.AtomPojoProvider;
import org.apache.cxf.jaxrs.provider.json.JSONProvider;
import org.apache.cxf.jaxrs.resources.Book;
-import org.apache.cxf.jaxrs.resources.TagVO;
import org.apache.cxf.message.MessageImpl;
import org.junit.Before;
@@ -43,25 +41,6 @@ public class ProviderFactoryAllTest {
}
@Test
- public void testAtomPojoProvider() {
- ProviderFactory pf = ServerProviderFactory.getInstance();
- AtomPojoProvider provider = new AtomPojoProvider();
- pf.registerUserProvider(provider);
- MessageBodyReader<?> feedReader = pf.createMessageBodyReader(Book.class,
- Book.class, null,
- MediaType.valueOf("application/atom+xml"),
- new MessageImpl());
- assertSame(feedReader, provider);
-
- MessageBodyReader<?> entryReader = pf.createMessageBodyReader(TagVO.class,
- TagVO.class, null,
- MediaType.valueOf("application/atom+xml;type=entry"),
- new MessageImpl());
- assertSame(entryReader, provider);
- }
-
-
- @Test
public void testCustomJsonProvider() {
ProviderFactory pf = ServerProviderFactory.getInstance();
JSONProvider<Book> provider = new JSONProvider<>();
diff --git a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/AtomEntryProviderTest.java b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/AtomEntryProviderTest.java
deleted file mode 100644
index 251c114..0000000
--- a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/AtomEntryProviderTest.java
+++ /dev/null
@@ -1,103 +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.jaxrs.provider.atom;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-
-import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.Feed;
-import org.apache.abdera.parser.stax.FOMEntry;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class AtomEntryProviderTest {
-
- private AtomEntryProvider afd;
-
- @Before
- public void setUp() {
- afd = new AtomEntryProvider();
- }
-
- @Test
- public void testReadFrom() throws Exception {
- InputStream is = getClass().getResourceAsStream("atomEntry.xml");
- Entry simple = afd.readFrom(Entry.class, null, null, null, null, is);
- assertEquals("Wrong entry title",
- "Atom-Powered Robots Run Amok", simple.getTitle());
-
- }
-
- @Test
- public void testWriteTo() throws Exception {
- InputStream is = getClass().getResourceAsStream("atomEntry.xml");
- Entry simple = afd.readFrom(Entry.class, null,
- null, MediaType.valueOf("application/atom+xml;type=entry"), null, is);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- afd.writeTo(simple, null, null, null,
- MediaType.valueOf("application/atom+xml;type=entry"), null, bos);
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- Entry simpleCopy = afd.readFrom(Entry.class, null,
- null, MediaType.valueOf("application/atom+xml"), null, bis);
- assertEquals("Wrong entry title",
- "Atom-Powered Robots Run Amok", simpleCopy.getTitle());
- assertEquals("Wrong entry title",
- simple.getTitle(), simpleCopy.getTitle());
- }
-
- @Test
- public void testWriteable() {
- assertTrue(afd.isWriteable(Entry.class, null, null, null));
- assertTrue(afd.isWriteable(FOMEntry.class, null, null, null));
- assertFalse(afd.isWriteable(Feed.class, null, null, null));
- }
-
- @Test
- public void testReadable() {
- assertTrue(afd.isReadable(Entry.class, null, null, null));
- assertTrue(afd.isReadable(FOMEntry.class, null, null, null));
- assertFalse(afd.isReadable(Feed.class, null, null, null));
- }
-
- @Test
- public void testAnnotations() {
- String[] values = afd.getClass().getAnnotation(Produces.class).value();
- assertEquals("3 types can be produced", 3, values.length);
- assertTrue("application/atom+xml".equals(values[0])
- && "application/atom+xml;type=entry".equals(values[1])
- && "application/json".equals(values[2]));
- values = afd.getClass().getAnnotation(Consumes.class).value();
- assertEquals("2 types can be consumed", 2, values.length);
- assertTrue("application/atom+xml".equals(values[0])
- && "application/atom+xml;type=entry".equals(values[1]));
- }
-
-}
\ No newline at end of file
diff --git a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/AtomFeedProviderTest.java b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/AtomFeedProviderTest.java
deleted file mode 100644
index 6a3845e..0000000
--- a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/AtomFeedProviderTest.java
+++ /dev/null
@@ -1,98 +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.jaxrs.provider.atom;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Produces;
-
-import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.Feed;
-import org.apache.abdera.parser.stax.FOMFeed;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-public class AtomFeedProviderTest {
-
- private AtomFeedProvider afd;
-
- @Before
- public void setUp() {
- afd = new AtomFeedProvider();
- }
-
- @Test
- public void testReadFrom() throws Exception {
- InputStream is = getClass().getResourceAsStream("atomFeed.xml");
- Feed simple = afd.readFrom(Feed.class, null, null, null, null, is);
- assertEquals("Wrong feed title", "Example Feed", simple.getTitle());
-
- }
-
- @Test
- public void testWriteTo() throws Exception {
- InputStream is = getClass().getResourceAsStream("atomFeed.xml");
- Feed simple = afd.readFrom(Feed.class, null, null, null, null, is);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- afd.writeTo(simple, null, null, null, null, null, bos);
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- Feed simpleCopy = afd.readFrom(Feed.class, null, null, null, null, bis);
- assertEquals("Wrong entry title",
- "Example Feed", simpleCopy.getTitle());
- assertEquals("Wrong entry title",
- simple.getTitle(), simpleCopy.getTitle());
- }
-
- @Test
- public void testWriteable() {
- assertTrue(afd.isWriteable(Feed.class, null, null, null));
- assertTrue(afd.isWriteable(FOMFeed.class, null, null, null));
- assertFalse(afd.isWriteable(Entry.class, null, null, null));
- }
-
- @Test
- public void testReadable() {
- assertTrue(afd.isReadable(Feed.class, null, null, null));
- assertTrue(afd.isReadable(FOMFeed.class, null, null, null));
- assertFalse(afd.isReadable(Entry.class, null, null, null));
- }
-
- @Test
- public void testAnnotations() {
- String[] values = afd.getClass().getAnnotation(Produces.class).value();
- assertEquals("3 types can be produced", 3, values.length);
- assertTrue("application/atom+xml".equals(values[0])
- && "application/atom+xml;type=feed".equals(values[1])
- && "application/json".equals(values[2]));
- values = afd.getClass().getAnnotation(Consumes.class).value();
- assertEquals("2 types can be consumed", 2, values.length);
- assertTrue("application/atom+xml".equals(values[0])
- && "application/atom+xml;type=feed".equals(values[1]));
- }
-
-}
\ No newline at end of file
diff --git a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProviderTest.java b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProviderTest.java
deleted file mode 100644
index ce28783..0000000
--- a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/AtomPojoProviderTest.java
+++ /dev/null
@@ -1,408 +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.jaxrs.provider.atom;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.StringReader;
-import java.lang.annotation.Annotation;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-import javax.ws.rs.core.MediaType;
-import javax.xml.bind.Unmarshaller;
-import javax.xml.bind.annotation.XmlRootElement;
-
-import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.Feed;
-import org.apache.cxf.jaxrs.impl.MetadataMap;
-import org.apache.cxf.jaxrs.provider.JAXBElementProvider;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-
-
-public class AtomPojoProviderTest {
-
- private ClassPathXmlApplicationContext ctx;
-
- @Before
- public void setUp() {
- ctx =
- new ClassPathXmlApplicationContext(
- new String[] {"/org/apache/cxf/jaxrs/provider/atom/servers.xml"});
- }
-
- @Test
- public void testWriteFeedWithBuilders() throws Exception {
- AtomPojoProvider provider = (AtomPojoProvider)ctx.getBean("atom");
- assertNotNull(provider);
- provider.setFormattedOutput(true);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
-
- Books books = new Books();
- List<Book> bs = new ArrayList<>();
- bs.add(new Book("a"));
- bs.add(new Book("b"));
- books.setBooks(bs);
- provider.writeTo(books, Books.class, Books.class, new Annotation[]{},
- MediaType.valueOf("application/atom+xml"), null, bos);
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- Feed feed = new AtomFeedProvider().readFrom(Feed.class, null, null, null, null, bis);
- assertEquals("Books", feed.getTitle());
- List<Entry> entries = feed.getEntries();
- assertEquals(2, entries.size());
- verifyEntry(getEntry(entries, "a"), "a");
- verifyEntry(getEntry(entries, "b"), "b");
- }
-
- @Test
- public void testWriteFeedWithBuildersNoJaxb() throws Exception {
- AtomPojoProvider provider = (AtomPojoProvider)ctx.getBean("atomNoJaxb");
- assertNotNull(provider);
- provider.setFormattedOutput(true);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
-
- Books books = new Books();
- List<Book> bs = new ArrayList<>();
- bs.add(new Book("a"));
- bs.add(new Book("b"));
- books.setBooks(bs);
- provider.writeTo(books, Books.class, Books.class, new Annotation[]{},
- MediaType.valueOf("application/atom+xml"), null, bos);
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- Feed feed = new AtomFeedProvider().readFrom(Feed.class, null, null, null, null, bis);
- assertEquals("Books", feed.getTitle());
- List<Entry> entries = feed.getEntries();
- assertEquals(2, entries.size());
-
- Entry entryA = getEntry(entries, "a");
- verifyEntry(entryA, "a");
- String entryAContent = entryA.getContent();
- assertTrue("<a/>".equals(entryAContent) || "<a><a/>".equals(entryAContent)
- || "<a xmlns=\"\"/>".equals(entryAContent));
-
- Entry entryB = getEntry(entries, "b");
- verifyEntry(entryB, "b");
- String entryBContent = entryB.getContent();
- assertTrue("<b/>".equals(entryBContent) || "<b><b/>".equals(entryBContent)
- || "<b xmlns=\"\"/>".equals(entryBContent));
- }
-
- @Test
- public void testWriteEntryWithBuilders() throws Exception {
- AtomPojoProvider provider = (AtomPojoProvider)ctx.getBean("atom2");
- assertNotNull(provider);
- provider.setFormattedOutput(true);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- provider.writeTo(new Book("a"), Book.class, Book.class, new Annotation[]{},
- MediaType.valueOf("application/atom+xml;type=entry"), null, bos);
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- Entry entry = new AtomEntryProvider().readFrom(Entry.class, null, null, null, null, bis);
- verifyEntry(entry, "a");
-
- }
-
- @Test
- public void testReadEntryWithBuilders() throws Exception {
- AtomPojoProvider provider = (AtomPojoProvider)ctx.getBean("atom3");
- assertNotNull(provider);
- doTestReadEntry(provider);
- }
-
- @Test
- public void testReadEntryWithoutBuilders() throws Exception {
- doTestReadEntry(new AtomPojoProvider());
- }
-
- private void doTestReadEntry(AtomPojoProvider provider) throws Exception {
- provider.setFormattedOutput(true);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- MediaType mt = MediaType.valueOf("application/atom+xml;type=entry");
- provider.writeTo(new Book("a"), Book.class, Book.class, new Annotation[]{}, mt, null, bos);
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- @SuppressWarnings({"unchecked", "rawtypes" })
- Book book = (Book)provider.readFrom((Class)Book.class, Book.class,
- new Annotation[]{}, mt, null, bis);
- assertEquals("a", book.getName());
- }
- @Test
- public void testReadEntryNoBuilders2() throws Exception {
- final String entry =
- "<!DOCTYPE entry SYSTEM \"entry://entry\"><entry xmlns=\"http://www.w3.org/2005/Atom\">"
- + "<title type=\"text\">a</title>"
- + "<content type=\"application/xml\">"
- + "<book xmlns=\"\">"
- + "<name>a</name>"
- + "</book>"
- + "</content>"
- + "</entry>";
- AtomPojoProvider provider = new AtomPojoProvider();
- ByteArrayInputStream bis = new ByteArrayInputStream(entry.getBytes());
- MediaType mt = MediaType.valueOf("application/atom+xml;type=entry");
- @SuppressWarnings({"unchecked", "rawtypes" })
- Book book = (Book)provider.readFrom((Class)Book.class, Book.class,
- new Annotation[]{}, mt, null, bis);
- assertEquals("a", book.getName());
- }
-
-
- @Test
- public void testReadFeedWithBuilders() throws Exception {
- AtomPojoProvider provider = (AtomPojoProvider)ctx.getBean("atom4");
- assertNotNull(provider);
- doTestReadFeed(provider);
- }
-
- @Test
- public void testReadFeedWithoutBuilders() throws Exception {
- AtomPojoProvider provider = new AtomPojoProvider();
- doTestReadFeed(provider);
- }
-
- private void doTestReadFeed(AtomPojoProvider provider) throws Exception {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- MediaType mt = MediaType.valueOf("application/atom+xml;type=feed");
- Books books = new Books();
- List<Book> bs = new ArrayList<>();
- bs.add(new Book("a"));
- bs.add(new Book("b"));
- books.setBooks(bs);
- provider.writeTo(books, Books.class, Books.class, new Annotation[]{}, mt, null, bos);
- ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
- @SuppressWarnings({"unchecked", "rawtypes" })
- Books books2 = (Books)provider.readFrom((Class)Books.class, Books.class,
- new Annotation[]{}, mt, null, bis);
- List<Book> list = books2.getBooks();
- assertEquals(2, list.size());
- assertTrue("a".equals(list.get(0).getName()) || "a".equals(list.get(1).getName()));
- assertTrue("b".equals(list.get(0).getName()) || "b".equals(list.get(1).getName()));
- }
-
- @Test
- public void testReadFeedWithoutBuilders2() throws Exception {
- AtomPojoProvider provider = new AtomPojoProvider();
- final String feed =
- "<!DOCTYPE feed SYSTEM \"feed://feed\"><feed xmlns=\"http://www.w3.org/2005/Atom\">"
- + "<entry><content type=\"application/xml\"><book xmlns=\"\"><name>a</name></book></content></entry>"
- + "<entry><content type=\"application/xml\"><book xmlns=\"\"><name>b</name></book></content></entry>"
- + "</feed>";
- MediaType mt = MediaType.valueOf("application/atom+xml;type=feed");
- ByteArrayInputStream bis = new ByteArrayInputStream(feed.getBytes());
- @SuppressWarnings({"unchecked", "rawtypes" })
- Books books2 = (Books)provider.readFrom((Class)Books.class, Books.class,
- new Annotation[]{}, mt, null, bis);
- List<Book> list = books2.getBooks();
- assertEquals(2, list.size());
- assertTrue("a".equals(list.get(0).getName()) || "a".equals(list.get(1).getName()));
- assertTrue("b".equals(list.get(0).getName()) || "b".equals(list.get(1).getName()));
- }
- @Test
- public void testReadEntryNoContent() throws Exception {
- /** A sample entry without content. */
- final String entryNoContent =
- "<?xml version='1.0' encoding='UTF-8'?>\n"
- + "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
- + " <id>84297856</id>\n"
- + "</entry>";
-
- AtomPojoProvider atomPojoProvider = new AtomPojoProvider();
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- JaxbDataType type = (JaxbDataType)atomPojoProvider.readFrom((Class)JaxbDataType.class,
- JaxbDataType.class,
- new Annotation[0],
- MediaType.valueOf("application/atom+xml;type=entry"),
- new MetadataMap<String, String>(),
- new ByteArrayInputStream(entryNoContent.getBytes(StandardCharsets.UTF_8)));
- assertNull(type);
- }
-
- @Test
- public void testReadEntryWithUpperCaseTypeParam() throws Exception {
- doReadEntryWithContent("application/atom+xml;type=ENTRY");
- }
-
- @Test
- public void testReadEntryNoTypeParam() throws Exception {
- doReadEntryWithContent("application/atom+xml");
- }
-
- private void doReadEntryWithContent(String mediaType) throws Exception {
- final String entryWithContent =
- "<?xml version='1.0' encoding='UTF-8'?>\n"
- + "<entry xmlns=\"http://www.w3.org/2005/Atom\">\n"
- + " <id>84297856</id>\n"
- + " <content type=\"application/xml\">\n"
- + " <jaxbDataType xmlns=\"\">\n"
- + " </jaxbDataType>\n"
- + " </content>\n"
- + "</entry>";
-
- AtomPojoProvider atomPojoProvider = new AtomPojoProvider();
- @SuppressWarnings({
- "rawtypes", "unchecked"
- })
- JaxbDataType type = (JaxbDataType)atomPojoProvider.readFrom((Class)JaxbDataType.class,
- JaxbDataType.class,
- new Annotation[0],
- MediaType.valueOf(mediaType),
- new MetadataMap<String, String>(),
- new ByteArrayInputStream(entryWithContent.getBytes(StandardCharsets.UTF_8)));
- assertNotNull(type);
- }
-
- /**
- * A sample JAXB data-type to read data into.
- */
- @XmlRootElement
- public static class JaxbDataType {
- // no data
- }
-
- private Entry getEntry(List<Entry> entries, String title) {
- for (Entry e : entries) {
- if (title.equals(e.getTitle())) {
- return e;
- }
- }
- return null;
- }
-
- private void verifyEntry(Entry e, String title) {
- assertNotNull(e);
- assertEquals(title, e.getTitle());
- }
-
- public static class CustomFeedWriter implements AtomElementWriter<Feed, Books> {
-
- public void writeTo(Feed feed, Books pojoFeed) {
- feed.setTitle("Books");
- }
-
- }
-
- public static class CustomEntryWriter implements AtomElementWriter<Entry, Book> {
-
- public void writeTo(Entry entry, Book pojoEntry) {
- entry.setTitle(pojoEntry.getName());
- }
-
- }
-
- public static class CustomEntryReader implements AtomElementReader<Entry, Book> {
-
- public Book readFrom(Entry element) {
- try {
- String s = element.getContent();
-
- Unmarshaller um =
- new JAXBElementProvider<Book>().getJAXBContext(Book.class, Book.class)
- .createUnmarshaller();
- return (Book)um.unmarshal(new StringReader(s));
- } catch (Exception ex) {
- // ignore
- }
- return null;
- }
-
- }
-
- public static class CustomFeedReader implements AtomElementReader<Feed, Books> {
-
- public Books readFrom(Feed element) {
- Books books = new Books();
- List<Book> list = new ArrayList<>();
- CustomEntryReader entryReader = new CustomEntryReader();
- for (Entry e : element.getEntries()) {
- list.add(entryReader.readFrom(e));
- }
- books.setBooks(list);
- return books;
- }
-
- }
-
- public static class CustomFeedBuilder extends AbstractFeedBuilder<Books> {
- @Override
- public String getBaseUri(Books books) {
- return "http://books";
- }
- }
-
- public static class CustomEntryBuilder extends AbstractEntryBuilder<Book> {
- @Override
- public String getBaseUri(Book books) {
- return "http://book";
- }
- }
-
-
- @XmlRootElement
- public static class Book {
- private String name = "Book";
-
- public Book() {
-
- }
-
- public Book(String name) {
- this.name = name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public String getXMLContent() {
- return "<" + name + "/>";
- }
-
- }
-
- @XmlRootElement
- public static class Books {
-
- private List<Book> books;
-
- public Books() {
-
- }
-
- public List<Book> getBooks() {
- return books;
- }
-
- public void setBooks(List<Book> list) {
- books = list;
- }
- }
-}
\ No newline at end of file
diff --git a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/atomEntry.xml b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/atomEntry.xml
deleted file mode 100644
index 1e11215..0000000
--- a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/atomEntry.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<entry xmlns="http://www.w3.org/2005/Atom" xml:base="http://example.org/">
- <title>Atom-Powered Robots Run Amok</title>
- <link href="/2003/12/13/atom03"/>
- <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
- <updated>2003-12-13T18:30:02Z</updated>
- <summary>Some text.</summary>
-</entry>
diff --git a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/atomFeed.xml b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/atomFeed.xml
deleted file mode 100644
index 06a7808..0000000
--- a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/atomFeed.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<feed xmlns="http://www.w3.org/2005/Atom" xml:base="http://example.org/">
- <title>Example Feed</title>
- <link href=""/>
- <updated>2003-12-13T18:30:02Z</updated>
- <author>
- <name>John Doe</name>
- </author>
- <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
- <entry>
- <title>Atom-Powered Robots Run Amok</title>
- <link href="/2003/12/13/atom03"/>
- <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
- <updated>2003-12-13T18:30:02Z</updated>
- <summary>Some text.</summary>
- </entry>
-</feed>
diff --git a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/servers.xml b/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/servers.xml
deleted file mode 100644
index 5377896..0000000
--- a/rt/rs/extensions/providers/src/test/java/org/apache/cxf/jaxrs/provider/atom/servers.xml
+++ /dev/null
@@ -1,72 +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.
--->
-<beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:util="http://www.springframework.org/schema/util"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd">
- <bean id="atom" class="org.apache.cxf.jaxrs.provider.atom.AtomPojoProvider">
- <property name="atomWriters" ref="atomWriters"/>
- <property name="atomBuilders" ref="atomBuilders"/>
- </bean>
- <bean id="atomNoJaxb" class="org.apache.cxf.jaxrs.provider.atom.AtomPojoProvider">
- <property name="atomWriters" ref="atomWriters"/>
- <property name="atomBuilders" ref="atomBuilders"/>
- <property name="useJaxbForContent" value="false"/>
- <property name="entryContentMethodName" value="getXMLContent"/>
- </bean>
- <bean id="atom2" class="org.apache.cxf.jaxrs.provider.atom.AtomPojoProvider">
- <property name="atomWriters" ref="atomWriters2"/>
- <property name="atomBuilders" ref="atomBuilders2"/>
- </bean>
- <bean id="atom3" class="org.apache.cxf.jaxrs.provider.atom.AtomPojoProvider">
- <property name="atomWriters" ref="atomWriters2"/>
- <property name="atomReaders" ref="atomReaders2"/>
- </bean>
- <bean id="atom4" class="org.apache.cxf.jaxrs.provider.atom.AtomPojoProvider">
- <property name="atomWriters" ref="atomWriters"/>
- <property name="atomReaders" ref="atomReaders"/>
- </bean>
- <util:map id="atomWriters">
- <entry key="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$Books" value-ref="feedWriter"/>
- <entry key="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$Book" value-ref="entryWriter"/>
- </util:map>
- <util:map id="atomWriters2">
- <entry key="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$Book" value-ref="entryWriter"/>
- </util:map>
- <util:map id="atomReaders">
- <entry key="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$Books" value-ref="feedReader"/>
- </util:map>
- <util:map id="atomReaders2">
- <entry key="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$Book" value-ref="entryReader"/>
- </util:map>
- <bean id="feedWriter" class="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$CustomFeedWriter"/>
- <bean id="entryWriter" class="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$CustomEntryWriter"/>
- <bean id="entryReader" class="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$CustomEntryReader"/>
- <bean id="feedReader" class="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$CustomFeedReader"/>
- <util:map id="atomBuilders">
- <entry key="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$Books" value-ref="simpleFeedBuilder"/>
- <entry key="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$Book" value-ref="simpleEntryBuilder"/>
- </util:map>
- <bean id="simpleFeedBuilder" class="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$CustomFeedBuilder"/>
- <util:map id="atomBuilders2">
- <entry key="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$Book" value-ref="simpleEntryBuilder"/>
- </util:map>
- <bean id="simpleEntryBuilder" class="org.apache.cxf.jaxrs.provider.atom.AtomPojoProviderTest$CustomEntryBuilder"/>
-</beans>
\ No newline at end of file
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AtomFeed.java
similarity index 50%
rename from systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java
rename to systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AtomFeed.java
index 06f1618..0ec1d72 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBook.java
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AtomFeed.java
@@ -16,35 +16,44 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.cxf.systests.cdi.base;
-package org.apache.cxf.systest.jaxrs;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collection;
-import javax.ws.rs.GET;
-import javax.ws.rs.Produces;
+public class AtomFeed implements Serializable {
+ private static final long serialVersionUID = 1L;
-import org.apache.abdera.model.Entry;
+ private String id;
+ private String language;
+ private Collection<AtomFeedEntry> entries = new ArrayList<>();
-
-public class AtomBook {
- private Book book;
-
- public AtomBook(Book book) {
- this.book = book;
+ public AtomFeed() {
}
-
-
- @GET
- @Produces("application/atom+xml")
- public Entry getAsEntry() {
- try {
- return AtomUtils.createBookEntry(book);
- } catch (Exception ex) {
- // common, it's just a test
- }
- return null;
+ public String getLanguage() {
+ return language;
}
+ public void setLanguage(final String language) {
+ this.language = language;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getId() {
+ return id;
+ }
-
+ public void addEntry(AtomFeedEntry entry) {
+ entries.add(entry);
+ }
+
+ public Collection<AtomFeedEntry> getEntries() {
+ return entries;
+ }
}
+
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore3.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AtomFeedEntry.java
similarity index 74%
rename from systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore3.java
rename to systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AtomFeedEntry.java
index 59df36d..cd682d1 100644
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore3.java
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AtomFeedEntry.java
@@ -16,22 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
+package org.apache.cxf.systests.cdi.base;
+public class AtomFeedEntry {
+ private String link;
-package org.apache.cxf.systest.jaxrs;
-
-
-import javax.ws.rs.Path;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.UriInfo;
-
-@Path("/atom")
-public class AtomBookStore3 extends AtomBookStore {
-
- @Context
- public void setUriInfo(UriInfo ui) {
- super.uField = ui;
+ public void addLink(String l) {
+ this.link = l;
+ }
+
+ public String getLink() {
+ return link;
}
}
-
-
diff --git a/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AtomFeedProvider.java b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AtomFeedProvider.java
new file mode 100644
index 0000000..2deeee0
--- /dev/null
+++ b/systests/cdi/base/src/main/java/org/apache/cxf/systests/cdi/base/AtomFeedProvider.java
@@ -0,0 +1,83 @@
+/**
+ * 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.systests.cdi.base;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+import javax.ws.rs.Consumes;
+import javax.ws.rs.Produces;
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.ext.MessageBodyWriter;
+import javax.ws.rs.ext.Provider;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamWriter;
+
+import org.apache.cxf.staxutils.StaxUtils;
+
+@Produces({"application/atom+xml", "application/atom+xml;type=feed", "application/json" })
+@Consumes({"application/atom+xml", "application/atom+xml;type=feed" })
+@Provider
+public class AtomFeedProvider implements MessageBodyWriter<AtomFeed> {
+ @Override
+ public boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mt) {
+ return AtomFeed.class.isAssignableFrom(type);
+ }
+
+ @Override
+ public void writeTo(AtomFeed t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
+ MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream)
+ throws IOException, WebApplicationException {
+ final XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(entityStream);
+ try {
+ writer.writeStartDocument();
+ writer.writeStartElement("feed");
+ if (t.getId() != null) {
+ writer.writeAttribute("id", t.getId());
+ }
+ if (t.getLanguage() != null) {
+ writer.writeAttribute("language", t.getLanguage());
+ }
+ writer.writeStartElement("entries");
+ for (final AtomFeedEntry entry: t.getEntries()) {
+ writer.writeStartElement("entry");
+ if (entry.getLink() != null) {
+ writer.writeAttribute("link", entry.getLink());
+ }
+ writer.writeEndElement();
+ }
+ writer.writeEndElement();
+ writer.writeEndElement();
+ writer.writeEndDocument();
+ } catch (XMLStreamException ex) {
+ throw new IOException(ex);
+ } finally {
+ try {
+ writer.close();
+ } catch (XMLStreamException ex) {
+ throw new IOException(ex);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/pom.xml b/systests/cdi/cdi-owb/cdi-producers-owb/pom.xml
index 6b4f144..95b42e4 100644
--- a/systests/cdi/cdi-owb/cdi-producers-owb/pom.xml
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/pom.xml
@@ -42,14 +42,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-parser</artifactId>
- </dependency>
- <dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${cxf.mockito.version}</version>
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java
index 89f0d52..998e49d 100644
--- a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java
@@ -24,9 +24,8 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
-import org.apache.abdera.model.Feed;
-import org.apache.abdera.parser.stax.FOMEntry;
-import org.apache.abdera.parser.stax.FOMFeed;
+import org.apache.cxf.systests.cdi.base.AtomFeed;
+import org.apache.cxf.systests.cdi.base.AtomFeedEntry;
import org.apache.cxf.systests.cdi.base.Book;
import org.apache.cxf.systests.cdi.base.BookStoreService;
@@ -42,11 +41,11 @@ public class BookStoreFeed {
@Path("/books/feed")
@NotNull @Valid
@Produces("application/atom+xml")
- public Feed getBooks() {
- final FOMFeed feed = new FOMFeed();
+ public AtomFeed getBooks() {
+ final AtomFeed feed = new AtomFeed();
for (final Book book: service.all()) {
- final FOMEntry entry = new FOMEntry();
+ final AtomFeedEntry entry = new AtomFeedEntry();
entry.addLink("/bookstore/books/" + book.getId());
feed.addEntry(entry);
}
diff --git a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
index 9aa2638..d2f838e 100644
--- a/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
+++ b/systests/cdi/cdi-owb/cdi-producers-owb/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
@@ -22,7 +22,7 @@ package org.apache.cxf.systest.jaxrs.cdi;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
-import org.apache.cxf.jaxrs.provider.atom.AtomFeedProvider;
+import org.apache.cxf.systests.cdi.base.AtomFeedProvider;
import org.apache.cxf.systests.cdi.base.BookStoreRequestFilter;
import org.apache.cxf.systests.cdi.base.BookStoreResponseFilter;
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/pom.xml b/systests/cdi/cdi-weld/cdi-producers-weld/pom.xml
index e628a7c..f95b7ac 100644
--- a/systests/cdi/cdi-weld/cdi-producers-weld/pom.xml
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/pom.xml
@@ -42,14 +42,6 @@
<version>${project.version}</version>
</dependency>
<dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-parser</artifactId>
- </dependency>
- <dependency>
<groupId>org.jboss.weld.se</groupId>
<artifactId>weld-se-core</artifactId>
<version>${cxf.jboss.weld.version}</version>
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java
index b0c345f..707bcd6 100644
--- a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/BookStoreFeed.java
@@ -26,9 +26,8 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Response;
-import org.apache.abdera.model.Feed;
-import org.apache.abdera.parser.stax.FOMEntry;
-import org.apache.abdera.parser.stax.FOMFeed;
+import org.apache.cxf.systests.cdi.base.AtomFeed;
+import org.apache.cxf.systests.cdi.base.AtomFeedEntry;
import org.apache.cxf.systests.cdi.base.Book;
import org.apache.cxf.systests.cdi.base.BookStoreService;
@@ -47,11 +46,11 @@ public class BookStoreFeed {
@Path("/books/feed")
@NotNull @Valid
@Produces("application/atom+xml")
- public Feed getBooks() {
- final FOMFeed feed = new FOMFeed();
+ public AtomFeed getBooks() {
+ final AtomFeed feed = new AtomFeed();
for (final Book book: service.all()) {
- final FOMEntry entry = new FOMEntry();
+ final AtomFeedEntry entry = new AtomFeedEntry();
entry.addLink("/bookstore/books/" + book.getId());
feed.addEntry(entry);
}
diff --git a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
index 9aa2638..d2f838e 100644
--- a/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
+++ b/systests/cdi/cdi-weld/cdi-producers-weld/src/test/java/org/apache/cxf/systest/jaxrs/cdi/SampleFeature.java
@@ -22,7 +22,7 @@ package org.apache.cxf.systest.jaxrs.cdi;
import javax.ws.rs.core.Feature;
import javax.ws.rs.core.FeatureContext;
-import org.apache.cxf.jaxrs.provider.atom.AtomFeedProvider;
+import org.apache.cxf.systests.cdi.base.AtomFeedProvider;
import org.apache.cxf.systests.cdi.base.BookStoreRequestFilter;
import org.apache.cxf.systests.cdi.base.BookStoreResponseFilter;
diff --git a/systests/jaxrs/pom.xml b/systests/jaxrs/pom.xml
index 3a93486..d50a7fe 100644
--- a/systests/jaxrs/pom.xml
+++ b/systests/jaxrs/pom.xml
@@ -98,18 +98,6 @@
<artifactId>xalan</artifactId>
</dependency>
<dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-core</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-parser</artifactId>
- </dependency>
- <dependency>
- <groupId>org.apache.abdera</groupId>
- <artifactId>abdera-extensions-json</artifactId>
- </dependency>
- <dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-rs-service-description</artifactId>
<version>${project.version}</version>
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java
deleted file mode 100644
index a7eba9e..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookServer.java
+++ /dev/null
@@ -1,41 +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;
-
-public class AtomBookServer extends AbstractSpringServer {
-
- public static final String PORT = allocatePort(AtomBookServer.class);
-
- public AtomBookServer() {
- super("/jaxrs_atom", Integer.parseInt(PORT));
- }
-
- public static void main(String[] args) {
- try {
- AtomBookServer s = new AtomBookServer();
- s.start();
- } catch (Exception ex) {
- ex.printStackTrace();
- System.exit(-1);
- } finally {
- System.out.println("done!");
- }
- }
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java
deleted file mode 100644
index d462c46..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore.java
+++ /dev/null
@@ -1,210 +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.net.URI;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.GET;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.WebApplicationException;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.HttpHeaders;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.ws.rs.core.UriInfo;
-import javax.xml.bind.JAXBContext;
-
-import org.apache.abdera.Abdera;
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.Feed;
-import org.apache.cxf.customer.book.BookNotFoundDetails;
-import org.apache.cxf.customer.book.BookNotFoundFault;
-
-@Path("/")
-public class AtomBookStore {
-
- @Context protected UriInfo uField;
- private HttpHeaders headers;
- private Map<Long, Book> books = new HashMap<>();
- private Map<Long, CD> cds = new HashMap<>();
- private long bookId = 123;
- private long cdId = 123;
-
- public AtomBookStore() {
- init();
- //System.out.println("----books: " + books.size());
- }
-
- @Context
- public void setHttpHeaders(HttpHeaders theHeaders) {
- headers = theHeaders;
- }
-
- @GET
- @Path("/books/jsonfeed")
- @Produces({"application/xml", "application/json", "text/html", "application/atom+xml" })
- public Feed getBooksAsJsonFeed(@Context UriInfo uParam) {
- return getBooksAsFeed(uParam);
- }
-
-
- @GET
- @Path("/books/feed")
- @Produces({"application/atom+xml", "application/json" })
- public Feed getBooksAsFeed(@Context UriInfo uParam) {
-
- MediaType mt = headers.getMediaType();
- if (!mt.equals(MediaType.valueOf(MediaType.MEDIA_TYPE_WILDCARD))
- && !mt.equals(MediaType.APPLICATION_JSON_TYPE)
- && !mt.equals(MediaType.APPLICATION_ATOM_XML_TYPE)) {
- throw new WebApplicationException();
- }
-
- return doGetBookAsFeed(uParam);
- }
-
- private Feed doGetBookAsFeed(@Context UriInfo uParam) {
- Factory factory = Abdera.getNewFactory();
- Feed f = factory.newFeed();
- f.setBaseUri(uParam.getAbsolutePath().toString());
- f.setTitle("Collection of Books");
- f.setId("http://www.books.com");
- f.addAuthor("BookStore Management Company");
- try {
- for (Book b : books.values()) {
-
- Entry e = AtomUtils.createBookEntry(factory, b);
-
- f.addEntry(e);
- }
- } catch (Exception ex) {
- // ignore
- }
- return f;
- }
-
- @POST
- @Path("/books/feed")
- @Consumes("application/atom+xml")
- public Response addBookAsEntry(Entry e) {
- try {
- String text = e.getContentElement().getValue();
- StringReader reader = new StringReader(text);
- JAXBContext jc = JAXBContext.newInstance(Book.class);
- Book b = (Book)jc.createUnmarshaller().unmarshal(reader);
- books.put(b.getId(), b);
-
- URI uri =
- uField.getBaseUriBuilder().path("books").path("entries")
- .path(Long.toString(b.getId())).build();
- return Response.created(uri).entity(e).build();
- } catch (Exception ex) {
- return Response.serverError().build();
- }
- }
-
- @POST
- @Path("/books/feed/relative")
- @Consumes("application/atom+xml")
- public Response addBookAsEntryRelativeURI(Entry e) throws Exception {
- try {
- String text = e.getContentElement().getValue();
- StringReader reader = new StringReader(text);
- JAXBContext jc = JAXBContext.newInstance(Book.class);
- Book b = (Book)jc.createUnmarshaller().unmarshal(reader);
- books.put(b.getId(), b);
-
- URI uri = URI.create("books/entries/" + Long.toString(b.getId()));
- return Response.created(uri).entity(e).build();
- } catch (Exception ex) {
- return Response.serverError().build();
- }
- }
-
-
- @GET
- @Path("/books/entries/{bookId}/")
- @Produces({"application/atom+xml", "application/json" })
- public Entry getBookAsEntry(@PathParam("bookId") String id) throws BookNotFoundFault {
- //System.out.println("----invoking getBook with id: " + id);
- Book book = books.get(Long.parseLong(id));
- if (book != null) {
- try {
- return AtomUtils.createBookEntry(book, uField.getAbsolutePath().toString());
- } catch (Exception ex) {
- // ignore
- }
- } else {
- BookNotFoundDetails details = new BookNotFoundDetails();
- details.setId(Long.parseLong(id));
- throw new BookNotFoundFault(details);
- }
- return null;
- }
-
- @Path("/books/subresources/{bookId}/")
- public AtomBook getBook(@PathParam("bookId") String id) throws BookNotFoundFault {
- //System.out.println("----invoking getBook with id: " + id);
- Book book = books.get(Long.parseLong(id));
- if (book != null) {
- try {
- return new AtomBook(book);
- } catch (Exception ex) {
- // ignore
- }
- } else {
- BookNotFoundDetails details = new BookNotFoundDetails();
- details.setId(Long.parseLong(id));
- throw new BookNotFoundFault(details);
- }
- return null;
- }
-
-
-
-
- final void init() {
- Book book = new Book();
- book.setId(bookId);
- book.setName("CXF in Action");
- books.put(book.getId(), book);
-
- CD cd = new CD();
- cd.setId(cdId);
- cd.setName("BOHEMIAN RHAPSODY");
- cds.put(cd.getId(), cd);
- CD cd1 = new CD();
- cd1.setId(++cdId);
- cd1.setName("BICYCLE RACE");
- cds.put(cd1.getId(), cd1);
- }
-}
-
-
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore2.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore2.java
deleted file mode 100644
index bb3587c..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomBookStore2.java
+++ /dev/null
@@ -1,50 +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 javax.ws.rs.GET;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.Context;
-import javax.ws.rs.core.UriInfo;
-
-import org.apache.abdera.model.Feed;
-
-@Path("/")
-public class AtomBookStore2 extends AtomBookStore {
-
- @GET
- @Path("/")
- @Produces({"application/atom+xml", "application/json" })
- public Feed getBooksAsFeed(@Context UriInfo uParam) {
-
- return super.getBooksAsFeed(uParam);
-
- }
-
- @Context
- public void setUriInfo(UriInfo ui) {
- super.uField = ui;
- }
-}
-
-
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomUtils.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomUtils.java
deleted file mode 100644
index 8e96cef..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/AtomUtils.java
+++ /dev/null
@@ -1,66 +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.StringWriter;
-
-import javax.xml.bind.JAXBContext;
-
-import org.apache.abdera.Abdera;
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Content;
-import org.apache.abdera.model.Entry;
-
-public final class AtomUtils {
-
- private AtomUtils() {
-
- }
-
- public static Entry createBookEntry(Book b) throws Exception {
- return createBookEntry(Abdera.getNewFactory(), b, null);
- }
- public static Entry createBookEntry(Factory factory, Book b) throws Exception {
- return createBookEntry(factory, b, null);
- }
- public static Entry createBookEntry(Book b, String baseUri) throws Exception {
- return createBookEntry(Abdera.getNewFactory(), b, baseUri);
- }
- public static Entry createBookEntry(Factory factory, Book b, String baseUri) throws Exception {
- JAXBContext jc = JAXBContext.newInstance(Book.class);
-
- Entry e = factory.newEntry();
- if (baseUri != null) {
- e.setBaseUri(baseUri);
- }
- e.setTitle(b.getName());
- e.setId(Long.toString(b.getId()));
-
-
- StringWriter writer = new StringWriter();
- jc.createMarshaller().marshal(b, writer);
-
- e.setContent(writer.toString(), Content.Type.XML);
-
- return e;
- }
-
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomAtomFeedProvider.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomAtomFeedProvider.java
deleted file mode 100644
index 85b1e8b..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/CustomAtomFeedProvider.java
+++ /dev/null
@@ -1,47 +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.IOException;
-import java.io.OutputStream;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-import javax.ws.rs.Consumes;
-import javax.ws.rs.Produces;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
-import javax.ws.rs.ext.Provider;
-
-import org.apache.abdera.model.Feed;
-import org.apache.cxf.jaxrs.provider.atom.AtomFeedProvider;
-
-@Produces({"application/atom+xml", "application/atom+xml;type=feed", "application/json" })
-@Consumes({"application/atom+xml", "application/atom+xml;type=feed" })
-@Provider
-public class CustomAtomFeedProvider extends AtomFeedProvider {
-
- @Override
- public void writeTo(Feed element, Class<?> clazz, Type type, Annotation[] a,
- MediaType mt, MultivaluedMap<String, Object> headers, OutputStream os)
- throws IOException {
- os.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>".getBytes());
- super.writeTo(element, clazz, type, a, mt, headers, os);
- }
-}
diff --git a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java b/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java
deleted file mode 100644
index 6c60b59..0000000
--- a/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/JAXRSAtomBookTest.java
+++ /dev/null
@@ -1,267 +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.InputStream;
-import java.io.StringWriter;
-
-import javax.xml.bind.JAXBContext;
-
-import org.apache.abdera.Abdera;
-import org.apache.abdera.factory.Factory;
-import org.apache.abdera.model.Content;
-import org.apache.abdera.model.Document;
-import org.apache.abdera.model.Entry;
-import org.apache.abdera.model.Feed;
-import org.apache.cxf.helpers.IOUtils;
-import org.apache.cxf.io.CachedOutputStream;
-import org.apache.cxf.jaxrs.model.AbstractResourceInfo;
-import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.impl.client.CloseableHttpClient;
-import org.apache.http.impl.client.HttpClientBuilder;
-import org.apache.http.util.EntityUtils;
-import org.codehaus.jettison.json.JSONObject;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-public class JAXRSAtomBookTest extends AbstractBusClientServerTestBase {
- public static final String PORT = AtomBookServer.PORT;
-
- private Abdera abdera = new Abdera();
-
- @BeforeClass
- public static void startServers() throws Exception {
- AbstractResourceInfo.clearAllMaps();
- assertTrue("server did not launch correctly",
- launchServer(AtomBookServer.class, true));
- createStaticBus();
- }
-
- @Test
- public void testGetBooks() throws Exception {
- String endpointAddress =
- "http://localhost:" + PORT + "/bookstore/bookstore/books/feed";
- Feed feed = getFeed(endpointAddress, null);
- assertEquals("http://localhost:" + PORT + "/bookstore/bookstore/books/feed",
- feed.getBaseUri().toString());
- assertEquals("Collection of Books", feed.getTitle());
-
- getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/feed",
- "resources/expected_atom_books_json.txt",
- "application/json");
-
- getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/jsonfeed",
- "resources/expected_atom_books_jsonfeed.txt",
- "application/json, text/html, application/xml;q=0.9,"
- + " application/xhtml+xml, image/png, image/jpeg, image/gif,"
- + " image/x-xbitmap, */*;q=0.1");
-
- addEntry(endpointAddress);
- addEntry(endpointAddress + "/relative");
-
- endpointAddress =
- "http://localhost:" + PORT + "/bookstore/bookstore/books/subresources/123";
- Entry entry = getEntry(endpointAddress, null);
- assertEquals("CXF in Action", entry.getTitle());
-
- getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123",
- "resources/expected_atom_book_json.txt",
- "application/json");
-
- getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123?_type="
- + "application/json",
- "resources/expected_atom_book_json.txt",
- "*/*");
- getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123?_type="
- + "json",
- "resources/expected_atom_book_json.txt",
- "*/*");
-
- // do the same using extension mappings
- getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123.json",
- "resources/expected_atom_book_json.txt",
- "*/*");
- // do the same using extension mappings & matrix parameters
- getAndCompareJson("http://localhost:" + PORT + "/bookstore/bookstore/books/entries/123.json;a=b",
- "resources/expected_atom_book_json_matrix.txt",
- "*/*");
-
-
- }
-
- private Entry addEntry(String endpointAddress) throws Exception {
- Entry e = createBookEntry(256, "AtomBook");
- StringWriter w = new StringWriter();
- e.writeTo(w);
-
- CloseableHttpClient client = HttpClientBuilder.create().build();
- HttpPost post = new HttpPost(endpointAddress);
- post.setEntity(new StringEntity(w.toString(), ContentType.APPLICATION_ATOM_XML));
-
- final String location;
- try {
- CloseableHttpResponse response = client.execute(post);
- assertEquals(201, response.getStatusLine().getStatusCode());
- location = response.getFirstHeader("Location").getValue();
- InputStream ins = response.getEntity().getContent();
- Document<Entry> entryDoc = abdera.getParser().parse(copyIn(ins));
- assertEquals(entryDoc.getRoot().toString(), e.toString());
- } finally {
- post.releaseConnection();
- }
-
- Entry entry = getEntry(location, null);
- assertEquals(location, entry.getBaseUri().toString());
- assertEquals("AtomBook", entry.getTitle());
- return entry;
- }
-
- @Test
- public void testGetBooks2() throws Exception {
- String endpointAddress =
- "http://localhost:" + PORT + "/bookstore/sub/";
- Feed feed = getFeed(endpointAddress, null);
- assertEquals("http://localhost:" + PORT + "/bookstore/sub/",
- feed.getBaseUri().toString());
- assertEquals("Collection of Books", feed.getTitle());
-
- getAndCompareJson("http://localhost:" + PORT + "/bookstore/sub/books/entries/123.json",
- "resources/expected_atom_book_json2.txt",
- "*/*");
- }
-
- @Test
- public void testGetBooks3() throws Exception {
- getAndCompareJson("http://localhost:" + PORT + "/atom/atomservice3/atom/books/entries/123.json",
- "resources/expected_atom_book_json3.txt",
- "*/*");
- }
-
- @Test
- public void testGetBooksWithCustomProvider() throws Exception {
- String endpointAddress =
- "http://localhost:" + PORT + "/bookstore/bookstore4/books/feed";
- Feed feed = getFeed(endpointAddress, null);
- assertEquals("http://localhost:" + PORT + "/bookstore/bookstore4/books/feed",
- feed.getBaseUri().toString());
- assertEquals("Collection of Books", feed.getTitle());
- }
-
- private void getAndCompareJson(String address,
- String resourcePath,
- String type) throws Exception {
- CloseableHttpClient client = HttpClientBuilder.create().build();
- HttpGet get = new HttpGet(address);
- get.setHeader("Content-Type", "*/*");
- get.setHeader("Accept", type);
- try {
- CloseableHttpResponse response = client.execute(get);
- String jsonContent = EntityUtils.toString(response.getEntity());
- String expected = getStringFromInputStream(
- getClass().getResourceAsStream(resourcePath));
- expected = expected.replaceAll("9080", PORT);
-
- JSONObject obj1 = new JSONObject(jsonContent);
- JSONObject obj2 = new JSONObject(expected);
-
- assertEquals("Atom entry should've been formatted as json",
- obj1.toString(), obj2.toString());
- } finally {
- get.releaseConnection();
- }
- }
-
- private Entry createBookEntry(int id, String name) throws Exception {
-
- Book b = new Book();
- b.setId(id);
- b.setName(name);
-
-
- Factory factory = Abdera.getNewFactory();
- JAXBContext jc = JAXBContext.newInstance(Book.class);
-
- Entry e = factory.getAbdera().newEntry();
- e.setTitle(b.getName());
- e.setId(Long.toString(b.getId()));
-
-
- StringWriter writer = new StringWriter();
- jc.createMarshaller().marshal(b, writer);
-
- Content ct = factory.newContent(Content.Type.XML);
- ct.setValue(writer.toString());
- e.setContentElement(ct);
- return e;
- }
-
- private Feed getFeed(String endpointAddress, String acceptType) throws Exception {
- CloseableHttpClient client = HttpClientBuilder.create().build();
- HttpGet get = new HttpGet(endpointAddress);
- get.setHeader("Content-Type", "*/*");
- if (acceptType != null) {
- get.setHeader("Accept", acceptType);
- }
- try {
- CloseableHttpResponse response = client.execute(get);
- Document<Feed> doc = abdera.getParser().parse(copyIn(response.getEntity().getContent()));
- return doc.getRoot();
- } finally {
- get.releaseConnection();
- }
- }
-
- private Entry getEntry(String endpointAddress, String acceptType) throws Exception {
- CloseableHttpClient client = HttpClientBuilder.create().build();
- HttpGet get = new HttpGet(endpointAddress);
- get.setHeader("Content-Type", "*/*");
- if (acceptType != null) {
- get.setHeader("Accept", acceptType);
- }
- try {
- CloseableHttpResponse response = client.execute(get);
- Document<Entry> doc = abdera.getParser().parse(copyIn(response.getEntity().getContent()));
- return doc.getRoot();
- } finally {
- get.releaseConnection();
- }
- }
-
- private InputStream copyIn(InputStream in) throws Exception {
- try (CachedOutputStream bos = new CachedOutputStream()) {
- IOUtils.copyAndCloseInput(in, bos);
- in = bos.getInputStream();
- bos.close();
- return in;
- }
- }
- private String getStringFromInputStream(InputStream in) throws Exception {
- return IOUtils.toString(in);
- }
-}
diff --git a/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml b/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml
deleted file mode 100644
index 8250e89..0000000
--- a/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/beans.xml
+++ /dev/null
@@ -1,94 +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.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:aop="http://www.springframework.org/schema/aop"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
- <import resource="classpath:META-INF/cxf/cxf.xml"/>
- <import resource="classpath:META-INF/cxf/cxf-servlet.xml"/>
- <jaxrs:server id="atomservice" address="/bookstore" staticSubresourceResolution="true">
- <jaxrs:serviceBeans>
- <ref bean="atomstore"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <ref bean="entry"/>
- </jaxrs:providers>
- <jaxrs:extensionMappings>
- <entry key="json" value="application/json"/>
- </jaxrs:extensionMappings>
- </jaxrs:server>
- <jaxrs:server id="atomservice2" address="/sub" staticSubresourceResolution="true">
- <jaxrs:serviceBeans>
- <ref bean="atomstore2"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <ref bean="entry"/>
- </jaxrs:providers>
- <jaxrs:extensionMappings>
- <entry key="json" value="application/json"/>
- </jaxrs:extensionMappings>
- </jaxrs:server>
- <jaxrs:server id="atomservice3" address="/atomservice3">
- <jaxrs:serviceBeans>
- <ref bean="atomstore3"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed"/>
- <ref bean="entry"/>
- </jaxrs:providers>
- <jaxrs:extensionMappings>
- <entry key="json" value="application/json"/>
- </jaxrs:extensionMappings>
- <jaxrs:properties>
- <entry key="org.apache.cxf.output.buffering" value="true"/>
- </jaxrs:properties>
- </jaxrs:server>
- <jaxrs:server id="atomservice4" address="/bookstore4">
- <jaxrs:serviceBeans>
- <ref bean="atomstore"/>
- </jaxrs:serviceBeans>
- <jaxrs:providers>
- <ref bean="feed2"/>
- </jaxrs:providers>
- </jaxrs:server>
- <bean id="atomstore" class="org.apache.cxf.systest.jaxrs.AtomBookStore"/>
- <bean id="atomstore2" class="org.apache.cxf.systest.jaxrs.AtomBookStore2"/>
- <bean id="atomstore3" class="org.apache.cxf.systest.jaxrs.AtomBookStore3"/>
- <bean id="feed" class="org.apache.cxf.jaxrs.provider.atom.AtomFeedProvider">
- <property name="formattedOutput" value="true"/>
- </bean>
- <bean id="feed2" class="org.apache.cxf.systest.jaxrs.CustomAtomFeedProvider">
- <!--
- <property name="formattedOutput" value="true"/>
- -->
- </bean>
- <bean id="entry" class="org.apache.cxf.jaxrs.provider.atom.AtomEntryProvider"/>
-</beans>
-<!-- END SNIPPET: beans -->
\ No newline at end of file
diff --git a/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/web.xml b/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/web.xml
deleted file mode 100644
index b39d6f2..0000000
--- a/systests/jaxrs/src/test/resources/jaxrs_atom/WEB-INF/web.xml
+++ /dev/null
@@ -1,50 +0,0 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
-<!--
- 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 xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
- version="3.0">
- <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>/bookstore/*</url-pattern>
- </servlet-mapping>
- <servlet-mapping>
- <servlet-name>CXFServlet</servlet-name>
- <url-pattern>/atom/*</url-pattern>
- </servlet-mapping>
-</web-app>
-<!-- END SNIPPET: webxml -->