SlideShare a Scribd company logo
Test Driven Development with
   Java EE 7, Arquillian and
    Enterprise Containers	





            Peter Pilgrim	

    Java Champion, Software Developer	

          Independent Contractor	

           @peter_pilgrim
Biography

 ■  Completed Java Sybase course in 1998	

 ■  Working as an Independent
    Contractor 	

 ■  Founded JAVAWUG 2004-2010	

 ■  Blue-chip business and Banking: IT,
    Deutsche, Credit Suisse, UBS, Lloyds
    Banking	




                                              3
The Java EE 7 Developer User Guide
           Written by Peter Pilgrim	

            Late Summer 2013
Agile Software Development?
Why do we test?
Architectural Competencies

    Performance and Efficiency	



    Stability and Robustness	



    Maintainability and Refactor-ability
Tools of the Trade
 § Frameworks: JUnit, TestNG and XUnit; JBehave, Spock, ScalaTest 	

 § Integrated Development Environment and Selenium
How do we test?
The Test Driven Cycle
                                              Write A
                                             Failing Test	


           Ensure All                                                          Make The
           Tests Pass	

                                                       Test Pass	




                     Refactor the                              Refactor the
                      Main Code	

                                 Test	



"Oh, East is East, and West is West, and never the twain shall meet.”, Rudyard Kipling, 1892
Essentials of Block Testing



    Assign	

      Act	

     Assert
Traditional Java Enterprise Testing

     Outside of the Container	


      Mock and Stub objects	


     Writing Tests around Deployment
Java EE 7
Java EE 7 Framework Updates
 Interface Boundary        Management and    Web and HTML
      Endpoints     	

	

    Storage	

    Service Endpoints	

      JAX RS 2.0	

          EJB 3.2	

         Servlet 3.1	

                                              WebSocket 1.0	

        JMS 2.0	

           CDI 1.1	

                                                  JSF 2.2	

  Bean Validation 1.1	

     JPA 2.1	

          JSON 1.0
Time to Change JavaEE Testing
Open Source Integration Testing
 Peter Muir, David Blewin and Aslak Knutsen and from Red Hat JBoss.
Arquillian Test Framework


    Portable In-Container Integration Testing	



    Deployment of Unit Test and Dependencies together	



    Extension of Existing Test Framework Support
Shrink Wrap

   An Aid to Better Test Enterprise Components	



   “What if we could declare, in Java, an object to
   represent that archive?”	



   Builder pattern for Virtual JAR file
Context & Dependency Injection 1.1

    Inject Beans in strongly typed manner	



    Contextual Scopes, Qualifiers and Providers	



    Life-cycle, Event Management and Event Listeners
Gradle Dependencies I
  dependencies {
	

     compile     'org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec:
        1.0.0.Alpha1'
	

        compile     'org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:1.0.0.Alpha2'
	

        compile     'javax.enterprise:cdi-api:1.1-PFD’
	

        compile     'javax.validation:validation-api:1.1.0.CR3'
	

        compile     'org.hibernate:hibernate-validator:5.0.0.CR4'
	

        compile     'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Draft-14'
	

        runtime     'org.glassfish.main.extras:glassfish-embedded-all:4.0-b81’
	

        testCompile 'org.jboss.arquillian.junit:arquillian-junit-container:1.0.3.Final'
	

        testCompile 'org.jboss.arquillian.container:arquillian-glassfish-
	

     embedded-3.1:1.0.0.Final-SNAPSHOT'
	

     testCompile 'junit:junit:4.11'
	

 }
Gradle Dependencies II
  dependencies {
	

     //...
	

     compile     'javax:javaee-api:7.0-b81'
	

     runtime     'javax:javaee-api:7.0-b81'
	

     //...
	

     testCompile 'junit:junit:4.11'
	

 }
Arquillian Test Structure I
 @RunWith(Arquillian.class)
	

 public class BasicUserDetailRepositoryTest {
	

     @Deployment
	

     public static JavaArchive createDeployment() {
	

         JavaArchive jar = ShrinkWrap.create(JavaArchive.class)
	

                 .addClasses(BasicUserDetailRepository.class,

	

                         UserDetailRepository.class, User.class)

	

                 .addAsManifestResource(

	

                         EmptyAsset.INSTANCE, "beans.xml");
            return jar;
	

        }
	

        /* ... */
	

	

 }
