25.02.2015 Views

Introducing Spring Framework

Introducing Spring Framework

Introducing Spring Framework

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 13 ■ Adding E-mail and Scheduling Tasks<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

true<br />

true<br />

<br />

<br />

<br />

<br />

<br />

Listing 13-6 shows that adding the tag will let the container know when a method<br />

call will be asynchronous because it will have the @Async annotation on it. Listing 13-7 contains the unit test; let’s see<br />

how long it will take to send the e-mail.<br />

Listing 13-7. MyDocumentsTest.java<br />

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

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

import java.util.Date;<br />

import org.junit.Ignore;<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.context.ContextConfiguration;<br />

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

import com.apress.isf.spring.email.EmailService;<br />

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

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

public class MyDocumentsTest {<br />

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

@Autowired<br />

EmailService email;<br />

@Test<br />

@Ignore<br />

188

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

Saved successfully!

Ooh no, something went wrong!