use of org.glassfish.contextpropagation.spi.ContextMapHelper in project Payara by payara.
the class ContextManagerImplUnitTest method testGetContextUseOfContextMap_new.
/**
* Verify the expected delegation to ContextMap by ContextManagerImpl on invocation of getContext.
*/
// @Test
public void testGetContextUseOfContextMap_new(@Mocked final ContextMap mockedContextMap) throws Exception {
new Expectations() {
// We expect ContextManagerImpl to call getScopeAwareContextMap, but
// we also need that method to return a ContextMap instance so
// we tell the mocking framework to return an instance.
ContextMapHelper expectationsRefContextMapHelper;
{
expectationsRefContextMapHelper.getScopeAwareContextMap();
returns(mockedContextMap, null);
}
// We expect ContextManagerImpl to then go ahead and use the
// ContextMap - in particular to call get (from which we deliberately
// return null) and the createViewCapable (from which we return null
// which is in practice an exceptional condition (which will result
// in a WARNING log message) but does fine for this test.
ContextMap expectationsRefContextMap = mockedContextMap;
{
expectationsRefContextMap.get(WORK_CONTEXT_KEY);
returns(null, null);
expectationsRefContextMap.createViewCapable(WORK_CONTEXT_KEY);
returns(null, null);
}
};
ContextManagerImpl cmi = new ContextManagerImpl();
Context ci = cmi.getContext();
}
Aggregations