use of org.easymock.EasyMockSupport in project Payara by payara.
the class WeldContextListenerTest method testcontextInitialized.
@Test
public void testcontextInitialized() throws Exception {
EasyMockSupport mockSupport = new EasyMockSupport();
ELResolver elResolver = mockSupport.createMock(ELResolver.class);
ExpressionFactory expressionFactory = mockSupport.createMock(ExpressionFactory.class);
StandardContext servletContext = new StandardContext();
servletContext.getServletContext();
ServletContextEvent servletContextEvent = mockSupport.createMock(ServletContextEvent.class);
BeanManager beanManager = mockSupport.createMock(BeanManager.class);
JspApplicationContextImpl jspApplicationContext = new JspApplicationContextImpl(servletContext);
expect(beanManager.getELResolver()).andReturn(elResolver);
expect(beanManager.wrapExpressionFactory(isA(ExpressionFactory.class))).andReturn(expressionFactory);
mockSupport.replayAll();
WeldContextListener weldContextListener = getWeldContextListener(beanManager, jspApplicationContext);
weldContextListener.contextInitialized(servletContextEvent);
assertSame(expressionFactory, jspApplicationContext.getExpressionFactory());
validateJspApplicationContext(jspApplicationContext, elResolver);
mockSupport.verifyAll();
mockSupport.resetAll();
}
use of org.easymock.EasyMockSupport in project Payara by payara.
the class WeldContextListenerTest method testcontextDestroyed.
@Test
public void testcontextDestroyed() throws Exception {
EasyMockSupport mockSupport = new EasyMockSupport();
BeanManager beanManager = mockSupport.createMock(BeanManager.class);
mockSupport.replayAll();
WeldContextListener weldContextListener = getWeldContextListener(beanManager, null);
Class<?> clazz = LocalWeldContextListener.class.getSuperclass();
Field beanManagerField = clazz.getDeclaredField("beanManager");
beanManagerField.setAccessible(true);
assertNotNull(beanManagerField.get(weldContextListener));
weldContextListener.contextDestroyed(null);
assertNull(beanManagerField.get(weldContextListener));
mockSupport.verifyAll();
mockSupport.resetAll();
}
use of org.easymock.EasyMockSupport in project easymock by easymock.
the class MockBuilderTest method testWithMockSupport.
@Test
public void testWithMockSupport() {
EasyMockSupport support = new EasyMockSupport();
MockBuilderTest a = support.createMockBuilder(MockBuilderTest.class).addMockedMethods("myMethod", "toString").createMock(MockType.NICE);
expect(a.myMethod(2)).andReturn(1);
support.replayAll();
assertEquals(1, a.myMethod(2));
assertEquals(0, a.myMethod(3));
support.verifyAll();
assertEquals("EasyMock for class org.easymock.tests2.MockBuilderTest", a.toString());
}
Aggregations