public class MockViewScopedContext extends ViewScopedContext
This is a Mock version of the ViewScopedContext
.
It will automatically get used instead of it's parent class
if we are in the
ProjectStage.UnitTest
.
There is of course no automatic cleaning if we transit over to the
next view! In this case you can use resetViewMap()
to clean
the mock ViewMap manually in your unit test.
Attention: The ViewMap is a shared static ConcurrentHashMap, so this implementation is not able to emulate the behaviour of multiple views at the same time!
Constructor and Description |
---|
MockViewScopedContext() |
Modifier and Type | Method and Description |
---|---|
protected Map<String,Object> |
getViewMap() |
boolean |
isActive()
The view context is active if a valid ViewRoot could be detected.
|
static void |
resetViewMap()
Simply clear the mock ViewMap.
|
get, get, getScope, getViewRoot, isListenerForSource, processEvent
public static void resetViewMap()
protected Map<String,Object> getViewMap()
getViewMap
in class ViewScopedContext
public boolean isActive()
ViewScopedContext
isActive
in interface javax.enterprise.context.spi.Context
isActive
in class ViewScopedContext
true
since in a unit test it's always active.Copyright © 2010-2014 The Apache Software Foundation. All Rights Reserved.