Return-Path: Delivered-To: apmail-incubator-wink-commits-archive@minotaur.apache.org Received: (qmail 43751 invoked from network); 8 Sep 2009 13:10:37 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 8 Sep 2009 13:10:37 -0000 Received: (qmail 10415 invoked by uid 500); 8 Sep 2009 13:10:36 -0000 Delivered-To: apmail-incubator-wink-commits-archive@incubator.apache.org Received: (qmail 10369 invoked by uid 500); 8 Sep 2009 13:10:36 -0000 Mailing-List: contact wink-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: wink-dev@incubator.apache.org Delivered-To: mailing list wink-commits@incubator.apache.org Received: (qmail 10344 invoked by uid 99); 8 Sep 2009 13:10:36 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Sep 2009 13:10:36 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.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; Tue, 08 Sep 2009 13:10:20 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 2488223888AD; Tue, 8 Sep 2009 13:10:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r812495 [2/3] - in /incubator/wink/trunk: ./ wink-client/src/test/java/org/apache/wink/client/ wink-common/ wink-common/src/main/java/org/apache/wink/common/internal/runtime/ wink-common/src/main/java/org/apache/wink/common/model/atom/ wink... Date: Tue, 08 Sep 2009 13:09:59 -0000 To: wink-commits@incubator.apache.org From: elman@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090908131000.2488223888AD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Modified: incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndText.java URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndText.java?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndText.java (original) +++ incubator/wink/trunk/wink-common/src/main/java/org/apache/wink/common/model/synd/SyndText.java Tue Sep 8 13:09:56 2009 @@ -22,8 +22,6 @@ public class SyndText extends SyndSimpleContent { - private SyndTextType type; - public SyndText() { } @@ -32,21 +30,19 @@ } public SyndText(String text, SyndTextType type) { - super(text); - this.type = type; + super(text, type == null ? null : type.name()); } public SyndText(SyndText other) { super(other); - this.type = other.type; } public SyndTextType getType() { - return type; + return type == null ? null : SyndTextType.valueOf(type); } public void setType(SyndTextType type) { - this.type = type; + this.type = type == null ? null : type.name(); } @Override Modified: incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties (original) +++ incubator/wink/trunk/wink-common/src/main/resources/org/apache/wink/common/internal/i18n/resource.properties Tue Sep 8 13:09:56 2009 @@ -57,6 +57,7 @@ # writing noWriterOrDataSourceProvider=Could not find a writer or DataSourceProvider for {} type and {} mediaType. +noWriterFound=Could not find a writer for {} type and {} mediaType. # Spring springClassReplaceNewerObjectFactory=The {} was replaced by a newer object factory. Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/application/ApplicationFileLoaderTest.java URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/application/ApplicationFileLoaderTest.java?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/application/ApplicationFileLoaderTest.java (original) +++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/internal/application/ApplicationFileLoaderTest.java Tue Sep 8 13:09:56 2009 @@ -20,16 +20,15 @@ package org.apache.wink.common.internal.application; import java.io.FileNotFoundException; +import java.io.IOException; import java.util.Iterator; import java.util.Set; -import org.apache.wink.common.internal.application.ApplicationFileLoader; - import junit.framework.TestCase; public class ApplicationFileLoaderTest extends TestCase { - public void testDefault() throws FileNotFoundException { + public void testDefault() throws IOException { ApplicationFileLoader applicationFileLoader = new ApplicationFileLoader(); Set> classes = applicationFileLoader.getClasses(); assertTrue(classes Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java (original) +++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/app/AppTest.java Tue Sep 8 13:09:56 2009 @@ -30,19 +30,13 @@ import javax.xml.bind.Unmarshaller; import javax.xml.namespace.QName; +import junit.framework.TestCase; + import org.apache.wink.common.RestException; -import org.apache.wink.common.model.app.AppAccept; -import org.apache.wink.common.model.app.AppCategories; -import org.apache.wink.common.model.app.AppCollection; -import org.apache.wink.common.model.app.AppService; -import org.apache.wink.common.model.app.AppWorkspace; -import org.apache.wink.common.model.app.AppYesNo; -import org.apache.wink.common.model.app.ObjectFactory; import org.apache.wink.common.model.atom.AtomCategory; import org.apache.wink.common.model.atom.AtomJAXBUtils; import org.apache.wink.common.model.atom.AtomText; - -import junit.framework.TestCase; +import org.apache.wink.test.mock.TestUtils; public class AppTest extends TestCase { @@ -105,7 +99,7 @@ // } // } - public void testAppMarshal() throws IOException { + public void testAppMarshal() throws Exception { // Marshaller m = AtomJAXBUtils.createMarshaller(ctx, new // JAXBNamespacePrefixMapper(RestConstants.NAMESPACE_APP)); Marshaller m = AppService.getMarshaller(); @@ -113,8 +107,9 @@ AppService service = getService(); JAXBElement element = (new ObjectFactory()).createService(service); ByteArrayOutputStream os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, os); - assertEquals(SERVICE_DOCUMENT, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + String msg = TestUtils.diffIgnoreUpdateWithAttributeQualifier(SERVICE_DOCUMENT, os.toString()); + assertNull(msg, msg); } public void testAppUnmarshal() throws IOException { @@ -130,7 +125,7 @@ assertService(expectedService, service); } - public void testAppUnmarshalMarshal() throws IOException { + public void testAppUnmarshalMarshal() throws Exception { // Marshaller m = AtomJAXBUtils.createMarshaller(ctx, new // JAXBNamespacePrefixMapper(RestConstants.NAMESPACE_APP)); Marshaller m = AppService.getMarshaller(); @@ -140,8 +135,9 @@ Object service = AtomJAXBUtils.unmarshal(u, new StringReader(SERVICE_DOCUMENT)); JAXBElement element = (new ObjectFactory()).createService((AppService)service); ByteArrayOutputStream os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, os); - assertEquals(SERVICE_DOCUMENT, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + String msg = TestUtils.diffIgnoreUpdateWithAttributeQualifier(SERVICE_DOCUMENT, os.toString()); + assertNull(msg, msg); } public void testCategories() { Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/atom/AtomTest.java URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/atom/AtomTest.java?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/atom/AtomTest.java (original) +++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/atom/AtomTest.java Tue Sep 8 13:09:56 2009 @@ -21,17 +21,26 @@ package org.apache.wink.common.model.atom; import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; import java.io.StringReader; import java.util.Arrays; import java.util.Date; import java.util.GregorianCalendar; import java.util.List; +import java.util.Set; +import javax.ws.rs.ext.Providers; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBElement; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; +import javax.xml.bind.annotation.XmlAnyElement; +import javax.xml.bind.annotation.XmlMixed; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlType; import javax.xml.datatype.DatatypeConfigurationException; import javax.xml.datatype.DatatypeFactory; import javax.xml.datatype.XMLGregorianCalendar; @@ -40,232 +49,235 @@ import junit.framework.TestCase; import org.apache.wink.common.RestConstants; +import org.apache.wink.common.internal.application.ApplicationFileLoader; +import org.apache.wink.common.internal.application.ApplicationValidator; +import org.apache.wink.common.internal.contexts.ProvidersImpl; +import org.apache.wink.common.internal.lifecycle.LifecycleManagersRegistry; +import org.apache.wink.common.internal.lifecycle.ScopeLifecycleManager; +import org.apache.wink.common.internal.registry.ProvidersRegistry; +import org.apache.wink.common.internal.registry.metadata.ProviderMetadataCollector; +import org.apache.wink.common.internal.runtime.AbstractRuntimeContext; +import org.apache.wink.common.internal.runtime.RuntimeContextTLS; import org.apache.wink.common.internal.utils.JAXBUtils; import org.apache.wink.common.model.JAXBNamespacePrefixMapper; import org.apache.wink.common.model.opensearch.OpenSearchQuery; +import org.apache.wink.test.mock.TestUtils; public class AtomTest extends TestCase { - private static final String ATOM_TEXT_TEXT = - "title\n"; - private static final String ATOM_TEXT_HTML = - "<h1>title</h1>\n"; - private static final String ATOM_TEXT_XHTML = - "\n" + " <div xmlns=\"" - + RestConstants.NAMESPACE_XHTML - + "\">\n" - + " <h1>title</h1>\n" - + " </div>\n" - + "\n"; - private static final String ATOM_TEXT_XHTML_WITH_TEXT = - "\n" + " <div xmlns=\"" - + RestConstants.NAMESPACE_XHTML - + "\">\n" - + " title\n" - + " </div>\n" - + "\n"; - - private static final String ATOM_TEXT_XHTML_WITH_DIV = - "\n" + " <div xmlns=\"" - + RestConstants.NAMESPACE_XHTML - + "\">\n" - + " <h1>\n" - + " <div>title</div>\n" - + " </h1>\n" - + " </div>\n" - + "\n"; - - private static final String ATOM_CONTENT_TEXT = - "title\n"; - private static final String ATOM_CONTENT_HTML = - "<h1>title</h1>\n"; - private static final String ATOM_CONTENT_XHTML = - "\n" + "
\n" - + "

