Search in sources :

Example 11 with IMocksControl

use of org.easymock.IMocksControl in project cxf by apache.

the class BareInInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    bus = BusFactory.newInstance().createBus();
    BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class);
    IMocksControl control = createNiceControl();
    BindingFactory bf = control.createMock(BindingFactory.class);
    Binding binding = control.createMock(Binding.class);
    expect(bf.createBinding(null)).andStubReturn(binding);
    expect(binding.getInFaultInterceptors()).andStubReturn(new ArrayList<Interceptor<? extends Message>>());
    expect(binding.getOutFaultInterceptors()).andStubReturn(new ArrayList<Interceptor<? extends Message>>());
    bfm.registerBindingFactory("http://schemas.xmlsoap.org/wsdl/soap/", bf);
}
Also used : IMocksControl(org.easymock.IMocksControl) Binding(org.apache.cxf.binding.Binding) Message(org.apache.cxf.message.Message) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) BareInInterceptor(org.apache.cxf.wsdl.interceptors.BareInInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) BindingFactory(org.apache.cxf.binding.BindingFactory) Before(org.junit.Before)

Example 12 with IMocksControl

use of org.easymock.IMocksControl in project cxf by apache.

the class CorbaMessageTest method setUp.

@Before
public void setUp() throws Exception {
    java.util.Properties props = System.getProperties();
    props.put("yoko.orb.id", "CXF-CORBA-Server-Binding");
    orb = ORB.init(new String[0], props);
    IMocksControl control = EasyMock.createNiceControl();
    message = control.createMock(Message.class);
}
Also used : IMocksControl(org.easymock.IMocksControl) Message(org.apache.cxf.message.Message) Before(org.junit.Before)

Example 13 with IMocksControl

use of org.easymock.IMocksControl in project cxf by apache.

the class SOAPHandlerInterceptorTest method testGetUnderstoodHeadersReturnsNull.

@Test
public void testGetUnderstoodHeadersReturnsNull() {
    @SuppressWarnings("rawtypes") List<Handler> list = new ArrayList<>();
    list.add(new SOAPHandler<SOAPMessageContext>() {

        public boolean handleMessage(SOAPMessageContext smc) {
            return true;
        }

        public boolean handleFault(SOAPMessageContext smc) {
            return true;
        }

        public Set<QName> getHeaders() {
            return null;
        }

        public void close(MessageContext messageContext) {
        }
    });
    HandlerChainInvoker invoker = new HandlerChainInvoker(list);
    IMocksControl control = createNiceControl();
    Binding binding = control.createMock(Binding.class);
    expect(binding.getHandlerChain()).andReturn(list).anyTimes();
    SoapMessage message = control.createMock(SoapMessage.class);
    Exchange exchange = control.createMock(Exchange.class);
    expect(message.getExchange()).andReturn(exchange).anyTimes();
    expect(message.keySet()).andReturn(new HashSet<>());
    expect(exchange.get(HandlerChainInvoker.class)).andReturn(invoker);
    control.replay();
    SOAPHandlerInterceptor li = new SOAPHandlerInterceptor(binding);
    Set<QName> understood = li.getUnderstoodHeaders();
    assertNotNull(understood);
    assertTrue(understood.isEmpty());
}
Also used : Binding(javax.xml.ws.Binding) Set(java.util.Set) HashSet(java.util.HashSet) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) SOAPHandler(javax.xml.ws.handler.soap.SOAPHandler) Handler(javax.xml.ws.handler.Handler) SoapMessage(org.apache.cxf.binding.soap.SoapMessage) IMocksControl(org.easymock.IMocksControl) Exchange(org.apache.cxf.message.Exchange) HandlerChainInvoker(org.apache.cxf.jaxws.handler.HandlerChainInvoker) SOAPMessageContext(javax.xml.ws.handler.soap.SOAPMessageContext) MessageContext(javax.xml.ws.handler.MessageContext) SOAPMessageContext(javax.xml.ws.handler.soap.SOAPMessageContext) Test(org.junit.Test)

