Java Code Examples for org.easymock.EasyMock#createNiceControl()

The following examples show how to use org.easymock.EasyMock#createNiceControl() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PolicyRegistryImplTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example 2
Source File: Wsdl11AttachmentPolicyProviderTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
    bus.getExtension(ConfiguredBeanLocator.class);
    EasyMock.expectLastCall().andReturn(null).anyTimes();
    AssertionBuilderRegistry abr = new AssertionBuilderRegistryImpl();
    abr.setIgnoreUnknownAssertions(false);


    PrimitiveAssertionBuilder ab = new PrimitiveAssertionBuilder();
    abr.registerBuilder(new QName("http://cxf.apache.org/test/assertions", "A"), ab);
    abr.registerBuilder(new QName("http://cxf.apache.org/test/assertions", "B"), ab);
    abr.registerBuilder(new QName("http://cxf.apache.org/test/assertions", "C"), ab);

    PolicyBuilderImpl pb = new PolicyBuilderImpl();
    bus.getExtension(PolicyBuilder.class);
    EasyMock.expectLastCall().andReturn(pb).anyTimes();
    bus.getExtension(PolicyEngine.class);
    EasyMock.expectLastCall().andReturn(null).anyTimes();

    pb.setAssertionBuilderRegistry(abr);
    app = new Wsdl11AttachmentPolicyProvider();
    app.setBuilder(pb);
    app.setRegistry(new PolicyRegistryImpl());
    control.replay();

}
 
Example 3
Source File: CorbaBindingFactoryTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testCreateBinding() throws Exception {
    IMocksControl control = EasyMock.createNiceControl();
    BindingInfo bindingInfo = control.createMock(BindingInfo.class);

    CorbaBinding binding = (CorbaBinding)factory.createBinding(bindingInfo);
    assertNotNull(binding);
    assertTrue(CorbaBinding.class.isInstance(binding));
    List<Interceptor<? extends Message>> inInterceptors = binding.getInInterceptors();
    assertNotNull(inInterceptors);
    List<Interceptor<? extends Message>> outInterceptors = binding.getOutInterceptors();
    assertNotNull(outInterceptors);
    assertEquals(2, inInterceptors.size());
    assertEquals(2, outInterceptors.size());
}
 
Example 4
Source File: HTTPConduitURLEasyMockTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendHttpGetConnectionAutoRedirect() throws Exception {
    control = EasyMock.createNiceControl();
    HTTPConduit conduit = setUpConduit(true, true, "GET");
    Message message = new MessageImpl();
    message.put(HTTPConduit.SET_HTTP_RESPONSE_MESSAGE, Boolean.TRUE);
    message.put(Message.HTTP_REQUEST_METHOD, "GET");
    conduit.prepare(message);
    verifySentMessage(conduit, message, "GET");
    assertEquals(HTTP_RESPONSE_MESSAGE, inMessage.get(HTTPConduit.HTTP_RESPONSE_MESSAGE));
    conduit.close(message);
    finalVerify();
}
 
Example 5
Source File: JaxbAssertionTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testEqual() {
    JaxbAssertion<FooType> assertion = new JaxbAssertion<>();
    FooType data = new FooType();
    data.setName("CXF");
    data.setNumber(2);
    QName qn = new QName("http://cxf.apache.org/test/assertions/foo", "FooType");
    assertion.setName(qn);
    assertion.setData(data);

    PolicyComponent pc = new Policy();
    assertFalse(assertion.equal(pc));
    pc = new All();
    assertFalse(assertion.equal(pc));
    pc = new ExactlyOne();
    assertFalse(assertion.equal(pc));

    IMocksControl ctrl = EasyMock.createNiceControl();
    PrimitiveAssertion xpa = ctrl.createMock(PrimitiveAssertion.class);
    QName oqn = new QName("http://cxf.apache.org/test/assertions/blah", "OtherType");
    EasyMock.expect(xpa.getName()).andReturn(oqn);
    EasyMock.expect(xpa.getType()).andReturn(Constants.TYPE_ASSERTION);

    ctrl.replay();
    assertFalse(assertion.equal(xpa));
    ctrl.verify();

    FooType odata = new FooType();
    odata.setName(data.getName());
    odata.setNumber(data.getNumber());
    JaxbAssertion<FooType> oassertion = new JaxbAssertion<>();
    oassertion.setData(odata);
    oassertion.setName(qn);
    assertFalse(assertion.equal(oassertion));
    oassertion.setData(data);
    assertTrue(assertion.equal(oassertion));
    assertTrue(assertion.equal(assertion));
}
 
Example 6
Source File: ServerLifecycleLoggerTest.java    From c2mon with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Before
public void init() {
  control = EasyMock.createNiceControl();
  lifecycleMapper = control.createMock(ServerLifecycleEventMapper.class);
  serverLifecycleLogger = new ServerLifecycleLogger(lifecycleMapper, new ServerProperties());
  serverLifecycleLogger.setTimeBetweenRelogs(1000);
}
 