title

\n" - + "
\n" - + "
\n"; - private static final String ATOM_CONTENT_XHTML_WITH_TEXT = - "\n" + "
\n" - + " title\n" - + "
\n" - + "
\n"; - - private static final String ATOM_CONTENT_XML = - "\n" + " title\n" - + "\n"; - - private static final String ATOM_ENTRY_1 = - replaceTimeToken("\n" + " 1\n" - + " @TIME@\n" - + " title\n" - + " summary\n" - + " @TIME@\n" - + " \n" - + " \n" - + " author@hp.com\n" - + " author\n" - + " http://uri\n" - + " \n" - + " \n" - + " cont@hp.com\n" - + " cont\n" - + " http://uri\n" - + " \n" - + " \n" - + "\n"); - private static final String ATOM_ENTRY_2 = - replaceTimeToken("\n" + " 2\n" - + " @TIME@\n" - + " title\n" - + " summary\n" - + " @TIME@\n" - + " \n" - + " \n" - + " author@hp.com\n" - + " author\n" - + " http://uri\n" - + " \n" - + " \n" - + " cont@hp.com\n" - + " cont\n" - + " http://uri\n" - + " \n" - + " \n" - + " Gustaf's Knäckebröd\n" - + "\n"); - private static final String ATOM_ENTRY_3 = - replaceTimeToken("\n" + " 3\n" - + " @TIME@\n" - + " title\n" - + " summary\n" - + " @TIME@\n" - + " \n" - + " \n" - + " author@hp.com\n" - + " author\n" - + " http://uri\n" - + " \n" - + " \n" - + " cont@hp.com\n" - + " cont\n" - + " http://uri\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " Gustaf's Knäckebröd\n" - + " \n" - + " \n" - + " \n" - + "\n"); - - private static final String ATOM_FEED_1 = - replaceTimeToken("\n" + " id\n" - + " @TIME@\n" - + " title\n" - + " subtitle\n" - + " 5\n" - + " 6\n" - + " 7\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " author@hp.com\n" - + " author\n" - + " http://uri\n" - + " \n" - + " \n" - + " cont@hp.com\n" - + " cont\n" - + " http://uri\n" - + " \n" - + " \n" - + " wink\n" - + " icon\n" - + " logo\n" - + " rights\n" - + " \n" - + " 1\n" - + " @TIME@\n" - + " title\n" - + " summary\n" - + " @TIME@\n" - + " \n" - + " \n" - + " author@hp.com\n" - + " author\n" - + " http://uri\n" - + " \n" - + " \n" - + " cont@hp.com\n" - + " cont\n" - + " http://uri\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " Gustaf's Knäckebröd\n" - + " \n" - + " \n" - + " \n" - + " \n" - + "\n"); - - private static final String ATOM_FEED_2 = - replaceTimeToken("\n" + " id\n" - + " @TIME@\n" - + " title\n" - + " subtitle\n" - + " \n" - + " \n" - + " author@hp.com\n" - + " author\n" - + " http://uri\n" - + " \n" - + " \n" - + " cont@hp.com\n" - + " cont\n" - + " http://uri\n" - + " \n" - + " \n" - + " wink\n" - + " icon\n" - + " logo\n" - + " rights\n" - + " \n" - + " 1\n" - + " @TIME@\n" - + " title\n" - + " summary\n" - + " @TIME@\n" - + " \n" - + " \n" - + " author@hp.com\n" - + " author\n" - + " http://uri\n" - + " \n" - + " \n" - + " cont@hp.com\n" - + " cont\n" - + " http://uri\n" - + " \n" - + " \n" - + " \n" - + " \n" - + " \n" - + " Gustaf's Knäckebröd\n" - + " \n" - + " \n" - + " \n" - + " \n" - + "\n"); + private static final String ATOM_TEXT_TEXT = + "title\n"; + private static final String ATOM_TEXT_HTML = + "<h1>title</h1>\n"; + private static final String ATOM_TEXT_XHTML = + "\n" + " <div xmlns=\"" + + RestConstants.NAMESPACE_XHTML + + "\">\n" + + " <h1>title</h1>\n" + + " </div>\n" + + "\n"; + private static final String ATOM_TEXT_XHTML_WITH_TEXT = + "\n" + " <div xmlns=\"" + + RestConstants.NAMESPACE_XHTML + + "\">\n" + + " title\n" + + " </div>\n" + + "\n"; + + private static final String ATOM_TEXT_XHTML_WITH_DIV = + "\n" + " <div xmlns=\"" + + RestConstants.NAMESPACE_XHTML + + "\">\n" + + " <h1>\n" + + " <div>title</div>\n" + + " </h1>\n" + + " </div>\n" + + "\n"; + + private static final String ATOM_CONTENT_TEXT = + "title\n"; + private static final String ATOM_CONTENT_HTML = + "<h1>title</h1>\n"; + private static final String ATOM_CONTENT_XHTML = + "\n" + "
\n" + + "