Arquillian Test Structure II
 @RunWith(Arquillian.class)
	

 public class BasicUserDetailRepositoryTest {     /* ... */
	

     @Inject
	

     private UserDetailRepository userDetailRepo;
	

	

     @Test
	

     public void shouldCreateUserInRepo() {
	

         User user = new User("frostj", "Jack", "Frost");
	

         assertFalse( userDetailRepo.containsUser(user ));
	

         userDetailRepo.createUser(user);
	

         assertTrue( userDetailRepo.containsUser(user ));
	

     }
	

 }
Demo: Arquillian


Context Dependency & Injection
Enterprise Java Beans 3.2
    Session Beans as Java Co-Located or Remote
    Service Endpoints	


    Transaction Support	


    Lifecycle Event Management, Interception and
    Containment	


    Endpoints Extended to Web Services, JAX-RS and/
    or WebSockets
Demo: Arquillian


Enterprise Java Beans
HTML5 Java WebSocket 1.0
   WebSocket connections are peer full-duplex
   HTTP interactions over a session	


   Reduced payload and lower latency	


   Designed for asynchronous operations,
   performance and Efficiency
Demo: Arquillian


Java WebSocket API 1.0
Embeddable Containers

   So-called “Container-less” Web Application	




   Deliver an Container Embedded in Application	



   You Have Control: Size, Framework and
   Libraries
GlassFish Embedded Initialization
  public class AbstractEmbeddedRunner {
	

      private int port;
	

      private GlassFish glassfish;
	

	

      public AbstractEmbeddedRunner init() throws Exception{
	

         BootstrapProperties bootstrapProperties = new BootstrapProperties();

	

          GlassFishRuntime glassfishRuntime =

	

              GlassFishRuntime.bootstrap(bootstrapProperties);

	

          GlassFishProperties glassfishProperties = new GlassFishProperties();
             glassfishProperties.setPort("http-listener", port);
	

	

 //         glassfishProperties.setPort("https-listener", port+1);
             glassfish = glassfishRuntime.newGlassFish(glassfishProperties);
	

             return this; } /* ... */
	

  }
GlassFish Embedded Start and Stop
  public class AbstractEmbeddedRunner {
	

     /* ... */
	

     public AbstractEmbeddedRunner start() throws Exception{
	

          glassfish.start();
	

          return this;
	

      }

	

	

      public AbstractEmbeddedRunner stop() throws Exception{

	

          glassfish.stop();
             return this;
	

         } /* ... */
	

	

 }
GlassFish Embedded Deploy WAR
  public class AbstractEmbeddedRunner {
	

     /* ... */
	

     public AbstractEmbeddedRunner deploy( String args[]) throws Exception{
	

          Deployer deployer = glassfish.getDeployer();
	

          for (String s: args) {
	

                 String application = deployer.deploy(new File(s));

	

                 System.out.printf("deploying "+application);

	

          }

	

          return this;
         }
	

         /* ... */
	

	

 }
Demo: GlassFish Embedded


GlassFish 4.0 Embedded Server
Heavyweight vs. Lightweight



   How on earth do you weigh 	

  a Java container of any type?
Developer Summary
What You Will Do Tomorrow?

                       Why
                       Mock?	



        Test
    Philosophy	

   CHANGE!	

       Arquillian	




                     Embedded
                     Containers
Resources
 § Arquillian Integration Server http://arquillian.org/	

 § Java EE 7 Specification http://jcp.org/en/jsr/detail?id=342	

 § Java Web Socket API 1.0 http://java.net/projects/websocket-spec/downloads 	

 § GlassFish 4.0 Promoted Builds https://blogs.oracle.com/theaquarium/entry/
    downloading_latest_glassfish_4_promoted	

 § WebSocket Client http://www.websocket.org/echo.html	

 § GlassFish Embedded Instructions http://embedded-glassfish.java.net/	

 § Thanks!
