Testing Java Microservices: Using Arquillian, Hoverfly, AssertJ, JUnit, Selenium, and Mockito
Summary

Testing Java Microservices teaches you to implement unit and integration tests for microservice systems running on the JVM. You'll work with a microservice environment built using Java EE, WildFly Swarm, and Docker. You'll learn how to increase your test coverage and productivity, and gain confidence that your system will work as you expect.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

Microservice applications present special testing challenges. Even simple services need to handle unpredictable loads, and distributed message-based designs pose unique security and performance concerns. These challenges increase when you throw in asynchronous communication and containers.

About the Book

Testing Java Microservices teaches you to implement unit and integration tests for microservice systems running on the JVM. You'll work with a microservice environment built using Java EE, WildFly Swarm, and Docker. You'll advance from writing simple unit tests for individual services to more-advanced practices like chaos or integration tests. As you move towards a continuous-delivery pipeline, you'll also master live system testing using technologies like the Arquillian, Wiremock, and Mockito frameworks, along with techniques like contract testing and over-the-wire service virtualization. Master these microservice-specific practices and tools and you'll greatly increase your test coverage and productivity, and gain confidence that your system will work as you expect.

What's Inside

  • Test automation
  • Integration testing microservice systems
  • Testing container-centric systems
  • Service virtualization

About the Reader

Written for Java developers familiar with Java EE, EE4J, Spring, or Spring Boot.

About the Authors

Alex Soto Bueno and Jason Porter are Arquillian team members. Andy Gumbrecht is an Apache TomEE developer and PMC. They all have extensive enterprise-testing experience.

Table of Contents

  1. An introduction to microservices
  2. Application under test
  3. Unit-testing microservices
  4. Component-testing microservices
  5. Integration-testing microservices
  6. Contract tests
  7. End-to-end testing
  8. Docker and testing
  9. Service virtualization
  10. Continuous delivery in microservices
1135862438
Testing Java Microservices: Using Arquillian, Hoverfly, AssertJ, JUnit, Selenium, and Mockito
Summary

Testing Java Microservices teaches you to implement unit and integration tests for microservice systems running on the JVM. You'll work with a microservice environment built using Java EE, WildFly Swarm, and Docker. You'll learn how to increase your test coverage and productivity, and gain confidence that your system will work as you expect.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

Microservice applications present special testing challenges. Even simple services need to handle unpredictable loads, and distributed message-based designs pose unique security and performance concerns. These challenges increase when you throw in asynchronous communication and containers.

About the Book

Testing Java Microservices teaches you to implement unit and integration tests for microservice systems running on the JVM. You'll work with a microservice environment built using Java EE, WildFly Swarm, and Docker. You'll advance from writing simple unit tests for individual services to more-advanced practices like chaos or integration tests. As you move towards a continuous-delivery pipeline, you'll also master live system testing using technologies like the Arquillian, Wiremock, and Mockito frameworks, along with techniques like contract testing and over-the-wire service virtualization. Master these microservice-specific practices and tools and you'll greatly increase your test coverage and productivity, and gain confidence that your system will work as you expect.

What's Inside

  • Test automation
  • Integration testing microservice systems
  • Testing container-centric systems
  • Service virtualization

About the Reader

Written for Java developers familiar with Java EE, EE4J, Spring, or Spring Boot.

About the Authors

Alex Soto Bueno and Jason Porter are Arquillian team members. Andy Gumbrecht is an Apache TomEE developer and PMC. They all have extensive enterprise-testing experience.

Table of Contents

  1. An introduction to microservices
  2. Application under test
  3. Unit-testing microservices
  4. Component-testing microservices
  5. Integration-testing microservices
  6. Contract tests
  7. End-to-end testing
  8. Docker and testing
  9. Service virtualization
  10. Continuous delivery in microservices
44.99 In Stock
Testing Java Microservices: Using Arquillian, Hoverfly, AssertJ, JUnit, Selenium, and Mockito

Testing Java Microservices: Using Arquillian, Hoverfly, AssertJ, JUnit, Selenium, and Mockito

Testing Java Microservices: Using Arquillian, Hoverfly, AssertJ, JUnit, Selenium, and Mockito

Testing Java Microservices: Using Arquillian, Hoverfly, AssertJ, JUnit, Selenium, and Mockito

Paperback(1st Edition)

$44.99 
  • SHIP THIS ITEM
    In stock. Ships in 6-10 days.
  • PICK UP IN STORE

    Your local store may have stock of this item.

Related collections and offers


Overview

Summary

