Search in sources :

Example 1 with BookStore

use of org.apache.cxf.jaxrs.resources.BookStore in project cxf by apache.

the class JAXRSClientFactoryBeanTest method testCreateClientWithUserResource.

@Test
public void testCreateClientWithUserResource() throws Exception {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    bean.setAddress("http://bar");
    UserResource r = new UserResource();
    r.setName(BookStore.class.getName());
    r.setPath("/");
    UserOperation op = new UserOperation();
    op.setName("getDescription");
    op.setVerb("GET");
    r.setOperations(Collections.singletonList(op));
    bean.setModelBeans(r);
    assertTrue(bean.create() instanceof BookStore);
}
Also used : BookStore(org.apache.cxf.jaxrs.resources.BookStore) UserOperation(org.apache.cxf.jaxrs.model.UserOperation) UserResource(org.apache.cxf.jaxrs.model.UserResource) Test(org.junit.Test)

Example 2 with BookStore

use of org.apache.cxf.jaxrs.resources.BookStore in project cxf by apache.

the class JAXRSClientFactoryBeanTest method testGetConduit.

@Test
public void testGetConduit() throws Exception {
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    bean.setAddress("http://bar");
    bean.setResourceClass(BookStore.class);
    BookStore store = bean.create(BookStore.class);
    Conduit conduit = WebClient.getConfig(store).getConduit();
    assertTrue(conduit instanceof HTTPConduit);
}
Also used : HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) BookStore(org.apache.cxf.jaxrs.resources.BookStore) Conduit(org.apache.cxf.transport.Conduit) HTTPConduit(org.apache.cxf.transport.http.HTTPConduit) Test(org.junit.Test)

Example 3 with BookStore

use of org.apache.cxf.jaxrs.resources.BookStore in project cxf by apache.

the class WebClientTest method testProxyConfiguration.

@Test
public void testProxyConfiguration() {
    // interface
    BookInterface proxy = JAXRSClientFactory.create("http://foo", BookInterface.class);
    assertNotNull(WebClient.getConfig(proxy) != null);
    // cglib
    BookStore proxy2 = JAXRSClientFactory.create("http://foo", BookStore.class);
    assertNotNull(WebClient.getConfig(proxy2) != null);
}
Also used : BookInterface(org.apache.cxf.jaxrs.resources.BookInterface) BookStore(org.apache.cxf.jaxrs.resources.BookStore) Test(org.junit.Test)

Example 4 with BookStore

use of org.apache.cxf.jaxrs.resources.BookStore in project cxf by apache.

the class JAXRSClientFactoryBeanTest method testCreateClientCustomLoader.

@Test
public void testCreateClientCustomLoader() throws Exception {
    ProxyClassLoader loader = new ProxyClassLoader(BookStore.class.getClassLoader());
    loader.addLoader(BookStore.class.getClassLoader());
    JAXRSClientFactoryBean bean = new JAXRSClientFactoryBean();
    bean.setAddress("http://bar");
    bean.setResourceClass(BookStore.class);
    bean.setClassLoader(loader);
    BookStore client = (BookStore) bean.createWithValues(BookStore.class);
    assertNotNull(client);
    assertSame(client.getClass().getClassLoader(), loader);
// tricky to test the loader has been used correctly with Maven
// given that the system loader loads all the test classes
}
Also used : BookStore(org.apache.cxf.jaxrs.resources.BookStore) ProxyClassLoader(org.apache.cxf.common.util.ProxyClassLoader) Test(org.junit.Test)

Example 5 with BookStore

use of org.apache.cxf.jaxrs.resources.BookStore in project cxf by apache.

the class UriBuilderImplTest method testAddPathClassMethod.

@Test
public void testAddPathClassMethod() throws Exception {
    URI uri = new URI("http://foo/");
    URI newUri = new UriBuilderImpl().uri(uri).path(BookStore.class).path(BookStore.class, "updateBook").path("bar").build();
    assertEquals("URI is not built correctly", new URI("http://foo/bookstore/books/bar"), newUri);
}
Also used : BookStore(org.apache.cxf.jaxrs.resources.BookStore) URI(java.net.URI) Test(org.junit.Test)

Aggregations

BookStore (org.apache.cxf.jaxrs.resources.BookStore)5 Test (org.junit.Test)5 URI (java.net.URI)1 ProxyClassLoader (org.apache.cxf.common.util.ProxyClassLoader)1 UserOperation (org.apache.cxf.jaxrs.model.UserOperation)1 UserResource (org.apache.cxf.jaxrs.model.UserResource)1 BookInterface (org.apache.cxf.jaxrs.resources.BookInterface)1 Conduit (org.apache.cxf.transport.Conduit)1 HTTPConduit (org.apache.cxf.transport.http.HTTPConduit)1