Example 7
Source File: RestClientCdiTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testProvidersRegisteredViaMPConfigProperty() throws Exception {
    Map<String, String> configValues = new HashMap<>();
    configValues.put(InterfaceWithoutProvidersDefined.class.getName() + "/mp-rest/providers",
                     HighPriorityClientReqFilter.class.getName() + ","
                     + LowPriorityClientReqFilter.class.getName() + ","
                     + InvokedMethodClientRequestFilter.class.getName());
    configValues.put(InterfaceWithoutProvidersDefined.class.getName() + "/mp-rest/providers/" 
                     + LowPriorityClientReqFilter.class.getName() + "/priority", "3");
    ((MockConfigProviderResolver)ConfigProviderResolver.instance()).setConfigValues(configValues);

    IMocksControl control = EasyMock.createNiceControl();
    BeanManager mockedBeanMgr = control.createMock(BeanManager.class);
    mockedBeanMgr.isScope(Path.class);
    EasyMock.expectLastCall().andReturn(false);
    mockedBeanMgr.isScope(Produces.class);
    EasyMock.expectLastCall().andReturn(false);
    mockedBeanMgr.isScope(Consumes.class);
    EasyMock.expectLastCall().andReturn(false);
    control.replay();

    RestClientBean bean = new RestClientBean(InterfaceWithoutProvidersDefined.class, mockedBeanMgr);
    List<Class<?>> registeredProviders = bean.getConfiguredProviders();
    assertEquals(3, registeredProviders.size());
    assertTrue(registeredProviders.contains(HighPriorityClientReqFilter.class));
    assertTrue(registeredProviders.contains(LowPriorityClientReqFilter.class));
    assertTrue(registeredProviders.contains(InvokedMethodClientRequestFilter.class));

    Map<Class<?>, Integer> priorities = bean.getConfiguredProviderPriorities(registeredProviders);
    assertEquals(3, priorities.size());
    assertEquals(3, (int) priorities.get(LowPriorityClientReqFilter.class));
    assertEquals(10, (int) priorities.get(HighPriorityClientReqFilter.class));
    assertEquals(Priorities.USER, (int) priorities.get(InvokedMethodClientRequestFilter.class));

    control.verify();
}
 
Example 8
Source File: HTTPConduitURLEasyMockTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendHttpConnectionAutoRedirect() throws Exception {
    control = EasyMock.createNiceControl();
    HTTPConduit conduit = setUpConduit(true, true, "POST");
    Message message = createMessage();
    message.put(HTTPConduit.SET_HTTP_RESPONSE_MESSAGE, Boolean.TRUE);
    conduit.prepare(message);
    verifySentMessage(conduit, message, "POST");
    assertEquals(HTTP_RESPONSE_MESSAGE, inMessage.get(HTTPConduit.HTTP_RESPONSE_MESSAGE));
    finalVerify();
}
 
Example 9
Source File: HTTPConduitURLEasyMockTest.java    From cxf with Apache License 2.0 5 votes vote down vote up
@Test
public void testSendOnewayDoNotProcessResponse()
    throws Exception {
    control = EasyMock.createNiceControl();
    HTTPConduit conduit = setUpConduit(true, false, "POST");
    Message message = createMessage();
    conduit.prepare(message);
    verifySentMessage(conduit,
                      message,
                      ResponseStyle.ONEWAY_NONE,
                      ResponseDelimiter.CHUNKED,
                      true,  // empty response
                      "POST");
    finalVerify();
}
 
Example 10
Source File: RMInInterceptorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
    rmps = control.createMock(RMProperties.class);
}
 
Example 11
Source File: FirstAlternativeSelectorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
}
 
Example 12
Source File: PolicyInterceptorsTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
    bus = control.createMock(Bus.class);
}
 
Example 13
Source File: DestinationRegistryImplTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
    registry = new DestinationRegistryImpl();
    observer = control.createMock(MessageObserver.class);
}
 
Example 14
Source File: ReflectionServiceFactorBeanTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() throws Exception {
    control = EasyMock.createNiceControl();
}
 
Example 15
Source File: AsyncResponseImplTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
}
 
Example 16
Source File: PolicyVerificationOutInterceptorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
}
 
Example 17
Source File: UriInfoImplTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
    control.makeThreadSafe(true);
}
 
Example 18
Source File: WadlGeneratorTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
    control.makeThreadSafe(true);
}
 
Example 19
Source File: RMTxStoreTwoSchemasTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
}
 
Example 20
Source File: EffectivePolicyImplTest.java    From cxf with Apache License 2.0 4 votes vote down vote up
@Before
public void setUp() {
    control = EasyMock.createNiceControl();
    Integer.valueOf(4);
}