Creative Commons Attributions
 §  Brett Lider, Folded Ruler, http://www.flickr.com/photos/brettlider/1575417754/sizes/o/in/
   photostream/ 	

 §  Daquella manera, Crutches donation to Haitian brothers and sisters, http://www.flickr.com/
   photos/daquellamanera/4390506017/sizes/l/in/photostream/ 	

 §  Marcus Tschiae, Electric Power Framework perspective http://www.flickr.com/photos/tschiae/
   8417927326/sizes/h/	

 §  Falk Neumman, September 5, 2005, You’ve Got A Fast Car, http://www.flickr.com/photos/
   coreforce/5910961411/ 	

 §  Stuart Webster, London skies from Waterloo Bridge, http://www.flickr.com/photos/
   stuartwebster/4192629903/sizes/o/
Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded Containers

More Related Content

What's hot

Take Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersTake Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersNaresha K
 
How to Test Enterprise Java Applications
How to Test Enterprise Java ApplicationsHow to Test Enterprise Java Applications
How to Test Enterprise Java ApplicationsAlex Soto
 
Automated Abstraction of Flow of Control in a System of Distributed Software...
Automated Abstraction of Flow of Control in a System of Distributed  Software...Automated Abstraction of Flow of Control in a System of Distributed  Software...
Automated Abstraction of Flow of Control in a System of Distributed Software...nimak
 
Head toward Java 14 and Java 15 #LINE_DM
Head toward Java 14 and Java 15 #LINE_DMHead toward Java 14 and Java 15 #LINE_DM
Head toward Java 14 and Java 15 #LINE_DMYuji Kubota
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpikeos890
 
OpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConOpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConos890
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 UpdateRyan Cuprak
 
Migrate Early, Migrate Often: JDK release cadence strategies
Migrate Early, Migrate Often: JDK release cadence strategiesMigrate Early, Migrate Often: JDK release cadence strategies
Migrate Early, Migrate Often: JDK release cadence strategiesDanHeidinga
 
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?Julian Robichaux
 
Arquillian in a nutshell
Arquillian in a nutshellArquillian in a nutshell
Arquillian in a nutshellBrockhaus Group
 
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010JUG Lausanne
 
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Robert Scholte
 
Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)Robert Scholte
 
50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutesArun Gupta
 
Getting Started with Java EE 7
Getting Started with Java EE 7Getting Started with Java EE 7
Getting Started with Java EE 7Arun Gupta
 
Migrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDI
Migrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDIMigrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDI
Migrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDIMario-Leander Reimer
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenMert Çalışkan
 

What's hot (20)

Take Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainersTake Control of your Integration Testing with TestContainers
Take Control of your Integration Testing with TestContainers
 
How to Test Enterprise Java Applications
How to Test Enterprise Java ApplicationsHow to Test Enterprise Java Applications
How to Test Enterprise Java Applications
 
Automated Abstraction of Flow of Control in a System of Distributed Software...
Automated Abstraction of Flow of Control in a System of Distributed  Software...Automated Abstraction of Flow of Control in a System of Distributed  Software...
Automated Abstraction of Flow of Control in a System of Distributed Software...
 
Head toward Java 14 and Java 15 #LINE_DM
Head toward Java 14 and Java 15 #LINE_DMHead toward Java 14 and Java 15 #LINE_DM
Head toward Java 14 and Java 15 #LINE_DM
 
Apache DeltaSpike
Apache DeltaSpikeApache DeltaSpike
Apache DeltaSpike
 
OpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheConOpenWebBeans and DeltaSpike at ApacheCon
OpenWebBeans and DeltaSpike at ApacheCon
 
Java EE 8 Update
Java EE 8 UpdateJava EE 8 Update
Java EE 8 Update
 
Migrate Early, Migrate Often: JDK release cadence strategies
Migrate Early, Migrate Often: JDK release cadence strategiesMigrate Early, Migrate Often: JDK release cadence strategies
Migrate Early, Migrate Often: JDK release cadence strategies
 
Java EE 8
Java EE 8Java EE 8
Java EE 8
 
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
Connect2017 DEV-1550 Why Java 8? Or, What's a Lambda?
 
JBoss AS7 OSDC 2011
JBoss AS7 OSDC 2011JBoss AS7 OSDC 2011
JBoss AS7 OSDC 2011
 
