Package org.apache.cxf.endpoint

Examples of org.apache.cxf.endpoint.ServerImpl


       
        Map<String, Object> props = new HashMap<String, Object>();
        props.put("contextMatchStrategy", "stem");
        sf.setProperties(props);
       
        ServerImpl svr = (ServerImpl) sf.create();

        URIMapper mapper = (URIMapper) svr.getEndpoint().getService().get(URIMapper.class.getName());
        assertNotNull(mapper);
       
        BindingOperationInfo bop = mapper.getOperation("/customers", "GET", null);
        assertNotNull(bop);
        assertEquals("getCustomers", bop.getName().getLocalPart());
       
        bop = mapper.getOperation("/customers", "POST", null);
        assertNotNull(bop);
        assertEquals("addCustomer", bop.getName().getLocalPart());
       
        bop = mapper.getOperation("/customers/123", "GET", null);
        assertNotNull(bop);
        assertEquals("getCustomer", bop.getName().getLocalPart());
       
        bop = mapper.getOperation("/customers/123", "PUT", null);
        assertNotNull(bop);
        assertEquals("updateCustomer", bop.getName().getLocalPart());
       
        // TEST POST/GETs
       
        Document res = get("http://localhost:9001/foo/customers");
        assertNotNull(res);

        addNamespace("c", "http://cxf.apache.org/jra");
        assertValid("/c:customers", res);
        assertValid("/c:customers/c:customer/c:id[text()='123']", res);
        assertValid("/c:customers/c:customer/c:name[text()='Dan Diephouse']", res);
       
        res = get("http://localhost:9001/foo/customers/123");
        assertNotNull(res);
       
        assertValid("/c:customer", res);
        assertValid("/c:customer/c:id[text()='123']", res);
        assertValid("/c:customer/c:name[text()='Dan Diephouse']", res);
       
        // Try invalid customer
        res = get("http://localhost:9001/foo/customers/0", 500);
        assertNotNull(res);
       
        assertValid("//c:CustomerNotFoundDetails", res);
       
        res = put("http://localhost:9001/foo/customers/123", "update.xml");
        assertNotNull(res);
       
        assertValid("/c:updateCustomer", res);
       
        res = post("http://localhost:9001/foo/customers", "add.xml");
        assertNotNull(res);
       
        assertValid("/c:addCustomer", res);

        // Get the updated document
        res = get("http://localhost:9001/foo/customers/123");
        assertNotNull(res);
       
        assertValid("/c:customer", res);
        assertValid("/c:customer/c:id[text()='123']", res);
        assertValid("/c:customer/c:name[text()='Danno Manno']", res);
       
        svr.stop();
    }
View Full Code Here


       
        Map<String, Object> props = new HashMap<String, Object>();
        props.put("Content-Type", "text/plain");
        sf.setProperties(props);
       
        ServerImpl svr = (ServerImpl) sf.create();
       
        URL url = new URL("http://localhost:9001/foo/customers/123");
        HttpURLConnection c = (HttpURLConnection)url.openConnection();
        c.setRequestMethod("GET");
       
        assertEquals("text/plain", c.getContentType());

        svr.stop();
    }
View Full Code Here

       
        Map<String, Object> props = new HashMap<String, Object>();
        props.put("contextMatchStrategy", "stem");
        sf.setProperties(props);
       
        ServerImpl svr = (ServerImpl) sf.create();

        svr.getEndpoint().getOutInterceptors().add(new LoggingOutInterceptor());
       
        ClientImpl client = new ClientImpl(getBus(), svr.getEndpoint());
       
        Object[] objects = client.invoke(new QName("http://cxf.apache.org/jra", "getCustomers"),
                                         new GetCustomers());
        assertNotNull(objects);
       
        Customers c = (Customers) objects[0];
        Customer customer = c.getCustomer().iterator().next();
        assertEquals("Dan Diephouse", customer.getName());
       
        GetCustomer getCustomer = new GetCustomer();
        getCustomer.setId(customer.getId());
        objects = client.invoke(new QName("http://cxf.apache.org/jra", "getCustomer"), getCustomer);
       
        customer = (Customer) objects[0];
        assertEquals("Dan Diephouse", customer.getName());
//       
//        objects = client.invoke(new QName("http://cxf.apache.org/jra", "deleteCustomer"),
//        customer.getId());
//        assertTrue(objects == null || objects.length == 0);
//       
        svr.stop();
    }
View Full Code Here

        svrBean.setAddress("http://localhost/Hello");
        svrBean.setServiceClass(HelloService.class);
        svrBean.setBus(getBus());
        svrBean.setDestinationFactory(new CustomDestinationFactory());

        ServerImpl server = (ServerImpl)svrBean.create();
        assertTrue(server.getDestination() instanceof CustomDestination);
    }
View Full Code Here

                    getBus().getOutInterceptors());
            cxfService.getOutFaultInterceptors().addAll(
                    getBus().getOutFaultInterceptors());

            chain = new JbiChainInitiationObserver(ep, getBus());
            server = new ServerImpl(getBus(), ep, null, chain);
            super.validate();
        } catch (DeploymentException e) {
            throw e;
        } catch (Exception e) {
            throw new DeploymentException(e);
View Full Code Here

            } else if (serviceBean != null) {
                getServiceFactory().setInvoker(createInvoker());
            }
           
            Endpoint ep = createEndpoint();
            server = new ServerImpl(getBus(),
                                    ep,
                                    getDestinationFactory(),
                                    getBindingFactory());
           
            if (invoker == null) {
View Full Code Here

   
    protected void doPublish(String addr) {
        checkPublishPermission();
       
        try {
            ServerImpl serv = getServer(addr);
            if (addr != null) {           
                EndpointInfo endpointInfo = serv.getEndpoint().getEndpointInfo();
                endpointInfo.setAddress(addr);
                if (publishedEndpointUrl != null) {
                    // TODO is there a good place to put this key-string as a constant?
                    endpointInfo.setProperty("publishedEndpointUrl", publishedEndpointUrl);
                }
                this.address = addr;
            }
            serv.start();
        } catch (WebServiceException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new WebServiceException(ex);
        }
View Full Code Here

                invoker = createInvoker();
                getServiceFactory().setInvoker(invoker);
            }

            Endpoint ep = createEndpoint();
            server = new ServerImpl(getBus(),
                                    ep,
                                    getDestinationFactory(),
                                    getBindingFactory());

            if (ep.getService().getInvoker() == null) {
View Full Code Here

                serviceFactory.create();
                updateClassResourceProviders();
            }
           
            Endpoint ep = createEndpoint();
            server = new ServerImpl(getBus(),
                                    ep,
                                    getDestinationFactory(),
                                    getBindingFactory());

            if (invoker == null) {
View Full Code Here

   
    protected void doPublish(String addr) {
        checkPublishPermission();
       
        try {
            ServerImpl serv = getServer(addr);
            if (addr != null) {           
                EndpointInfo endpointInfo = serv.getEndpoint().getEndpointInfo();
                if (!endpointInfo.getAddress().contains(addr)) {
                    endpointInfo.setAddress(addr);
                }
                if (publishedEndpointUrl != null) {
                    // TODO is there a good place to put this key-string as a constant?
                    endpointInfo.setProperty("publishedEndpointUrl", publishedEndpointUrl);
                }
                this.address = endpointInfo.getAddress();
            }
            serv.start();
        } catch (WebServiceException ex) {
            throw ex;
        } catch (Exception ex) {
            throw new WebServiceException(ex);
        }
View Full Code Here

TOP

Related Classes of org.apache.cxf.endpoint.ServerImpl

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.