Package org.apache.cxf.jaxrs.fortest

Examples of org.apache.cxf.jaxrs.fortest.AegisTestBean


    public void testReadFrom() throws Exception {
        MessageBodyReader<Object> p = new AegisElementProvider();
        byte[] simpleBytes = SIMPLE_BEAN_XML.getBytes("utf-8");
        Object beanObject = p.readFrom((Class)AegisTestBean.class, null, null,
                                          null, null, new ByteArrayInputStream(simpleBytes));
        AegisTestBean bean = (AegisTestBean) beanObject;
        assertEquals("hovercraft", bean.getStrValue());
        assertEquals(Boolean.TRUE, bean.getBoolValue());
    }
View Full Code Here


   
    @Test
    public void testWriteTo() throws Exception {
        MessageBodyWriter<Object> p = new AegisElementProvider();
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        AegisTestBean bean = new AegisTestBean();
        bean.setBoolValue(Boolean.TRUE);
        bean.setStrValue("hovercraft");
        p.writeTo(bean, null, null, null, null, null, os);
        byte[] bytes = os.toByteArray();
        String xml = new String(bytes, "utf-8");
        assertEquals(SIMPLE_BEAN_XML, xml);
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    @Test
    @org.junit.Ignore
    public void testReadWriteComplexMap() throws Exception {
        Map<AegisTestBean, String> map = new HashMap<AegisTestBean, String>();
        AegisTestBean bean = new AegisTestBean();
        bean.setBoolValue(Boolean.TRUE);
        bean.setStrValue("hovercraft");
        map.put(bean, "hovercraft");
       
        MessageBodyWriter<Object> writer = new AegisElementProvider();
        ByteArrayOutputStream os = new ByteArrayOutputStream();
       
        writer.writeTo(bean, null, null, null, null, null, os);
        byte[] bytes = os.toByteArray();
        String xml = new String(bytes, "utf-8");
               
        MessageBodyReader<Object> reader = new AegisElementProvider();        
        byte[] simpleBytes = xml.getBytes("utf-8");
       
        Class<InterfaceWithMap> iwithMapClass = InterfaceWithMap.class;
        Method method = iwithMapClass.getMethod("mapFunction");
        Type mapType = method.getGenericReturnType();
       
        Object beanObject = reader.readFrom((Class)Map.class, mapType, null,
                                          null, null, new ByteArrayInputStream(simpleBytes));
        Map<AegisTestBean, String> map2 = (Map)beanObject;
        AegisTestBean bean2 = map2.keySet().iterator().next();
        assertEquals("hovercraft", bean2.getStrValue());
        assertEquals(Boolean.TRUE, bean2.getBoolValue());
       
       
    }
View Full Code Here

TOP

Related Classes of org.apache.cxf.jaxrs.fortest.AegisTestBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.