Arquillian in a nutshell
Arquillian in a nutshellArquillian in a nutshell
Arquillian in a nutshell
 
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
Java EE 6 & GlassFish V3 - Alexis Moussine-Pouchkine - May 2010
 
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
Java 9 and the impact on Maven Projects (ApacheCon Europe 2016)
 
Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)Java9 and the impact on Maven Projects (JFall 2016)
Java9 and the impact on Maven Projects (JFall 2016)
 
50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes50 New Features of Java EE 7 in 50 minutes
50 New Features of Java EE 7 in 50 minutes
 
Getting Started with Java EE 7
Getting Started with Java EE 7Getting Started with Java EE 7
Getting Started with Java EE 7
 
Migrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDI
Migrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDIMigrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDI
Migrating a JSF-Based Web Application from Spring 3 to Java EE 7 and CDI
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
Gradle como alternativa a maven
Gradle como alternativa a mavenGradle como alternativa a maven
Gradle como alternativa a maven
 

Similar to Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded Containers

Testing the Enterprise Layers - the A, B, C's of Integration Testing - Aslak ...
Testing the Enterprise Layers - the A, B, C's of Integration Testing - Aslak ...Testing the Enterprise Layers - the A, B, C's of Integration Testing - Aslak ...
Testing the Enterprise Layers - the A, B, C's of Integration Testing - Aslak ...JAXLondon2014
 
Testing the Enterprise layers, with Arquillian
Testing the Enterprise layers, with ArquillianTesting the Enterprise layers, with Arquillian
Testing the Enterprise layers, with ArquillianVirtual JBoss User Group
 
GlassFish OSGi Server
GlassFish OSGi ServerGlassFish OSGi Server
GlassFish OSGi ServerArtur Alves
 
Glass Fish Slides Fy2009 2
Glass Fish Slides Fy2009 2Glass Fish Slides Fy2009 2
Glass Fish Slides Fy2009 2Abhishek Gupta
 
Easy Java Integration Testing with Testcontainers​
Easy Java Integration Testing with Testcontainers​Easy Java Integration Testing with Testcontainers​
Easy Java Integration Testing with Testcontainers​Payara
 
Glass Fish Slides Fy2009 2
Glass Fish Slides Fy2009 2Glass Fish Slides Fy2009 2
Glass Fish Slides Fy2009 2Abhishek Gupta
 
Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)Ryan Cuprak
 
Java 6 [Mustang] - Features and Enchantments
Java 6 [Mustang] - Features and Enchantments Java 6 [Mustang] - Features and Enchantments
Java 6 [Mustang] - Features and Enchantments Pavel Kaminsky
 
Deploying Java EE 6 Apps in a Cluster: GlassFish 3.1 at Dallas Tech Fest 2011
Deploying Java EE 6 Apps in a Cluster: GlassFish 3.1 at Dallas Tech Fest 2011Deploying Java EE 6 Apps in a Cluster: GlassFish 3.1 at Dallas Tech Fest 2011
Deploying Java EE 6 Apps in a Cluster: GlassFish 3.1 at Dallas Tech Fest 2011Arun Gupta
 
JUDCON India 2014 Java EE 7 talk
JUDCON India 2014 Java EE 7 talkJUDCON India 2014 Java EE 7 talk
JUDCON India 2014 Java EE 7 talkVijay Nair
 
Level Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersLevel Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersVMware Tanzu
 
Haj 4328-java ee 7 overview
Haj 4328-java ee 7 overviewHaj 4328-java ee 7 overview
Haj 4328-java ee 7 overviewKevin Sutter
 
Developer Productivity with Forge, Java EE 6 and Arquillian
Developer Productivity with Forge, Java EE 6 and ArquillianDeveloper Productivity with Forge, Java EE 6 and Arquillian
Developer Productivity with Forge, Java EE 6 and ArquillianRay Ploski
 
Testing Java EE apps with Arquillian
Testing Java EE apps with ArquillianTesting Java EE apps with Arquillian
Testing Java EE apps with ArquillianIvan Ivanov
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Arun Gupta
 
