Mặc dù vẫn còn được sử dụng rộng rãi, SOAP chưa bao giờ thực sự hoàn thành tiềm năng của nó, và một mô hình đơn giản đã nổi lên được gọi là Representational State Transfer1 (REST) . | 508 CHAPTER 16 LEVERAGING SPRING def notSubscribed attrs body - if checkSubscribed out body Of course testing is crucial too. You could test the tag library using the GroovyPagesTestCase class you used to test the AlbumArtTagLib. However since the SubscriptionTagLib is mainly about branching logic and not markup rendering it is probably easier to take advantage of the agLibUnitT estCase class that lets you unit test tag libraries but not the markup they generate. Simply create a new a unit test in the test unit com g2one gtunes directory called SubscriptionTagLibTests that extends from the TagLibUnitTestCase class as shown in Listing 16-29. Listing 16-29. Using the TagLibUnitTestCase Class package class SubscriptionTagLibTests extends . You can then write a couple of simple tests that check the behavior of the gtunes isSubscribed and gtunes notSubscribed tags. Listing 16-30 shows two tests called testIsSubscribed and testNotSubscribed. Listing 16-30. Testing the SubscriptionTagLib Class void testIsSubscribed mockDomain ArtistSubscription def artist new Artist name Kings of Leon def user new User login testuser new ArtistSubscription artist artist user user .save user artist artist subscribed artist artist notsubscribed assertEquals subscribed void testNotSubscribed CHAPTER 16 LEVERAGING SPRING 509 mockDomain ArtistSubscription def artist new Artist name Kings of Leon def user new User login testuser user artist artist subscribed artist artist notsubscribed assertEquals notsubscribed A closure can be passed as the body of the tag as long as it returns a String representing the body contents. In Listing 16-30 either subscribed or notsubscribed will be written to the mock out variable. OK with the tests out of the way the