Examples of AegisTestBean


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

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

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

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

    @Test
    public void testNoNamespaceReadFrom() throws Exception {
        MessageBodyReader<AegisTestBean> p = new NoNamespaceAegisElementProvider<AegisTestBean>();
        byte[] bytes = noNamespaceXml.getBytes("utf-8");
        AegisTestBean bean = p.readFrom(AegisTestBean.class, null, null,
                                          null, null, new ByteArrayInputStream(bytes));
        assertEquals("hovercraft", bean.getStrValue());
        assertEquals(Boolean.TRUE, bean.getBoolValue());
    }
View Full Code Here

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

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

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

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

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

        Class<InterfaceWithMap> iwithMapClass = InterfaceWithMap.class;
        Method method = iwithMapClass.getMethod("mapFunction");
        Type mapType = method.getGenericReturnType();

        AegisTestBean bean = new AegisTestBean();
        bean.setBoolValue(Boolean.TRUE);
        bean.setStrValue("hovercraft");

        AegisSuperBean bean2 = new AegisSuperBean();
        bean2.setBoolValue(Boolean.TRUE);
        bean2.setStrValue("hovercraft2");
        testMap.put(bean, bean2);

        MessageBodyWriter<Map<AegisTestBean, AegisSuperBean>> writer
            = new AegisElementProvider<Map<AegisTestBean, AegisSuperBean>>();
        ByteArrayOutputStream os = new ByteArrayOutputStream();

        writer.writeTo(testMap, testMap.getClass(), mapType, new Annotation[]{},
                       MediaType.APPLICATION_OCTET_STREAM_TYPE,
                       new MetadataMap<String, Object>(), os);
        byte[] bytes = os.toByteArray();
        String xml = new String(bytes, "utf-8");
        MessageBodyReader<Map<AegisTestBean, AegisSuperBean>> reader
            = new AegisElementProvider<Map<AegisTestBean, AegisSuperBean>>();
        byte[] simpleBytes = xml.getBytes("utf-8");

        Map<AegisTestBean, AegisSuperBean> map2 = reader.readFrom(null, mapType, new Annotation[]{},
                                                                  MediaType.APPLICATION_OCTET_STREAM_TYPE,
                                                                  new MetadataMap<String, String>(),
                                                                  new ByteArrayInputStream(simpleBytes));
        assertEquals(1, map2.size());
        Map.Entry<AegisTestBean, AegisSuperBean> entry = map2.entrySet().iterator().next();
        AegisTestBean bean1 = entry.getKey();
        assertEquals("hovercraft", bean1.getStrValue());
        assertEquals(Boolean.TRUE, bean1.getBoolValue());
        AegisTestBean bean22 = entry.getValue();
        assertEquals("hovercraft2", bean22.getStrValue());
        assertEquals(Boolean.TRUE, bean22.getBoolValue());

    }
View Full Code Here

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

            + "\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft\"}}";
       
        byte[] simpleBytes = data.getBytes("utf-8");
        Object beanObject = p.readFrom(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

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

            namespaceMap.put("http://fortest.jaxrs.cxf.apache.org", "ns1");
            namespaceMap.put("http://www.w3.org/2001/XMLSchema-instance", "xsi");
            p.setNamespaceMap(namespaceMap);
        }   
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        AegisTestBean bean = new AegisTestBean();
        bean.setBoolValue(Boolean.TRUE);
        bean.setStrValue("hovercraft");
        p.writeTo(bean, AegisTestBean.class, AegisTestBean.class,
                  AegisTestBean.class.getAnnotations(),
                  MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(), os);
        byte[] bytes = os.toByteArray();
        String json = new String(bytes, "utf-8");
View Full Code Here

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

            p.setSerializeAsArray(true);
            p.setArrayKeys(Collections.singletonList(arrayKey));
        }
        AbstractAegisProvider.clearContexts();
        ByteArrayOutputStream os = new ByteArrayOutputStream();
        AegisTestBean bean = new AegisTestBean();
        bean.setBoolValue(Boolean.TRUE);
        bean.setStrValue("hovercraft");
        List<AegisTestBean> beans = new ArrayList<AegisTestBean>();
        beans.add(bean);
        if (twoBeans) {
            AegisTestBean bean2 = new AegisTestBean();
            bean2.setBoolValue(Boolean.TRUE);
            bean2.setStrValue("hovercraft2");
            beans.add(bean2);
        }
        Method m = CollectionsResource.class.getMethod("getAegisBeans", new Class[] {});
        p.writeTo(beans, m.getReturnType(), m.getGenericReturnType(), AegisTestBean.class
            .getAnnotations(), MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(), os);
View Full Code Here

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

        // the only way to get the right class ref in there is to make a dummy list object.
        // is that reasonable?
        List<AegisTestBean> list = p.readFrom(null, m.getGenericReturnType(), null,
                                              null, null, new ByteArrayInputStream(simpleBytes));
        assertEquals(2, list.size());
        AegisTestBean bean = list.get(0);
        assertEquals("hovercraft", bean.getStrValue());
        assertEquals(Boolean.TRUE, bean.getBoolValue());
        bean = list.get(1);
        assertEquals("hovercraft2", bean.getStrValue());
        assertEquals(Boolean.TRUE, bean.getBoolValue());
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.