title

\n" + + "
\n" + + "
\n"; + private static final String ATOM_CONTENT_XHTML_WITH_TEXT = + "\n" + "
\n" + + " title\n" + + "
\n" + + "
\n"; + + private static final String ATOM_CONTENT_XML = + "\n" + " title\n" + + "\n"; + + private static final String ATOM_ENTRY_1 = + replaceTimeToken("\n" + " 1\n" + + " @TIME@\n" + + " title\n" + + " summary\n" + + " @TIME@\n" + + " \n" + + " \n" + + " author@hp.com\n" + + " author\n" + + " http://uri\n" + + " \n" + + " \n" + + " cont@hp.com\n" + + " cont\n" + + " http://uri\n" + + " \n" + + " \n" + + "\n"); + private static final String ATOM_ENTRY_2 = + replaceTimeToken("\n" + " 2\n" + + " @TIME@\n" + + " title\n" + + " summary\n" + + " @TIME@\n" + + " \n" + + " \n" + + " author@hp.com\n" + + " author\n" + + " http://uri\n" + + " \n" + + " \n" + + " cont@hp.com\n" + + " cont\n" + + " http://uri\n" + + " \n" + + " \n" + + " Gustaf's Knäckebröd\n" + + "\n"); + private static final String ATOM_ENTRY_3 = + replaceTimeToken("\r\n" + "\r\n" + + " 3\r\n" + + " 1970-01-01T02:20:34.567+02:00\r\n" + + " title\r\n" + + " summary\r\n" + + " 1970-01-01T02:20:34.567+02:00\r\n" + + " \r\n" + + " \r\n" + + " author@hp.com\r\n" + + " author\r\n" + + " http://uri\r\n" + + " \r\n" + + " \r\n" + + " cont@hp.com\r\n" + + " cont\r\n" + + " http://uri\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " Gustaf's Knäckebröd\r\n" + + " \r\n" + + ""); + + private static final String ATOM_FEED_1 = + replaceTimeToken("\n" + " id\n" + + " @TIME@\n" + + " title\n" + + " subtitle\n" + + " 5\n" + + " 6\n" + + " 7\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " author@hp.com\n" + + " author\n" + + " http://uri\n" + + " \n" + + " \n" + + " cont@hp.com\n" + + " cont\n" + + " http://uri\n" + + " \n" + + " \n" + + " wink\n" + + " icon\n" + + " logo\n" + + " rights\n" + + " \n" + + " 1\n" + + " @TIME@\n" + + " title\n" + + " summary\n" + + " @TIME@\n" + + " \n" + + " \n" + + " author@hp.com\n" + + " author\n" + + " http://uri\n" + + " \n" + + " \n" + + " cont@hp.com\n" + + " cont\n" + + " http://uri\n" + + " \n" + + " \n" + + " \n" + + " Gustaf's Knäckebröd\n" + + " \n" + + " \n" + + "\n"); + + private static final String ATOM_FEED_2 = + replaceTimeToken("\n" + " id\n" + + " @TIME@\n" + + " title\n" + + " subtitle\n" + + " \n" + + " \n" + + " author@hp.com\n" + + " author\n" + + " http://uri\n" + + " \n" + + " \n" + + " cont@hp.com\n" + + " cont\n" + + " http://uri\n" + + " \n" + + " \n" + + " wink\n" + + " icon\n" + + " logo\n" + + " rights\n" + + " \n" + + " 1\n" + + " @TIME@\n" + + " title\n" + + " summary\n" + + " @TIME@\n" + + " \n" + + " \n" + + " author@hp.com\n" + + " author\n" + + " http://uri\n" + + " \n" + + " \n" + + " cont@hp.com\n" + + " cont\n" + + " http://uri\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " Gustaf's Knäckebröd\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n"); private static JAXBContext ctx; @@ -277,7 +289,40 @@ } } + @Override + protected void setUp() throws Exception { + super.setUp(); + + LifecycleManagersRegistry ofFactoryRegistry = new LifecycleManagersRegistry(); + ofFactoryRegistry.addFactoryFactory(new ScopeLifecycleManager()); + ProvidersRegistry providersRegistry = + new ProvidersRegistry(ofFactoryRegistry, new ApplicationValidator()); + + Set> classes = new ApplicationFileLoader().getClasses(); + if (classes != null) { + for (Class cls : classes) { + if (ProviderMetadataCollector.isProvider(cls)) { + providersRegistry.addProvider(cls); + } + } + } + AbstractRuntimeContext runtimeContext = new AbstractRuntimeContext() { + + public OutputStream getOutputStream() throws IOException { + return null; + } + + public InputStream getInputStream() throws IOException { + return null; + } + }; + runtimeContext.setAttribute(Providers.class, new ProvidersImpl(providersRegistry, + runtimeContext)); + RuntimeContextTLS.setRuntimeContext(runtimeContext); + } + public void testAtomTextMarshal() throws Exception { + Marshaller m = JAXBUtils.createMarshaller(ctx); AtomText text = new AtomText(); @@ -293,24 +338,29 @@ text.setValue("title"); JAXBElement element = (new ObjectFactory()).createTitle(text); ByteArrayOutputStream os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, mapper, os); - assertEquals(ATOM_TEXT_TEXT, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + + String msg = + TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_TEXT_TEXT, os.toString()); + assertNull(msg, msg); // test type HTML text.setType(AtomTextType.html); text.setValue("

