Search in sources :

Example 11 with AegisDatabinding

use of org.apache.cxf.aegis.databinding.AegisDatabinding in project cxf by apache.

the class ClientServiceConfigTest method talkToJaxWsHolder.

@Test
public void talkToJaxWsHolder() throws Exception {
    JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
    factory.setDataBinding(new AegisDatabinding());
    factory.setAddress("local://JaxWsEcho");
    Echo client = factory.create(Echo.class);
    Holder<String> sholder = new Holder<String>();
    client.echo("Channa Doll", sholder);
    assertEquals("Channa Doll", sholder.value);
}
Also used : Holder(javax.xml.ws.Holder) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 12 with AegisDatabinding

use of org.apache.cxf.aegis.databinding.AegisDatabinding in project cxf by apache.

the class ExceptionTest method testJaxwsServerSimpleClient.

@Test(expected = HelloException.class)
public void testJaxwsServerSimpleClient() throws Exception {
    JaxWsServerFactoryBean sfbean = new JaxWsServerFactoryBean();
    sfbean.setServiceClass(ExceptionService.class);
    sfbean.setDataBinding(new AegisDatabinding());
    sfbean.setAddress("local://ExceptionServiceJaxWs1");
    Server server = sfbean.create();
    Service service = server.getEndpoint().getService();
    service.setInvoker(new BeanInvoker(new ExceptionServiceImpl()));
    ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
    proxyFac.setAddress("local://ExceptionServiceJaxWs1");
    proxyFac.setBus(getBus());
    setupAegis(proxyFac.getClientFactoryBean());
    ExceptionService clientInterface = proxyFac.create(ExceptionService.class);
    clientInterface.sayHiWithException();
}
Also used : Server(org.apache.cxf.endpoint.Server) BeanInvoker(org.apache.cxf.service.invoker.BeanInvoker) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) Service(org.apache.cxf.service.Service) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) Test(org.junit.Test) AbstractAegisTest(org.apache.cxf.aegis.AbstractAegisTest)

Example 13 with AegisDatabinding

use of org.apache.cxf.aegis.databinding.AegisDatabinding in project cxf by apache.

the class ExplicitPrefixTest method setupService.

private ServiceAndMapping setupService(Class<?> seiClass, Map<String, String> namespaces) {
    AegisDatabinding db = new AegisDatabinding();
    db.setNamespaceMap(namespaces);
    Server s = createService(seiClass, null, db);
    ServiceAndMapping serviceAndMapping = new ServiceAndMapping();
    serviceAndMapping.setServer(s);
    serviceAndMapping.setService(s.getEndpoint().getService());
    serviceAndMapping.setTypeMapping((TypeMapping) serviceAndMapping.getService().get(TypeMapping.class.getName()));
    return serviceAndMapping;
}
Also used : Server(org.apache.cxf.endpoint.Server) TypeMapping(org.apache.cxf.aegis.type.TypeMapping) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding)

Example 14 with AegisDatabinding

use of org.apache.cxf.aegis.databinding.AegisDatabinding in project cxf by apache.

the class AegisClientServerTest method testAegisClient.

