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 />

}<br />

public void testTwitter(){<br />

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

assertNotNull(documentTweet);<br />

documentTweet.tweet("Playing with <strong>Spring</strong> Social!");<br />

}<br />

Listing 17-4 shows the MyDocumentTest class that is using your DocumentTweet instance and the tweet method<br />

you defined. If you run this test with<br />

gradle :ch17:test<br />

you will see on your Twitter account the status “Playing with <strong>Spring</strong> Social!”. See Figure 17-14.<br />

Figure 17-14. Showing the Result of Running the Unit Test<br />

Pretty cool! You have sent your first tweet! Next, you are going to integrate the DocumentTweet class into your<br />

My Documents <strong>Spring</strong> application.<br />

Sending Tweets from My <strong>Spring</strong> Application<br />

Now that you have everything in place, let’s see how you are going to integrate sending tweets using your My Documents<br />

<strong>Spring</strong> application. You are going to update your DocumentFacade that implements the DocumentService interface,<br />

so after it saves or updates a Book document type you can tweet about it. In other words, you are going to reuse the<br />

DocumentTweet class. See Listing 17-5.<br />

Listing 17-5. DocumentFacade.java<br />

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

import java.util.List;<br />

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

import org.springframework.stereotype.Service;<br />

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

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

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

import com.apress.isf.spring.data.DocumentDAO;<br />

import com.apress.isf.spring.social.DocumentTweet;<br />

247

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

Saved successfully!

Ooh no, something went wrong!