Groovy и Grails. Практические советы. В оригинале Groovy and Grails RecipesКнигу не читал. Сказать что-то не могу. Английская версия гуляет по просторам глобальной паутины. Опирается на Groovy 1.5.6 и Grails 1.0.3 UP от 18 августа 2010 Полистал книжку - ИМХО довольно интересна с точки зрения Groovy, с точки зрения Grails - не особо. Содержание: Код | CHAPTER 1 Getting Started with Groovy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1-1. What Is Groovy?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 1-2. What Is Wrong with Java? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 1-3. How Does Groovy Address the Shortcomings of Java? . . . . . . . . . . . . 5 1-4. How Do I Download and Install Groovy? . . . . . . . . . . . . . . . . . . . . . . . . . 8 1-5. What Tools Come with Groovy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1-6. How Do I Use the Groovy Shell? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 1-7. How Do I Use the Groovy Console? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 1-8. How Do I Use groovyc and groovy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 1-9. Is There IDE Support for Groovy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 1-10. How Do I Integrate Groovy with Eclipse? . . . . . . . . . . . . . . . . . . . . . . 12 1-11. How Do I Integrate Groovy with IntelliJ IDEA? . . . . . . . . . . . . . . . . . . 14 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 CHAPTER 2 From Java to Groovy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 2-1. What Are the Similarities Between Java and Groovy? . . . . . . . . . . . . 17 2-2. What Are the Differences Between Java and Groovy? . . . . . . . . . . . . 19 Optional Syntax Elements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 New and Enhanced Syntax Elements, Structures, and Constructs . . . 22 New Helpers, Libraries, and APIs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28 Other Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 2-3. How Do I Integrate Groovy with Java? . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Compiling to Bytecode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Using GroovyShell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38 Using GroovyScriptEngine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 39 Using GroovyClassLoader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40 Using JSR 223 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 42 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43 CHAPTER 3 Groovy Data Types and Control Structures . . . . . . . . . . . . . . . . 45 3-1. What Are the Different Kinds of Strings in Groovy and How Do I Use Them? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45 3-2. How Do I Use Regular Expressions in Groovy? . . . . . . . . . . . . . . . . . . 50 3-3. How Are Numbers in Groovy Different from Those in Java? . . . . . . . 53 3-4. How Do I Use Lists in Groovy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 3-5. How Do I Implement a Merge Sort in Groovy? . . . . . . . . . . . . . . . . . . . 62 3-6. How Do I Use Maps in Groovy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63 3-7. What Are Ranges and How Do I Use Them in Groovy? . . . . . . . . . . . . 66 3-8. What Is the Groovy Truth? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 3-9. How Is the switch Statement in Groovy Different from Java? . . . . . . 68 3-10. How Do I Perform Looping in Groovy? . . . . . . . . . . . . . . . . . . . . . . . . 69 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 70 CHAPTER 4 Object-Oriented Groovy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 4-1. What Are the Differences Between Classes and Scripts? . . . . . . . . . 71 One Public Class per File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Multiple Classes per File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Scripting Code Only . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 73 Classes and Scripting Code in the Same File . . . . . . . . . . . . . . . . . . . 73 Choosing a Strategy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 4-2. How Do I Use Packages? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 4-3. What Is Type Aliasing and How Do I Use It? . . . . . . . . . . . . . . . . . . . . . 75 4-4. How Do I Use Inheritance in Groovy? . . . . . . . . . . . . . . . . . . . . . . . . . . . 76 4-5. How Do I Use Interfaces in Groovy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77 4-6. What Are Multimethods and How Do I Use Them? . . . . . . . . . . . . . . . 80
4-7. What Are Categories and How Do I Use Them? . . . . . . . . . . . . . . . . . . 82 4-8. How Are Groovy Fields and Local Variables Different from Those in Java? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 4-9. How Are Groovy Methods Different from Java Methods? . . . . . . . . . 85 Using Positional Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Using a List as a Single Argument . . . . . . . . . . . . . . . . . . . . . . . . . . . . 86 Using an Array for Optional Parameters . . . . . . . . . . . . . . . . . . . . . . . . 87 Using Mapped Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87 4-10. How Are Groovy Constructors Different from Those in Java? . . . . . 88 4-11. What Are GroovyBeans? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89 4-12. What Are GPaths? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90 4-13. How Do I Use the Expando Class? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 4-14. What Is Metaclass and How Do I Use It? . . . . . . . . . . . . . . . . . . . . . . 93 4-15. How Do I Intercept All Method Calls on an Object?. . . . . . . . . . . . . . 94 4-16. How Do I Intercept Methods That Don’t Exist on a Class? . . . . . . . . 95 4-17. How Do I Add Additional Behavior to a Class by Using ExpandoMetaClass? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 CHAPTER 5 Closures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 5-1. What Is a Closure? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97 5-2. Why Do I Need Closures? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 5-3. How Do Closures Compare with Anonymous Inner Classes? . . . . . . 99 5-4. How Do I Create a Closure? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 5-5. How Do I Call a Closure? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100 5-6. How Do I Return a Value from a Closure? . . . . . . . . . . . . . . . . . . . . . . 101 5-7. How Do I Reuse a Method as a Closure? . . . . . . . . . . . . . . . . . . . . . . 101 5-8. How Do I Pass a Closure as an Argument to Another Method? . . . 102 5-9. What Is the Scope of a Closure? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 5-10. What Do this, owner, and delegate Mean Inside a Closure? . . . . . 105 5-11. How Can I Return from a Closure? . . . . . . . . . . . . . . . . . . . . . . . . . . 106 5-12. What Does It Mean to Curry Closures? . . . . . . . . . . . . . . . . . . . . . . . 107 5-13. How Do I Use a Closure Inside a switch Statement? . . . . . . . . . . . 108 5-14. How Do I Get More Information About the Parameters Passed to a Closure? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 5-15. How Do I Use Closures Inside a Map? . . . . . . . . . . . . . . . . . . . . . . . . 109 5-16. How Do I Use Closures with Files? . . . . . . . . . . . . . . . . . . . . . . . . . . 110 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 110 CHAPTER 6 Builders . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 6-1. What Are Builders? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 6-2. Why Do I Need Builders? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112 6-3. How Do I Use MarkupBuilder to Build XML? . . . . . . . . . . . . . . . . . . . 114 6-4. How Do I Use MarkupBuilder to Build HTML? . . . . . . . . . . . . . . . . . . 119 6-5. How Do I Use NodeBuilder to Build a Tree of Objects? . . . . . . . . . . 120 6-6. How Do I Use ObjectGraphBuilder to Build a Tree of Objects? . . . . 122 6-7. How Do I Use AntBuilder to Write Ant Tasks? . . . . . . . . . . . . . . . . . . 123 6-8. How Do I Use SwingBuilder to Create Swing Widgets? . . . . . . . . . . 125 6-9. How Do I Use Layout Managers with SwingBuilder? . . . . . . . . . . . . 128 6-10. How Do I Add an Action to a Swing Widget? . . . . . . . . . . . . . . . . . . 131 6-11. How Do I Share Actions Among Widgets? . . . . . . . . . . . . . . . . . . . . 132 6-12. How Do I Use Swing Models? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133 6-13. How Do I Create My Own Builder? . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 138 CHAPTER 7 Working with Databases . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 7-1. How Do I Connect to a Database? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 7-2. How Do I Use Connection Pooling? . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 7-3. How Do I Create a New Table? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141 7-4. How Do I Insert, Update, and Delete Data? . . . . . . . . . . . . . . . . . . . . 143 7-5. How Do I Read Data from My Tables? . . . . . . . . . . . . . . . . . . . . . . . . . 145 7-6. How Do I Retrieve a Table’s Metadata? . . . . . . . . . . . . . . . . . . . . . . . 147 7-7. How Do I Use DataSet? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 148 7-8. How Do I Use DataSet with Joined Tables? . . . . . . . . . . . . . . . . . . . . 151 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 CHAPTER 8 Testing with Groovy . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155 8-1. How Do I Write an Inline Test in Groovy? . . . . . . . . . . . . . . . . . . . . . . 155 8-2. How Do I Write a Test Class in Groovy? . . . . . . . . . . . . . . . . . . . . . . . 156 8-3. How Do I Use Groovy to Test Java Code? . . . . . . . . . . . . . . . . . . . . . . 160 8-4. How Do I Organize Tests into Suites and Run Them from My IDE? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 161 8-5. How Do I Use Ant to Run My Tests? . . . . . . . . . . . . . . . . . . . . . . . . . . 163 8-6. How Do I Use Maven to Run My Tests? . . . . . . . . . . . . . . . . . . . . . . . 164 8-7. What Are the Advanced Testing Techniques Offered by Groovy? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 8-8. How Do I Use Maps to Test My Code? . . . . . . . . . . . . . . . . . . . . . . . . 167 8-9. How Do I Use an Expando Object to Test My Code? . . . . . . . . . . . . . 169 8-10. How Do I Use Stubs and Mocks in Groovy? . . . . . . . . . . . . . . . . . . . 169 8-11. How Do I Use GroovyLogTestCase? . . . . . . . . . . . . . . . . . . . . . . . . . . 173 8-12. How Can I Measure My Code Coverage by Using Cobertura?. . . . 175 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 181 CHAPTER 9 Miscellaneous Recipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 9-1. How Do I Use Groovy Templates to Generate Dynamic and Reusable Content? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183 9-2. How Do I Use Groovlets to Generate Dynamic Web Content? . . . . . 187 9-3. How Do I Read and Process XML with XmlParser? . . . . . . . . . . . . . . 189 9-4. How Do I Read and Process XML with XmlSlurper? . . . . . . . . . . . . . 193 9-5. How Do I Use XPath? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 195 9-6. How Do I Read an XML RSS Feed? . . . . . . . . . . . . . . . . . . . . . . . . . . . 196 9-7. How Do I Use Groovy on the Command Line? . . . . . . . . . . . . . . . . . . 196 9-8. How Do I Use ConfigSlurper to Write Configuration Files? . . . . . . . . 198 9-9. How Do I Use Groovy to Run External Processes? . . . . . . . . . . . . . . 200 9-10. How Do I Download a File in Groovy? . . . . . . . . . . . . . . . . . . . . . . . . 201 9-11. How Do I Process All Files in a Directory? . . . . . . . . . . . . . . . . . . . . 201 9-12. How Do I Count All Occurrences of a Word in a String? . . . . . . . . 202 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
CHAPTER 10 Getting Started with Grails . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 10-1. What Is Grails? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207 10-2. Why Another Framework? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 10-3. How Do I Download and Install Grails? . . . . . . . . . . . . . . . . . . . . . . . 209 10-4. How Do I Create My First Application in Grails? . . . . . . . . . . . . . . . 210 10-5. How Do I Use Grails with Eclipse? . . . . . . . . . . . . . . . . . . . . . . . . . . . 213 10-6. How Do I Use Grails with IntelliJ IDEA? . . . . . . . . . . . . . . . . . . . . . . . 214 10-7. What Are the Different Grails Commands? . . . . . . . . . . . . . . . . . . . . 216 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217 CHAPTER 11 The Web Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219 11-1. How Do I Create a Controller? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 220 11-2. What Are Groovy Server Pages?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 222 11-3. What Is the Relationship Between Controllers and GSPs? . . . . . . . 224 11-4. How Can I Pass Variables from a Controller to a GSP? . . . . . . . . . 225 11-5. How Do I Use Tags as Method Calls? . . . . . . . . . . . . . . . . . . . . . . . . 226 11-6. How Can I Have Multiple Actions Inside a Controller? . . . . . . . . . . 227 11-7. What Are the Available Implicit Objects Inside a Controller and a GSP? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 11-8. How Can I Render a Different View for the User? . . . . . . . . . . . . . . 235 11-9. How Do I Chain Actions? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237 11-10. How Do I Intercept Actions in a Controller? . . . . . . . . . . . . . . . . . . 238 11-11. How Do I Bind Incoming Parameters? . . . . . . . . . . . . . . . . . . . . . . 239 11-12. How Do I Output JSON? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 11-13. How Do I Render Domain Classes as XML or JSON (Marshalling)? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 11-14. How Do I Upload and Download Files? . . . . . . . . . . . . . . . . . . . . . . 242 11-15. What Are Templates and How Do I Use Them? . . . . . . . . . . . . . . . 243 11-16. How Do I Change the Application’s Layout and Look? . . . . . . . . . 245 11-17. How Do I Write My Own Custom Tags? . . . . . . . . . . . . . . . . . . . . . 249 11-18. How Do I Use Filters? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 11-19. How Do I Use Ajax? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 254
CHAPTER 12 The Data Layer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 255 12-1. How Do I Configure My Application to Use a Database? . . . . . . . . 255 12-2. How Do I Create a Domain Class? . . . . . . . . . . . . . . . . . . . . . . . . . . . 259 12-3. How Do I Model Relationships? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263 12-4. How Do I Use Composition? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 270 12-5. How Do I Perform CRUD Operations on My Domain Classes? . . . 270 12-6. How Do I Query with GORM? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 274 12-7. How Do I Use Dynamic Finders? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 275 12-8. How Do I Use Criteria? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 277 12-9. How Do I Use HQL? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 280 12-10. How Do I Use Inheritance? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 281 12-11. What Is Optimistic and Pessimistic Locking? . . . . . . . . . . . . . . . . 282 12-12. How Do I Use Events? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283 12-13. How Do I Use Timestamps? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 12-14. How Do I Use Caching? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 12-15. How Do I Use a Custom Database Identifier? . . . . . . . . . . . . . . . . 287 12-16. How Do I Use a Composite Primary Key? . . . . . . . . . . . . . . . . . . . . 288 12-17. How Do I Add an Index to a Column? . . . . . . . . . . . . . . . . . . . . . . . 288 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 289 CHAPTER 13 Scaffolding . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 291 13-1. How Do I Use Dynamic Scaffolding? . . . . . . . . . . . . . . . . . . . . . . . . . 292 13-2. How Do I Dynamically Scaffold Relationships? . . . . . . . . . . . . . . . . 295 13-3. How Do I Customize the Generated Views? . . . . . . . . . . . . . . . . . . . 298 13-4. What Are the Built-In Constraints in Grails? . . . . . . . . . . . . . . . . . . . 302 13-5. How Do I Override Scaffolded Actions and Views? . . . . . . . . . . . . . 305 13-6. How Do I Use Static Scaffolding? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 13-7. How Do I Change the Scaffolding Templates? . . . . . . . . . . . . . . . . . 313 13-8. How Do I Add My Own Property Editor? . . . . . . . . . . . . . . . . . . . . . . 314 13-9. How Do I Use Scaffolding with Hibernate Mapped Classes?. . . . . 318 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 320
CHAPTER 14 Security . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 321 14-1. How Do I Protect My Application from SQL Injection Attacks? . . . .321 14-2. How Do I Protect My Application from Cross- Site Scripting (XSS)? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 14-3. How Do I Use Codecs? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 323 14-4. How Do I Restrict the HTTP Request Methods That Can Call an Action? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 324 14-5. How Do I Implement Authentication in My Application? . . . . . . . . 325 14-6. How Do I Use the AcegiSecurity Plug- In? . . . . . . . . . . . . . . . . . . . . . 328 14-7. How Do I Use OpenID? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 337 CHAPTER 15 Testing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 339 15-1. How Do I Unit- Test My Application? . . . . . . . . . . . . . . . . . . . . . . . . . 339 15-2. How Do I Create Integration Tests? . . . . . . . . . . . . . . . . . . . . . . . . . . 343 15-3. How Do I Test render and redirect Methods? . . . . . . . . . . . . . . . . . 345 15-4. How Do I Test Tag Libraries? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 15-5. How Do I Test Domain Classes? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347 15-6. How Do I Create a Functional Test with Canoo WebTest? . . . . . . . 349 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 352 CHAPTER 16 Miscellaneous Recipes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 16-1. What About the Service Layer? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 16-2. How Can I Use Some of Spring’s Advanced Features with Grails? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 16-3. How Do I Configure My Application by Using External Files? . . . . 360 16-4. How Do I Configure Logging in My Application? . . . . . . . . . . . . . . . 363 16-5. How Do I Use Grails with Maven 2?. . . . . . . . . . . . . . . . . . . . . . . . . . 364 16-6. How Do I Use Grails with REST? . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 16-7. How Do I Write SOAP Web Services in Grails with CXF? . . . . . . . . 369 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 376
|
Добавлено @ 00:47Русскоязычные статьи на сайте IBM:Groovy на практике: Взгляд на Groovy как на DSL для Java-разработчиков Groovy: меньше кода – больше дела! Работа с Grails: Cоздание первого Grails-приложенияУзнайте, как много возможностей заключено в этой маленькой инфраструктуре для разработки Web-приложений Работа с Grails: GORM - Забавное название и серьезная технологияРабота с базами данных в Grails Изучение Grails: Изменение представления данных с помощью Groovy Server PagesИзучение Grails: Oсвежите ваше приложение GrailsПридайте свежий вид своему приложению с помощью CSS, шаблонов, библиотек тегов и т. д. Изучение Grails: Cоздание собственного подключаемого модуляУзнайте о создании модулей, пригодных для использования в различных приложениях Grails Изучение Grails: Асинхронная обработка данных в Grails при помощи JSON и AjaxРабота с mashup-компонентами Google Maps в Grails Изучение Grails: Grails и мобильный WebM – новый WWW Groovy и Spring: Oсновы интеграцииУзнайте, как использование Groovy может повысить гибкость приложений на основе Spring Groovy и Spring: Часть 2. Изменение поведения приложения в процессе выполненияДобавление динамически обновляемых объектов Groovy в приложение Spring Это сообщение отредактировал(а) Vasay - 18.8.2010, 17:18
--------------------
Придумать идеальную защиту от дурака невозможно, дураки, наудивление, изобретательны.
|