Examples of AegisTestBean


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

            + "\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft\"}}";
       
        byte[] simpleBytes = data.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.fortest.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, (Class)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.fortest.AegisTestBean

   
    private String writeCollection() throws Exception {
        AegisJSONProvider p = new AegisJSONProvider();
        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);
        Method m = CollectionsResource.class.getMethod("getAegisBeans", new Class[] {});
        p.writeTo(beans, (Class)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.fortest.AegisTestBean

        AegisJSONProvider p = new AegisJSONProvider();
        Object beanObject = p.readFrom((Class)m.getReturnType(), m.getGenericReturnType(), null,
                                          null, null, new ByteArrayInputStream(simpleBytes));
        List<AegisTestBean> list = (List)beanObject;
        assertEquals(1, list.size());
        AegisTestBean bean = list.get(0);
        assertEquals("hovercraft", bean.getStrValue());
        assertEquals(Boolean.TRUE, bean.getBoolValue());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.fortest.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);
       
        AegisJSONProvider writer = new AegisJSONProvider();
        Map<String, String> namespaceMap = new HashMap<String, String>();
        namespaceMap.put("urn:org.apache.cxf.aegis.types", "ns1");
        namespaceMap.put("http://fortest.jaxrs.cxf.apache.org", "ns2");
        writer.setNamespaceMap(namespaceMap);
       
       
        ByteArrayOutputStream os = new ByteArrayOutputStream();
       
        writer.writeTo(testMap, testMap.getClass(), mapType, null, null, null, os);
        byte[] bytes = os.toByteArray();
        String xml = new String(bytes, "utf-8");
        String expected = "{\"ns1.AegisTestBean2AegisSuperBeanMap\":{\"@xsi.type\":"
            + "\"ns1:AegisTestBean2AegisSuperBeanMap\",\"ns1.entry\":{\"ns1.key\":{\"@xsi.type\":\"ns1:"
            + "AegisTestBean\",\"ns2.boolValue\":true,\"ns2.strValue\":\"hovercraft\"},\"ns1.value\":"
            + "{\"@xsi.type\":\"ns1:AegisSuperBean\",\"ns2.boolValue\":true,"
            + "\"ns2.strValue\":\"hovercraft2\"}}}}";
        assertEquals(expected, xml);       
        AegisJSONProvider reader = new AegisJSONProvider();      
        Map<String, String> namespaceMap2 = new HashMap<String, String>();
        namespaceMap2.put("urn:org.apache.cxf.aegis.types", "ns1");
        namespaceMap2.put("http://fortest.jaxrs.cxf.apache.org", "ns2");
        reader.setNamespaceMap(namespaceMap2);
        byte[] simpleBytes = xml.getBytes("utf-8");
       
        Object beanObject = reader.readFrom((Class)Map.class, mapType, null,
                                          null, null, new ByteArrayInputStream(simpleBytes));
        Map<AegisTestBean, AegisSuperBean> map2 = (Map)beanObject;
        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.fortest.AegisTestBean

            + "\"ns1.boolValue\":true,\"ns1.strValue\":\"hovercraft\"}}";
       
        byte[] simpleBytes = data.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.fortest.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, (Class)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.fortest.AegisTestBean

   
    private String writeCollection() throws Exception {
        AegisJSONProvider p = new AegisJSONProvider();
        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);
        Method m = CollectionsResource.class.getMethod("getAegisBeans", new Class[] {});
        p.writeTo(beans, (Class)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.fortest.AegisTestBean

        AegisJSONProvider p = new AegisJSONProvider();
        Object beanObject = p.readFrom((Class)m.getReturnType(), m.getGenericReturnType(), null,
                                          null, null, new ByteArrayInputStream(simpleBytes));
        List<AegisTestBean> list = (List)beanObject;
        assertEquals(1, list.size());
        AegisTestBean bean = list.get(0);
        assertEquals("hovercraft", bean.getStrValue());
        assertEquals(Boolean.TRUE, bean.getBoolValue());
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.fortest.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);
       
        AegisJSONProvider writer = new AegisJSONProvider();
        Map<String, String> namespaceMap = new HashMap<String, String>();
        namespaceMap.put("urn:org.apache.cxf.aegis.types", "ns1");
        namespaceMap.put("http://fortest.jaxrs.cxf.apache.org", "ns2");
        writer.setNamespaceMap(namespaceMap);
       
       
        ByteArrayOutputStream os = new ByteArrayOutputStream();
       
        writer.writeTo(testMap, testMap.getClass(), mapType, null, null, null, os);
        byte[] bytes = os.toByteArray();
        String xml = new String(bytes, "utf-8");
        String expected = "{\"ns1.AegisTestBean2AegisSuperBeanMap\":{\"@xsi.type\":"
            + "\"ns1:AegisTestBean2AegisSuperBeanMap\",\"ns1.entry\":{\"ns1.key\":{\"@xsi.type\":\"ns2:"
            + "AegisTestBean\",\"ns2.boolValue\":true,\"ns2.strValue\":\"hovercraft\"},\"ns1.value\":"
            + "{\"@xsi.type\":\"ns3:AegisSuperBean\",\"ns2.boolValue\":true,"
            + "\"ns2.strValue\":\"hovercraft2\"}}}}";
        assertEquals(expected, xml);
        AegisJSONProvider reader = new AegisJSONProvider();      
        Map<String, String> namespaceMap2 = new HashMap<String, String>();
        namespaceMap2.put("urn:org.apache.cxf.aegis.types", "ns1");
        namespaceMap2.put("http://fortest.jaxrs.cxf.apache.org", "ns2");
        reader.setNamespaceMap(namespaceMap2);
        byte[] simpleBytes = xml.getBytes("utf-8");
       
        Object beanObject = reader.readFrom((Class)Map.class, mapType, null,
                                          null, null, new ByteArrayInputStream(simpleBytes));
        Map<AegisTestBean, AegisSuperBean> map2 = (Map)beanObject;
        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());
        AegisSuperBean bean22 = entry.getValue();
        assertEquals("hovercraft2", bean22.getStrValue());
        assertEquals(Boolean.TRUE, bean22.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.