Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 65E5DE2B7 for ; Fri, 8 Feb 2013 12:20:27 +0000 (UTC) Received: (qmail 48998 invoked by uid 500); 8 Feb 2013 12:20:27 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 48927 invoked by uid 500); 8 Feb 2013 12:20:26 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 48750 invoked by uid 99); 8 Feb 2013 12:20:26 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2013 12:20:26 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 08 Feb 2013 12:20:25 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 5CB8623888E7; Fri, 8 Feb 2013 12:20:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1443983 - in /cxf/branches/2.7.x-fixes: ./ rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java Date: Fri, 08 Feb 2013 12:20:06 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20130208122006.5CB8623888E7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: sergeyb Date: Fri Feb 8 12:20:05 2013 New Revision: 1443983 URL: http://svn.apache.org/r1443983 Log: Merged revisions 1443515 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1443515 | sergeyb | 2013-02-07 14:51:17 +0000 (Thu, 07 Feb 2013) | 1 line [CXF-4799] Adding a test ........ Modified: cxf/branches/2.7.x-fixes/ (props changed) cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java Propchange: cxf/branches/2.7.x-fixes/ ------------------------------------------------------------------------------ Merged /cxf/trunk:r1443515 Propchange: cxf/branches/2.7.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java?rev=1443983&r1=1443982&r2=1443983&view=diff ============================================================================== --- cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java (original) +++ cxf/branches/2.7.x-fixes/rt/frontend/jaxrs/src/test/java/org/apache/cxf/jaxrs/provider/JAXBElementProviderTest.java Fri Feb 8 12:20:05 2013 @@ -207,6 +207,43 @@ public class JAXBElementProviderTest ext testXmlList(provider); } + @Test + public void testGenericsAndSingleContext2() throws Exception { + ClassResourceInfo cri = + ResourceUtils.createClassResourceInfo(XmlListResource.class, XmlListResource.class, true, true); + JAXBElementProvider provider = new JAXBElementProvider(); + provider.setSingleJaxbContext(true); + provider.init(Collections.singletonList(cri)); + + List list = + new ArrayList(); + for (int i = 0; i < 10; i++) { + org.apache.cxf.jaxrs.fortest.jaxb.SuperBook o = + new org.apache.cxf.jaxrs.fortest.jaxb.SuperBook(); + o.setName("name #" + i); + list.add(o); + } + XmlList xmlList = + new XmlList(list); + + Method m = XmlListResource.class.getMethod("testJaxb2", new Class[]{}); + JAXBContext context = provider.getJAXBContext(m.getReturnType(), m.getGenericReturnType()); + + ByteArrayOutputStream os = new ByteArrayOutputStream(); + context.createMarshaller().marshal(xmlList, os); + @SuppressWarnings("unchecked") + XmlList list2 = + (XmlList)context.createUnmarshaller() + .unmarshal(new ByteArrayInputStream(os.toByteArray())); + + List actualList = list2.getList(); + assertEquals(10, actualList.size()); + for (int i = 0; i < 10; i++) { + org.apache.cxf.jaxrs.fortest.jaxb.SuperBook object = actualList.get(i); + assertEquals("name #" + i, object.getName()); + } + } + @SuppressWarnings("unchecked") private void testXmlList(JAXBElementProvider provider) throws Exception { @@ -218,7 +255,8 @@ public class JAXBElementProviderTest ext } XmlList xmlList = new XmlList(list); - JAXBContext context = provider.getJAXBContext(XmlList.class, XmlList.class); + Method m = XmlListResource.class.getMethod("testJaxb", new Class[]{}); + JAXBContext context = provider.getJAXBContext(m.getReturnType(), m.getGenericReturnType()); ByteArrayOutputStream os = new ByteArrayOutputStream(); context.createMarshaller().marshal(xmlList, os); @@ -1587,6 +1625,12 @@ public class JAXBElementProviderTest ext public XmlList testJaxb() { return null; } + + @GET + @Path("/jaxb2") + public XmlList testJaxb2() { + return null; + } } private Message createMessage() {