use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.
the class AegisClientServerTest method testJaxWsAegisClient.
@Test
public void testJaxWsAegisClient() throws Exception {
AegisDatabinding aegisBinding = new AegisDatabinding();
JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
proxyFactory.setDataBinding(aegisBinding);
proxyFactory.setServiceClass(AuthService.class);
proxyFactory.setAddress("http://localhost:" + PORT + "/jaxwsAndAegis");
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]);
roles = service.getRolesAsArray("null");
assertNull(roles);
roles = service.getRolesAsArray("0");
assertEquals(0, roles.length);
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));
}
use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.
the class AegisClientServerTest method testReturnQualifiedPair.
@Test
public void testReturnQualifiedPair() 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();
Pair<Integer, String> ret = service.getReturnQualifiedPair(111, "ffang");
assertEquals(Integer.valueOf(111), ret.getFirst());
assertEquals("ffang", ret.getSecond());
}
use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.
the class MtomTest method setupForTest.
private void setupForTest(boolean enableClientMTOM) throws Exception {
AegisDatabinding aegisBinding = new AegisDatabinding();
aegisBinding.setMtomEnabled(enableClientMTOM);
ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
proxyFac.setDataBinding(aegisBinding);
proxyFac.setAddress("http://localhost:" + PORT + "/mtom");
JaxWsProxyFactoryBean jaxwsFac = new JaxWsProxyFactoryBean();
jaxwsFac.setDataBinding(new AegisDatabinding());
jaxwsFac.setAddress("http://localhost:" + PORT + "/jaxWsMtom");
Map<String, Object> props = new HashMap<>();
if (enableClientMTOM) {
props.put("mtom-enabled", Boolean.TRUE);
}
proxyFac.setProperties(props);
client = proxyFac.create(MtomTestService.class);
jaxwsClient = jaxwsFac.create(MtomTestService.class);
impl = (MtomTestImpl) applicationContext.getBean("mtomImpl");
}
use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.
the class DOCBareClientServerTest method testBare.
@Test
public void testBare() throws Exception {
ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
factory.setServiceClass(Server.BareSoapService.class);
factory.setAddress("http://localhost:" + Server.PORT + "/SOAPDocLitBareService/SoapPort1");
factory.setBus(BusFactory.newInstance().createBus());
Server.BareSoapService client = (Server.BareSoapService) factory.create();
try {
client.doSomething();
fail("This should fail, ClientProxyFactoryBean doesn't support @SOAPBinding annotation");
} catch (IllegalStateException t) {
// expected
}
factory = new JaxWsProxyFactoryBean();
factory.setServiceClass(Server.BareSoapService.class);
factory.setAddress("http://localhost:" + Server.PORT + "/SOAPDocLitBareService/SoapPort1");
factory.setBus(BusFactory.newInstance().createBus());
client = (Server.BareSoapService) factory.create();
client.doSomething();
}
use of org.apache.cxf.jaxws.JaxWsProxyFactoryBean in project cxf by apache.
the class UDPTransportTest method testBroadcastUDP.
@Test
public void testBroadcastUDP() throws Exception {
// Disable the test on Redhat Enterprise Linux which doesn't enable the UDP broadcast by default
if ("Linux".equals(System.getProperties().getProperty("os.name")) && System.getProperties().getProperty("os.version").indexOf("el") > 0) {
System.out.println("Skipping broadcast test for REL");
return;
}
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
int count = 0;
if (interfaces != null) {
while (interfaces.hasMoreElements()) {
NetworkInterface networkInterface = interfaces.nextElement();
if (!networkInterface.isUp() || networkInterface.isLoopback()) {
continue;
}
count++;
}
}
if (count == 0) {
// no non-loopbacks, cannot do broadcasts
System.out.println("Skipping broadcast test");
return;
}
JaxWsProxyFactoryBean fact = new JaxWsProxyFactoryBean();
fact.setAddress("udp://:" + PORT + "/foo");
Greeter g = fact.create(Greeter.class);
assertEquals("Hello World", g.greetMe("World"));
((java.io.Closeable) g).close();
}
Aggregations