Andrei Niculae - glassfish - 24mai2011
Andrei Niculae - glassfish - 24mai2011Andrei Niculae - glassfish - 24mai2011
Andrei Niculae - glassfish - 24mai2011Agora Group
 

Similar to Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded Containers (20)

EmbbededGF@JavaOneHyd
EmbbededGF@JavaOneHydEmbbededGF@JavaOneHyd
EmbbededGF@JavaOneHyd
 
Testing the Enterprise Layers - the A, B, C's of Integration Testing - Aslak ...
Testing the Enterprise Layers - the A, B, C's of Integration Testing - Aslak ...Testing the Enterprise Layers - the A, B, C's of Integration Testing - Aslak ...
Testing the Enterprise Layers - the A, B, C's of Integration Testing - Aslak ...
 
Testing the Enterprise layers, with Arquillian
Testing the Enterprise layers, with ArquillianTesting the Enterprise layers, with Arquillian
Testing the Enterprise layers, with Arquillian
 
GlassFish OSGi Server
GlassFish OSGi ServerGlassFish OSGi Server
GlassFish OSGi Server
 
Glass Fish Slides Fy2009 2
Glass Fish Slides Fy2009 2Glass Fish Slides Fy2009 2
Glass Fish Slides Fy2009 2
 
Easy Java Integration Testing with Testcontainers​
Easy Java Integration Testing with Testcontainers​Easy Java Integration Testing with Testcontainers​
Easy Java Integration Testing with Testcontainers​
 
GlassFish and JavaEE, Today and Future
GlassFish and JavaEE, Today and FutureGlassFish and JavaEE, Today and Future
GlassFish and JavaEE, Today and Future
 
Glass Fish Slides Fy2009 2
Glass Fish Slides Fy2009 2Glass Fish Slides Fy2009 2
Glass Fish Slides Fy2009 2
 
Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)Jakarta EE Test Strategies (2022)
Jakarta EE Test Strategies (2022)
 
Java 6 [Mustang] - Features and Enchantments
Java 6 [Mustang] - Features and Enchantments Java 6 [Mustang] - Features and Enchantments
Java 6 [Mustang] - Features and Enchantments
 
Deploying Java EE 6 Apps in a Cluster: GlassFish 3.1 at Dallas Tech Fest 2011
Deploying Java EE 6 Apps in a Cluster: GlassFish 3.1 at Dallas Tech Fest 2011Deploying Java EE 6 Apps in a Cluster: GlassFish 3.1 at Dallas Tech Fest 2011
Deploying Java EE 6 Apps in a Cluster: GlassFish 3.1 at Dallas Tech Fest 2011
 
Javaee6 Overview
Javaee6 OverviewJavaee6 Overview
Javaee6 Overview
 
JUDCON India 2014 Java EE 7 talk
JUDCON India 2014 Java EE 7 talkJUDCON India 2014 Java EE 7 talk
JUDCON India 2014 Java EE 7 talk
 
Level Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With TestcontainersLevel Up Your Integration Testing With Testcontainers
Level Up Your Integration Testing With Testcontainers
 
Haj 4328-java ee 7 overview
Haj 4328-java ee 7 overviewHaj 4328-java ee 7 overview
Haj 4328-java ee 7 overview
 
Developer Productivity with Forge, Java EE 6 and Arquillian
Developer Productivity with Forge, Java EE 6 and ArquillianDeveloper Productivity with Forge, Java EE 6 and Arquillian
Developer Productivity with Forge, Java EE 6 and Arquillian
 
Testing Java EE apps with Arquillian
Testing Java EE apps with ArquillianTesting Java EE apps with Arquillian
Testing Java EE apps with Arquillian
 
Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011Java EE 6 workshop at Dallas Tech Fest 2011
Java EE 6 workshop at Dallas Tech Fest 2011
 
Arquillian
ArquillianArquillian
Arquillian
 
Andrei Niculae - glassfish - 24mai2011
Andrei Niculae - glassfish - 24mai2011Andrei Niculae - glassfish - 24mai2011
Andrei Niculae - glassfish - 24mai2011
 

More from Peter Pilgrim

Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?Peter Pilgrim
 