Testing Java Microservices teaches you to implement unit and integration tests for microservice systems running on the JVM. You'll work with a microservice environment built using Java EE, WildFly Swarm, and Docker. You'll learn how to increase your test coverage and productivity, and gain confidence that your system will work as you expect.

Purchase of the print book includes a free eBook in PDF, Kindle, and ePub formats from Manning Publications.

About the Technology

Microservice applications present special testing challenges. Even simple services need to handle unpredictable loads, and distributed message-based designs pose unique security and performance concerns. These challenges increase when you throw in asynchronous communication and containers.

About the Book

Testing Java Microservices teaches you to implement unit and integration tests for microservice systems running on the JVM. You'll work with a microservice environment built using Java EE, WildFly Swarm, and Docker. You'll advance from writing simple unit tests for individual services to more-advanced practices like chaos or integration tests. As you move towards a continuous-delivery pipeline, you'll also master live system testing using technologies like the Arquillian, Wiremock, and Mockito frameworks, along with techniques like contract testing and over-the-wire service virtualization. Master these microservice-specific practices and tools and you'll greatly increase your test coverage and productivity, and gain confidence that your system will work as you expect.

What's Inside

  • Test automation
  • Integration testing microservice systems
  • Testing container-centric systems
  • Service virtualization

About the Reader

Written for Java developers familiar with Java EE, EE4J, Spring, or Spring Boot.

About the Authors

Alex Soto Bueno and Jason Porter are Arquillian team members. Andy Gumbrecht is an Apache TomEE developer and PMC. They all have extensive enterprise-testing experience.

Table of Contents

  1. An introduction to microservices
  2. Application under test
  3. Unit-testing microservices
  4. Component-testing microservices
  5. Integration-testing microservices
  6. Contract tests
  7. End-to-end testing
  8. Docker and testing
  9. Service virtualization
  10. Continuous delivery in microservices

Product Details

ISBN-13: 9781617292897
Publisher: Manning
Publication date: 10/26/2018
Edition description: 1st Edition
Pages: 296
Product dimensions: 7.30(w) x 9.10(h) x 0.60(d)

About the Author

Alex Soto Bueno is a software engineer and is passionate about Java development and the open source software model. He leads the NoSQLUnit project and is a team member and evangelist of Arquillian. He has spread the word of testing at several conferences including Devoxx or GeeCon.

Andy Gumbrecht is a Senior Software Engineer and lead developer on several successful local government and commercial industry projects. As a senior Java developer he has never lost his love for coding, open source and best practices within the industry and has an attention to detail, performance and infrastructure.

Jason Porter works at Red Hat and has been involved with Arquillian since the early days. He created the first glassfish adapter and laid groundwork for the website. He also has used it extensively while testing Seam 3 and Apache DeltaSpike.

Table of Contents

Preface xi

Acknowledgments xiii

About this book xv

About the authors xviii

About the cover xx

1 An introduction to microservices 1

1.1 What are microservices, and why use them? 3

Why use microservices? 3

What are microservices? 4

Continuous integration, deployment, and Docker 6

1.2 Microservice networks and features 6

Microservice networks 6

Microservice features 7

1.3 Microservice architecture 8

Resource component 9

Business-domain component 9

Remote resources component 9

Persistence component 10

1.4 Microservice unit testing 10

Solitary unit tests 11

Sociable unit tests 11

2 Application under test 13

2.1 Getting started 14

2.2 Prerequisites 15

Java Development Kit 15

Build tools 15

Environment variables 16

Integrated development environment (IDE) 16

2.3 Architecture 17

The game service 18

The comments service 21

The video service 23

The aggregator service 25

Overall architecture 26

2.4 Application design patterns 27

Anatomy 27

ECB pattern 36

Miscellaneous patterns 38

2.5 Design decisions 40

3 Unit-testing microservices 41

3.1 Unit testing techniques 41

Sociable unit tests 42

Test doubles 43

Solitary unit tests 45

Unit testing in microservices 46

3.2 Tools 47

JUnit 48

AssertJ 48

Mockito 49

Build-script modifications 50

3.3 Writing unit tests for the Garner app 51

YouTubeVideoLinkCreator test 51

YouTubeLink test 52

Games test 54

GamesService test 56

GamesResource test 58

4 Component-testing microseruices 64

4.1 The Arquillian test framework 65

4.2 Introducing the @RunWith(Arquillian.class) annotation 68

4.3 The ShrinkWrap utility class 70

Building an archive with ShrinkWrap 71

Adding content to the ShrinkWrap archive 71

Adding resources 73

