SlideShare a Scribd company logo
1 of 43
THE SOFTWARE EXPERTS
Apache DeltaSpike
... closes the gaps!
THE SOFTWARE EXPERTS
Agenda
• History
• DeltaSpike is…
• DeltaSpike by Example
 Core
 JSF Module
 Test-Control Module
• Portability
• Module Overview
• Bonus
THE SOFTWARE EXPERTS
History
Java EE
without CDI
Spring
Framework
Seam2
MyFaces
Orchestra
MyFaces CODI
Java EE
with CDI
Seam3
+ CDI implementation
DeltaSpike
Other
Extensions
THE SOFTWARE EXPERTS
DeltaSpike is...
• Portable CDI-Extension
(for Apache OpenWebBeans and JBoss Weld)
• Possible base for own CDI-Extensions
• Source of proper usages of CDI (API and SPI)
• Collection of the best concepts of
 Apache MyFaces CODI
 JBoss Seam3
 ...
THE SOFTWARE EXPERTS
Parts of DS
• Core (v0.1+)
• Container-Control (v0.2+)
• Modules
THE SOFTWARE EXPERTS
DS by Example
THE SOFTWARE EXPERTS
DS Core
THE SOFTWARE EXPERTS
Deactivate Beans
• Disable CDI-Bean unconditionally
@Exclude
public class MockMailService
implements MailService { /*...*/ }
• Enable CDI-Bean only for Unit-Tests
@Exclude(exceptIfProjectStage =
ProjectStage.UnitTest.class)
@Alternative
public class TestMailService
implements MailService { /*...*/ }
THE SOFTWARE EXPERTS
Window-Scope - Overview
• Based on the CDI Session-Scope
• A HTTP-Session is optional
 Allows logical windows (for batches,...)
 Simple/r to test
• Needs to get de-/activated explicitly
(autom. handling with the JSF-Module)
• Base for
 Grouped-Conversation-Scope
 View-Access-Scope
THE SOFTWARE EXPERTS
Window-Scope - Usage
• Bean-Definition
@WindowScoped
public class UserHolder
implements Serializable {
private User user;
public void setCurrentUser(User user) {
this.user = user;
}
//...
}
• Usage
@Inject private UserHolder holder;
//...
holder.setCurrentUser(authenticatedUser);
THE SOFTWARE EXPERTS
Highlights (DS Core)
• Scopes
 Window-Scope
 Grouped-Conversation-Scope
 View-Access-Scope
