Search in sources :

Example 51 with IMocksControl

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

the class JAASLoginInterceptorTest method createTestCert.

private X509Certificate createTestCert(String subjectDn) {
    IMocksControl c = EasyMock.createControl();
    X509Certificate cert = c.createMock(X509Certificate.class);
    Principal principal = c.createMock(Principal.class);
    EasyMock.expect(principal.getName()).andReturn(subjectDn);
    EasyMock.expect(cert.getSubjectDN()).andReturn(principal);
    c.replay();
    return cert;
}
Also used : IMocksControl(org.easymock.IMocksControl) X509Certificate(java.security.cert.X509Certificate) Principal(java.security.Principal)

Example 52 with IMocksControl

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

the class CachedStreamTestBase method testUseBusProps.

@Test
public void testUseBusProps() throws Exception {
    Bus oldbus = BusFactory.getThreadDefaultBus(false);
    try {
        Object cache = createCache(64);
        File tmpfile = getTmpFile("Hello World!", cache);
        assertNull("expects no tmp file", tmpfile);
        close(cache);
        IMocksControl control = EasyMock.createControl();
        Bus b = control.createMock(Bus.class);
        EasyMock.expect(b.getProperty("bus.io.CachedOutputStream.Threshold")).andReturn("4");
        EasyMock.expect(b.getProperty("bus.io.CachedOutputStream.MaxSize")).andReturn(null);
        EasyMock.expect(b.getProperty("bus.io.CachedOutputStream.CipherTransformation")).andReturn(null);
        BusFactory.setThreadDefaultBus(b);
        control.replay();
        cache = createCache();
        tmpfile = getTmpFile("Hello World!", cache);
        assertNotNull("expects a tmp file", tmpfile);
        assertTrue("expects a tmp file", tmpfile.exists());
        close(cache);
        assertFalse("expects no tmp file", tmpfile.exists());
        control.verify();
    } finally {
        BusFactory.setThreadDefaultBus(oldbus);
    }
}
Also used : IMocksControl(org.easymock.IMocksControl) Bus(org.apache.cxf.Bus) File(java.io.File) Test(org.junit.Test)

Example 53 with IMocksControl

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

the class TestBase method getMockedServiceModel.

protected ServiceInfo getMockedServiceModel(String wsdlUrl) throws Exception {
    WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader();
    wsdlReader.setFeature("javax.wsdl.verbose", false);
    Definition def = wsdlReader.readWSDL(wsdlUrl);
    IMocksControl control = EasyMock.createNiceControl();
    Bus bus = control.createMock(Bus.class);
    BindingFactoryManager bindingFactoryManager = control.createMock(BindingFactoryManager.class);
    DestinationFactoryManager dfm = control.createMock(DestinationFactoryManager.class);
    WSDLServiceBuilder wsdlServiceBuilder = new WSDLServiceBuilder(bus);
    Service service = null;
    for (Iterator<?> it = def.getServices().values().iterator(); it.hasNext(); ) {
        Object obj = it.next();
        if (obj instanceof Service) {
            service = (Service) obj;
            break;
        }
    }
    EasyMock.expect(bus.getExtension(BindingFactoryManager.class)).andReturn(bindingFactoryManager);
    EasyMock.expect(bus.getExtension(DestinationFactoryManager.class)).andStubReturn(dfm);
    control.replay();
    ServiceInfo serviceInfo = wsdlServiceBuilder.buildServices(def, service).get(0);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
    serviceInfo.setProperty(WSDLServiceBuilder.WSDL_SERVICE, null);
    return serviceInfo;
}
Also used : IMocksControl(org.easymock.IMocksControl) ServiceInfo(org.apache.cxf.service.model.ServiceInfo) Bus(org.apache.cxf.Bus) DestinationFactoryManager(org.apache.cxf.transport.DestinationFactoryManager) Definition(javax.wsdl.Definition) WSDLServiceBuilder(org.apache.cxf.wsdl11.WSDLServiceBuilder) Service(javax.wsdl.Service) BindingFactoryManager(org.apache.cxf.binding.BindingFactoryManager) WSDLReader(javax.wsdl.xml.WSDLReader)

Example 54 with IMocksControl

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

the class BareOutInterceptorTest method setUp.

@Before
public void setUp() throws Exception {
    super.setUp();
    interceptor = new BareOutInterceptor();
    baos = new ByteArrayOutputStream();
    writer = getXMLStreamWriter(baos);
    message.setContent(XMLStreamWriter.class, writer);
    message.getExchange().put(BindingOperationInfo.class, operation);
    IMocksControl control = EasyMock.createNiceControl();
    InterceptorChain ic = control.createMock(InterceptorChain.class);
    message.setInterceptorChain(ic);
    control.replay();
}
Also used : BareOutInterceptor(org.apache.cxf.wsdl.interceptors.BareOutInterceptor) IMocksControl(org.easymock.IMocksControl) InterceptorChain(org.apache.cxf.interceptor.InterceptorChain) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Before(org.junit.Before)

Example 55 with IMocksControl

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

the class DocLiteralInInterceptorTest 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) DocLiteralInInterceptor(org.apache.cxf.wsdl.interceptors.DocLiteralInInterceptor) Interceptor(org.apache.cxf.interceptor.Interceptor) BindingFactory(org.apache.cxf.binding.BindingFactory) Before(org.junit.Before)

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