@ContextConfiguration(locations={"file:application-home/beans.xml","classpath:org/appng/testsupport/application-testcontext.xml"}) @DirtiesContext public class TestBase extends Object implements org.springframework.context.ApplicationContextInitializer<org.springframework.context.support.GenericApplicationContext>
Application
.@org.springframework.test.context.ContextConfiguration(initializers = MyTest.class) public class MyTest extends TestBase { public MyTest() { super("myapplication", "application-home"); } }Example Usage (with JPA):
@org.springframework.test.context.ContextConfiguration(locations = { TestBase.TESTCONTEXT_JPA }, initializers = MyTest.class) public class MyTest extends TestBase { public MyTest() { super("myapplication", "application-home"); setEntityPackage("org.myapplication.domain"); setRepositoryBase("org.myapplication.repository"); } }Testing
ActionProvider
s and DataProvider
s is this simple:
@org.junit.Test public void testShowPersons() throws ProcessingException, IOException { addParameter("sortPersons", "name:desc"); initParameters(); CallableDataSource datasource = getDataSource("persons").getCallableDataSource(); datasource.perform("personPage"); validate(datasource.getDatasource()); } @org.junit.Test public void testCreatePerson() throws ProcessingException, IOException { CallableAction callableAction = getAction("personEvent", "create").withParam(FORM_ACTION, "create") .getCallableAction(new Person("John", "Doe")); FieldProcessor fieldProcessor = callableAction.perform(); validate(callableAction.getAction(), "-action"); validate(fieldProcessor.getMessages(), "-messages"); }
Modifier and Type | Class and Description |
---|---|
protected class |
TestBase.ActionCall |
protected class |
TestBase.DataSourceCall |
protected class |
TestBase.SimpleApplication |
protected class |
TestBase.SimpleFeatureProvider |
Modifier and Type | Field and Description |
---|---|
protected Application |
application |
static String |
BEANS_PATH |
protected org.springframework.context.ConfigurableApplicationContext |
context |
protected org.springframework.core.convert.ConversionService |
conversionService |
protected Environment |
environment |
protected static String |
FORM_ACTION |
protected MarshallService |
marshallService |
protected org.springframework.context.MessageSource |
messageSource |
protected Path |
path |
protected ApplicationRequest |
request |
protected javax.servlet.ServletContext |
servletContext |
protected org.springframework.mock.web.MockHttpServletRequest |
servletRequest |
protected org.springframework.mock.web.MockHttpServletResponse |
servletResponse |
protected javax.servlet.http.HttpSession |
session |
protected Site |
site |
protected Subject |
subject |
static String |
TESTCONTEXT |
static String |
TESTCONTEXT_CORE |
static String |
TESTCONTEXT_JPA |
Constructor and Description |
---|
TestBase() |
TestBase(String applicationName,
String applicationLocation) |
Modifier and Type | Method and Description |
---|---|
protected void |
addParameter(String name,
String value) |
protected TestBase.ActionCall |
getAction(String eventId,
String id) |
protected List<ApplicationSubject> |
getApplicationSubjects() |
protected TestBase.DataSourceCall |
getDataSource(String id) |
protected String |
getEntityPackage() |
protected FormUpload |
getFormUpload(String resourceName) |
protected List<Property> |
getPlatformProperties(String prefix) |
protected Properties |
getProperties() |
protected String |
getRepositoryBase() |
protected List<Property> |
getSiteProperties(String prefix) |
protected void |
init(boolean isPost) |
protected void |
initEnvironment() |
void |
initialize(org.springframework.context.support.GenericApplicationContext applicationContext) |
protected void |
initParameters() |
protected void |
initParameters(boolean isPost) |
protected void |
initRequest() |
protected boolean |
isUseFullClassname() |
protected void |
setEntityPackage(String entityPackage) |
protected void |
setRepositoryBase(String repositoryBase) |
void |
setup() |
protected void |
setUseFullClassname(boolean useFullClassname) |
protected void |
subjectWithRole(String roleName) |
void |
validate(BaseObject object) |
void |
validate(BaseObject object,
DifferenceListener differenceListener) |
void |
validate(BaseObject object,
String suffix) |
void |
validate(BaseObject object,
String suffix,
DifferenceListener differenceListener) |
public static final String TESTCONTEXT
public static final String TESTCONTEXT_CORE
public static final String TESTCONTEXT_JPA
public static final String BEANS_PATH
protected static final String FORM_ACTION
@Autowired protected javax.servlet.ServletContext servletContext
protected javax.servlet.http.HttpSession session
@Autowired protected org.springframework.mock.web.MockHttpServletRequest servletRequest
protected org.springframework.mock.web.MockHttpServletResponse servletResponse
@Autowired protected org.springframework.context.ConfigurableApplicationContext context
@Autowired protected org.springframework.context.MessageSource messageSource
@Autowired protected org.springframework.core.convert.ConversionService conversionService
@Autowired protected MarshallService marshallService
protected Environment environment
protected ApplicationRequest request
protected Application application
@Mock protected Site site
@Mock protected Subject subject
@Mock protected Path path
protected void subjectWithRole(String roleName)
public void initialize(org.springframework.context.support.GenericApplicationContext applicationContext)
initialize
in interface org.springframework.context.ApplicationContextInitializer<org.springframework.context.support.GenericApplicationContext>
protected Properties getProperties()
protected FormUpload getFormUpload(String resourceName) throws URISyntaxException
URISyntaxException
protected List<ApplicationSubject> getApplicationSubjects()
protected void initRequest() throws InvalidConfigurationException, JAXBException
protected void initParameters()
protected void initParameters(boolean isPost)
protected void init(boolean isPost)
protected void initEnvironment()
public void validate(BaseObject object) throws IOException
IOException
public void validate(BaseObject object, DifferenceListener differenceListener) throws IOException
IOException
public void validate(BaseObject object, String suffix, DifferenceListener differenceListener) throws IOException
IOException
public void validate(BaseObject object, String suffix) throws IOException
IOException
protected String getEntityPackage()
protected void setEntityPackage(String entityPackage)
protected String getRepositoryBase()
protected void setRepositoryBase(String repositoryBase)
protected boolean isUseFullClassname()
protected void setUseFullClassname(boolean useFullClassname)
protected TestBase.DataSourceCall getDataSource(String id)
protected TestBase.ActionCall getAction(String eventId, String id)
Copyright © 2011–2017 aiticon GmbH. All rights reserved.