Skip to content

kurtinaitis/spring-test-portlet-mvc

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 

Repository files navigation

spring-test-portlet-mvc

This project is based on the concepts of the server-side component of spring-test-mvc aka MockMvc (https://github.com/spring-projects/spring-test-mvc). It tries to adapt the features for the portlet environment.

The project is still work in progress, but the general API (since derived from spring-test-mvc) is almost finished.

Feel free to contribute and send me a pull request or drop a message.

Update: It is now also possible to test without an existing Application Context (see StandaloneAppContextTest)

Update 2: The project has been published to maven central and can now be easily referenced in your project of choice!

##Maven Integration The project can be obtained trough the maven central repository.

<dependency>
  <groupId>com.github.markusf</groupId>
  <artifactId>spring-test-portlet-mvc</artifactId>
  <version>0.1.0</version>
  <scope>test</scope>
</dependency>

##Sample (Standalone Application Context)

see https://github.com/markusf/spring-test-portlet-mvc/blob/master/src/test/java/org/springframework/test/web/portlet/server/samples/StandaloneAppContextTest.java

##Sample (Existing Application Context)

###Controller

@Controller
@RequestMapping("VIEW") 
public class PersonController {
	
	@RequestMapping
	public String view(RenderRequest request, RenderResponse response, Model model) {
		Person person = new Person();
		model.addAttribute(person);
		return "view";
	}
	
}

###Test

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:testApplicationContext.xml"})	
public class BasicTests {
	
	@Autowired
	private ApplicationContext applicationContext;
	
	@Test
	public void testBasicPortlet() throws Exception {
		existingApplicationContext(applicationContext).build()
			.perform(render().param("test", "test"))
			.andExpect(view().name("view"))
			.andExpect(model().attributeExists("person"))
			.andReturn();
	}
	
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 100.0%