@SpringBootTest(classes={TestConfig.class,TestRestConfig.class}) public abstract class AbstractRestTest extends AbstractDbTest
If you want to test REST services on mock backend services (without database) then define your own unit test
with using TestRestConfig
that defines basic MVC configuration.
Example:
RunWith(SpringRunner.class) SpringBootTest(classes = TestRestConfig.class) WebAppConfiguration public class BookmarkRestControllerTest {See blog post Building REST services with Spring for more details.
AbstractDbTest.MessageCallback
Modifier and Type | Field and Description |
---|---|
protected org.springframework.test.web.servlet.MockMvc |
mockMvc |
static String |
TEST_PASSWORD |
static String |
TEST_USERNAME |
protected org.springframework.web.context.WebApplicationContext |
webApplicationContext |
em, transactionManager
DEFAULT_LOCALE
Constructor and Description |
---|
AbstractRestTest() |
Modifier and Type | Method and Description |
---|---|
static org.springframework.security.authentication.TestingAuthenticationToken |
mockAuthentication(String... profiles)
Creates authentication token with required profiles (granted authorities).
|
void |
prepareAuthentication()
Sets authenticated user with username '"testUser"' and password '"testPass"'.
|
void |
setUp() |
createAndSaveMessage, createAndSaveMessages, createAndSaveMessages, createMessage, getJdbcTemplate, printEntities
assertErrorCode, configureXmlUnit, getApplContext, getCamelContext, mockDirect, mockDirect, setDefaultLocale, setPrivateField, validateMockito
public static final String TEST_USERNAME
public static final String TEST_PASSWORD
protected org.springframework.test.web.servlet.MockMvc mockMvc
@Autowired protected org.springframework.web.context.WebApplicationContext webApplicationContext
public void setUp()
public void prepareAuthentication()
public static org.springframework.security.authentication.TestingAuthenticationToken mockAuthentication(String... profiles)
profiles
- which represents modules and granted authoritiesTestingAuthenticationToken
Copyright © 2018 Pivotal Software, Inc.. All rights reserved.