Package org.javalite.activeweb
Class AppIntegrationSpec
java.lang.Object
org.javalite.activeweb.SpecHelper
org.javalite.activeweb.RequestSpecHelper
org.javalite.activeweb.IntegrationSpec
org.javalite.activeweb.AppIntegrationSpec
- All Implemented Interfaces:
JSpecSupport
Bootstraps entire application, including AppControllerConfig class, which sets up all filters exactly as at run time.
If a
DBConnectionFilter
is used in the application, it is bypassed.
Instead, the DB connection to a test DB is made from test configuration. A connection is opened to
a test DB, transaction is started before each test. After each test, a connection is closed and a transaction
is rolled back.- Author:
- Igor Polevoy
-
Nested Class Summary
Nested classes/interfaces inherited from class org.javalite.activeweb.SpecHelper
SpecHelper.DynamicBuilder, SpecHelper.ModuleBuilder
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
static void
void
protected RequestBuilder
controller(String controllerPath)
Takes controller path.Returns instance ofAppContext
static void
boolean
rollback()
Current state of 'rollback' flag.void
setRollback(boolean rollback)
Set to true in order to rollback a transaction at the end of the test (default is true).protected void
Call this method from a constructor of your spec in cases you do not need DB connections.Methods inherited from class org.javalite.activeweb.IntegrationSpec
addFilter, addFilter, resetFilters, setTemplateLocation
Methods inherited from class org.javalite.activeweb.RequestSpecHelper
assigns, atStart00, bytesContent, contentType, cookie, cookieValue, count, getCookies, header, headerNames, headers, layout, redirected, redirectValue, responseContent, responseJSONList, responseJSONMap, statusCode, template, text, val, val, valBoolean, valDouble, valFloat, valInteger, valLong, vals, valString
Methods inherited from class org.javalite.activeweb.SpecHelper
afterEnd, atStart, createInjector, flash, flash, flashExists, injector, registerTag, session, session, session, sessionBoolean, sessionDouble, sessionFloat, sessionHas, sessionInteger, sessionLong, sessionObject, sessionString, setInjector
-
Constructor Details
-
AppIntegrationSpec
public AppIntegrationSpec()
-
-
Method Details
-
rollback
public boolean rollback()Current state of 'rollback' flag.- Returns:
- Current state of 'rollback' flag.
-
setRollback
public void setRollback(boolean rollback)Set to true in order to rollback a transaction at the end of the test (default is true). This method will set theautocommit = !rollback
on all connections found on this thread.WARNING: if you set this value to false inside your test, the framework will not clean any remaining data you insert into your test database. Basically, this is a "manual mode" where you are responsible for cleaning after yourself.
- Parameters:
rollback
- true to rollback transactions at the end of the test, false to not rollback.
-
initDBConfig
@BeforeAll public static void initDBConfig() -
beforeAppIntegrationSpec
@BeforeEach public void beforeAppIntegrationSpec() throws javax.servlet.ServletException- Throws:
javax.servlet.ServletException
-
closeTestConnections
@AfterEach public void closeTestConnections() -
clearConnectionConfigs
@AfterAll public static void clearConnectionConfigs() -
getContext
Returns instance ofAppContext
- Returns:
- instance of
AppContext
-
controller
Takes controller path. A controller path is a full path to controller starting from context and ending in a name of a controller on URI.- Overrides:
controller
in classIntegrationSpec
- Parameters:
controllerPath
- path to controller. Example:/admin/permissions
where "admin" is a sub-package of controller and "permissions" is a name of controller. Such path implies a name of a controller class:app.controllers.admin.PermissionsController
. Controller paths always starts with a slash: "/".- Returns:
- instance of a builder to help define request.
-
suppressDb
protected void suppressDb()Call this method from a constructor of your spec in cases you do not need DB connections. Calling from a "before" method will not work.
-