@ApplicationScoped public class ContextController extends Object
If you are testing code that runs over several requests then you may want to explicitly control activation and deactivation of scopes. Use ContextControllerEjbCdiUnit to do this.
@RunWith(CdiRunner.class)
@AdditionalClasses(RequestScopedWarpDrive.class)
class TestStarship {
@Inject
ContextControllerEjbCdiUnit contextController; // Obtain an instance of the context
// controller.
@Inject
Starship starship;
@Test
void testStart() {
contextController.openRequest(); // Start a new request.
starship.start();
contextController.closeRequest(); // Close the current request.
}
}
| Constructor and Description |
|---|
ContextController() |
| Modifier and Type | Method and Description |
|---|---|
void |
closeRequest()
Close the currently active request.
|
void |
closeSession()
Close the currently active session.
|
javax.servlet.http.HttpServletRequest |
currentRequest() |
javax.servlet.http.HttpSession |
getSession() |
javax.servlet.http.HttpServletRequest |
openRequest()
Start a request.
|
public javax.servlet.http.HttpServletRequest openRequest()
public javax.servlet.http.HttpServletRequest currentRequest()
public void closeRequest()
public void closeSession()
public javax.servlet.http.HttpSession getSession()
Copyright © 2017–2018. All rights reserved.