Cloud native java are we there yet go tech world 2019
Cloud native java   are we there yet  go tech world 2019Cloud native java   are we there yet  go tech world 2019
Cloud native java are we there yet go tech world 2019Peter Pilgrim
 
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!Peter Pilgrim
 
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017Peter Pilgrim
 
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...Peter Pilgrim
 
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVMQCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVMPeter Pilgrim
 
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and NoteworthyJava EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and NoteworthyPeter Pilgrim
 
BOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala appsBOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala appsPeter Pilgrim
 
AOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java PlatformAOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java PlatformPeter Pilgrim
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesPeter Pilgrim
 
JavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java PlatformJavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java PlatformPeter Pilgrim
 
ACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the EnterpiseACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the EnterpisePeter Pilgrim
 
JavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom ComponentsJavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom ComponentsPeter Pilgrim
 
ACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming LanguageACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming LanguagePeter Pilgrim
 

More from Peter Pilgrim (14)

Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?Devoxx 2019 - Why we pair?
Devoxx 2019 - Why we pair?
 
Cloud native java are we there yet go tech world 2019
Cloud native java   are we there yet  go tech world 2019Cloud native java   are we there yet  go tech world 2019
Cloud native java are we there yet go tech world 2019
 
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
LJC 2018 - PEAT UK - Java EE - Ah, ah, ah! Staying Alive!
 
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
CON6148 - You Are Not Cut Out To Be A Java Contractor - JavaOne 2017
 
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...
JavaOne 2015 CON5211 Digital Java EE 7 with JSF Conversations, Flows, and CDI...
 
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVMQCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
QCon 2015 Scala for the Enterprise: Get FuNkEd Up on the JVM
 
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and NoteworthyJava EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
Java EE & Glass Fish User Group: Digital JavaEE 7 - New and Noteworthy
 
BOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala appsBOF2644 Developing Java EE 7 Scala apps
BOF2644 Developing Java EE 7 Scala apps
 
AOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java PlatformAOTB2014: Agile Testing on the Java Platform
AOTB2014: Agile Testing on the Java Platform
 
JavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development ExperiencesJavaCro 2014 Scala and Java EE 7 Development Experiences
JavaCro 2014 Scala and Java EE 7 Development Experiences
 
JavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java PlatformJavaCro 2014 Digital Development with Java EE and Java Platform
JavaCro 2014 Digital Development with Java EE and Java Platform
 
ACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the EnterpiseACCU 2013 Taking Scala into the Enterpise
ACCU 2013 Taking Scala into the Enterpise
 
JavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom ComponentsJavaOne 2011 Progressive JavaFX 2.0 Custom Components
JavaOne 2011 Progressive JavaFX 2.0 Custom Components
 
ACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming LanguageACCU 2011 Introduction to Scala: An Object Functional Programming Language
ACCU 2011 Introduction to Scala: An Object Functional Programming Language
 

Recently uploaded

Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...Sri Ambati
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...Product School
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaCzechDreamin
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...CzechDreamin
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3DianaGray10
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsExpeed Software
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxDavid Michel
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekCzechDreamin
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...Product School
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutesconfluent
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor TurskyiFwdays
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Product School
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1DianaGray10
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyJohn Staveley
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonDianaGray10
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Julian Hyde
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupCatarinaPereira64715
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomCzechDreamin
 

Recently uploaded (20)

Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Powerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara LaskowskaPowerful Start- the Key to Project Success, Barbara Laskowska
Powerful Start- the Key to Project Success, Barbara Laskowska
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
Behind the Scenes From the Manager's Chair: Decoding the Secrets of Successfu...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
In-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT ProfessionalsIn-Depth Performance Testing Guide for IT Professionals
In-Depth Performance Testing Guide for IT Professionals
 
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptxUnpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
Unpacking Value Delivery - Agile Oxford Meetup - May 2024.pptx
 
AI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří KarpíšekAI revolution and Salesforce, Jiří Karpíšek
AI revolution and Salesforce, Jiří Karpíšek
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Speed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in MinutesSpeed Wins: From Kafka to APIs in Minutes
Speed Wins: From Kafka to APIs in Minutes
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1UiPath Test Automation using UiPath Test Suite series, part 1
UiPath Test Automation using UiPath Test Suite series, part 1
 
Demystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John StaveleyDemystifying gRPC in .Net by John Staveley
Demystifying gRPC in .Net by John Staveley
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
Measures in SQL (a talk at SF Distributed Systems meetup, 2024-05-22)
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone KomSalesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
Salesforce Adoption – Metrics, Methods, and Motivation, Antone Kom
 

Devoxx UK 2013 Test-Driven Development with JavaEE 7, Arquillian and Embedded Containers

  • 1.
  • 2. Test Driven Development with Java EE 7, Arquillian and Enterprise Containers Peter Pilgrim Java Champion, Software Developer Independent Contractor @peter_pilgrim
  • 3. Biography ■  Completed Java Sybase course in 1998 ■  Working as an Independent Contractor ■  Founded JAVAWUG 2004-2010 ■  Blue-chip business and Banking: IT, Deutsche, Credit Suisse, UBS, Lloyds Banking 3
  • 4. The Java EE 7 Developer User Guide Written by Peter Pilgrim Late Summer 2013
  • 6. Why do we test?
  • 7. Architectural Competencies Performance and Efficiency Stability and Robustness Maintainability and Refactor-ability
  • 8. Tools of the Trade § Frameworks: JUnit, TestNG and XUnit; JBehave, Spock, ScalaTest § Integrated Development Environment and Selenium
  • 9. How do we test?
  • 10. The Test Driven Cycle Write A Failing Test Ensure All Make The Tests Pass Test Pass Refactor the Refactor the Main Code Test "Oh, East is East, and West is West, and never the twain shall meet.”, Rudyard Kipling, 1892
  • 11. Essentials of Block Testing Assign Act Assert
  • 12. Traditional Java Enterprise Testing Outside of the Container Mock and Stub objects Writing Tests around Deployment
  • 14. Java EE 7 Framework Updates Interface Boundary Management and Web and HTML Endpoints Storage Service Endpoints JAX RS 2.0 EJB 3.2 Servlet 3.1 WebSocket 1.0 JMS 2.0 CDI 1.1 JSF 2.2 Bean Validation 1.1 JPA 2.1 JSON 1.0
  • 15. Time to Change JavaEE Testing
  • 16. Open Source Integration Testing Peter Muir, David Blewin and Aslak Knutsen and from Red Hat JBoss.
  • 17. Arquillian Test Framework Portable In-Container Integration Testing Deployment of Unit Test and Dependencies together Extension of Existing Test Framework Support
  • 18. Shrink Wrap An Aid to Better Test Enterprise Components “What if we could declare, in Java, an object to represent that archive?” Builder pattern for Virtual JAR file
  • 19. Context & Dependency Injection 1.1 Inject Beans in strongly typed manner Contextual Scopes, Qualifiers and Providers Life-cycle, Event Management and Event Listeners
  • 20. Gradle Dependencies I dependencies { compile 'org.jboss.spec.javax.annotation:jboss-annotations-api_1.2_spec: 1.0.0.Alpha1' compile 'org.jboss.spec.javax.ejb:jboss-ejb-api_3.2_spec:1.0.0.Alpha2' compile 'javax.enterprise:cdi-api:1.1-PFD’ compile 'javax.validation:validation-api:1.1.0.CR3' compile 'org.hibernate:hibernate-validator:5.0.0.CR4' compile 'org.hibernate.javax.persistence:hibernate-jpa-2.1-api:1.0.0.Draft-14' runtime 'org.glassfish.main.extras:glassfish-embedded-all:4.0-b81’ testCompile 'org.jboss.arquillian.junit:arquillian-junit-container:1.0.3.Final' testCompile 'org.jboss.arquillian.container:arquillian-glassfish- embedded-3.1:1.0.0.Final-SNAPSHOT' testCompile 'junit:junit:4.11' }
  • 21. Gradle Dependencies II dependencies { //... compile 'javax:javaee-api:7.0-b81' runtime 'javax:javaee-api:7.0-b81' //... testCompile 'junit:junit:4.11' }
  • 22. Arquillian Test Structure I @RunWith(Arquillian.class) public class BasicUserDetailRepositoryTest { @Deployment public static JavaArchive createDeployment() { JavaArchive jar = ShrinkWrap.create(JavaArchive.class) .addClasses(BasicUserDetailRepository.class, UserDetailRepository.class, User.class) .addAsManifestResource( EmptyAsset.INSTANCE, "beans.xml"); return jar; } /* ... */ }
  • 23. Arquillian Test Structure II @RunWith(Arquillian.class) public class BasicUserDetailRepositoryTest { /* ... */ @Inject private UserDetailRepository userDetailRepo; @Test public void shouldCreateUserInRepo() { User user = new User("frostj", "Jack", "Frost"); assertFalse( userDetailRepo.containsUser(user )); userDetailRepo.createUser(user); assertTrue( userDetailRepo.containsUser(user )); } }
  • 25. Enterprise Java Beans 3.2 Session Beans as Java Co-Located or Remote Service Endpoints Transaction Support Lifecycle Event Management, Interception and Containment Endpoints Extended to Web Services, JAX-RS and/ or WebSockets
  • 27. HTML5 Java WebSocket 1.0 WebSocket connections are peer full-duplex HTTP interactions over a session Reduced payload and lower latency Designed for asynchronous operations, performance and Efficiency
  • 29. Embeddable Containers So-called “Container-less” Web Application Deliver an Container Embedded in Application You Have Control: Size, Framework and Libraries
  • 30. GlassFish Embedded Initialization public class AbstractEmbeddedRunner { private int port; private GlassFish glassfish; public AbstractEmbeddedRunner init() throws Exception{ BootstrapProperties bootstrapProperties = new BootstrapProperties(); GlassFishRuntime glassfishRuntime = GlassFishRuntime.bootstrap(bootstrapProperties); GlassFishProperties glassfishProperties = new GlassFishProperties(); glassfishProperties.setPort("http-listener", port); // glassfishProperties.setPort("https-listener", port+1); glassfish = glassfishRuntime.newGlassFish(glassfishProperties); return this; } /* ... */ }
  • 31. GlassFish Embedded Start and Stop public class AbstractEmbeddedRunner { /* ... */ public AbstractEmbeddedRunner start() throws Exception{ glassfish.start(); return this; } public AbstractEmbeddedRunner stop() throws Exception{ glassfish.stop(); return this; } /* ... */ }
  • 32. GlassFish Embedded Deploy WAR public class AbstractEmbeddedRunner { /* ... */ public AbstractEmbeddedRunner deploy( String args[]) throws Exception{ Deployer deployer = glassfish.getDeployer(); for (String s: args) { String application = deployer.deploy(new File(s)); System.out.printf("deploying "+application); } return this; } /* ... */ }
  • 33. Demo: GlassFish Embedded GlassFish 4.0 Embedded Server
  • 34. Heavyweight vs. Lightweight How on earth do you weigh a Java container of any type?
  • 36. What You Will Do Tomorrow? Why Mock? Test Philosophy CHANGE! Arquillian Embedded Containers
  • 37. Resources § Arquillian Integration Server http://arquillian.org/ § Java EE 7 Specification http://jcp.org/en/jsr/detail?id=342 § Java Web Socket API 1.0 http://java.net/projects/websocket-spec/downloads § GlassFish 4.0 Promoted Builds https://blogs.oracle.com/theaquarium/entry/ downloading_latest_glassfish_4_promoted § WebSocket Client http://www.websocket.org/echo.html § GlassFish Embedded Instructions http://embedded-glassfish.java.net/ § Thanks!
  • 38. Creative Commons Attributions §  Brett Lider, Folded Ruler, http://www.flickr.com/photos/brettlider/1575417754/sizes/o/in/ photostream/ §  Daquella manera, Crutches donation to Haitian brothers and sisters, http://www.flickr.com/ photos/daquellamanera/4390506017/sizes/l/in/photostream/ §  Marcus Tschiae, Electric Power Framework perspective http://www.flickr.com/photos/tschiae/ 8417927326/sizes/h/ §  Falk Neumman, September 5, 2005, You’ve Got A Fast Car, http://www.flickr.com/photos/ coreforce/5910961411/ §  Stuart Webster, London skies from Waterloo Bridge, http://www.flickr.com/photos/ stuartwebster/4192629903/sizes/o/