Adding libraries and dependencies 74

Adding complex dependencies with the Maven resolver 75

Adding a service implementation 76

4.4 Write once and reuse your code 77

4.5 Build-script modifications 78

Defining Maven dependencies 79

Defining Gradle dependencies 80

4.6 Overriding the default Arquillian configuration 81

The container definition 82

Specifying container properties 83

4.7 Using Arquillian REST extensions 83

The Arquillian REST client extension 84

The Warp REST extension 85

4.8 Testing Spring applications using Arquillian 87

The Arquillian Spring Framework extension 87

Testing Spring Boot applications 89

4.9 More-complex Arquillian test examples 91

Testing the remote component 91

Testing the resource component 94

Testing the domain component 96

Testing the persistence component 96

5 Integration-testing microservices 100

5.1 Integration testing in the microservices architecture 101

Gateway component layer 102

Data mappers and repositories 103

5.2 Persistence testing with the Arquillian Persistence Extension 103

Declarative approach 106

Programmatic approach 108

Persistence testing with NoSQLUnit 112

Persistence testing with Arquillian multideployment 116

Persistence testing with Arquillian sequence 117

Build-script modifications 117

5.3 Writing integration tests for the Gamer application 118

Testing the Comments class 119

Testing the CommentsGateway class 122

6 Contract tests 128

6.1 Understanding contracts 128

Contracts and monolithic applications 129

Contracts and microservice applications 130

Verifying with integration tests 135

What are contract tests? 135

Who owns the contracts? 136

6.2 Tools 138

Pact 139

Pact in JVM languages 140

Integrating Pact JVM into the Arquillian ecosystem with Algeron 149

6.3 Build-script modifications 155

Using Pact JVM for contract testing 156

Using Arquillian Algeron for contract testing 156

6.4 Writing consumer-driven contracts for the Gamer application 157

Consumer side of the comments service 157

Provider side of the comments service 160

6.5 Contract type summary 163

7 End-to-end testing 164

7.1 End-to-end tests in the overall testing picture 165

7.2 End-to-end testing techniques 165

Vertical tests 166

Horizontal tests 166

7.3 Introduction to end-to-end testing tools 167

Arquillian Cube 167

Arquillian Drone 167

Arquillian Graphene 2 168

JMeter 168

Cukes in Space 168

7.4 Example end-to-end test 168

Building the microservices 169

Adding the build dependencies and configuration 169

Adding @Deployment and @TargetsContainer to the test 176

Cross-origin resource sharing 177

Coping with a mixed environment using @ClassRule 178

Operating on the deployments with @OperateOnDeployment 183

Introducing @Drone, page objects, @Location, and the WebDriver 184

Working with page objects in a test 186

Running the test 187

8 Docker and testing 190

8.1 Tools in the Docker ecosystem 191

Docker 191

Docker Machine 193

Docker Compose 194

8.2 Arquillian Cube 196

Setting up Arquillian Cube 197

Writing container tests 199

Writing integration tests 201

Writing end-to-end tests 205

8.3 Rest API 208

8.4 Arquillian Drone and Graphene 209

Integrating Arquillian Cube and Arquillian Drone 209

Integrating Arquillian Cube and Arquillian Graphene 212

8.5 Parallelizing tests 214

8.6 Arquillian Cube and Algeron 215

8.7 Using the container-objects pattern 216

Using a flexible container-object DSL 221

8.8 Deployment tests and Kubernetes 223

8.9 Build-script modifications 228

Arquillian Cube Docker 228

Arquillian Cube Docker JUnit rule 229

Arquillian Cube Kubernetes 229

Arquillian Cube OpenShift 229

8.10 Testing the Dockerfile for the video service 230

9 Service virtualization 233

9.1 What is service virtualization? 234

Why use service virtualization? 234

When to use service virtualization 235

9.2 Mimicking service responses with Hoverfly 236

Hoverfly modes 236

JUnit Hoverfly 238

Configuring Hoverfly 239

9.3 Build-script modifications 240

9.4 Using service virtualization for the Gamer application 240

10 Continuous delivery in microservices 244

10.1 What is continuous delivery? 245

10.2 Continuous delivery and the microservices architecture 246

10.3 Orchestrating continuous delivery 248

Working with Jenkins 249

The Jenkins pipeline 249

Deploying with certainty 252

10.4 Jenkins 254

Defining a pipeline 257

Example of a Jenkins pipeline 259

Appendix Masking multiple containers with Arquillian Chameleon 263

Index 265

From the B&N Reads Blog

Customer Reviews