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 17 ■ Be Social and Go Mobile<br />

Next, you are going to do the integration test, as shown in Listing 17-6.<br />

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

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

import org.junit.Test;<br />

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

import static org.junit.Assert.assertNotNull;<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.java.service.DocumentService;<br />

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

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

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

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

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

"classpath:META-INF/spring/mydocuments-mongo-context.xml"})<br />

public class MyDocumentsTest {<br />

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

//The ID was taken from the src/main/resources/META-INF/data/data.sql<br />

private final String WEB_TYPE_ID = "4980d2e4-a424-4ff4-a0b2-476039682f43";<br />

@Autowired<br />

DocumentService documentFacade;<br />

@Autowired<br />

TypeService typeFacade;<br />

@Test<br />

public void testMyDocumentsTwitter(){<br />

log.debug("Testing My Documents with <strong>Spring</strong> Social....");<br />

assertNotNull(documentTweet);<br />

assertNotNull(typeFacade);<br />

Document document = new Document();<br />

document.setName("Beginning Blender");<br />

document.setType(typeFacade.getTypeById(WEB_TYPE_ID));<br />

document.setDescription("");<br />

document.setLocation("http://www.apress.com/9781430262237");<br />

}<br />

}<br />

documentFacade.saveDocument(document.getDocumentId(),document);<br />

249

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

Saved successfully!

Ooh no, something went wrong!