@Test
public void testAegisClient() throws Exception {
    AegisDatabinding aegisBinding = new AegisDatabinding();
    ClientProxyFactoryBean proxyFactory = new ClientProxyFactoryBean();
    proxyFactory.setDataBinding(aegisBinding);
    proxyFactory.setServiceClass(AuthService.class);
    proxyFactory.setAddress("http://localhost:" + PORT + "/service");
    AuthService service = (AuthService) proxyFactory.create();
    assertTrue(service.authenticate("Joe", "Joe", "123"));
    assertFalse(service.authenticate("Joe1", "Joe", "fang"));
    assertTrue(service.authenticate("Joe", null, "123"));
    List<String> list = service.getRoles("Joe");
    assertEquals(3, list.size());
    assertEquals("Joe", list.get(0));
    assertEquals("Joe-1", list.get(1));
    assertEquals("Joe-2", list.get(2));
    String[] roles = service.getRolesAsArray("Joe");
    assertEquals(2, roles.length);
    assertEquals("Joe", roles[0]);
    assertEquals("Joe-1", roles[1]);
    assertEquals("get Joe", service.getAuthentication("Joe"));
    Authenticate au = new Authenticate();
    au.setSid("ffang");
    au.setUid("ffang");
    assertTrue(service.authenticate(au));
    au.setUid("ffang1");
    assertFalse(service.authenticate(au));
}
Also used : Authenticate(org.apache.cxf.authservice.Authenticate) ClientProxyFactoryBean(org.apache.cxf.frontend.ClientProxyFactoryBean) AuthService(org.apache.cxf.authservice.AuthService) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) Test(org.junit.Test)

Example 15 with AegisDatabinding

use of org.apache.cxf.aegis.databinding.AegisDatabinding in project cxf by apache.

the class AegisClientServerTest method testComplexMapResult.

@Test
public void testComplexMapResult() throws Exception {
    AegisDatabinding aegisBinding = new AegisDatabinding();
    JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    proxyFactory.setDataBinding(aegisBinding);
    proxyFactory.setServiceClass(SportsService.class);
    proxyFactory.setAddress("http://localhost:" + PORT + "/jaxwsAndAegisSports");
    proxyFactory.getInInterceptors().add(new LoggingInInterceptor());
    proxyFactory.getOutInterceptors().add(new LoggingOutInterceptor());
    SportsService service = (SportsService) proxyFactory.create();
    Map<String, Map<Integer, Integer>> result = service.testComplexMapResult();
    assertEquals(result.size(), 1);
    assertTrue(result.containsKey("key1"));
    assertNotNull(result.get("key1"));
    assertEquals(result.toString(), "{key1={1=3}}");
}
Also used : LoggingOutInterceptor(org.apache.cxf.ext.logging.LoggingOutInterceptor) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) LoggingInInterceptor(org.apache.cxf.ext.logging.LoggingInInterceptor) AegisDatabinding(org.apache.cxf.aegis.databinding.AegisDatabinding) Map(java.util.Map) Test(org.junit.Test)

Aggregations

AegisDatabinding (org.apache.cxf.aegis.databinding.AegisDatabinding)37 Test (org.junit.Test)21 JaxWsProxyFactoryBean (org.apache.cxf.jaxws.JaxWsProxyFactoryBean)14 ClientProxyFactoryBean (org.apache.cxf.frontend.ClientProxyFactoryBean)12 AbstractAegisTest (org.apache.cxf.aegis.AbstractAegisTest)10 LoggingInInterceptor (org.apache.cxf.ext.logging.LoggingInInterceptor)7 LoggingOutInterceptor (org.apache.cxf.ext.logging.LoggingOutInterceptor)7 Before (org.junit.Before)7 ServerFactoryBean (org.apache.cxf.frontend.ServerFactoryBean)6 JaxWsServerFactoryBean (org.apache.cxf.jaxws.JaxWsServerFactoryBean)5 AegisContext (org.apache.cxf.aegis.AegisContext)4 Server (org.apache.cxf.endpoint.Server)4 BeanInvoker (org.apache.cxf.service.invoker.BeanInvoker)4 HashSet (java.util.HashSet)3 ReflectionServiceFactoryBean (org.apache.cxf.wsdl.service.factory.ReflectionServiceFactoryBean)3 QName (javax.xml.namespace.QName)2 XFireCompatibilityServiceConfiguration (org.apache.cxf.aegis.databinding.XFireCompatibilityServiceConfiguration)2 AuthService (org.apache.cxf.authservice.AuthService)2 Authenticate (org.apache.cxf.authservice.Authenticate)2 Service (org.apache.cxf.service.Service)2