• @Exclude
• Type-safe Project-Stages
• Builders for CDI-Metadata
• Exception-Control
• JMX integration
• Utilities
THE SOFTWARE EXPERTS
DS JSF-Module
THE SOFTWARE EXPERTS
Window-Scope with JSF
• Like a session per browser window/tab
• Pluggable ClientWindow
(+ optional adapter for JSF 2.2+)
• Requires ds:windowId Tag in the page(-template)
(Namespace: http://deltaspike.apache.org/jsf)
THE SOFTWARE EXPERTS
Type-safe View-Config - Overview
• Type-safe configuration
 Re-usable for JSF-Navigation
 Parameters (static or dynamic)
• Highly customizable/extensible
 Custom naming conventions,…
 Custom Metadata,…
• Std. Java  Std. IDE Support
 Autocomplete
 Usages / Code-Navigation
 Refactoring
 Show inheritance hierarchy
THE SOFTWARE EXPERTS
View-Config - Minimal Example
• Definition
public class MyPage
implements ViewConfig {}
• Usage
public Class<? extends ViewConfig>
toNextPage() {
return MyPage.class;
}
/myPage.xhtml
THE SOFTWARE EXPERTS
View-Config with Metadata - 1
• Definition
@View(navigation = REDIRECT)
public interface Pages extends ViewConfig {
interface Admin extends Pages {
class Overview implements Admin {}
}
}
• Usage
public Class<? extends Pages> toNextPage() {
return Pages.Admin.Overview.class;
}
/pages/admin/overview.xhtml?faces-redirect=true
THE SOFTWARE EXPERTS
View-Config with Metadata - 2
• Definition
@Secured(MyAccessDecisionVoter.class)
public interface SecuredPages {}
@View(navigation = REDIRECT)
public interface Pages extends ViewConfig {
interface Admin extends Pages,SecuredPages {
@ViewControllerRef(AdminPage.class)
class Overview implements Admin { }
}
}
THE SOFTWARE EXPERTS
Custom Metadata
• Definition
@ViewMetaData
@interface InfoPage { /*...*/ }
• Usage
@Inject
private ViewConfigResolver vcr;
//...
ViewConfigDescriptor vcd =
vcr.getViewConfigDescriptor(
/*[Class|String]*/);
List<InfoPage> metaDataList =
vcd.getMetaData(InfoPage.class);
THE SOFTWARE EXPERTS
Highlights (JSF Module)
• Type-safe View-Config
• View-Controller concept
• Double-Submit prevention
• Injection for converters and validators
• JSF Scope- and Event-Bridge
• Special integration of other parts provided by DS
(e.g. Security-adapter, Scopes, I18n,...)
• Optional JSF 2.2+ integration/support
THE SOFTWARE EXPERTS
DS Test-Control
THE SOFTWARE EXPERTS
Testing CDI Applications with DS
• Available options
 Manual usage of DS-Core and Container-Control
 JUnit Runner of DS-Test-Control
• Mainly for CDI-Beans
 No full Java EE tests like with Arquillian
 Optional support of EJBs with
Apache TomEE (embedded)
 Optional integration with Apache MyFaces-Test
(e.g. to test JSF Page-Beans manually)
THE SOFTWARE EXPERTS
Inject CDI-Beans in Tests - Setup
• Add OpenWebBeans or Weld
• Add DeltaSpike (at least Core)
• Add the test-dependencies
 JUnit
 DeltaSpike Container-Control
 DeltaSpike Test-Control
THE SOFTWARE EXPERTS
Inject CDI-Beans in Tests - Usage
• Use the Test-Runner to write a test
@RunWith(CdiTestRunner.class)
public class SimpleTest {
@Inject
private QuestionOfLifeBean bean;
@Test
public void ultimateAnswer() {
assertEquals(42, bean.getAnswer());
}
}
THE SOFTWARE EXPERTS
Page-Bean Tests - Setup
• Add MyFaces-Core and MyFaces-Test
• Add one of the adapters to the configuration
(META-INFservicesorg.apache.deltaspike.testcontrol.spi.ExternalContainer)
THE SOFTWARE EXPERTS
Page-Bean Tests - Usage
• Use the JSF-API in a test
@Test
public void registerUser() {
FacesContext fc =
FacesContext.getCurrentInstance();
assertTrue(
fc.getMessageList().isEmpty());
//...
assertEquals(Pages.User.Login.class,
this.registrationPage.register());
assertFalse(
fc.getMessageList().isEmpty());
//...
}
THE SOFTWARE EXPERTS
Tests with Context-Control
• No additional Setup
• Inject ContextControl
• Control scopes specified by the CDI specification
THE SOFTWARE EXPERTS
Tests with Scope-Control - Usage
• Simulate multiple Requests/... per Test-Method
@Test
public void registerUser() {
//...
assertFalse(
fc.getMessageList().isEmpty());
this.contextControl.stopContexts();
this.contextControl.startContexts();
assertTrue(
fc.getMessageList().isEmpty());
//...
}
THE SOFTWARE EXPERTS
Tests with DeltaSpike Scopes
• No additional Setup
• Context-implementations provide Management-API
• Examples
 @WindowScoped
 WindowContext
 @GroupedConversationScoped
 GroupedConversationManager
THE SOFTWARE EXPERTS
Window Aware Tests - Usage
• Control the Window
@Test
public void registerUserAndLogin() {
this.windowContext.activateWindow("w1");
//...
this.registrationPage.register();
//...
this.contextControl.stopContexts();
this.contextControl.startContexts();
this.windowContext.activateWindow("w1");
//...
this.registrationPage.login();
//...
}
THE SOFTWARE EXPERTS
Tests with Mocks for CDI-Beans
• Only needed if a single Test-Bean isn’t possible/useful
(via @Specializes or @Alternative)
• Mocking framework is optional
( additional Setup depends on it)
• Register custom (mock-)instances
 Inject ApplicationMockManager
for application scoped mocks
 Inject DynamicMockManager
for mocks per request ( Test-Method per default)
THE SOFTWARE EXPERTS
Tests with Mocks - Usage
• Register mock-instance created via Mockito
@Test
public void registerUserWithMockedBean() {
UserRepository mocked =
mock(UserRepository.class);
when(mockedRepository.findUser("gp"))
.thenReturn(new User(/*...*/));
this.dynamicMockManager.addMock(mocked);
//...
this.registrationPage.register();
assertEquals("gp",
this.userRepository.findUser("gp")
.getUserName());
}
THE SOFTWARE EXPERTS
Advantages of DS Test-Control
• Easy to use and fast
(no additional container-/deployment-configurations)
• Testing the whole application
(no "Micro-Deployments" like with Arquillian)
• Integration with DS Project-Stages
(see the optional @TestControl Annotation)
• Allows to (re-)use mocks
(and mocking frameworks like Mockito)
THE SOFTWARE EXPERTS
Disadvantages of DS Test-Control
• No deployment to the Target-EE-Server
• Mainly for CDI
• EJB-Support just with TomEE embedded
(@Transactional of DeltaSpike
might be easier for tests)
THE SOFTWARE EXPERTS
Tested Portability
THE SOFTWARE EXPERTS
Tested Portability - 1
• CDI-Implementations
 Apache OpenWebBeans (>= 1.1.5)
 JBoss Weld (>= 1.1.9)
• EE6+ Servers
 Apache TomEE 1.6.0+
 JBoss AS7 und WildFly8
 Oracle WebLogic 12.1.3+
 IBM WebSphere 8+
THE SOFTWARE EXPERTS
Tested Portability - 2
THE SOFTWARE EXPERTS
DS Module Overview
THE SOFTWARE EXPERTS
DS Modules
• Security (since v0.2+)
• JPA (Transaction) (since v0.3+)
• JSF (since v0.4+)
• Partial-Bean (since v0.4+)
• Bean-Validation (since v0.5+)
• Data (Query) (since v0.5+)
• Servlet (since v0.5+)
• Scheduler (since v0.6+)
• Test-Control (since v0.6+)
THE SOFTWARE EXPERTS
Bonus - Advanced CDI
THE SOFTWARE EXPERTS
Customize CDI-Beans
• CDI-Bootstrapping-Process provides
several useful events
• Creating custom Bean-Metadata manually
can be tricky
THE SOFTWARE EXPERTS
DS helps with Builders for Metadata
• Dynamically change the existing metadata
AnnotatedType<T> annotatedType =
processAnnotatedType.getAnnotatedType();
processAnnotatedType.setAnnotatedType(
new AnnotatedTypeBuilder<T>()
.readFromType(annotatedType)
.addToClass(
new MyAnnotationLiteral())
.create());
THE SOFTWARE EXPERTS
Q&A!?!
THE SOFTWARE EXPERTS
Links
• Apache DeltaSpike
http://deltaspike.apache.org
• Add-ons, Project-Templates,…
https://github.com/os890
• CDI@Work
http://cdiatwork.irian.at
• Professional Support
http://www.irian.at

More Related Content

What's hot

Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVMRyan Cuprak
 
Spring - CDI Interop
Spring - CDI InteropSpring - CDI Interop
Spring - CDI InteropRay Ploski
 
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
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeansRyan Cuprak
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with GradleRyan Cuprak
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Introboyw165
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenMert Çalışkan
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for DummiesTomer Gabel
 
Spring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerSpring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerZeroTurnaround
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Ryan Cuprak
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomavenManav Prasad
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparisonManav Prasad
 
Open Services Gateway Initiative (OSGI)
Open Services Gateway Initiative (OSGI)Open Services Gateway Initiative (OSGI)
Open Services Gateway Initiative (OSGI)Peter R. Egli
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Shekhar Gulati
 
Java 9 Modularity and Project Jigsaw
Java 9 Modularity and Project JigsawJava 9 Modularity and Project Jigsaw
Java 9 Modularity and Project JigsawComsysto Reply GmbH
 

What's hot (20)

Polygot Java EE on the GraalVM
Polygot Java EE on the GraalVMPolygot Java EE on the GraalVM
Polygot Java EE on the GraalVM
 
Spring - CDI Interop
Spring - CDI InteropSpring - CDI Interop
Spring - CDI Interop
 
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)
 