title

"); element = (new ObjectFactory()).createTitle(text); os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, mapper, os); - assertEquals(ATOM_TEXT_HTML, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + msg = TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_TEXT_HTML, os.toString()); + assertNull(msg, msg); // test type XHTML text.setType(AtomTextType.xhtml); text.setValue("

title

"); element = (new ObjectFactory()).createTitle(text); os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, mapper, os); - assertEquals(ATOM_TEXT_XHTML, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + msg = TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_TEXT_XHTML, os.toString()); + assertNull(msg, msg); } public void testAtomTextUnmarshal() throws Exception { @@ -342,8 +392,11 @@ assertNotNull(text); assertEquals("en-us", text.getLang()); assertEquals("http://title/base", text.getBase()); - assertEquals("

title

", text - .getValue()); + String msg = + TestUtils + .diffIgnoreUpdateWithAttributeQualifier("

title

", + text.getValue()); + assertNull(msg, msg); assertEquals(AtomTextType.xhtml, text.getType()); element = AtomJAXBUtils.unmarshal(u, new StringReader(ATOM_TEXT_XHTML_WITH_TEXT)); @@ -353,10 +406,9 @@ assertNotNull(text); assertEquals("en-us", text.getLang()); assertEquals("http://title/base", text.getBase()); - assertEquals("title", text - .getValue()); + assertEquals("title", text.getValue().trim()); assertEquals(AtomTextType.xhtml, text.getType()); -} + } public void testAtomTextUnmarshalXhtml() throws Exception { Unmarshaller u = JAXBUtils.createUnmarshaller(ctx); @@ -368,8 +420,14 @@ assertNotNull(text); assertEquals("en-us", text.getLang()); assertEquals("http://title/base", text.getBase()); - assertEquals("

