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 14 ■ Using Dynamic Languages<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

You can see in Listing 14-5 that you are using a new tag, the namespace. This tag helps the<br />

<strong>Spring</strong> container identify the dynamic language to be used. You pass the path where your script is located with the<br />

script-source property, and then you set the refresh rate (if you want to change the script at runtime, it will load it<br />

again after 5 seconds) with the refresh-check-delay property. Lastly, you provide the two property values needed<br />

(the same as a regular <strong>Spring</strong> bean).<br />

Also, you define the “security” bean that has a reference to your SecurityServiceFacade class, and you set the<br />

login property by referencing the groovyloginScript id. Now let’s see Listing 14-6, the unit test.<br />

Listing 14-6. MyDocumentsTest.java<br />

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

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

import static org.junit.Assert.assertTrue;<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.service.SecurityServiceFacade;<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 />

private static String EMAIL = "john@email.com";<br />

private static String PASSWORD = "doe";<br />

@Autowired<br />

SecurityServiceFacade security;<br />

198

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

Saved successfully!

Ooh no, something went wrong!