Continuous enterprise development in java

256 118 0
Continuous enterprise development in java

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Free ebooks ==> www.ebook777.com m o c 777 k o o b e w w w www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com m o c 777 k o o b e w w w www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com Continuous Enterprise Development in Java m o c 777 k o o b e w w w Andrew Lee Rubinger and Aslak Knutsen www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com Continuous Enterprise Development in Java by Andrew Lee Rubinger and Aslak Knutsen Copyright © 2014 Andrew Lee Rubinger and Aslak Knutsen All rights reserved Printed in the United States of America Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472 O’Reilly books may be purchased for educational, business, or sales promotional use Online editions are also available for most titles (http://my.safaribooksonline.com) For more information, contact our corporate/ institutional sales department: 800-998-9938 or corporate@oreilly.com Editors: Mike Loukides and Meghan Blanchette Production Editor: Kara Ebrahim Copyeditor: Kim Cofer Proofreader: Becca Freed March 2014: Indexer: WordCo Indexing Services, Inc Cover Designer: Randy Comer Interior Designer: David Futato Illustrator: Rebecca Demarest First Edition Revision History for the First Edition: 2014-03-11: First release See http://oreilly.com/catalog/errata.csp?isbn=9781449328290 for release details m o c 777 Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc Continuous Enterprise Development in Java, the image of a Violet Turaco, and related trade dress are trademarks of O’Reilly Media, Inc k o o b e w w Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks Where those designations appear in this book, and O’Reilly Media, Inc was aware of a trademark claim, the designations have been printed in caps or initial caps w While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein ISBN: 978-1-449-32829-0 [LSI] www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com Table of Contents Foreword vii Preface ix Continuity The Zen of Prevention Reactive Error Handling Proactive Quality Policies Software Development Processes Serial Models Iterative Models Testing Is Development Levels of Testing Unit Integration Foundation Test Frameworks JUnit TestNG Continuous Development 1 2 3 5 10 12 13 m o c 777 k o o b e w w w Enabling Technologies 15 Bootstrapping Apache Maven JBoss Forge Version Control Git A Test Platform for Java EE Arquillian ShrinkWrap ShrinkWrap Resolvers 15 16 17 18 19 20 20 22 27 iii www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com Experimental Features Runtime WildFly OpenShift On to the Code 35 37 37 38 38 Scratch to Production 39 The Development Environment A New Project Writing Our First Integration Test with Arquillian Running the Application Locally Running the Arquillian Integration Test Deploying to OpenShift via JBoss Developer Studio 39 40 48 51 53 55 Requirements and the Example Application 63 Introducing GeekSeek Featureset Conceptual Data Model Logical Data Model Obtaining, Building, Testing, and Running GeekSeek Use Cases and Chapter Guide Chapter 5: Java Persistence and Relational Data Chapter 6: NoSQL: Data Grids and Graph Databases Chapter 7: Business Logic and the Services Layer Chapter 8: REST and Addressable Services Chapter 9: Security Chapter 10: UI Chapter 11: Assembly and Deployment m o c 777 k o o b e w w w 64 64 65 66 68 73 73 73 73 74 74 75 75 Java Persistence and Relational Data 77 The Relational Database Model The Java Persistence API POJO Entities Use Cases and Requirements User Perspective Technical Concerns Implementation Entity Objects Repository EJBs Requirement Test Scenarios Test Setup iv | Table of Contents www.it-ebooks.info WWW.EBOOK777.COM 79 81 82 83 84 84 85 86 90 93 93 Free ebooks ==> www.ebook777.com CRUD Tests 95 NoSQL: Data Grids and Graph Databases 101 RDBMS: Bad at Binary Data Data Grids RDBMS: Bad at Relationships Graph Theory Use Cases and Requirements Implementation Attachment Relation Requirement Test Scenarios Attachment CRUD Tests Transactional Integrity of Attachment Persistence Validating Relationships 102 103 104 105 107 107 107 111 119 120 123 127 Business Logic and the Services Layer 131 Use Cases and Requirements Send Email on New User Signup Implementation Requirement Test Scenarios A Test-Only SMTP Server The Test 132 133 134 139 140 142 m o c 777 k o o b e REST and Addressable Services .w ww 149 REST in Enterprise Java: The JAX-RS Specification Use Cases and Requirements Implementation Repository Resources The Representation Converter The @ResourceModel LinkableRepresentation ResourceLink Requirement Test Scenarios A Black-Box Test Validating the HTTP Contracts with Warp Arquillian Warp Test Harness Setup The HTTP Contracts Test 152 154 157 157 161 163 164 167 168 169 171 171 173 174 Security 177 Use Cases and Requirements 178 Table of Contents www.it-ebooks.info WWW.EBOOK777.COM | v Free ebooks ==> www.ebook777.com Implementation Supporting Software Requirement Test Scenarios Overview Setup Security Tests 178 178 186 187 187 188 10 The User Interface 197 Use Cases and Requirements Implementation Requirement Test Scenarios Pure JavaScript Functional Behavior 197 198 201 201 203 11 Assembly and Deployment 211 Obtaining JBoss EAP Running Against JBoss EAP Using the EAP Remote Container Using the EAP Managed Container Continuous Integration and the Authoritative Build Server Configuring the GeekSeek Build on CloudBees Populating CloudBees Jenkins with the EAP Repository Automatic Building on Git Push Events Pushing to Staging and Production Setting Up the OpenShift Application Removing the Default OpenShift Application Pushing from the CI Build Job to OpenShift m o c 777 k o o b e w w w 211 213 213 215 218 218 220 223 224 224 227 227 12 Epilogue 231 Index 233 vi | Table of Contents www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com Foreword Even ancient J2EE was never just about development From the advent of enterprise Java there has been a strictly defined holistic role concept Component providers, assemblers, system administrators, and server providers have clear and distinct responsibilities, but these have been rarely upheld in the real world Because of politics and organizational structures, often the developer assumes the re‐ sponsibility of all these roles, with the possible exception of system administration and operations The developer’s main goal is development, and the well-intentioned role separation collapses quickly m o c 777 k o o b e w w In the “real world,” a dedicated operations department takes the results of the develop‐ ment cycle and attempts to install, run, and just keep it alive Such an artificially sepa‐ rated model works, but is far away from being optimal Sometimes it gets even worse, and signing off documents becomes more important than software quality w If you are only interested in quick hacks, you will hate Java EE, application servers, and probably this book altogether Packaging, deployment, monitoring, and management sounds like bloat and is bloat, if you are only focusing on development However the “DevOps” movement also considers operations and development as a single unit Who needs beautiful code that cannot be properly installed in a predefined environment? DevOps is nothing groundbreaking; rather, it’s a “back to the roots” movement This book is not just compatible with the “DevOps” ideals; it pragmatically shows how to build a Java EE application from scratch and also patches holes in the Java EE spec Automation of project and archive creation, pragmatic integration of Maven builds into the process, and testing on all levels are deeply explained with concrete code Rather than focusing on best-case scenarios, this book shows you how to test the inconvenient, including examples with SMTP servers or Message Driven Beans Although the tools, libraries, and frameworks introduced in this book were initiated by Red Hat employees, this book will be equally valuable for you if you are not using JBoss vii www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com or WildFly at all In fact, I used Arquillian, ShrinkWrap, and Forge to test applications on GlassFish and TomEE at the same time Also, in my workshops I use Arquillian to test plug-ins, extensions, and sophisticated dependency injection without deploying mocks to a production archive It was fun to read this book on the flight to JavaOne 2013 in San Francisco; I learned a lot I wish you happy reading—enjoy the lightweight Java EE development lifecycle! —Adam Bien http://adam-bien.com m o c 777 k o o b e w w w viii | Foreword www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com The default DNS record will be in the format http://appName-domainId.rhcloud.com It’s likely that this isn’t really the name we desire for public consumption, so let’s add our own custom DNS name This is a two-step process: Create a DNS entry with your domain registrar or DNS Management interface to point to http://appName-domainId.rhcloud.com In our case, we’ll opt for a sub‐ domain, which amounts to a CNAME record Consult your domain authority for the specifics of this step, but generally you might be presented with a screen that looks similar to Figure 11-14 Figure 11-14 Add CNAME Add an “alias” in your OpenShift application’s configuration You can this via the web interface shown in Figure 11-15 Figure 11-15 Add alias m o c 777 k o o b e w w w Alternatively, you can acquire the OpenShift client-side command-line tools These rely on a Ruby installation of 1.8.7 or greater on your system, and are obtained by installing a Ruby gem: $> sudo gem install rhc Once the gem is installed, you can add the domain record to OpenShift using the com‐ mand rhc alias add appName alias -l username For instance: $> $ rhc alias add geekseek geekseek.continuousdev.org -l admin@continuousdev.org Password: ***************** Alias 'geekseek.continuousdev.org' has been added Assuming the CNAME is properly set up with your domain registrar, the record has percolated through the network’s DNS tree (which may or may not take some time), and the alias is set up correctly, your application should now be available directly at the provided alias In our case, this is http://geekseek.continuousdev.org/ 226 | Chapter 11: Assembly and Deployment www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com Removing the Default OpenShift Application Now let’s clear the way for our real application First we’ll clone the OpenShift applica‐ tion repository into our local workspace The Git URL for your application is displayed on the application’s status screen on your OpenShift account The git clone command will look a little like this: $> git clone ssh://(somehash))@geekseek-continuousdev rhcloud.com/~/git/geekseek.git/ Cloning into 'geekseek' The authenticity of host 'geekseek-continuousdev.rhcloud.com (72.44.62.62)' can't be established RSA key fingerprint is cf:ee:77:cb:0e:fc:02:d7:72:7e:ae:80:c0:90:88:a7 Are you sure you want to continue connecting (yes/no)? yes Warning: Permanently added 'geekseek-continuousdev.rhcloud.com,72.44.62.62' (RSA) to the list of known hosts remote: Counting objects: 39, done remote: Compressing objects: 100% (31/31), done remote: Total 39 (delta 1), reused (delta 0) Receiving objects: 100% (39/39), 19.98 KiB, done Resolving deltas: 100% (1/1), done Now we have a full copy of the OpenShift application’s repository on our local disk Because we don’t need the default landing page shown in Figure 11-13, we can safely remove it We can this easily by cd-ing into our repository directory, removing the files in question with git rm, committing the changes, and then pushing the commit to the remote OpenShift repository: m o c 777 k o o b e w w $> cd geekseek geekseek $> git rm -rf pom.xml src/ rm 'pom.xml' rm 'src/main/java/.gitkeep' rm 'src/main/resources/.gitkeep' rm 'src/main/webapp/WEB-INF/web.xml' rm 'src/main/webapp/images/jbosscorp_logo.png' rm 'src/main/webapp/index.html' rm 'src/main/webapp/snoop.jsp' geekseek $> git commit -m 'Remove OpenShift default application structure' geekseek $> git push origin master w When the git push command concludes and the remote build is complete, reloading our application in the web browser should now yield us a blank page, because we’ve deleted the only content in the OpenShift repo We’ll replace that with fresh content from our CI builds Pushing from the CI Build Job to OpenShift The final piece of the automated deployment puzzle lies in deploying artifacts built from our CI server into our runtime environment In our case, this amounts to configuring Pushing to Staging and Production www.it-ebooks.info WWW.EBOOK777.COM | 227 Free ebooks ==> www.ebook777.com the CloudBees Jenkins instance to perform some Git operations against our OpenShift repository We’ll need to allow access for CloudBees Jenkins to interact with the OpenShift repos‐ itory On the Configure screen for our CI job is a section named CloudBees DEV@Cloud Authorization, which contains our public key (see Figure 11-16) Copy this to your OS’s clipboard Figure 11-16 CloudBees SSH public key Then log in to your OpenShift Management Console and select Settings; there will be a dialog to manage the public keys allowed access to our repository (see Figure 11-17) Add the CloudBees Jenkins key by pasting it here m o c 777 k o o b e w w w Figure 11-17 OpenShift public keys Switching back to our Jenkins job configuration screen, toward the bottom is a section where we can add “post-build” steps (see Figure 11-18) Let’s create a shell-based action that will be set to execute only upon successful build 228 | Chapter 11: Assembly and Deployment www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com Figure 11-18 CloudBees post-build steps The following script will handle the task for us: if [ -d geekseek ]; then cd geekseek if [ -f deployments/ROOT.war ]; then rm -rf deployments/ROOT.war fi git pull origin master else git clone ssh://51abd6c84382ec5c160002e2@geekseek-continuousdev.rhcloud.com/ ~/git/geekseek.git/ cd geekseek fi m o c 777 k o o b e w w cp $WORKSPACE/code/application/application/target/*.war deployments/ROOT.war touch deployments/ROOT.WAR.dodeploy git add -Av COMMIT_MESSAGE='Updated application from ' COMMIT_MESSAGE=$COMMIT_MESSAGE$BUILD_URL git commit -m "$COMMIT_MESSAGE" git push origin master w Let’s see what’s going on here First we have some bash logic to either clone the remote OpenShift repository if this node hasn’t already, or update the existing copy Then we copy the final deployable web application We’ll WAR into the deployments directory of the repository, renaming it to ROOT.war so that this acts as our application servicing requests from the web root Also, we’ll add or update an empty ROOT.war.dodeploy file to let OpenShift know that we want this application deployed when it’s discovered (full documentation on this feature is available on the OpenShift site) Finally, we add our changes to be staged for commit, perform the commit, and then push the changes to our remote OpenShift repository As we’ve seen before, OpenShift will dutifully exercise the remote operations to redeploy our application and make it available for our use Pushing to Staging and Production www.it-ebooks.info WWW.EBOOK777.COM | 229 Free ebooks ==> www.ebook777.com Using the OpenShift client command-line tools, we can tail the server logs for the ap‐ plication to monitor status: $> rhc tail {openshift_appname} -l {openshift_username} If we look closely, we’ll see that the application has deployed, and is ready for use! 2013/06/04 05:38:52,413 INFO [org.jboss.as.server] (ServerService Thread Pool 36) JBAS018559: Deployed "ROOT.war" (runtime-name : "ROOT.war") m o c 777 k o o b e w w w 230 | Chapter 11: Assembly and Deployment www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com CHAPTER 12 Epilogue Now this is not the end It is not even the beginning of the end But it is, perhaps, the end of the beginning — Winston Churchill Enterprise Java is, as technologies go, not a highly opinionated landscape; it does not prescribe only one way of accomplishing a task Although Java EE provides a suite of APIs, we’ve seen in our GeekSeek example that it may be appropriate to look outside the platform and integrate with external frameworks This freedom carries with it a burden of choice: developers new and seasoned alike may find that bringing together a working application at all layers may carry complexity m o c 777 k o o b e w w w We’ve set out to show one cohesive application, but this is not a book of best practices We’ve taken one approach of many, and it fit our requirements What we intend to underscore is the importance the role of testing takes in respon‐ sible development The applications we deploy into production are composed of much more than what we write on our own; we need to be sure that all components are working in concert Additionally, it’s helpful to isolate business logic where we can, and further ensure that everything is connected properly when integrated The Arquillian project in particular has been a wonderful means for us to explore the bounds of how simple we can make testing of even the most complex use cases, and its community has been instrumental in pushing the limits of testability in a landscape that has historically been cumbersome to manipulate We hope that the techniques outlined here, on the companion source repository, and running proof in production on http://geekseek.continuousdev.org are beneficial to your own path in building reliable applications in Enterprise Java 231 www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com m o c 777 k o o b e w w w www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com Index A Acceptance testing, account-centric actions, 64 ACID properties, 85 addressable services, 149–152 Agile Software Development, 4, 13 Agorava, 182–186 Amazon, 101 AngularJS, 198 Apache Cassandra, 79 Apache HBase, 79 Apache Maven, 16 actions, 16 experimental ShrinkWrap Resolver inter‐ faces for, 36 resolving coordinates with ShrinkWrap, 30– 34 ShrinkWrap Resolvers plug-in, 36 application assembly, 211–224 authoritative build servers, 218–224 JBoss EAP, 211–218 application deployment, 224–230 logging for, 122 pushing build jobs, 227–230 set up in OpenShift, 224–226 to OpenShift, 224–230 application level security, 178–182 application nouns, 65 application requirements, 63–73 conceptual data models, 65 featureset, defining, 64 logical data models, 66–68 testing, 93–99 application services JBoss EAP, 211–218 OpenShift, 38 WildFly, 37 application states, 77 Architectural Styles and the Design of Networkbased Software Architectures (Fielding), 150 Arquillian, 20 core principles, 21 Drone, 203–209 Graphene, 203–209 Persistence Extension, 73 QUnit interface, 201 running integration tests, 53 Warp, 171–175 writing integration tests, 48–51 assembly (of applications), 211–224 authoritative build servers, 218–224 JBoss EAP, 211–218 authentication, 178 Agorava, 182–186 OAuth, 184, 192–195 process, 182 social, 178–182 m o c 777 k o o b e w w w We’d like to hear your suggestions for improving our indexes Send email to index@oreilly.com 233 www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com continuous development, 13–14 continuous integration, 13–14, 211 authoritative build servers and, 218–224 continuous integration server, 11 (see also authoritative build servers) conversational scope, 132 copying repositories, 68 cross-cutting, 131 CRUD interface, 47 operations, 84 testing, 95–99 authoritative build servers, 218–224 CloudBees, 218–220 configuring, 218–222 Jenkins CI Server, 218 authoritative repositories, 68 authorization, 177 (see also OAuth, authentication) B Basically Available, Soft state, Eventual consis‐ tency (BASE), 101 Bean Validation Specification, 44 Beck, Kent, Berners-Lee, Tim, 149 big data, 103 Big Design Up Front development model, binary data and RDBMS, 102 black-box testing, for JAX-RS, 169–171 blocking, 102 Burke, Bill, 82, 153 business logic, 131–148 implementing, 134–139 testing, 142–148 C D data, 77–79 Java Persistence API, 81 requirement test scenarios, 93–99 technical concerns with, 84 user perspective on, 84 data grids, 103 binary data and, 103 Infinispan, 103 RDBMS vs., 103 data models conceptual, 65 logical, 66–68 data storage, 101–129 data grids, 103 in GeekSeek, 107 graph databases, 105 implementing, 107–129 relational databases and, 102 database management systems (DBMS), 78 role of, 79 davfs2 project, 220 declarative build tool, 16 declarative security, defensive coding, denormalized view, 104 dependency injection, dependency management solutions, 16 dependent services, 131 deploying applications, 224–230 pushing build jobs, 227–230 set up in OpenShift, 224–226 to OpenShift, 224–230 deployments, 229 development, m o c 777 cardinality of relationships, 66 cloning repositories, 69 CloudBees, 218–220 configuring, 218–222 documentation, 220 Git push events and, 223 populating with EAP repository, 220–222 clustering, 103 coding, defensive, column-oriented DBMS, 79 committing repositories, 69 compatibility testing, conceptual data models, 65 conceptual weight, 85 concurrent access, 84 concurrent versions systems (CVS), 19 container independence, 152 container services, containers, containment, Context and Dependency Injection (CDI), 7, 20, 73 k o o b e w w w 234 | Index www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com development process, 39–62 deployment, 55–62, 224–230 designing data storage, 101–129 encoding business logic, 131–148 environment for, 39 integration tests, 48–51 projects, creating, 40–48 running applications locally, 51–53 running integration tests, 53 security, 177–195 directory views, 64 distributed version control systems (DVCSs), 19 document store, 73 Domain Application Protocol (DAP), 155 Drone, 75, 203–209 E Eclipse IDE, 40 EclipseLink, 82 elasticity of data grids, 103 Enterprise Application Archives (EARs), 28, 51 Enterprise Java Beans 3.1, 6E (Rubinger and Burke), 82 Enterprise JavaBeans (EJB), 28, 73, 85 repository, 90–93 entities managed, 82 objects, 86–90 error handling, proactive, reactive, Euler, Leonhard, 106 European Organization for Nuclear Research (CERN), 149 eventual consistency, 101 Eventually Consistent (Vogels), 101 extension repo, 215 Extreme Programming (XP), 4, 13 Extreme Programming Explained: Embrace Change, 2E (Beck), F Facebook, 67, 102, 182 (see also authentication, authorization) Facelet templates, 197 fail-fast policies, fault-tolerance, 84 featuresets, defining, 64 Federation, 179 Fielding, Roy, 150 fire and forget, 136 firefighting, foreign keys, 81 Forge Console view, 41 forking repositories, 68 format independence, 152 Fowler, Martin, 151 functional testing, G GeekSeek Attachment, modeling, 107–111 building, 71 business logic, encoding, 133 data use cases/requirements, 107 entity objects in, 86–90 features, 64 issues to consider, 133 LinkableRepresentation, 164–167 obtaining, 68–71 Relation, implementing, 111–119 repository EJBs, 90–93 requirements for, defining, 63–73 ResourceLink, 167 REST implementation in, 164–167 running, 72 security in, 178 services layer in, 133 SMTP server, testing, 140–142 technical concerns, 84 testing, 71 user interface for, 197 user perspective, 84 geometric complexity, 105 Git, 19 push events and CloudBees, 223 GlassFish Application Server, 154 goals, 16 graph databases, 73 Neo4j, 106 RDBMS vs., 105 Graph Databases (Robinson, Webber, and Ei‐ frem), 106 graph DBMS, 79 graph theory, 105 Graphene, 203–209 gray-box testing (Warp), 172 m o c 777 k o o b e w w w Index www.it-ebooks.info WWW.EBOOK777.COM | 235 Free ebooks ==> www.ebook777.com H HATEOAS, handling with AngularJS, 198 Hibernate, 82 HTTP contracts testing, 174 validating, 171–175 HyperText Markup Language (HTML), 150 HyperText Transfer Protocol (HTTP), 151 I identity managers, 179 IDM, 179 Infinispan, 73, 79, 103 Infinispan Data Grid Platform (Marchioni and Surtani, 104 integration testing, 7, 48–51 invariants, iterative model of software development, J Java API for RESTful Web Services (JAX-RS), 152–157 Java Archives (JARs), 51 Java Connector Architecture (JCA), 138 Java Persistence API, 43, 73, 81 entity objects in, 86–90 implementing, 85–93 POJO entities, 82 repository EJBs, 90–93 testing, 123–127 Java Persistence Query Language (JPQL), 81 Java Transaction API, 85 JavaMail API, 133 JavaScript, testing, 201 JavaServer Faces (JSF), 197 JAX-RS specification, 152–157 black-box testing for, 169–171 HTTP contracts, validating, 171–175 implementing, 157 repository resources, 157–175 representation converter for, 161–163 @Resource model for, 163 JAX-RS Specification API, 153 JBoss Developer Studio (JBDS), 40 deployment, 55–62 OpenShift and, 55–62 236 | JBoss Enterprise Application Platform (JBoss EAP), 211–218 managed container, 215–218 obtaining, 211–213 populating CloudBees with, 220–222 remote container, 213–215 JBoss Forge, 17 projects, creating, 40–48 running applications locally, 51–53 JBossForge, 41 Jenkins CI Server, 218 Jersey reference implementation, 154 JMS Queue, 136 JPA (see Java Persistence API) JTA (see Java Transaction API) JUnit test framework, 10–12 K key DBMS, 79 key/value store, 73 L m o c 777 Lanyrd service, 64 LinkableRepresentation (GeekSeek), 164–167 LinkedIn, 182 (see also authentication, authorization) load testing, locking, 102 logical data models, 66–68 intended use, 67 relationships, 66 loose coupling, k o o b e w w w M managed container configuration, 214 entities, 82 objects, 83 managed mode, 215 Manifesto for Agile Software Development, many-to-many relationships, 66 Marchioni, Francesco, 104 MariaDB, 101 master instances, 103 Maven (see Apache Maven) MavenImporter, 36 Message-Driven Bean (MDB), 138 Index www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com post-conditions, PostgreSQL, 79, 101 precondition checks, primary key, 81 proactive quality policies, projects, creating, 40–48 provided scopes, 32 pull models, 19 push models, 19 pushing repositories, 69 mock objects, 7, 20 Model, View, Controller (MVC) pattern, 198 modulars, 18 MongoDB, 73, 79 multiuser access, 84 MySQL, 79, 101 N Neo4j, 73, 79, 106 nodes, 106 normalized forms, 67 NoSQL systems, 102 Q query caches, 102 query results, joining, 105 QUnit, 201 execution, 201 O OAuth, 192–195 Agorva and, 182 sessions, 184 object relational mapping, 82 objects, managed, 83 one-to-many relationships, 66 one-to-one relationships, 66 OpenJPA, 82 OpenShift application service, 38 default application, removing, 227 deploying applications to, 224–230 deploying to, via JBDS, 55–62 pushing build jobs to, 227–230 set up, 224–226 optional dependencies, 32 Oracle, 101 P R reactive error handling, Red Hat, 211 regression testing, relational database management systems (RDBMS), 79, 101, 104 binary data and, 102 data grids vs., 103 graph theory vs., 105 relationships and, 104 relationships, handling in separate layer, 111–119 testing, 127–129 relational databases, 79 binary data and, 102 relationships, handling in separate layer, 111–119 relational mapping, 82 relational models, 73 relationships between entities, 66 cardinality of, 66 Remote Procedure Call (RPC), 74, 151 replication, 103 repository EJBs, 90–93 repostitory resources, 157–168 representation converters, 161–163 Representational State Transfer (see REST) requirement test scenarios, 93–99 of business logic, 140–148 CRUD functions, 95–99 m o c 777 k o o b e w w w PageFragments, 203 PageObjects, 203 performance testing, persistence, 78 unit, 83 PhantomJS browser, 202 PicketLink, 178–182 project source, 74 Platform as a Service (PaaS), 38 POJO (Plain Old Java Object), entities, 82 programming model, 20 POM files, resolving artifacts with ShrinkWrap, 34 models, 34 Index www.it-ebooks.info WWW.EBOOK777.COM | 237 Free ebooks ==> www.ebook777.com for data storage, 119–129 for JavaScript, 201 for JAX-RS, 168–175 for REST, 168–175 for security, 186–195 of services layer, 140–148 setting up, 93 for user interface, 201–209 @Resource model, 163 ResourceLink (GeekSeek), 167 REST, 149 as addressable service, 149–152 black-box testing for, 169–171 HTTP contracts, validating, 171–175 implementing, 157 in Enterprise Java, 152–157 JAX-RS specification, 152–157 repostitory resources, 157–168 representation converter for, 161–163 testing HTTP contracts, 174 validating services, 170 RESTEasy reference implementation, 154 RESTful Java with JAX-RS (Burke), 153 Richardson, Leonard, 151 role-based security, 177 Rubinger, Andrew Lee, 82 runtime services, 37 S scaling, 103 scopes, 77 security, 177–195 (see also authentication, authorization) Agorava, 182–186 application level, 178–182 implementing, 178–186 in GeekSeek, 178 models, 177 OAuth, testing, 192–195 PicketLink, 178–182 requirement test scenarios for, 186–195 secured options, 188–191 social authentication, 182–186 testing current user, 191 Selenium, 203 sequential model of software development, serial model of software development, server-side rendering, 197 Service Locater Pattern, 132 238 | services layer, 131–148 implementing, 134–139 testing, 142–148 services, application OpenShift, 38 WildFly, 37 Seven Bridges of Königsberg problem, 106 shared state in multiuser environments, 132 ShrinkWrap, 22–27 archive types, 24 asset types, 25 ShrinkWrap Resolvers, 27–37 adding to project, 28 experimental Maven interfaces, 36 Maven coordinates, resolving with, 30–34 Maven plug-in, 36 MavenImporter, 36 POM files, resolving artifacts with, 34 system properties, overriding with, 35 slave instances, 103 smoke testing, SMTP server, testing, 140–142 SMTPMailService, implementing, 134–139 social authentication, 182–186 (see also authentication, authorization) software development process, 2–4 Agile, 4, 13 Extreme Programming (XP), 4, 13 iterative model of, sequential model of, serial model of, software repositories, 28 storing data, 101–129 data grids, 103 graph databases, 105 implementing, 107–129 in GeekSeek, 107 relational databases and, 102 stress testing, Structured Query Language (SQL), 79 SubEtha project, 140 Subversion (SVN), 19 Surtani, Marik, 104 system properties, overriding, 35 m o c 777 k o o b e w w w T tasks, 177 technical concerns, 84 Index www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com test frameworks, 8–13 JUnit, 10–12 TestNG, 12 test harness setup in Warp, 173 test platforms, 20–37 Arquillian, 20 ShrinkWrap, 22–27 test scopes, 32 testable development, 48, 93 testing, 5–8 CRUD functions, 95–99 frameworks for, 8–13 functional behavior of UI, 203–209 HTTP contracts, 174 integration, levels of, relationships, 127–129 requirements, 93–99 security, 186–195 transactional integrity, 123–127 unit, TestNG test framework, 12 tools, 15–38, 20 (see also Arquillian) Apache Maven, 16 bootstrapping, 15–18 for building file systems, 15–18 JBoss Forge, 17 version control, 18 transactions database, 85 integrity testing, 123–127 invoking, 131 managing, transitive relationships, 105 Twitter, 64, 102, 182 (see also authentication, authorization) typesafe injection, 20 U unit testing, University of California at Irvine, 150 unreserved checkouts, 19 upstream repositories, 68 use cases, in Warp, 172 user interface, 197–209 Drone, testing with, 203–209 functional behavior of, 203–209 Graphene, testing with, 203–209 implementing, 198–200 JavaScript and, 201 QUnit, testing with, 201 requirement test scenarios for, 201–209 users perspective of, 84 requirements of, 83 security and, 177 V value DBMS, 79 value equality, 113 version control systems (VCS), 18 Git, 19 Subversion, 19 vertices, 106 Vogels, Werner, 101 m o c 777 k o o b e w w W Warp (Arquillian), 74, 171–175 deploying, 172 frameworks, 173 test harness setup, 173 Waterfall development model, Web Archives (WARs), 51 white-box testing, WildFly application service, 37, 154, 211 world wide web, origins of, 149 w X XACML, 179 XP (see Extreme Programming) Index www.it-ebooks.info WWW.EBOOK777.COM | 239 Free ebooks ==> www.ebook777.com About the Authors As senior software engineer at JBoss, a division of Red Hat, Andrew Lee Rubinger is primarily responsible for development of the company’s EJB 3.x implementation He was an early adopter of Java EE technologies and is an active contributor in the tech community Aslak Knutsen, the project lead of Arquillian, is a senior software engineer at JBoss, by Red Hat He’s involved in projects such as Arquillian, ShrinkWrap, Weld, and Seam and is one of the founders of the JBoss Testing initiative, as well as a speaker at major industry conferences including Devoxx, JavaOne, Jazoon, JFokus, and Geecon Colophon The animal on the cover of Continuous Enterprise Development in Java is a Violet Turaco (Musophaga violacea), also known as a Plantain Eater, a large bird inhabiting West Africa in tropical savannas, wetlands, woodlands, and forests Its plumage is a glossy violet color except for its thick orange bill, yellow forehead, and crimson crown The main flight feathers on the wings are also crimson in color However, despite these bright colors, the birds are often quite indistinguishable in the dense canopy of their forest home m o c 777 Like all turacos, the Violet Turaco is an important disperser of seeds When flying in search of fruit, rounded wings and a long, widespread tail give the turaco great agility when maneuvering through the dense treetops Its flight is characterized by irregular, flapping wing beats interspersed with gliding To cross an open space, they fly single file k o o b e w w w Their diet consists of fruit, and they are quite partial to figs, but they will also eat leaves, buds, flowers, insects, snails, and slugs For savanna species, the widespread destruction of gallery forest and riverine woodlands is a big threat However, because of its wide distribution and great numbers, the Violet Turaco is not in imminent peril For the same reason, it’s not in danger from trapping for the pet trade, though local people hunt them for their ostentatious red feathers The cover image is from Wood’s Animate Creation The cover fonts are URW Typewriter and Guardian Sans The text font is Adobe Minion Pro; the heading font is Adobe Myriad Condensed; and the code font is Dalton Maag’s Ubuntu Mono www.it-ebooks.info WWW.EBOOK777.COM ... www.ebook777.com Continuous Enterprise Development in Java by Andrew Lee Rubinger and Aslak Knutsen Copyright © 2014 Andrew Lee Rubinger and Aslak Knutsen All rights reserved Printed in the United... www.it-ebooks.info WWW.EBOOK777.COM Free ebooks ==> www.ebook777.com Continuous Enterprise Development in Java m o c 777 k o o b e w w w Andrew Lee Rubinger and Aslak Knutsen www.it-ebooks.info WWW.EBOOK777.COM... EAP Remote Container Using the EAP Managed Container Continuous Integration and the Authoritative Build Server Configuring the GeekSeek Build on CloudBees Populating CloudBees Jenkins with the EAP

Ngày đăng: 12/02/2019, 16:01

Mục lục

    Conventions Used in This Book

    How to Contact Us

    The Zen of Prevention

    A Test Platform for Java EE

    On to the Code

    Writing Our First Integration Test with Arquillian

    Running the Application Locally

    Running the Arquillian Integration Test

    Deploying to OpenShift via JBoss Developer Studio

    Chapter 4. Requirements and the Example Application

Tài liệu cùng người dùng

Tài liệu liên quan