Node.js Development with Apache NetBeans
Node.js Development with Apache NetBeansNode.js Development with Apache NetBeans
Node.js Development with Apache NetBeans
 
Maven basic concept
Maven basic conceptMaven basic concept
Maven basic concept
 
Faster Java EE Builds with Gradle
Faster Java EE Builds with GradleFaster Java EE Builds with Gradle
Faster Java EE Builds with Gradle
 
Note - Apache Maven Intro
Note - Apache Maven IntroNote - Apache Maven Intro
Note - Apache Maven Intro
 
Java EE 8
Java EE 8Java EE 8
Java EE 8
 
BMO - Intelligent Projects with Maven
BMO - Intelligent Projects with MavenBMO - Intelligent Projects with Maven
BMO - Intelligent Projects with Maven
 
Maven for Dummies
Maven for DummiesMaven for Dummies
Maven for Dummies
 
Spring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen HoellerSpring 4 on Java 8 by Juergen Hoeller
Spring 4 on Java 8 by Juergen Hoeller
 
Intro To OSGi
Intro To OSGiIntro To OSGi
Intro To OSGi
 
Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)Exploring Java Heap Dumps (Oracle Code One 2018)
Exploring Java Heap Dumps (Oracle Code One 2018)
 
Introduction tomaven
Introduction tomavenIntroduction tomaven
Introduction tomaven
 