title

", - text.getValue().replaceAll("\n", "").replaceAll(" ", "")); + String msg = + TestUtils + .diffIgnoreUpdateWithAttributeQualifier("

title

", + text.getValue().replaceAll("\r", "") + .replaceAll("\n", "") + .replaceAll(" ", "")); + assertNull(msg, msg); assertEquals(AtomTextType.xhtml, text.getType()); } @@ -388,29 +446,57 @@ content.setValue("title"); JAXBElement element = (new ObjectFactory()).createContent(content); ByteArrayOutputStream os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, mapper, os); - assertEquals(ATOM_CONTENT_TEXT, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + String msg = + TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_CONTENT_TEXT, os.toString()); + assertNull(msg, msg); content.setType("html"); content.setValue("

title

"); element = (new ObjectFactory()).createContent(content); os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, mapper, os); - assertEquals(ATOM_CONTENT_HTML, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + msg = TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_CONTENT_HTML, os.toString()); + assertNull(msg, msg); content.setType("xhtml"); content.setValue("

title

"); element = (new ObjectFactory()).createContent(content); os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, mapper, os); - assertEquals(ATOM_CONTENT_XHTML, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + msg = TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_CONTENT_XHTML, os.toString()); + assertNull(msg, msg); content.setType("application/xml"); + X x = new X(); + x.setTitle("title"); + content.setValue(x); + element = (new ObjectFactory()).createContent(content); + os = new ByteArrayOutputStream(); + AtomJAXBUtils.marshal(m, element, os); + msg = TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_CONTENT_XML, os.toString()); + assertNull(msg, msg); + content.setValue("title"); element = (new ObjectFactory()).createContent(content); os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, mapper, os); - assertEquals(ATOM_CONTENT_XML, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + msg = TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_CONTENT_XML, os.toString()); + assertNull(msg, msg); + } + + @XmlRootElement(name = "x", namespace = "http://x/") + @XmlType(name = "x", propOrder = {"title"}) + protected static class X { + + @XmlMixed + @XmlAnyElement + private List title; + + public void setTitle(String title) { + this.title = Arrays.asList((Object)title); + } + } public void testAtomContentUnmarshal() throws Exception { @@ -442,10 +528,14 @@ assertNotNull(content); assertEquals("en-us", content.getLang()); assertEquals("http://title/base", content.getBase()); - assertEquals("

