25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 7 ■ Testing Your <strong>Spring</strong> Application<br />

Listing 7-6. mydocuments-custom-profiles-context.xml<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

You just removed the tag from Listing 7-6. Let’s look at Listing 7-7 to see what happens<br />

to the test.<br />

Listing 7-7. MyDocumentsWithCustomProfilesTest.java<br />

package com.apress.isf.spring.test;<br />

import static org.junit.Assert.assertEquals;<br />

import static org.junit.Assert.assertNotNull;<br />

import static org.junit.Assert.assertTrue;<br />

import java.util.List;<br />

import org.junit.Test;<br />

import org.junit.runner.RunWith;<br />

import org.slf4j.Logger;<br />

import org.slf4j.LoggerFactory;<br />

import org.springframework.beans.factory.annotation.Autowired;<br />

import org.springframework.test.annotation.IfProfileValue;<br />

import org.springframework.test.annotation.ProfileValueSourceConfiguration;<br />

import org.springframework.test.context.ContextConfiguration;<br />

import org.springframework.test.context.junit4.<strong>Spring</strong>JUnit4ClassRunner;<br />

import com.apress.isf.java.model.Document;<br />

import com.apress.isf.java.model.Type;<br />

import com.apress.isf.java.service.SearchEngine;<br />

import com.apress.isf.spring.test.profile.CustomProfile;<br />

@RunWith(<strong>Spring</strong>JUnit4ClassRunner.class)<br />

@ContextConfiguration("classpath:META-INF/spring/mydocuments-custom-profiles-context.xml")<br />

@ProfileValueSourceConfiguration(CustomProfile.class)<br />

public class MyDocumentsWithCustomProfilesTest {<br />

private static final Logger log = LoggerFactory.getLogger(MyDocumentsWithCustomProfilesTest.class);<br />

81

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!