Java 9 preview
Java 9 previewJava 9 preview
Java 9 preview
 
Java build tool_comparison
Java build tool_comparisonJava build tool_comparison
Java build tool_comparison
 
Open Services Gateway Initiative (OSGI)
Open Services Gateway Initiative (OSGI)Open Services Gateway Initiative (OSGI)
Open Services Gateway Initiative (OSGI)
 
Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud Java(ee) mongo db applications in the cloud
Java(ee) mongo db applications in the cloud
 
Java 9 Modularity and Project Jigsaw
Java 9 Modularity and Project JigsawJava 9 Modularity and Project Jigsaw
Java 9 Modularity and Project Jigsaw
 

Similar to Apache DeltaSpike

JavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint DevelopersJavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint DevelopersRob Windsor
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterBoni García
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introductionvstorm83
 
JLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containersJLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containersGrace Jansen
 
JBCN_Testing_With_Containers
JBCN_Testing_With_ContainersJBCN_Testing_With_Containers
JBCN_Testing_With_ContainersGrace Jansen
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUlrich Krause
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014scolestock
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Robert Scholte
 
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
 
HOW TO DRONE.IO IN CI/CD WORLD
HOW TO DRONE.IO IN CI/CD WORLDHOW TO DRONE.IO IN CI/CD WORLD
HOW TO DRONE.IO IN CI/CD WORLDAleksandr Maklakov
 
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan KustInfinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan KustInfinum
 
How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?Dmitry Buzdin
 
StorageQuery: federated querying on object stores, powered by Alluxio and Presto
StorageQuery: federated querying on object stores, powered by Alluxio and PrestoStorageQuery: federated querying on object stores, powered by Alluxio and Presto
StorageQuery: federated querying on object stores, powered by Alluxio and PrestoAlluxio, Inc.
 
Java 8 in Anger (QCon London)
Java 8 in Anger (QCon London)Java 8 in Anger (QCon London)
Java 8 in Anger (QCon London)Trisha Gee
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh! Chalermpon Areepong
 
