Examples of ProvidersImpl


Examples of org.apache.clerezza.triaxrs.providers.ProvidersImpl

  private Set<HttpMethod> httpMethods = new HashSet<HttpMethod>();

  public JaxRsHandler() {
    // initialize default providers
    Class<?>[] defaultProviders = DefaultProviders.getDefaultProviders();
    Providers builtInProviders = new ProvidersImpl(defaultProviders);
    providers.reset(componentSpecifiedProviders,
        builtInProviders);
    rootResources = new RootResources();
    resourceExecutor = new RootResourceExecutorImpl();
  }
View Full Code Here

Examples of org.apache.clerezza.triaxrs.providers.ProvidersImpl

   * Returns mapper for exception and a direct subclass
   */
  @Test
  public void getExceptionMapper() {
    Class[] mapperClasses = {RuntimeExceptionMapper.class};
    Providers providers = new ProvidersImpl(mapperClasses);
    assertNull(providers.getExceptionMapper(IOException.class));
    assertEquals(RuntimeExceptionMapper.class, providers.getExceptionMapper(
        RuntimeException.class).getClass());
    assertEquals(RuntimeExceptionMapper.class, providers.getExceptionMapper(
        SecurityException.class).getClass());
  }
View Full Code Here

Examples of org.apache.clerezza.triaxrs.providers.ProvidersImpl

   * Testing with a mapper for SecurityException
   */
  @Test
  public void getExceptionMapper2() {
    Class[] mapperClasses = {RuntimeExceptionMapper.class, SecurityExceptionMapper.class};
    Providers providers = new ProvidersImpl(mapperClasses);
    assertNull(providers.getExceptionMapper(IOException.class));
    assertEquals(RuntimeExceptionMapper.class, providers.getExceptionMapper(
        RuntimeException.class).getClass());
    assertEquals(RuntimeExceptionMapper.class, providers.getExceptionMapper(
        UnsupportedOperationException.class).getClass());
    assertEquals(SecurityExceptionMapper.class, providers.getExceptionMapper(
        SecurityException.class).getClass());
  }
View Full Code Here

Examples of org.apache.cxf.jaxrs.impl.ProvidersImpl

   
    @Test
    public void testWriteJSON() throws Exception {
        org.dom4j.Document dom = readXML();
        DOM4JProvider p = new DOM4JProvider();
        p.setProviders(new ProvidersImpl(createMessage()));
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.writeTo(dom, org.dom4j.Document.class, org.dom4j.Document.class,
                   new Annotation[]{}, MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
                   bos);
View Full Code Here

Examples of org.apache.cxf.jaxrs.impl.ProvidersImpl

   
    @Test
    public void testWriteJSONDropRoot() throws Exception {
        org.dom4j.Document dom = readXML(MediaType.APPLICATION_XML_TYPE, "<root><a/></root>");
        DOM4JProvider p = new DOM4JProvider();
        p.setProviders(new ProvidersImpl(createMessageWithJSONProvider()));
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.writeTo(dom, org.dom4j.Document.class, org.dom4j.Document.class,
                   new Annotation[]{}, MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
                   bos);
View Full Code Here

Examples of org.apache.cxf.jaxrs.impl.ProvidersImpl

        provider.setSerializeAsArray(true);
        provider.setDropRootElement(true);
        provider.setDropElementsInXmlStream(false);
        provider.setIgnoreNamespaces(true);
        factory.registerUserProvider(provider);
        p.setProviders(new ProvidersImpl(createMessage(factory)));
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.writeTo(dom, org.dom4j.Document.class, org.dom4j.Document.class,
                   new Annotation[]{}, MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, Object>(),
                   bos);
View Full Code Here

Examples of org.apache.cxf.jaxrs.impl.ProvidersImpl

    private org.dom4j.Document readXML() throws Exception {
        return readXML(MediaType.APPLICATION_XML_TYPE, "<a/>");
    }
    private org.dom4j.Document readXML(MediaType ct, final String xml) throws Exception {
        DOM4JProvider p = new DOM4JProvider();
        p.setProviders(new ProvidersImpl(createMessage()));
        org.dom4j.Document dom = p.readFrom(org.dom4j.Document.class, org.dom4j.Document.class,
            new Annotation[] {}, ct, new MetadataMap<String, String>(),
            new ByteArrayInputStream(xml.getBytes("UTF-8")));
        return dom;
    }
View Full Code Here

Examples of org.apache.cxf.jaxrs.impl.ProvidersImpl

   
    @Test
    public void testReadJSONConvertToXML() throws Exception {
        final String xml = "{\"a\":{\"b\":2}}";
        DOM4JProvider p = new DOM4JProvider();
        p.setProviders(new ProvidersImpl(createMessage()));
        org.dom4j.Document dom = p.readFrom(org.dom4j.Document.class, org.dom4j.Document.class,
                   new Annotation[]{}, MediaType.APPLICATION_JSON_TYPE, new MetadataMap<String, String>(),
                   new ByteArrayInputStream(xml.getBytes("UTF-8")));
        String str = dom.asXML();
        // starts with the xml PI
View Full Code Here

Examples of org.apache.cxf.jaxrs.impl.ProvidersImpl

    }
   
    private void doTestWriteXML(MediaType ct) throws Exception {
        org.dom4j.Document dom = readXML(ct, "<a/>");
        DOM4JProvider p = new DOM4JProvider();
        p.setProviders(new ProvidersImpl(createMessage()));
       
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        p.writeTo(dom, org.dom4j.Document.class, org.dom4j.Document.class,
            new Annotation[]{}, ct, new MetadataMap<String, Object>(), bos);
        String str = bos.toString();
View Full Code Here

Examples of org.apache.cxf.jaxrs.impl.ProvidersImpl

            o = new RequestImpl(contextMessage);
        } else if (SecurityContext.class.isAssignableFrom(clazz)) {
            SecurityContext customContext = contextMessage.get(SecurityContext.class);
            o = customContext == null ? new SecurityContextImpl(contextMessage) : customContext;
        } else if (Providers.class.isAssignableFrom(clazz)) {
            o = new ProvidersImpl(contextMessage);
        } else if (ContextResolver.class.isAssignableFrom(clazz)) {
            o = createContextResolver(genericType, contextMessage);
        } else if (MessageContext.class.isAssignableFrom(clazz)) {
            o = new MessageContextImpl(m);
        }
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.