You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@juddi.apache.org by ks...@apache.org on 2008/07/23 17:06:22 UTC
svn commit: r679108 - in /webservices/juddi/branches/v3_trunk:
uddi-api/src/test/java/org/uddi/api_v3/AuthInfoTest.java uddi-ws/
Author: kstam
Date: Wed Jul 23 08:06:21 2008
New Revision: 679108
URL: http://svn.apache.org/viewvc?rev=679108&view=rev
Log:
Adding assert
Modified:
webservices/juddi/branches/v3_trunk/uddi-api/src/test/java/org/uddi/api_v3/AuthInfoTest.java
webservices/juddi/branches/v3_trunk/uddi-ws/ (props changed)
Modified: webservices/juddi/branches/v3_trunk/uddi-api/src/test/java/org/uddi/api_v3/AuthInfoTest.java
URL: http://svn.apache.org/viewvc/webservices/juddi/branches/v3_trunk/uddi-api/src/test/java/org/uddi/api_v3/AuthInfoTest.java?rev=679108&r1=679107&r2=679108&view=diff
==============================================================================
--- webservices/juddi/branches/v3_trunk/uddi-api/src/test/java/org/uddi/api_v3/AuthInfoTest.java (original)
+++ webservices/juddi/branches/v3_trunk/uddi-api/src/test/java/org/uddi/api_v3/AuthInfoTest.java Wed Jul 23 08:06:21 2008
@@ -24,6 +24,10 @@
private final static String EXPECTED_XML_FRAGMENT = "<fragment xmlns:ns3=\"urn:uddi-org:api_v3\" xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\">\n"
+" <ns3:authInfo>AuthInfo String</ns3:authInfo>\n"
+"</fragment>";
+ private final static String UTF8_WORD = "ã¡ã¤ã³ãã¼ã¸";
+ private final static String EXPECTED_UTF8_XML_FRAGMENT = "<fragment xmlns:ns3=\"urn:uddi-org:api_v3\" xmlns:ns2=\"http://www.w3.org/2000/09/xmldsig#\">\n"
+ +" <ns3:authInfo>" + UTF8_WORD + "</ns3:authInfo>\n"
+ +"</fragment>";
/**
* Testing going from object to XML using JAXB using a XML Fragment.
*/
@@ -51,7 +55,8 @@
/**
* Unmarshall an xml fragment.
*/
- @Test public void unmarshall()
+ @Test
+ public void unmarshall()
{
try {
JAXBContext jaxbContext=JAXBContext.newInstance("org.uddi.api_v3");
@@ -64,4 +69,46 @@
fail("No exception should be thrown");
}
}
+ /**
+ * Test handling of utf8 characters
+ */
+ @Test
+ public void marshallUTF8()
+ {
+ try {
+ JAXBContext jaxbContext=JAXBContext.newInstance("org.uddi.api_v3");
+ Marshaller marshaller = jaxbContext.createMarshaller();
+ marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+ marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
+ marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
+ ObjectFactory factory = new ObjectFactory();
+ AuthToken authToken = factory.createAuthToken();
+ authToken.setAuthInfo(UTF8_WORD);
+ StringWriter writer = new StringWriter();
+ JAXBElement<AuthToken> element = new JAXBElement<AuthToken>(new QName("","fragment"),AuthToken.class,authToken);
+ marshaller.marshal(element,writer);
+ String actualXml=writer.toString();
+ assertEquals(EXPECTED_UTF8_XML_FRAGMENT, actualXml);
+ } catch (JAXBException jaxbe) {
+ fail("No exception should be thrown");
+ }
+ }
+
+ /**
+ * Test handling of utf8 characters
+ */
+ @Test
+ public void unmarshallUTF8()
+ {
+ try {
+ JAXBContext jaxbContext=JAXBContext.newInstance("org.uddi.api_v3");
+ Unmarshaller unMarshaller = jaxbContext.createUnmarshaller();
+ StringReader reader = new StringReader(EXPECTED_UTF8_XML_FRAGMENT);
+ JAXBElement<AuthToken> utf8Element = unMarshaller.unmarshal(new StreamSource(reader),AuthToken.class);
+ String infoString = utf8Element.getValue().getAuthInfo();
+ assertEquals(UTF8_WORD, infoString);
+ } catch (JAXBException jaxbe) {
+ fail("No exception should be thrown");
+ }
+ }
}
Propchange: webservices/juddi/branches/v3_trunk/uddi-ws/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Wed Jul 23 08:06:21 2008
@@ -0,0 +1 @@
+target
---------------------------------------------------------------------
To unsubscribe, e-mail: juddi-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: juddi-cvs-help@ws.apache.org