title

", content - .getValue()); + String msg = + TestUtils + .diffIgnoreUpdateWithAttributeQualifier("

title

", + content.getValue()); + assertNull(msg, msg); assertEquals("xhtml", content.getType()); - + element = AtomJAXBUtils.unmarshal(u, new StringReader(ATOM_CONTENT_XHTML_WITH_TEXT)); assertNotNull(element); assertTrue(element instanceof AtomContent); @@ -453,9 +543,8 @@ assertNotNull(content); assertEquals("en-us", content.getLang()); assertEquals("http://title/base", content.getBase()); - assertEquals("title", content - .getValue()); - assertEquals("xhtml", content.getType()); + assertEquals("title", content.getValue().trim()); + assertEquals("xhtml", content.getType()); element = AtomJAXBUtils.unmarshal(u, new StringReader(ATOM_CONTENT_XML)); assertNotNull(element); @@ -464,7 +553,10 @@ assertNotNull(content); assertEquals("en-us", content.getLang()); assertEquals("http://title/base", content.getBase()); - assertEquals("title", content.getValue()); + msg = + TestUtils.diffIgnoreUpdateWithAttributeQualifier("title", + content.getValue()); + assertNull(msg, msg); assertEquals("application/xml", content.getType()); } @@ -474,20 +566,27 @@ AtomEntry entry = getEntryWithoutContent("1"); JAXBElement element = (new ObjectFactory()).createEntry(entry); ByteArrayOutputStream os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, os); - assertEquals(ATOM_ENTRY_1, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + String msg = TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_ENTRY_1, os.toString()); + assertNull(msg, msg); entry = getEntryWithPlainTextContent("2"); element = (new ObjectFactory()).createEntry(entry); os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, os); - assertTrue(Arrays.equals(ATOM_ENTRY_2.getBytes("UTF-8"), os.toByteArray())); + AtomJAXBUtils.marshal(m, element, os); + msg = + TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_ENTRY_2.getBytes("UTF-8"), os + .toByteArray()); + assertNull(msg, msg); entry = getEntryWithXmlContent("3"); element = (new ObjectFactory()).createEntry(entry); os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, os); - assertTrue(Arrays.equals(ATOM_ENTRY_3.getBytes("UTF-8"), os.toByteArray())); + AtomJAXBUtils.marshal(m, element, os); + msg = + TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_ENTRY_3.getBytes("UTF-8"), os + .toByteArray()); + assertNull(msg, msg); } public void testAtomEntryUnmarshal() throws Exception { @@ -539,8 +638,8 @@ assertEquals("3", entry.getId()); assertNotNull(entry.getContent()); assertEquals("application/xml", entry.getContent().getType()); - assertEquals("Gustaf's Knäckebröd", - entry.getContent().getValue().replaceAll("\n", "").replaceAll(" ", "")); + X x = entry.getContent().getValue(X.class); + assertEquals("Gustaf's Knäckebröd", x.title.get(0)); } public void testAtomFeedMarshal() throws Exception { @@ -549,8 +648,11 @@ AtomFeed feed = getFeed(); JAXBElement element = (new ObjectFactory()).createFeed(feed); ByteArrayOutputStream os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, os); - assertTrue(Arrays.equals(ATOM_FEED_1.getBytes("UTF-8"), os.toByteArray())); + AtomJAXBUtils.marshal(m, element, os); + String msg = + TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_FEED_1.getBytes("UTF-8"), os + .toByteArray()); + assertNull(msg, msg); } public void testAtomFeedUnmarshal() throws Exception { @@ -601,8 +703,10 @@ AtomFeed feed = (AtomFeed)AtomJAXBUtils.unmarshal(u, new StringReader(ATOM_FEED_1)); JAXBElement element = (new ObjectFactory()).createFeed(feed); ByteArrayOutputStream os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, feed.getNamespacePrefixMapper(), os); - assertTrue(Arrays.equals(ATOM_FEED_1.getBytes("UTF-8"), os.toByteArray())); + AtomJAXBUtils.marshal(m, element, os); + String msg = + TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_FEED_1.getBytes("UTF-8"), os.toByteArray()); + assertNull(msg, msg); } public void testAtomFeedMarshalUnmarshalWithoutOpenSearch() throws Exception { @@ -615,8 +719,10 @@ assertEquals(0, feed.getOpenSearchQueries().size()); JAXBElement element = (new ObjectFactory()).createFeed(feed); ByteArrayOutputStream os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, feed.getNamespacePrefixMapper(), os); - assertTrue(Arrays.equals(ATOM_FEED_2.getBytes("UTF-8"), os.toByteArray())); + AtomJAXBUtils.marshal(m, element, os); + String msg = + TestUtils.diffIgnoreUpdateWithAttributeQualifier(ATOM_FEED_2.getBytes("UTF-8"), os.toByteArray()); + assertNull(msg, msg); } public void testGetLinkFromEntry() { @@ -837,8 +943,9 @@ AtomEntry entry = getEntryWithoutContent(id); AtomContent content = new AtomContent(); content.setType("application/xml"); - content - .setValue("Gustaf's Knäckebröd"); + X x = new X(); + x.setTitle("Gustaf's Knäckebröd"); + content.setValue(x); entry.setContent(content); return entry; } @@ -859,7 +966,9 @@ marshaller.setProperty(Marshaller.JAXB_ENCODING, enc); os = new ByteArrayOutputStream(); AtomJAXBUtils.marshal(marshaller, element, os); - assertEquals(enc + " failed", defaultContent, new String(os.toByteArray(), enc)); + String msg = + TestUtils.diffIgnoreUpdateWithAttributeQualifier(defaultContent, new String(os.toByteArray(), enc)); + assertNull(msg, msg); } } Modified: incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/opensearch/OpenSearchTest.java URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/opensearch/OpenSearchTest.java?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/opensearch/OpenSearchTest.java (original) +++ incubator/wink/trunk/wink-common/src/test/java/org/apache/wink/common/model/opensearch/OpenSearchTest.java Tue Sep 8 13:09:56 2009 @@ -33,6 +33,7 @@ import junit.framework.TestCase; import org.apache.wink.common.model.atom.AtomJAXBUtils; +import org.apache.wink.test.mock.TestUtils; public class OpenSearchTest extends TestCase { @@ -69,7 +70,7 @@ // } // } - public void testOpenSearchMarshal() throws IOException { + public void testOpenSearchMarshal() throws Exception { // Map p2n = new HashMap(); // p2n.put("otherAttrNs", "other"); // JAXBNamespacePrefixMapper namespacePrefixMapper = @@ -83,8 +84,9 @@ JAXBElement element = (new ObjectFactory()).createOpenSearchDescription(osd); ByteArrayOutputStream os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, os); - assertEquals(OPENSEARCH, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + String msg = TestUtils.diffIgnoreUpdateWithAttributeQualifier(OPENSEARCH, os.toString()); + assertNull(msg, msg); } public void testOpenSearchUnmarshal() throws IOException { @@ -100,7 +102,7 @@ assertOpenSearchDescription(expectedOsd, osd); } - public void testOpenSearchUnmarshalMarshal() throws IOException { + public void testOpenSearchUnmarshalMarshal() throws Exception { // Marshaller m = AtomJAXBUtils.createMarshaller(ctx, new // JAXBNamespacePrefixMapper(RestConstants.NAMESPACE_OPENSEARCH)); Marshaller m = OpenSearchDescription.getMarshaller(); @@ -111,8 +113,9 @@ JAXBElement element = (new ObjectFactory()).createOpenSearchDescription((OpenSearchDescription)service); ByteArrayOutputStream os = new ByteArrayOutputStream(); - AtomJAXBUtils.marshal(m, element, null, os); - assertEquals(OPENSEARCH, os.toString()); + AtomJAXBUtils.marshal(m, element, os); + String msg = TestUtils.diffIgnoreUpdateWithAttributeQualifier(OPENSEARCH, os.toString()); + assertNull(msg, msg); } private void assertOpenSearchDescription(OpenSearchDescription expectedOsd, Modified: incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/test/mock/TestUtils.java URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/test/mock/TestUtils.java?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/test/mock/TestUtils.java (original) +++ incubator/wink/trunk/wink-component-test-support/src/main/java/org/apache/wink/test/mock/TestUtils.java Tue Sep 8 13:09:56 2009 @@ -100,6 +100,22 @@ System.err.println("Actual:\r\n" + TestUtils.printPrettyXML(xmlActual)); return diff.toString(); } + public static String diffIgnoreUpdateWithAttributeQualifier(String expected, String actual) throws Exception { + return diffIgnoreUpdateWithAttributeQualifier(expected.getBytes("UTF-8"), actual.getBytes("UTF-8")); + } + + public static String diffIgnoreUpdateWithAttributeQualifier(byte[] expected, byte[] actual) + throws Exception { + Document xmlExpected = getXML(expected); + Document xmlActual = getXML(actual); + Diff diff = new DiffIgnoreUpdateWithAttributeQualifier(xmlExpected, xmlActual); + if (diff.similar()) { + return null; + } + System.err.println("Expected:\r\n" + TestUtils.printPrettyXML(xmlExpected)); + System.err.println("Actual:\r\n" + TestUtils.printPrettyXML(xmlActual)); + return diff.toString(); + } public static String printPrettyXML(Document doc) throws Exception { Transformer transformer = TransformerFactory.newInstance().newTransformer(); Modified: incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectAsset.java URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectAsset.java?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectAsset.java (original) +++ incubator/wink/trunk/wink-examples/ext/History/src/main/java/org/apache/wink/example/history/resources/DefectAsset.java Tue Sep 8 13:09:56 2009 @@ -111,9 +111,9 @@ } // serialize the defect xml - String contentString = - ProviderUtils.writeToString(providers, defect, MediaType.APPLICATION_XML_TYPE); - entry.setContent(new SyndContent(contentString, MediaType.APPLICATION_XML, false)); +// String contentString = +// ProviderUtils.writeToString(providers, defect, MediaType.APPLICATION_XML_TYPE); + entry.setContent(new SyndContent(defect, MediaType.APPLICATION_XML)); // set base uri if this is a standalone entry if (!child) { Modified: incubator/wink/trunk/wink-examples/ext/History/src/test/java/org/apache/wink/example/history/HistoryTest.java URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/History/src/test/java/org/apache/wink/example/history/HistoryTest.java?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-examples/ext/History/src/test/java/org/apache/wink/example/history/HistoryTest.java (original) +++ incubator/wink/trunk/wink-examples/ext/History/src/test/java/org/apache/wink/example/history/HistoryTest.java Tue Sep 8 13:09:56 2009 @@ -78,7 +78,7 @@ diff = TestUtils.diffIgnoreUpdateWithAttributeQualifier("initial_defect1_atom.xml", response .getContentAsString().getBytes(), getClass()); - assertNull(diff); + assertNull(diff, diff); // get revision of specific defect request = Modified: incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_1_afterdelete_atom.xml URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_1_afterdelete_atom.xml?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_1_afterdelete_atom.xml (original) +++ incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_1_afterdelete_atom.xml Tue Sep 8 13:09:56 2009 @@ -18,22 +18,23 @@ under the License. --> - + urn:com:hp:qadefects:defect:1 Missing asterisk for mandatory fields - + In Payment Services page, there is no indication for mandatory fields. + 1970-01-01T16:01:45.052+02:00 + + - - - - - + + tester2 - 1970-01-01T16:01:45.052+02:00 + + - + 1 1 false @@ -46,5 +47,4 @@ developer3 - In Payment Services page, there is no indication for mandatory fields. \ No newline at end of file Modified: incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_1_atom.xml URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_1_atom.xml?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_1_atom.xml (original) +++ incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_1_atom.xml Tue Sep 8 13:09:56 2009 @@ -18,23 +18,24 @@ under the License. --> - + urn:com:hp:qadefects:defect:1 Missing asterisk for mandatory fields + In Payment Services page, there is no indication for mandatory fields. + 1970-01-01T16:01:45.052+02:00 - + + - - - - - + + tester2 - 1970-01-01T16:01:45.052+02:00 + + - + 1 1 false @@ -47,5 +48,4 @@ developer3 - In Payment Services page, there is no indication for mandatory fields. \ No newline at end of file Modified: incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_4_atom.xml URL: http://svn.apache.org/viewvc/incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_4_atom.xml?rev=812495&r1=812494&r2=812495&view=diff ============================================================================== --- incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_4_atom.xml (original) +++ incubator/wink/trunk/wink-examples/ext/History/src/test/resources/org/apache/wink/example/history/defect1_4_atom.xml Tue Sep 8 13:09:56 2009 @@ -18,23 +18,24 @@ under the License. --> - + urn:com:hp:qadefects:defect:1 Missing asterisk for mandatory fields + In Payment Services page, there is no indication for mandatory fields. + 1970-01-01T16:01:45.052+02:00 - + + + + - - - - - tester2 - 1970-01-01T16:01:45.052+02:00 + + - + 1 4 false @@ -47,5 +48,4 @@ developer3 - In Payment Services page, there is no indication for mandatory fields. \ No newline at end of file