Java 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx FranceJava 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx FranceTrisha Gee
 

Similar to Apache DeltaSpike (20)

Apache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI ToolboxApache DeltaSpike: The CDI Toolbox
Apache DeltaSpike: The CDI Toolbox
 
JavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint DevelopersJavaScript and jQuery for SharePoint Developers
JavaScript and jQuery for SharePoint Developers
 
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-JupiterToolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
Toolbox for Selenium Tests in Java: WebDriverManager and Selenium-Jupiter
 
eXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework IntroductioneXo Platform SEA - Play Framework Introduction
eXo Platform SEA - Play Framework Introduction
 
JLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containersJLove - Replicating production on your laptop using the magic of containers
JLove - Replicating production on your laptop using the magic of containers
 
JBCN_Testing_With_Containers
JBCN_Testing_With_ContainersJBCN_Testing_With_Containers
JBCN_Testing_With_Containers
 
UKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basicsUKLUG 2012 - XPages, Beyond the basics
UKLUG 2012 - XPages, Beyond the basics
 
Eclipse e4
Eclipse e4Eclipse e4
Eclipse e4
 
DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014DevOps with Elastic Beanstalk - TCCC-2014
DevOps with Elastic Beanstalk - TCCC-2014
 
Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)Apache maven and its impact on java 9 (Java One 2017)
Apache maven and its impact on java 9 (Java One 2017)
 
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
 
HOW TO DRONE.IO IN CI/CD WORLD
HOW TO DRONE.IO IN CI/CD WORLDHOW TO DRONE.IO IN CI/CD WORLD
HOW TO DRONE.IO IN CI/CD WORLD
 
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan KustInfinum Android Talks #17 - Testing your Android applications by Ivan Kust
Infinum Android Talks #17 - Testing your Android applications by Ivan Kust
 
How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?How to Build Your Own Test Automation Framework?
How to Build Your Own Test Automation Framework?
 
StorageQuery: federated querying on object stores, powered by Alluxio and Presto
StorageQuery: federated querying on object stores, powered by Alluxio and PrestoStorageQuery: federated querying on object stores, powered by Alluxio and Presto
StorageQuery: federated querying on object stores, powered by Alluxio and Presto
 
DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020DevOps Odessa #TechTalks 21.01.2020
DevOps Odessa #TechTalks 21.01.2020
 
Java 8 in Anger (QCon London)
Java 8 in Anger (QCon London)Java 8 in Anger (QCon London)
Java 8 in Anger (QCon London)
 
Protractor survival guide
Protractor survival guideProtractor survival guide
Protractor survival guide
 
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
ZZ BC#7.5 asp.net mvc practice  and guideline refresh! ZZ BC#7.5 asp.net mvc practice  and guideline refresh!
ZZ BC#7.5 asp.net mvc practice and guideline refresh!
 
Java 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx FranceJava 8 in Anger, Devoxx France
Java 8 in Anger, Devoxx France
 

More from os890

Flexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpikeFlexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpikeos890
 
MyFaces Extensions Validator r4 news
MyFaces Extensions Validator r4 newsMyFaces Extensions Validator r4 news
MyFaces Extensions Validator r4 newsos890
 
MyFaces CODI v0.9.0 News
MyFaces CODI v0.9.0 NewsMyFaces CODI v0.9.0 News
MyFaces CODI v0.9.0 Newsos890
 
MyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 NewsMyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 Newsos890
 
Metadatenbasierte Validierung
Metadatenbasierte ValidierungMetadatenbasierte Validierung
Metadatenbasierte Validierungos890
 
MyFaces Extensions Validator 1.x.2 News
MyFaces Extensions Validator 1.x.2 NewsMyFaces Extensions Validator 1.x.2 News
MyFaces Extensions Validator 1.x.2 Newsos890
 
MyFaces Extensions Validator Part 1 of 3
MyFaces Extensions Validator Part 1 of 3MyFaces Extensions Validator Part 1 of 3
MyFaces Extensions Validator Part 1 of 3os890
 

More from os890 (7)

Flexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpikeFlexibilitaet mit CDI und Apache DeltaSpike
Flexibilitaet mit CDI und Apache DeltaSpike
 
MyFaces Extensions Validator r4 news
MyFaces Extensions Validator r4 newsMyFaces Extensions Validator r4 news
MyFaces Extensions Validator r4 news
 
MyFaces CODI v0.9.0 News
MyFaces CODI v0.9.0 NewsMyFaces CODI v0.9.0 News
MyFaces CODI v0.9.0 News
 
MyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 NewsMyFaces Extensions Validator r3 News
MyFaces Extensions Validator r3 News
 
Metadatenbasierte Validierung
Metadatenbasierte ValidierungMetadatenbasierte Validierung
Metadatenbasierte Validierung
 
MyFaces Extensions Validator 1.x.2 News
MyFaces Extensions Validator 1.x.2 NewsMyFaces Extensions Validator 1.x.2 News
MyFaces Extensions Validator 1.x.2 News
 
MyFaces Extensions Validator Part 1 of 3
MyFaces Extensions Validator Part 1 of 3MyFaces Extensions Validator Part 1 of 3
MyFaces Extensions Validator Part 1 of 3
 

Recently uploaded

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 

Recently uploaded (20)

The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 

Apache DeltaSpike

  • 1. THE SOFTWARE EXPERTS Apache DeltaSpike ... closes the gaps!
  • 2. THE SOFTWARE EXPERTS Agenda • History • DeltaSpike is… • DeltaSpike by Example  Core  JSF Module  Test-Control Module • Portability • Module Overview • Bonus
  • 3. THE SOFTWARE EXPERTS History Java EE without CDI Spring Framework Seam2 MyFaces Orchestra MyFaces CODI Java EE with CDI Seam3 + CDI implementation DeltaSpike Other Extensions
  • 4. THE SOFTWARE EXPERTS DeltaSpike is... • Portable CDI-Extension (for Apache OpenWebBeans and JBoss Weld) • Possible base for own CDI-Extensions • Source of proper usages of CDI (API and SPI) • Collection of the best concepts of  Apache MyFaces CODI  JBoss Seam3  ...
  • 5. THE SOFTWARE EXPERTS Parts of DS • Core (v0.1+) • Container-Control (v0.2+) • Modules
  • 8. THE SOFTWARE EXPERTS Deactivate Beans • Disable CDI-Bean unconditionally @Exclude public class MockMailService implements MailService { /*...*/ } • Enable CDI-Bean only for Unit-Tests @Exclude(exceptIfProjectStage = ProjectStage.UnitTest.class) @Alternative public class TestMailService implements MailService { /*...*/ }
  • 9. THE SOFTWARE EXPERTS Window-Scope - Overview • Based on the CDI Session-Scope • A HTTP-Session is optional  Allows logical windows (for batches,...)  Simple/r to test • Needs to get de-/activated explicitly (autom. handling with the JSF-Module) • Base for  Grouped-Conversation-Scope  View-Access-Scope
  • 10. THE SOFTWARE EXPERTS Window-Scope - Usage • Bean-Definition @WindowScoped public class UserHolder implements Serializable { private User user; public void setCurrentUser(User user) { this.user = user; } //... } • Usage @Inject private UserHolder holder; //... holder.setCurrentUser(authenticatedUser);
  • 11. THE SOFTWARE EXPERTS Highlights (DS Core) • Scopes  Window-Scope  Grouped-Conversation-Scope  View-Access-Scope • @Exclude • Type-safe Project-Stages • Builders for CDI-Metadata • Exception-Control • JMX integration • Utilities
  • 13. THE SOFTWARE EXPERTS Window-Scope with JSF • Like a session per browser window/tab • Pluggable ClientWindow (+ optional adapter for JSF 2.2+) • Requires ds:windowId Tag in the page(-template) (Namespace: http://deltaspike.apache.org/jsf)
  • 14. THE SOFTWARE EXPERTS Type-safe View-Config - Overview • Type-safe configuration  Re-usable for JSF-Navigation  Parameters (static or dynamic) • Highly customizable/extensible  Custom naming conventions,…  Custom Metadata,… • Std. Java  Std. IDE Support  Autocomplete  Usages / Code-Navigation  Refactoring  Show inheritance hierarchy
  • 15. THE SOFTWARE EXPERTS View-Config - Minimal Example • Definition public class MyPage implements ViewConfig {} • Usage public Class<? extends ViewConfig> toNextPage() { return MyPage.class; } /myPage.xhtml
  • 16. THE SOFTWARE EXPERTS View-Config with Metadata - 1 • Definition @View(navigation = REDIRECT) public interface Pages extends ViewConfig { interface Admin extends Pages { class Overview implements Admin {} } } • Usage public Class<? extends Pages> toNextPage() { return Pages.Admin.Overview.class; } /pages/admin/overview.xhtml?faces-redirect=true
  • 17. THE SOFTWARE EXPERTS View-Config with Metadata - 2 • Definition @Secured(MyAccessDecisionVoter.class) public interface SecuredPages {} @View(navigation = REDIRECT) public interface Pages extends ViewConfig { interface Admin extends Pages,SecuredPages { @ViewControllerRef(AdminPage.class) class Overview implements Admin { } } }
  • 18. THE SOFTWARE EXPERTS Custom Metadata • Definition @ViewMetaData @interface InfoPage { /*...*/ } • Usage @Inject private ViewConfigResolver vcr; //... ViewConfigDescriptor vcd = vcr.getViewConfigDescriptor( /*[Class|String]*/); List<InfoPage> metaDataList = vcd.getMetaData(InfoPage.class);
  • 19. THE SOFTWARE EXPERTS Highlights (JSF Module) • Type-safe View-Config • View-Controller concept • Double-Submit prevention • Injection for converters and validators • JSF Scope- and Event-Bridge • Special integration of other parts provided by DS (e.g. Security-adapter, Scopes, I18n,...) • Optional JSF 2.2+ integration/support
  • 20. THE SOFTWARE EXPERTS DS Test-Control
  • 21. THE SOFTWARE EXPERTS Testing CDI Applications with DS • Available options  Manual usage of DS-Core and Container-Control  JUnit Runner of DS-Test-Control • Mainly for CDI-Beans  No full Java EE tests like with Arquillian  Optional support of EJBs with Apache TomEE (embedded)  Optional integration with Apache MyFaces-Test (e.g. to test JSF Page-Beans manually)
  • 22. THE SOFTWARE EXPERTS Inject CDI-Beans in Tests - Setup • Add OpenWebBeans or Weld • Add DeltaSpike (at least Core) • Add the test-dependencies  JUnit  DeltaSpike Container-Control  DeltaSpike Test-Control
  • 23. THE SOFTWARE EXPERTS Inject CDI-Beans in Tests - Usage • Use the Test-Runner to write a test @RunWith(CdiTestRunner.class) public class SimpleTest { @Inject private QuestionOfLifeBean bean; @Test public void ultimateAnswer() { assertEquals(42, bean.getAnswer()); } }
  • 24. THE SOFTWARE EXPERTS Page-Bean Tests - Setup • Add MyFaces-Core and MyFaces-Test • Add one of the adapters to the configuration (META-INFservicesorg.apache.deltaspike.testcontrol.spi.ExternalContainer)
  • 25. THE SOFTWARE EXPERTS Page-Bean Tests - Usage • Use the JSF-API in a test @Test public void registerUser() { FacesContext fc = FacesContext.getCurrentInstance(); assertTrue( fc.getMessageList().isEmpty()); //... assertEquals(Pages.User.Login.class, this.registrationPage.register()); assertFalse( fc.getMessageList().isEmpty()); //... }
  • 26. THE SOFTWARE EXPERTS Tests with Context-Control • No additional Setup • Inject ContextControl • Control scopes specified by the CDI specification
  • 27. THE SOFTWARE EXPERTS Tests with Scope-Control - Usage • Simulate multiple Requests/... per Test-Method @Test public void registerUser() { //... assertFalse( fc.getMessageList().isEmpty()); this.contextControl.stopContexts(); this.contextControl.startContexts(); assertTrue( fc.getMessageList().isEmpty()); //... }
  • 28. THE SOFTWARE EXPERTS Tests with DeltaSpike Scopes • No additional Setup • Context-implementations provide Management-API • Examples  @WindowScoped  WindowContext  @GroupedConversationScoped  GroupedConversationManager
  • 29. THE SOFTWARE EXPERTS Window Aware Tests - Usage • Control the Window @Test public void registerUserAndLogin() { this.windowContext.activateWindow("w1"); //... this.registrationPage.register(); //... this.contextControl.stopContexts(); this.contextControl.startContexts(); this.windowContext.activateWindow("w1"); //... this.registrationPage.login(); //... }
  • 30. THE SOFTWARE EXPERTS Tests with Mocks for CDI-Beans • Only needed if a single Test-Bean isn’t possible/useful (via @Specializes or @Alternative) • Mocking framework is optional ( additional Setup depends on it) • Register custom (mock-)instances  Inject ApplicationMockManager for application scoped mocks  Inject DynamicMockManager for mocks per request ( Test-Method per default)
  • 31. THE SOFTWARE EXPERTS Tests with Mocks - Usage • Register mock-instance created via Mockito @Test public void registerUserWithMockedBean() { UserRepository mocked = mock(UserRepository.class); when(mockedRepository.findUser("gp")) .thenReturn(new User(/*...*/)); this.dynamicMockManager.addMock(mocked); //... this.registrationPage.register(); assertEquals("gp", this.userRepository.findUser("gp") .getUserName()); }
  • 32. THE SOFTWARE EXPERTS Advantages of DS Test-Control • Easy to use and fast (no additional container-/deployment-configurations) • Testing the whole application (no "Micro-Deployments" like with Arquillian) • Integration with DS Project-Stages (see the optional @TestControl Annotation) • Allows to (re-)use mocks (and mocking frameworks like Mockito)
  • 33. THE SOFTWARE EXPERTS Disadvantages of DS Test-Control • No deployment to the Target-EE-Server • Mainly for CDI • EJB-Support just with TomEE embedded (@Transactional of DeltaSpike might be easier for tests)
  • 35. THE SOFTWARE EXPERTS Tested Portability - 1 • CDI-Implementations  Apache OpenWebBeans (>= 1.1.5)  JBoss Weld (>= 1.1.9) • EE6+ Servers  Apache TomEE 1.6.0+  JBoss AS7 und WildFly8  Oracle WebLogic 12.1.3+  IBM WebSphere 8+
  • 36. THE SOFTWARE EXPERTS Tested Portability - 2
  • 37. THE SOFTWARE EXPERTS DS Module Overview
  • 38. THE SOFTWARE EXPERTS DS Modules • Security (since v0.2+) • JPA (Transaction) (since v0.3+) • JSF (since v0.4+) • Partial-Bean (since v0.4+) • Bean-Validation (since v0.5+) • Data (Query) (since v0.5+) • Servlet (since v0.5+) • Scheduler (since v0.6+) • Test-Control (since v0.6+)
  • 39. THE SOFTWARE EXPERTS Bonus - Advanced CDI
  • 40. THE SOFTWARE EXPERTS Customize CDI-Beans • CDI-Bootstrapping-Process provides several useful events • Creating custom Bean-Metadata manually can be tricky
  • 41. THE SOFTWARE EXPERTS DS helps with Builders for Metadata • Dynamically change the existing metadata AnnotatedType<T> annotatedType = processAnnotatedType.getAnnotatedType(); processAnnotatedType.setAnnotatedType( new AnnotatedTypeBuilder<T>() .readFromType(annotatedType) .addToClass( new MyAnnotationLiteral()) .create());
  • 43. THE SOFTWARE EXPERTS Links • Apache DeltaSpike http://deltaspike.apache.org • Add-ons, Project-Templates,… https://github.com/os890 • CDI@Work http://cdiatwork.irian.at • Professional Support http://www.irian.at