integration-testing

Does the new Spring MVC Test Framework released in Spring 3.2 test the web.xml configuration?

﹥>﹥吖頭↗ 提交于 2019-11-29 01:43:11
问题 I've read the docs ( http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/testing.html#spring-mvc-test-framework ) several times and I can't confirm if the WebApplicationContext context that gets injected when you use the @WebApplicationContext annotation is actually looking at the web.xml. In other words, I want to test my web.xml configuration. The filters and servlet path specifically. But when I configure my test it ignores the web.xml. (e.g. I try a get

Maven - separate integration tests from unit tests

随声附和 提交于 2019-11-29 01:38:54
Is it possible to isolate integration tests from unit tests within same module? I created simple pom: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>prj</artifactId> <packaging>war</packaging> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.6</source> <target

Integration Testing POSTing an entire object to Spring MVC controller

送分小仙女□ 提交于 2019-11-28 23:32:27
问题 Is there a way to pass an entire form object on mock request when integration testing a spring mvc web app? All I can find is to pass each field separately as a param like this: mockMvc.perform(post("/somehwere/new").param("items[0].value","value")); Which is fine for small forms. But what if my posted object gets larger? Also it makes the test code look nicer if I can just post an entire object. Specifically I'd like to test the selection of multiple items by checkbox and then posting them.

How would you test a Connection Pool

限于喜欢 提交于 2019-11-28 21:34:49
I have implemented a very simple ConnectionPool in Java. It has no fancy features, just get/release connection methods. How can I test it is working? I know there are plenty of connection Pools ready to use out there, which are much more reliable than what I'll do, but I am just trying to practice to understand how connections Pool work. Thank you! Here is the code in case it helps: public class ConnectionPoolImpl implements ConnectionPool { private Vector<PooledConnection> connections; // The connections container String url; String username; String password; /** * Instanciates a new

Adding classpath to jetty running in maven integration-test

倾然丶 夕夏残阳落幕 提交于 2019-11-28 19:46:23
I'm trying to set up integration tests for a Maven project that produces a war file. (As seen here http://docs.codehaus.org/display/JETTY/Maven+Jetty+Plugin/ .) However I the war file requires a bunch of .properties files on the classpath, that I don't want to bundle in the war. Is there a way (preferably through plugin configuration) to add a folder to the classpath used by jetty? I Googled this and found http://markmail.org/message/awtqrgxxttra3uxx but this, as far as I can tell, does not actually work at all. The .properties files are not found. This should be possible using the

TDD and ADO.NET Entity Framework

僤鯓⒐⒋嵵緔 提交于 2019-11-28 17:57:46
I've been playing with ADO.NET Entity Framework lately, and I find that it suits my needs for a project I'm developing. I also find cool its non-invasive nature. After generating a data model from an existing database you are faced with the task of integrating the generated model and your business logic. More specifically, I'm used to integration-test my classes that interact with the data store via mocks/stubs of the DAL interfaces. The problem is that you cannot do this using the ADO.NET Entity Framework because the entities it generates are simple classes with no interface. The question is:

Cucumber and Capybara, clicking a non-link or button element

倾然丶 夕夏残阳落幕 提交于 2019-11-28 17:25:21
I am trying to test an inplace editor using Cucumber/Capybara/Selenium stack, but my problem is that the editor is activated by clicking a div and not a link or button. I can not seem to figure out how to get Capybara to do this. Is there a way of doing this? You can click on an element via Capybara::Element.click . I add the following for this in my web_steps.rb to click on divs. When /^(?:|I )click within "([^"]*)"$/ do |selector| find(selector).click end There is also Element.trigger('mouseover') which appears to enable hover albeit not working with Selenium. It is also very likely you will

How to run individual test in the integration-test target in maven

时光总嘲笑我的痴心妄想 提交于 2019-11-28 17:23:41
问题 We have a hundreds of tests defined for our integration-test phase lifecycle in maven, and they take a long time to finish. What I want to do is run just one test in the integration-test . I tried doing : mvn -Dtest=<my-test> integration-test but that does not work. The -Dtest runs only the tests in the unit test goal, not the integration-test phase. I tried the -Dintegration-test=<my-test> instead, and that was ignored. Is there a way to do that ? My configuration is: <plugin> <groupId>org

Difference between MockMvc and RestTemplate in integration tests

蹲街弑〆低调 提交于 2019-11-28 16:49:59
Both MockMvc and RestTemplate are used for integration tests with Spring and JUnit. Question is: what's the difference between them and when we should choose one over another? Here are just examples of both options: //MockMVC example mockMvc.perform(get("/api/users")) .andExpect(status().isOk()) (...) //RestTemplate example ResponseEntity<User> entity = restTemplate.exchange("/api/users", HttpMethod.GET, new HttpEntity<String>(...), User.class); assertEquals(HttpStatus.OK, entity.getStatusCode()); As said in this article you should use MockMvc when you want to test Server-side of application:

Testing Spring's @RequestBody using Spring MockMVC

巧了我就是萌 提交于 2019-11-28 16:38:21
问题 I am trying to test a method that posts an object to the database using Spring's MockMVC framework. I've constructed the test as follows: @Test public void testInsertObject() throws Exception { String url = BASE_URL + "/object"; ObjectBean anObject = new ObjectBean(); anObject.setObjectId("33"); anObject.setUserId("4268321"); //... more Gson gson = new Gson(); String json = gson.toJson(anObject); MvcResult result = this.mockMvc.perform( post(url) .contentType(MediaType.APPLICATION_JSON)