Search in sources :

Example 11 with BookStore

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

the class LoadDistributorTest method testSingleAltAddress.

@Test
public void testSingleAltAddress() throws Exception {
    LoadDistributorFeature feature = new LoadDistributorFeature();
    List<String> alternateAddresses = new ArrayList<>();
    alternateAddresses.add(Server.ADDRESS2);
    SequentialStrategy strategy = new SequentialStrategy();
    strategy.setAlternateAddresses(alternateAddresses);
    feature.setStrategy(strategy);
    BookStore bookStore = getBookStore(Server.ADDRESS1, feature);
    Book book = bookStore.getBook("123");
    assertEquals("unexpected id", 123L, book.getId());
    book = bookStore.getBook("123");
    assertEquals("unexpected id", 123L, book.getId());
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.BookStore) SequentialStrategy(org.apache.cxf.clustering.SequentialStrategy) Book(org.apache.cxf.systest.jaxrs.Book) LoadDistributorFeature(org.apache.cxf.clustering.LoadDistributorFeature) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 12 with BookStore

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

the class Server method createEndpoint.

private void createEndpoint(String address) {
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(BookStore.class);
    sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore(), false));
    sf.setAddress(address);
    servers.add(sf.create());
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.BookStore) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) SingletonResourceProvider(org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)

Example 13 with BookStore

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

the class BookHttpsServer method run.

protected void run() {
    JAXRSServerFactoryBean sf = new JAXRSServerFactoryBean();
    sf.setResourceClasses(BookStore.class);
    // default lifecycle is per-request, change it to singleton
    sf.setResourceProvider(BookStore.class, new SingletonResourceProvider(new BookStore()));
    sf.setAddress("https://localhost:" + PORT + "/");
    sf.create();
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.BookStore) JAXRSServerFactoryBean(org.apache.cxf.jaxrs.JAXRSServerFactoryBean) SingletonResourceProvider(org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)

Example 14 with BookStore

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

the class JAXRSHttpsBookTest method testCustomVerbProxyFromSpringWildcard.

@Test
public void testCustomVerbProxyFromSpringWildcard() throws Exception {
    if (System.getProperty("java.version").startsWith("9")) {
        // CXF-7270
        return;
    }
    ClassPathXmlApplicationContext ctx = new ClassPathXmlApplicationContext(new String[] { CLIENT_CONFIG_FILE3 });
    Object bean = ctx.getBean("bookService.proxyFactory");
    assertNotNull(bean);
    JAXRSClientFactoryBean cfb = (JAXRSClientFactoryBean) bean;
    BookStore bs = cfb.create(BookStore.class);
    WebClient.getConfig(bs).getRequestContext().put("use.httpurlconnection.method.reflection", true);
    // CXF RS Client code will set this property to true if the http verb is unknown
    // and this property is not already set. The async conduit is loaded in the tests module
    // but we do want to test HTTPUrlConnection reflection hence we set this property to false
    WebClient.getConfig(bs).getRequestContext().put("use.async.http.conduit", false);
    Book book = bs.retrieveBook(new Book("Retrieve", 123L));
    assertEquals("Retrieve", book.getName());
    ctx.close();
}
Also used : BookStore(org.apache.cxf.systest.jaxrs.BookStore) JAXRSClientFactoryBean(org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) Book(org.apache.cxf.systest.jaxrs.Book) Test(org.junit.Test)

Aggregations

BookStore (org.apache.cxf.systest.jaxrs.BookStore)14 Book (org.apache.cxf.systest.jaxrs.Book)8 Test (org.junit.Test)8 ProcessingException (javax.ws.rs.ProcessingException)4 FailoverFeature (org.apache.cxf.clustering.FailoverFeature)3 JAXRSClientFactoryBean (org.apache.cxf.jaxrs.client.JAXRSClientFactoryBean)3 WebClient (org.apache.cxf.jaxrs.client.WebClient)3 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)3 ArrayList (java.util.ArrayList)2 SequentialStrategy (org.apache.cxf.clustering.SequentialStrategy)2 CircuitBreakerFailoverFeature (org.apache.cxf.clustering.circuitbreaker.CircuitBreakerFailoverFeature)2 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)2 SingletonResourceProvider (org.apache.cxf.jaxrs.lifecycle.SingletonResourceProvider)2 IOException (java.io.IOException)1 InternalServerErrorException (javax.ws.rs.InternalServerErrorException)1 Bus (org.apache.cxf.Bus)1 FailoverFailedException (org.apache.cxf.clustering.FailoverFailedException)1 LoadDistributorFeature (org.apache.cxf.clustering.LoadDistributorFeature)1 RandomStrategy (org.apache.cxf.clustering.RandomStrategy)1 ClientLifeCycleManager (org.apache.cxf.endpoint.ClientLifeCycleManager)1