SlideShare a Scribd company logo
No SQL Unit - Devoxx 2012
NoSQLUnit
Testing NoSQL Applications
Alex Soto Bueno
Computer Engineer
lordofthejars.com
@alexsotob
Carlo Strozzi
Introduction
Carlo Strozzi
Introduction
2000s
Carlo Strozzi
Introduction
2000s
Carlo Strozzi
Introduction
2000s
No Standard Way
About Me
Alex Soto Bueno
Computer Engineer
Diagnostic Grifols
Tutor at UOC
Active Blogger & Speaker
Theory
Theory
FIRST
Tests should Follow
FIRST Rules
Theory
Fast
FIRST
Theory
Isolation
FIRST
Theory
Repeatable
FIRST
Theory
Self-Validating
FIRST
Theory
Timely
FIRST
Theory
FIRST
Fast
Isolation
Repeatable
Self-Validating
Timely
Slow
Isolation
Repeatable
Self-Validating
Timely
Unit High
Theory
FIRST
Testing Persistence Layer May
Break Isolated Rule
Theory
FIRSTpublic void savePhone(Phone phone) {
...
}
@Test
public void should_insert_phone() {
phoneService.save(new Phone());
}
@Test
public void should_count_phones() {
int numberOfPhones = phoneService.count();
assertThat(numberOfPhones, equalTo(??));
}
Theory
FIRST
DBUnit
Theory
FIRST
DBUnit
NoSQLUnit
Theory
NoSQLUnit
Manage Lifecycle
Theory
NoSQLUnit
Manage Lifecycle
Maintain Database State
Theory
NoSQLUnit
Manage Lifecycle
Maintain Database State
Standardize Tests
Theory
NoSQLUnit
Two Groups JUnit Rules
Theory
NoSQLUnit
Two Groups JUnit Rules
Two Annotations
Theory
NoSQLUnit
First Group:
Start and Stop NoSQL Engine
Theory
NoSQLUnit
Second Group:
Connection to Databases
Theory
NoSQLUnit
@UsingDataSet for Seeding Contents
Theory
NoSQLUnit
@ShouldMatchDataSet forVerifying Contents
Theory
NoSQLUnit
Start
Theory
NoSQLUnit
Start Clean
Theory
NoSQLUnit
Start Clean
Populate
Theory
NoSQLUnit
Start Clean
PopulateExecute
Theory
NoSQLUnit
Start Clean
PopulateExecute
Verify
Theory
NoSQLUnit
Start Clean
PopulateExecute
Verify Stop
Action
Action
Action
Embedded InMemory Redis
com.lordofthejars.nosqlunit.redis.EmbeddedRedis
com.lordofthejars.nosqlunit.redis.ManagedRedis
Managed Redis
Redis Connection
com.lordofthejars.nosqlunit.redis.RedisRule
Action
Action
"data":[
{"simple": [{"key":"key1", "value":"value1"}]
},
{"list": [{"key":"key3","values":[{"value":"value3"},{"value":"value4"}]}]
},
{"sortset": [{"key":"key4","values":[
{"score":2, "value":"value5" },{"score":3, "value":1 }}]
}]
},
{"hash": [{"key":"user","values":[{"field":"name", "value":"alex"},]}]
},
{"set":[{"key":"key3","values":[{"value":"value3"},{"value":"value4"}]}]
}
]
Action
Demo
Action
Action
Action
Embedded Cassandra
com.lordofthejars.nosqlunit.cassandra.EmbeddedCassandra
com.lordofthejars.nosqlunit.cassandra.ManagedCassandra
Managed Cassandra
Cassandra Connection
com.lordofthejars.nosqlunit.cassandra.CassandraRule
Action
Action
"name" : "keyspaceName",
"columnFamilies" : [{
"name" : "columnFamilyName",
"rows" : [{
"key" : "key10",
"columns" : [{
"name" : "name11",
"value" : "value11"
}]
},
{
"name" : "otherColumnFamilyName",
"type" : "SUPER",
"rows" : [{
"key" : "10",
"superColumns" : [{
"name" : "1100",
"columns" : [{
"name" : "1110",
"value" : "1110"
}]
}
]
Action
Action
Embedded HBase
com.lordofthejars.nosqlunit.hbase.EmbeddedHBase
com.lordofthejars.nosqlunit.hbase.ManagedHBase
Managed HBase
HBase Connection
com.lordofthejars.nosqlunit.hbase.HBaseRule
Action
Action
"name" : "tablename",
"columnFamilies" : [{
"name" : "columnFamilyName",
"rows" : [{
"key" : "key1",
"columns" : [{
"name" : "columnName",
"value" : "columnValue"
},
...
]
},
...
]
},
...
]
Action
Action
Embedded InMemory Neo4j
com.lordofthejars.nosqlunit.neo4j.InMemoryNeo4j
com.lordofthejars.nosqlunit.neo4j.EmbeddedNeo4j
Embedded Neo4j
Managed Wrapped Neo4j
com.lordofthejars.nosqlunit.neo4j.ManagedWrappingNeoServer
Managed Neo4j
com.lordofthejars.nosqlunit.neo4j.ManagedNeoServer
Neo4j Connection
com.lordofthejars.nosqlunit.neo4j.Neo4jRule
Action
Action
<?xml version="1.0" encoding="UTF-8"?>
<graphml xmlns="http://graphml.graphdrawing.org/xmlns">
<key id="attr1" for="edge" attr.name="attr1" attr.type="float"/>
<key id="attr2" for="node" attr.name="attr2" attr.type="string"/>
<graph id="G" edgedefault="directed">
<node id="1">
<data key="attr2">value1</data>
</node>
<node id="2">
<data key="attr2">value2</data>
</node>
<edge id="7" source="1" target="2" label="label1">
<data key="attr1">float</data>
</edge>
</graph>
</graphml>
Action
Demo
Action
Action
Action
Embedded InMemory MongoDB
com.lordofthejars.nosqlunit.mongodb.InMemoryMongoDb
com.lordofthejars.nosqlunit.mongodb.ManagedMongoDb
Managed MongoDB
MongoDB Connection
com.lordofthejars.nosqlunit.mongodb.MongoDbRule
Action
Action
{
"name_collection1": [
{
"attribute_1":"value1",
"attribute_2":"value2"
},
{
"attribute_3":2,
"attribute_4":"value4"
}
],
"name_collection2": [
...
],
....
}
More
Action
NoSQLUnit
NoSQLUnit is Ready for the clouds
No lifecycle management
Action
Demo
NoSQLUnit
Action
NoSQLUnit
Acceptance Tests Cloud
Action
NoSQLUnit
NoSQL system may be polyglot
Populating different data in parallel
Action
NoSQLUnit
private final Neo4jConfiguration neo4jConfiguration =
newManagedNeoServerConfiguration().connectionIdentifier("neo4j").build();
@Rule
public final Neo4jRule neo4jRule = newNeo4jRule().configure(neo4jConfiguration).build();
private final RedisConfiguration redisConfiguration =
newManagedRedisConfiguration().connectionIdentifier("redis").build();
@Rule
public final RedisRule redisRule = newRedisRule().configure(redisConfiguration).build();
@Test
@UsingDataSet(withSelectiveLocations = {
! @Selective(identifier = "neo4j", locations = "matrix.xml"),
! @Selective(identifier = "redis", locations = "matrix.json") },
! loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void cached_friends_should_be_returned() {...}
Action
NoSQLUnit
private final Neo4jConfiguration neo4jConfiguration =
newManagedNeoServerConfiguration().connectionIdentifier("neo4j").build();
@Rule
public final Neo4jRule neo4jRule = newNeo4jRule().configure(neo4jConfiguration).build();
private final RedisConfiguration redisConfiguration =
newManagedRedisConfiguration().connectionIdentifier("redis").build();
@Rule
public final RedisRule redisRule = newRedisRule().configure(redisConfiguration).build();
@Test
@UsingDataSet(withSelectiveLocations = {
! @Selective(identifier = "neo4j", locations = "matrix.xml"),
! @Selective(identifier = "redis", locations = "matrix.json") },
! loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void cached_friends_should_be_returned() {...}
Action
NoSQLUnit
private final Neo4jConfiguration neo4jConfiguration =
newManagedNeoServerConfiguration().connectionIdentifier("neo4j").build();
@Rule
public final Neo4jRule neo4jRule = newNeo4jRule().configure(neo4jConfiguration).build();
private final RedisConfiguration redisConfiguration =
newManagedRedisConfiguration().connectionIdentifier("redis").build();
@Rule
public final RedisRule redisRule = newRedisRule().configure(redisConfiguration).build();
@Test
@UsingDataSet(withSelectiveLocations = {
! @Selective(identifier = "neo4j", locations = "matrix.xml"),
! @Selective(identifier = "redis", locations = "matrix.json") },
! loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void cached_friends_should_be_returned() {...}
Action
NoSQLUnit
Partial Support for JSR-330
@Inject
@Named
Action
NoSQLUnit
Rule
public final MongoDbRule mongoDb = newMongoDbRule().defaultManagedMongoDb(“test”, this);
@Inject
private Mongo mongo;
Action
Flashback
NoSQLUnit
Action
Spring Data MongoDB - _class attribute
Spring Data Redis - Serializer/OXM/JSON
Spring Data HBase - RowMapper interface
Spring Data Neo4j - __type__ attribute
Spring Data Cassandra - EntityWritter interface
Spring Data
Action
Hibernate MongoDB - name property
Hibernate
What’s
Coming
What’s Coming
Engines
What’s Coming
Integration
What’s Coming
Integration
https://github.com/lordofthejars/nosql-unit/issues
Conclusions
Conclusions
Hard and Tedious Job
Spiderman way
Conclusions
Spiderman way
Conclusions
Spiderman way
Conclusions
Spiderman way
Thank you
Questions
Questions
NoSQLUnit
Testing NoSQL Applications
Alex Soto Bueno
Computer Engineer
lordofthejars.com
@alexsotob
Umi no kanatani wa mou sagasanai, Kagayaku monowa itsumo kokoni (Itsumo Nando De Mo)
NoSQLUnit
Testing NoSQL Applications
Alex Soto Bueno
Computer Engineer
lordofthejars.com
@alexsotob
CC Photos

More Related Content

PDF
ESNext for humans - LvivJS 16 August 2014
PPT
Wicket Security Presentation
PDF
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
PDF
Java Concurrency Gotchas
PDF
Form認証で学ぶSpring Security入門
PPT
Using xUnit as a Swiss-Aarmy Testing Toolkit
PPTX
State of entity framework
DOC
Selenium Webdriver with data driven framework
ESNext for humans - LvivJS 16 August 2014
Wicket Security Presentation
Amazon Cognito使って認証したい?それならSpring Security使いましょう!
Java Concurrency Gotchas
Form認証で学ぶSpring Security入門
Using xUnit as a Swiss-Aarmy Testing Toolkit
State of entity framework
Selenium Webdriver with data driven framework

What's hot (20)

PPTX
#5 (Remote Method Invocation)
PPT
Refactoring Jdbc Programming
PPTX
The uniform interface is 42
RTF
Easy Button
PDF
Js 单元测试框架介绍
PPTX
Smarter Testing With Spock
PDF
Magic methods
DOCX
Nested loop join technique - part2
PDF
Spock framework
PDF
Using Fuzzy Code Search to Link Code Fragments in Discussions to Source Code
PPTX
PHP 5 Magic Methods
PPTX
Java practice programs for beginners
DOCX
Wwe Management System
PPTX
Nantes Jug - Java 7
PDF
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
PDF
Java 7 LavaJUG
PDF
2019-10-05 - Untangled - Voxxed days ticino
PDF
#JavaFX.forReal() - ElsassJUG
PDF
Spock: A Highly Logical Way To Test
PDF
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
#5 (Remote Method Invocation)
Refactoring Jdbc Programming
The uniform interface is 42
Easy Button
Js 单元测试框架介绍
Smarter Testing With Spock
Magic methods
Nested loop join technique - part2
Spock framework
Using Fuzzy Code Search to Link Code Fragments in Discussions to Source Code
PHP 5 Magic Methods
Java practice programs for beginners
Wwe Management System
Nantes Jug - Java 7
Java 7 Launch Event at LyonJUG, Lyon France. Fork / Join framework and Projec...
Java 7 LavaJUG
2019-10-05 - Untangled - Voxxed days ticino
#JavaFX.forReal() - ElsassJUG
Spock: A Highly Logical Way To Test
soft-shake.ch - Java SE 7: The Fork/Join Framework and Project Coin
Ad

Viewers also liked (8)

PDF
Slides cube
PDF
Any resistance is futile, infrastructure bugs will be assimilated
PDF
Arquillian Loves JavaScript too.
PDF
Resistance is futile mocks will be assimilated
PDF
Java8slides
PDF
Mocks, Stubs and Fakes. ¿What Else?
PDF
Testing strategies for legacy code
KEY
How to Test Enterprise Java Applications
Slides cube
Any resistance is futile, infrastructure bugs will be assimilated
Arquillian Loves JavaScript too.
Resistance is futile mocks will be assimilated
Java8slides
Mocks, Stubs and Fakes. ¿What Else?
Testing strategies for legacy code
How to Test Enterprise Java Applications
Ad

Similar to No SQL Unit - Devoxx 2012 (11)

PDF
Polyglot Persistence with MongoDB and Neo4j
ODP
Presentation Unit Testing process
PDF
Neo4j after 1 year in production
PPTX
NoSQL Endgame DevoxxUA Conference 2020
PPTX
NoSQL Endgame LWJUG 2021
PPTX
Appium TestNG Framework and Multi-Device Automation Execution
PDF
GraphConnect Europe 2016 - NoSQL Polyglot Persistence: Tools and Integrations...
PDF
Exploring Neo4j Graph Database as a Fast Data Access Layer
PPTX
EclipseCon 2021 NoSQL Endgame
PPTX
Going Reactive with Relational Databases
PDF
Some testing - Everything you should know about testing to go with @pedro_g_s...
Polyglot Persistence with MongoDB and Neo4j
Presentation Unit Testing process
Neo4j after 1 year in production
NoSQL Endgame DevoxxUA Conference 2020
NoSQL Endgame LWJUG 2021
Appium TestNG Framework and Multi-Device Automation Execution
GraphConnect Europe 2016 - NoSQL Polyglot Persistence: Tools and Integrations...
Exploring Neo4j Graph Database as a Fast Data Access Layer
EclipseCon 2021 NoSQL Endgame
Going Reactive with Relational Databases
Some testing - Everything you should know about testing to go with @pedro_g_s...

More from Alex Soto (20)

PDF
Kubernetes Native Java
PDF
Reactive Programming for Real Use Cases
PDF
Chaos Engineering Kubernetes
PDF
Chaos Engineering Kubernetes
PDF
Microservices testing and automation
PDF
Testing in Production: From DevTestOops to DevTestOps
PDF
Supersonic Subatomic Java
PDF
From DevTestOops to DevTestOps
PDF
Istio service mesh & pragmatic microservices architecture
PDF
Zero Downtime Deployment in Microservices era
PDF
Service Mesh Patterns
PDF
Supersonic, Subatomic Java
PDF
Zero Downtime Deployment in Microservices era
PDF
Long Live and Prosper To Monolith
PDF
Sail in the cloud - An intro to Istio commit
PDF
KubeBoot - Spring Boot deployment on Kubernetes
PDF
Sail in the Cloud - An intro to Istio
PDF
Testing XXIst Century
PDF
Arquillian Constellation
PDF
Testing for Unicorns
Kubernetes Native Java
Reactive Programming for Real Use Cases
Chaos Engineering Kubernetes
Chaos Engineering Kubernetes
Microservices testing and automation
Testing in Production: From DevTestOops to DevTestOps
Supersonic Subatomic Java
From DevTestOops to DevTestOps
Istio service mesh & pragmatic microservices architecture
Zero Downtime Deployment in Microservices era
Service Mesh Patterns
Supersonic, Subatomic Java
Zero Downtime Deployment in Microservices era
Long Live and Prosper To Monolith
Sail in the cloud - An intro to Istio commit
KubeBoot - Spring Boot deployment on Kubernetes
Sail in the Cloud - An intro to Istio
Testing XXIst Century
Arquillian Constellation
Testing for Unicorns

Recently uploaded (20)

PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Machine learning based COVID-19 study performance prediction
PPTX
A Presentation on Artificial Intelligence
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PDF
Electronic commerce courselecture one. Pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
Unlocking AI with Model Context Protocol (MCP)
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Digital-Transformation-Roadmap-for-Companies.pptx
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Programs and apps: productivity, graphics, security and other tools
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Machine learning based COVID-19 study performance prediction
A Presentation on Artificial Intelligence
Network Security Unit 5.pdf for BCA BBA.
MIND Revenue Release Quarter 2 2025 Press Release
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Empathic Computing: Creating Shared Understanding
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
NewMind AI Weekly Chronicles - August'25-Week II
Dropbox Q2 2025 Financial Results & Investor Presentation
Electronic commerce courselecture one. Pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Mobile App Security Testing_ A Comprehensive Guide.pdf
Assigned Numbers - 2025 - Bluetooth® Document
Unlocking AI with Model Context Protocol (MCP)

No SQL Unit - Devoxx 2012