You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jaxme-dev@ws.apache.org by Dean Hiller <de...@xsoftware.biz> on 2005/09/20 06:53:41 UTC

test fixed

okay, here is the tests that work with that formatting unset....(thanks 
by the way).  I assume you still have the patch I sent you, or have you 
committed that already?

  /** <p>Tests marshalling of non-registered element and then
   *     registers package and test that it can be marshalled now</p>
   */
    public void testDynamicMarshal() throws Exception {
        JAXBContext ctx = getFactory();
        Marshaller marshaller = ctx.createMarshaller();
       
        org.apache.ws.jaxme.test.misc.address.ObjectFactory factory = 
new org.apache.ws.jaxme.test.misc.address.ObjectFactory();
        Address addr = factory.createAddress();
        NameType name = factory.createAddressTypeNameType();
        PostalType postal = factory.createAddressTypePostalType();
        postal.setStreet("56 East Ave");
        postal.setZIP("50344");
        postal.setCity("thornton");
        postal.setCountry("US");
        postal.setState("CO");
        name.setFirst("dean");
        name.setLast("hiller");
        addr.setId("someID");
        addr.setName(name);
        addr.setPostal(postal);
        StringWriter writer = new StringWriter();
       
        try {
            marshaller.marshal(addr, writer);
            fail("Should have thrown an exception since address is not 
registered yet");
        } catch(JAXBException e) {}
       
        //now register(this is not JAXB compliant as of yet)
        JAXBContextImpl ctxImpl = (JAXBContextImpl)ctx;
        
ctxImpl.registerPackages("org.apache.ws.jaxme.test.misc.address", 
addr.getClass().getClassLoader());
       
        writer = new StringWriter();
        marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, 
Boolean.FALSE);
        marshaller.marshal(addr, writer);

        assertEquals(getXml(), writer.toString());
    }
   
    public String getXml() {
        return "<?xml version='1.0' encoding='UTF-8'?><Address 
id=\"someID\" 
xmlns=\"http://ws.apache.org/jaxme/test/misc/address\"><Name><First>dean</First><Last>hiller</Last></Name><Postal><Street>56 
East 
Ave</Street><ZIP>50344</ZIP><City>thornton</City><State>CO</State><Country>US</Country></Postal></Address>";
    }
   
    public void testDynamicUnmarshal() throws JAXBException {
        JAXBContext ctx = getFactory();
        Unmarshaller unmarshaller = ctx.createUnmarshaller();
       
        StringReader reader = new StringReader(getXml());
        InputSource src = new InputSource(reader);
        try {
            unmarshaller.unmarshal(src);
            fail("Should fail since package not registered");
        } catch(JAXBException e) {}
       
        //now register(this is not JAXB compliant as of yet)
        JAXBContextImpl ctxImpl = (JAXBContextImpl)ctx;
        
ctxImpl.registerPackages("org.apache.ws.jaxme.test.misc.address", 
Address.class.getClassLoader());

        reader = new StringReader(getXml());
        src = new InputSource(reader);
       
        Address addr = (Address)unmarshaller.unmarshal(src);
        assertEquals("someID", addr.getId());
        assertEquals("dean", addr.getName().getFirst());
        assertEquals("hiller", addr.getName().getLast());
    }

Jochen Wiedmann wrote:

> Dean Hiller wrote:
>
>> So I found MarshallerTest and I added the following tests.  (I am 
>> having trouble with the marshaller test with whitespace 
>> comparison...can you help me out here....how do you deal with this?).
>
>
> Simple: Turn whitespace off. :-) (JAXB_FORMATTED, or whatever the 
> marshaller property is named.)
>
>
> Jochen
>


---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org


Re: test fixed

Posted by Jochen Wiedmann <jo...@gmail.com>.
Dean Hiller wrote:

> okay, here is the tests that work with that formatting unset....(thanks 
> by the way).  I assume you still have the patch I sent you, or have you 
> committed that already?

I have it still. I am just waiting for your response to

http://mail-archives.apache.org/mod_mbox/ws-jaxme-dev/200509.mbox/%3c432B2DAD.2000505@gmail.com%3e


Jochen

---------------------------------------------------------------------
To unsubscribe, e-mail: jaxme-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: jaxme-dev-help@ws.apache.org