Example 14 with IMocksControl

use of org.easymock.IMocksControl in project cxf by apache.

the class PolicyRegistryImplTest method testAll.

@Test
public void testAll() {
    PolicyRegistryImpl reg = new PolicyRegistryImpl();
    IMocksControl control = EasyMock.createNiceControl();
    Policy policy = control.createMock(Policy.class);
    String key = "key";
    assertNull(reg.lookup(key));
    reg.register(key, policy);
    assertSame(policy, reg.lookup(key));
    reg.remove(key);
    assertNull(reg.lookup(key));
}
Also used : IMocksControl(org.easymock.IMocksControl) Policy(org.apache.neethi.Policy) Test(org.junit.Test)

Example 15 with IMocksControl

use of org.easymock.IMocksControl in project cxf by apache.

the class Wsdl11AttachmentPolicyProviderTest method oneTimeSetUp.

@BeforeClass
public static void oneTimeSetUp() throws Exception {
    IMocksControl control = EasyMock.createNiceControl();
    Bus bus = control.createMock(Bus.class);
    WSDLManager manager = new WSDLManagerImpl();
    WSDLServiceBuilder builder = new WSDLServiceBuilder(bus);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andReturn(dfm).anyTimes();
    EasyMock.expect(dfm.getDestinationFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
    BindingFactoryManager bfm = control.createMock(BindingFactoryManager.class);
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bfm).anyTimes();
    EasyMock.expect(bfm.getBindingFactory(EasyMock.isA(String.class))).andReturn(null).anyTimes();
    control.replay();
    int n = 19;
    services = new ServiceInfo[n];
    endpoints = new EndpointInfo[n];
    for (int i = 0; i < n; i++) {
        String resourceName = "/attachment/wsdl11/test" + i + ".wsdl";
        URL url = Wsdl11AttachmentPolicyProviderTest.class.getResource(resourceName);
        try {
            services[i] = builder.buildServices(manager.getDefinition(url.toString())).get(0);
        } catch (WSDLException ex) {
            ex.printStackTrace();
            fail("Failed to build service from resource " + resourceName);
        }
        assertNotNull(services[i]);
        endpoints[i] = services[i].getEndpoints().iterator().next();
        assertNotNull(endpoints[i]);
    }
    control.verify();
}
Also used : IMocksControl(org.easymock.IMocksControl) Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) WSDLException(javax.wsdl.WSDLException) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) WSDLManager(org.apache.cxf.wsdl.WSDLManager) WSDLManagerImpl(org.apache.cxf.wsdl11.WSDLManagerImpl) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) URL(java.net.URL) BeforeClass(org.junit.BeforeClass)

Aggregations

IMocksControl (org.easymock.IMocksControl)57 Test (org.junit.Test)34 HttpServletRequest (javax.servlet.http.HttpServletRequest)11 Message (org.apache.cxf.message.Message)11 HttpServletResponse (javax.servlet.http.HttpServletResponse)9 MessageImpl (org.apache.cxf.message.MessageImpl)9 QName (javax.xml.namespace.QName)7 BindingFactoryManager (org.apache.cxf.binding.BindingFactoryManager)7 Before (org.junit.Before)7 ArrayList (java.util.ArrayList)6 HashSet (java.util.HashSet)6 Set (java.util.Set)6 Exchange (org.apache.cxf.message.Exchange)6 FakeHttpServletRequest (com.google.gerrit.util.http.testutil.FakeHttpServletRequest)5 FakeHttpServletResponse (com.google.gerrit.util.http.testutil.FakeHttpServletResponse)5 IOException (java.io.IOException)5 HashMap (java.util.HashMap)5 Binding (javax.xml.ws.Binding)5 Handler (javax.xml.ws.handler.Handler)5 MessageContext (javax.xml.ws.handler.MessageContext)5