SlideShare une entreprise Scribd logo
1  sur  22
A MOP Based DSL for Testing Java Programs using OCL Tony Clark http://itcentre.tvu.ac.uk/~clark/ Centre for Model Driven Software Engineering School of Computing Thames Valley University London, UK
context SalesSystem::placeOrder(name:String,amount:int)   pre: accountsSystem.accounts->exists(a | a.cid = name)   post: accountsSystem.getAccount(name).items->exists(item |  item.amount = amount) and accountsSystem.getAccount(name).items->size =            self@pre.accountsSystem.getAccount(name).items->size + 1 2 OCL 09
Aim To extend XMF with a language feature for testing Java implementations. To use OCL as the constraint language. Problem: how to deal with all the possible implementation strategies for the model? OCL 09 3
A Little OCL-based Language @MSpec <name> [<method-name>] (<args>)   pre <pre-condition>   do <body>   post <post-condition> end @Test <name>   <spec>* end OCL 09 4
Example Test Scenario context SalesSystem @MSpecsuccessfulPlaceOrder[placeOrder](name,amount)   pre accountsSystem.accounts->exists(a | a.cid = name)   do run   post  accountsSystem.getAccount(name).items->exists(item | item.amount = amount) and accountsSystem.getAccount(name).items->size = preSelf.accountsSystem.getAccount(name).items->size + 1 end @Test Test0 successfulContact("fred") successfulRegister("fred") successfulPlaceOrder("fred",100) end OCL 09 5
Generate Reports OCL 09 6
XMF and OCL @Class Account   @Attribute cid : String end   @Constructor(cid) end end @Class AccountsSystem   @Attribute accounts : Set(Account) (+) end end   @Class SalesSystem   @Attribute accountsSystem : AccountsSystem = AccountsSystem() end   @Operation addAccount(cid:String)     accountsSystem.addToAccounts(Account(cid)) end   @Operation checkNameExists(name:String):Boolean accountsSystem.accounts->exists(a | a.cid = name)     end end 7 OCL 09
Java Implementation public class Account {   public String cid;   ... } public class AccountsSystem {   public Vector<Account> accounts = new Vector<Account>();   ... } public class SalesSystem {   public AccountsSystemaccountsSystem     = new AccountsSystem();   public ContactsDatabasecontactsDatabase     = new ContactsDatabase();   public void addAccount(String cid) { accountsSystem.addToAccounts(new Account(cid));   }   ... } OCL 09 8
Meta Classes in XMF OCL 09 9
Foreign Objects OCL 09 10
Java Classes in XMF OCL 09 11
A Metaclass: JavaClass @Class JavaClass extends Class   @Attribute descriptor : JavaDescriptor (?,!) end   @Operation addDescriptor(d:JavaDescriptor) xmf.foreignTypeMapping().put(d.type(),self); xmf.foreignMOPMapping().put(d.type(),d.mopName()); self.setDescriptor(d)   end   @Operation invoke(target,args)     let class = xmf.javaClass(descriptor.type(),descriptor.paths())     in class.invoke(target,args)     end   end   ... end OCL 09 12
A Java MOP public class ForeignObjectMOP {   public void dot(Machine m, intobj, int name) {      Object o = m.getForeignObject(obj);     Class<?> c = o.getClass();     Field f = c.getField(m.getString(name)); m.pushStack(f.get(o));   }   public void send(Machine m, int o, int m, intargs) {     // Send message and push return value...   }   public booleanhasSlot(Machine m, int o, int name) {     // Return true when object has named slot   }   public void set(Machine m, int o, int name, int value) {     // Set named slot...   } } OCL 09 13
XMF access to Java @Class Account metaclassJavaClass JavaDescriptor("Account","",Seq{"@/bin"}) end @Class AccountsSystemmetaclassJavaClass JavaDescriptor("AccountsSystem","",Seq{"@/bin"}) end @Class SalesSystemmetaclassJavaClass JavaDescriptor("SalesSystem","",Seq{"@/bin"})   @Operation checkNameExists(name:String):Boolean accountsSystem.accounts->exists(a | a.cid = name)     end end OCL 09 14
Making the Default MOP Explicit @Class Account metaclassJavaClass JavaDescriptor("Account",“foreignobj.ForeignObjectMOP",Seq{"@/bin"}) end context Root @Class AccountsSystemmetaclassJavaClass JavaDescriptor("AccountsSystem",“foreignobj.ForeignObjectMOP",Seq{"@/bin"}) end context Root @Class SalesSystemmetaclassJavaClass JavaDescriptor("SalesSystem","foreignobj.ForeignObjectMOP",Seq{"@/bin"})   @Operation checkNameExists(name:String):Boolean accountsSystem.accounts->exists(a | a.cid = name)     end end OCL 09 15
A Different Implementation: EMF OCL 09 16
An EMF MOP OCL 09 17
A Metaclass: EMFClass @Class EMFClass extends JavaClass@Operation invoke(target,args)     let factory = descriptor.getFactory() then       package = descriptor.getPackage() then       class = package.send("get" + name,Seq{}) then       object = factory.create(class)      in // Set fields from args using constructor...         object      end    end    ...  end OCL 09 18
EMFMop public class EObjectMOP extends foreignobj.ForeignObjectMOP {   public void dot(Machine machine, int object, int name) { EObjecteobject = (Eobject)machine.getForeignObject(object); EClasseclass = eobject.eClass();     String string = machine.getString(name); EStructuralFeature feature = eclass.getEStructuralFeature(string); machine.pushStack(eobject.eGet(feature));   }   public booleanhasSlot(Machine machine, intobj, int name) {     ...   }   public void set(Machine machine, intobj, int name, int value) {     ...   } } OCL 09 19
XMF access to EMF @Class Account metaclassEMFClass EMFDescriptor("sales.impl.AccountImpl","sales","sales","test.EObjectMOP")   @Constructor(cid) end end @Class AccountsSystemmetaclassEMFClass EMFDescriptor("sales.impl.AccountsSystemImpl","sales","sales","test.EObjectMOP") end @Class SalesSystemmetaclassEMFClass EMFDescriptor("sales.impl.SalesSystemImpl","sales","sales","test.EObjectMOP")   @Operation init() self.accountsSystem := AccountsSystem()   end   @Operation addAccount(cid:String) accountsSystem.getAccounts().add(Account(cid))   end   @Operation checkNameExists(name:String):Boolean accountsSystem.accounts->exists(a | a.cid = name)     end end OCL 09 20
Implementing the DSL 21 OCL 09
Example @MSpecsuccessfulPlaceOrder[placeOrder](name,amount)   pre accountsSystem.accounts->exists(a | a.cid = name)   do run   post accountsSystem.getAccount(name).items->exists(...) and ...  end @Operation successfulPlaceOrder(.args)  let name = args->at(0)      amount = args->at(1)  in let preSelf = self.deepCopy()     in if accountsSystem.accounts->exists(a | a.cid = name)        then let result = self.send(“placeOrder”,Seq{name,amount})             in if accountsSystem.getAccount(name).items->exists(...) and ...                then CallSucceeds(result,”placeOrder”,args)                else PostFails(“placeOrder”,args)                end             end        else PreFails(“placeOrder”,args)        end      end  end end OCL 09 22

Contenu connexe

Tendances

friends functionToshu
friends functionToshufriends functionToshu
friends functionToshuSidd Singh
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17LogeekNightUkraine
 
Operator overloading2
Operator overloading2Operator overloading2
Operator overloading2zindadili
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 FeaturesJan Rüegg
 
Lambda выражения и Java 8
Lambda выражения и Java 8Lambda выражения и Java 8
Lambda выражения и Java 8Alex Tumanoff
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Geeks Anonymes
 
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...Frank Nielsen
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Sumant Tambe
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsPrincess Sam
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbookManusha Dilan
 
Python Part 1
Python Part 1Python Part 1
Python Part 1Sunil OS
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrencyxu liwei
 
C++aptitude questions and answers
C++aptitude questions and answersC++aptitude questions and answers
C++aptitude questions and answerssheibansari
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overviewgourav kottawar
 

Tendances (20)

Compile time polymorphism
Compile time polymorphismCompile time polymorphism
Compile time polymorphism
 
C Basics
C BasicsC Basics
C Basics
 
Summary of C++17 features
Summary of C++17 featuresSummary of C++17 features
Summary of C++17 features
 
friends functionToshu
friends functionToshufriends functionToshu
friends functionToshu
 
E:\Plp 2009 2\Plp 9
E:\Plp 2009 2\Plp 9E:\Plp 2009 2\Plp 9
E:\Plp 2009 2\Plp 9
 
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
Vladymyr Bahrii Understanding polymorphism in C++ 16.11.17
 
Operator overloading2
Operator overloading2Operator overloading2
Operator overloading2
 
C++ 11 Features
C++ 11 FeaturesC++ 11 Features
C++ 11 Features
 
Lambda выражения и Java 8
Lambda выражения и Java 8Lambda выражения и Java 8
Lambda выражения и Java 8
 
Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)Modern c++ (C++ 11/14)
Modern c++ (C++ 11/14)
 
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
(chapter 5) A Concise and Practical Introduction to Programming Algorithms in...
 
Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)Fun with Lambdas: C++14 Style (part 1)
Fun with Lambdas: C++14 Style (part 1)
 
Lec 42.43 - virtual.functions
Lec 42.43 - virtual.functionsLec 42.43 - virtual.functions
Lec 42.43 - virtual.functions
 
Java_practical_handbook
Java_practical_handbookJava_practical_handbook
Java_practical_handbook
 
Python Part 1
Python Part 1Python Part 1
Python Part 1
 
C++11 concurrency
C++11 concurrencyC++11 concurrency
C++11 concurrency
 
C++ via C#
C++ via C#C++ via C#
C++ via C#
 
C++aptitude questions and answers
C++aptitude questions and answersC++aptitude questions and answers
C++aptitude questions and answers
 
Java practical
Java practicalJava practical
Java practical
 
classes & objects in cpp overview
classes & objects in cpp overviewclasses & objects in cpp overview
classes & objects in cpp overview
 

En vedette

Model Slicing
Model SlicingModel Slicing
Model SlicingClarkTony
 
Mcms and ids sig
Mcms and ids sigMcms and ids sig
Mcms and ids sigClarkTony
 
Overview of the interim budget 2014 15
Overview of the interim budget 2014 15Overview of the interim budget 2014 15
Overview of the interim budget 2014 15Jiten Sharma
 
Reverse engineering and theory building v3
Reverse engineering and theory building v3Reverse engineering and theory building v3
Reverse engineering and theory building v3ClarkTony
 
Scrum 開發流程導入經驗分享
Scrum 開發流程導入經驗分享Scrum 開發流程導入經驗分享
Scrum 開發流程導入經驗分享謝 宗穎
 
Sails.js Model / ORM introduce
Sails.js Model / ORM introduceSails.js Model / ORM introduce
Sails.js Model / ORM introduce謝 宗穎
 
Demand forecasting
Demand forecastingDemand forecasting
Demand forecastingJiten Sharma
 

En vedette (9)

Model Slicing
Model SlicingModel Slicing
Model Slicing
 
Mcms and ids sig
Mcms and ids sigMcms and ids sig
Mcms and ids sig
 
Overview of the interim budget 2014 15
Overview of the interim budget 2014 15Overview of the interim budget 2014 15
Overview of the interim budget 2014 15
 
Reverse engineering and theory building v3
Reverse engineering and theory building v3Reverse engineering and theory building v3
Reverse engineering and theory building v3
 
Scrum 開發流程導入經驗分享
Scrum 開發流程導入經驗分享Scrum 開發流程導入經驗分享
Scrum 開發流程導入經驗分享
 
Demand & Supply
Demand & SupplyDemand & Supply
Demand & Supply
 
Sails.js Model / ORM introduce
Sails.js Model / ORM introduceSails.js Model / ORM introduce
Sails.js Model / ORM introduce
 
Lays Vs Bingo
Lays Vs BingoLays Vs Bingo
Lays Vs Bingo
 
Demand forecasting
Demand forecastingDemand forecasting
Demand forecasting
 

Similaire à Ocl 09

Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheeltcurdt
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesCHOOSE
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09Guy Korland
 
NetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience ReportNetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience ReportAnton Arhipov
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design PatternsZohar Arad
 
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...Akaks
 
Eclipse Modeling Framework
Eclipse Modeling FrameworkEclipse Modeling Framework
Eclipse Modeling FrameworkAjay K
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Guillaume Laforge
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsBartosz Kosarzycki
 
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016STX Next
 
EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
EclipseCon 2008: Fundamentals of the Eclipse Modeling FrameworkEclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
EclipseCon 2008: Fundamentals of the Eclipse Modeling FrameworkDave Steinberg
 
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Tudor Dragan
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript IntroductionHans Höchtl
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To ScalaPeter Maas
 

Similaire à Ocl 09 (20)

Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
 
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of TonguesChoose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
 
Deuce STM - CMP'09
Deuce STM - CMP'09Deuce STM - CMP'09
Deuce STM - CMP'09
 
NetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience ReportNetBeans Plugin Development: JRebel Experience Report
NetBeans Plugin Development: JRebel Experience Report
 
Wien15 java8
Wien15 java8Wien15 java8
Wien15 java8
 
Javascript Design Patterns
Javascript Design PatternsJavascript Design Patterns
Javascript Design Patterns
 
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...
documents.pub_new-features-in-java-8-it-jpoialjavanaitedwien15java8pdf-java-8...
 
Eclipse Modeling Framework
Eclipse Modeling FrameworkEclipse Modeling Framework
Eclipse Modeling Framework
 
Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008Groovy Introduction - JAX Germany - 2008
Groovy Introduction - JAX Germany - 2008
 
JavaScript Core
JavaScript CoreJavaScript Core
JavaScript Core
 
Kotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projectsKotlin Developer Starter in Android projects
Kotlin Developer Starter in Android projects
 
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
Kotlin Developer Starter in Android - STX Next Lightning Talks - Feb 12, 2016
 
EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
EclipseCon 2008: Fundamentals of the Eclipse Modeling FrameworkEclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
 
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
Kotlin - The Swiss army knife of programming languages - Visma Mobile Meet-up...
 
TechTalk - Dotnet
TechTalk - DotnetTechTalk - Dotnet
TechTalk - Dotnet
 
Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++Using the Windows 8 Runtime from C++
Using the Windows 8 Runtime from C++
 
TypeScript Introduction
TypeScript IntroductionTypeScript Introduction
TypeScript Introduction
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
Treinamento Qt básico - aula II
Treinamento Qt básico - aula IITreinamento Qt básico - aula II
Treinamento Qt básico - aula II
 
Introduction To Scala
Introduction To ScalaIntroduction To Scala
Introduction To Scala
 

Plus de ClarkTony

The Uncertain Enterprise
The Uncertain EnterpriseThe Uncertain Enterprise
The Uncertain EnterpriseClarkTony
 
Actors for Behavioural Simulation
Actors for Behavioural SimulationActors for Behavioural Simulation
Actors for Behavioural SimulationClarkTony
 
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...ClarkTony
 
LEAP A Language for Architecture Design, Simulation and Analysis
LEAP A Language for Architecture Design, Simulation and AnalysisLEAP A Language for Architecture Design, Simulation and Analysis
LEAP A Language for Architecture Design, Simulation and AnalysisClarkTony
 
A Common Basis for Modelling Service-Oriented and Event-Driven Architecture
A Common Basis for Modelling Service-Oriented and Event-Driven ArchitectureA Common Basis for Modelling Service-Oriented and Event-Driven Architecture
A Common Basis for Modelling Service-Oriented and Event-Driven ArchitectureClarkTony
 
Context Aware Reactive Applications
Context Aware Reactive ApplicationsContext Aware Reactive Applications
Context Aware Reactive ApplicationsClarkTony
 
Patterns 200711
Patterns 200711Patterns 200711
Patterns 200711ClarkTony
 
Kings 120711
Kings 120711Kings 120711
Kings 120711ClarkTony
 
Iswim for testing
Iswim for testingIswim for testing
Iswim for testingClarkTony
 
Iswim for testing
Iswim for testingIswim for testing
Iswim for testingClarkTony
 
Kiss at oopsla 09
Kiss at oopsla 09Kiss at oopsla 09
Kiss at oopsla 09ClarkTony
 
Onward presentation.en
Onward presentation.enOnward presentation.en
Onward presentation.enClarkTony
 
Formalizing homogeneous language embeddings
Formalizing homogeneous language embeddingsFormalizing homogeneous language embeddings
Formalizing homogeneous language embeddingsClarkTony
 
Filmstrip testing
Filmstrip testingFilmstrip testing
Filmstrip testingClarkTony
 
Dsm as theory building
Dsm as theory buildingDsm as theory building
Dsm as theory buildingClarkTony
 
Dsl overview
Dsl overviewDsl overview
Dsl overviewClarkTony
 
Dsl tutorial
Dsl tutorialDsl tutorial
Dsl tutorialClarkTony
 
Code gen 09 kiss results
Code gen 09   kiss resultsCode gen 09   kiss results
Code gen 09 kiss resultsClarkTony
 

Plus de ClarkTony (20)

The Uncertain Enterprise
The Uncertain EnterpriseThe Uncertain Enterprise
The Uncertain Enterprise
 
Actors for Behavioural Simulation
Actors for Behavioural SimulationActors for Behavioural Simulation
Actors for Behavioural Simulation
 
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...
Context-Aware Content-Centric Collaborative Workflow Management for Mobile De...
 
LEAP A Language for Architecture Design, Simulation and Analysis
LEAP A Language for Architecture Design, Simulation and AnalysisLEAP A Language for Architecture Design, Simulation and Analysis
LEAP A Language for Architecture Design, Simulation and Analysis
 
A Common Basis for Modelling Service-Oriented and Event-Driven Architecture
A Common Basis for Modelling Service-Oriented and Event-Driven ArchitectureA Common Basis for Modelling Service-Oriented and Event-Driven Architecture
A Common Basis for Modelling Service-Oriented and Event-Driven Architecture
 
Context Aware Reactive Applications
Context Aware Reactive ApplicationsContext Aware Reactive Applications
Context Aware Reactive Applications
 
Patterns 200711
Patterns 200711Patterns 200711
Patterns 200711
 
Kings 120711
Kings 120711Kings 120711
Kings 120711
 
Iswim for testing
Iswim for testingIswim for testing
Iswim for testing
 
Iswim for testing
Iswim for testingIswim for testing
Iswim for testing
 
Kiss at oopsla 09
Kiss at oopsla 09Kiss at oopsla 09
Kiss at oopsla 09
 
Scam 08
Scam 08Scam 08
Scam 08
 
Onward presentation.en
Onward presentation.enOnward presentation.en
Onward presentation.en
 
Hcse pres
Hcse presHcse pres
Hcse pres
 
Formalizing homogeneous language embeddings
Formalizing homogeneous language embeddingsFormalizing homogeneous language embeddings
Formalizing homogeneous language embeddings
 
Filmstrip testing
Filmstrip testingFilmstrip testing
Filmstrip testing
 
Dsm as theory building
Dsm as theory buildingDsm as theory building
Dsm as theory building
 
Dsl overview
Dsl overviewDsl overview
Dsl overview
 
Dsl tutorial
Dsl tutorialDsl tutorial
Dsl tutorial
 
Code gen 09 kiss results
Code gen 09   kiss resultsCode gen 09   kiss results
Code gen 09 kiss results
 

Dernier

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxBkGupta21
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????blackmambaettijean
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 

Dernier (20)

Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
unit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptxunit 4 immunoblotting technique complete.pptx
unit 4 immunoblotting technique complete.pptx
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
What is Artificial Intelligence?????????
What is Artificial Intelligence?????????What is Artificial Intelligence?????????
What is Artificial Intelligence?????????
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 

Ocl 09

  • 1. A MOP Based DSL for Testing Java Programs using OCL Tony Clark http://itcentre.tvu.ac.uk/~clark/ Centre for Model Driven Software Engineering School of Computing Thames Valley University London, UK
  • 2. context SalesSystem::placeOrder(name:String,amount:int) pre: accountsSystem.accounts->exists(a | a.cid = name) post: accountsSystem.getAccount(name).items->exists(item | item.amount = amount) and accountsSystem.getAccount(name).items->size = self@pre.accountsSystem.getAccount(name).items->size + 1 2 OCL 09
  • 3. Aim To extend XMF with a language feature for testing Java implementations. To use OCL as the constraint language. Problem: how to deal with all the possible implementation strategies for the model? OCL 09 3
  • 4. A Little OCL-based Language @MSpec <name> [<method-name>] (<args>) pre <pre-condition> do <body> post <post-condition> end @Test <name> <spec>* end OCL 09 4
  • 5. Example Test Scenario context SalesSystem @MSpecsuccessfulPlaceOrder[placeOrder](name,amount) pre accountsSystem.accounts->exists(a | a.cid = name) do run post accountsSystem.getAccount(name).items->exists(item | item.amount = amount) and accountsSystem.getAccount(name).items->size = preSelf.accountsSystem.getAccount(name).items->size + 1 end @Test Test0 successfulContact("fred") successfulRegister("fred") successfulPlaceOrder("fred",100) end OCL 09 5
  • 7. XMF and OCL @Class Account @Attribute cid : String end @Constructor(cid) end end @Class AccountsSystem @Attribute accounts : Set(Account) (+) end end @Class SalesSystem @Attribute accountsSystem : AccountsSystem = AccountsSystem() end @Operation addAccount(cid:String) accountsSystem.addToAccounts(Account(cid)) end @Operation checkNameExists(name:String):Boolean accountsSystem.accounts->exists(a | a.cid = name) end end 7 OCL 09
  • 8. Java Implementation public class Account { public String cid; ... } public class AccountsSystem { public Vector<Account> accounts = new Vector<Account>(); ... } public class SalesSystem { public AccountsSystemaccountsSystem = new AccountsSystem(); public ContactsDatabasecontactsDatabase = new ContactsDatabase(); public void addAccount(String cid) { accountsSystem.addToAccounts(new Account(cid)); } ... } OCL 09 8
  • 9. Meta Classes in XMF OCL 09 9
  • 11. Java Classes in XMF OCL 09 11
  • 12. A Metaclass: JavaClass @Class JavaClass extends Class @Attribute descriptor : JavaDescriptor (?,!) end @Operation addDescriptor(d:JavaDescriptor) xmf.foreignTypeMapping().put(d.type(),self); xmf.foreignMOPMapping().put(d.type(),d.mopName()); self.setDescriptor(d) end @Operation invoke(target,args) let class = xmf.javaClass(descriptor.type(),descriptor.paths()) in class.invoke(target,args) end end ... end OCL 09 12
  • 13. A Java MOP public class ForeignObjectMOP { public void dot(Machine m, intobj, int name) { Object o = m.getForeignObject(obj); Class<?> c = o.getClass(); Field f = c.getField(m.getString(name)); m.pushStack(f.get(o)); } public void send(Machine m, int o, int m, intargs) { // Send message and push return value... } public booleanhasSlot(Machine m, int o, int name) { // Return true when object has named slot } public void set(Machine m, int o, int name, int value) { // Set named slot... } } OCL 09 13
  • 14. XMF access to Java @Class Account metaclassJavaClass JavaDescriptor("Account","",Seq{"@/bin"}) end @Class AccountsSystemmetaclassJavaClass JavaDescriptor("AccountsSystem","",Seq{"@/bin"}) end @Class SalesSystemmetaclassJavaClass JavaDescriptor("SalesSystem","",Seq{"@/bin"}) @Operation checkNameExists(name:String):Boolean accountsSystem.accounts->exists(a | a.cid = name) end end OCL 09 14
  • 15. Making the Default MOP Explicit @Class Account metaclassJavaClass JavaDescriptor("Account",“foreignobj.ForeignObjectMOP",Seq{"@/bin"}) end context Root @Class AccountsSystemmetaclassJavaClass JavaDescriptor("AccountsSystem",“foreignobj.ForeignObjectMOP",Seq{"@/bin"}) end context Root @Class SalesSystemmetaclassJavaClass JavaDescriptor("SalesSystem","foreignobj.ForeignObjectMOP",Seq{"@/bin"}) @Operation checkNameExists(name:String):Boolean accountsSystem.accounts->exists(a | a.cid = name) end end OCL 09 15
  • 17. An EMF MOP OCL 09 17
  • 18. A Metaclass: EMFClass @Class EMFClass extends JavaClass@Operation invoke(target,args) let factory = descriptor.getFactory() then package = descriptor.getPackage() then class = package.send("get" + name,Seq{}) then object = factory.create(class) in // Set fields from args using constructor... object end end ... end OCL 09 18
  • 19. EMFMop public class EObjectMOP extends foreignobj.ForeignObjectMOP { public void dot(Machine machine, int object, int name) { EObjecteobject = (Eobject)machine.getForeignObject(object); EClasseclass = eobject.eClass(); String string = machine.getString(name); EStructuralFeature feature = eclass.getEStructuralFeature(string); machine.pushStack(eobject.eGet(feature)); } public booleanhasSlot(Machine machine, intobj, int name) { ... } public void set(Machine machine, intobj, int name, int value) { ... } } OCL 09 19
  • 20. XMF access to EMF @Class Account metaclassEMFClass EMFDescriptor("sales.impl.AccountImpl","sales","sales","test.EObjectMOP") @Constructor(cid) end end @Class AccountsSystemmetaclassEMFClass EMFDescriptor("sales.impl.AccountsSystemImpl","sales","sales","test.EObjectMOP") end @Class SalesSystemmetaclassEMFClass EMFDescriptor("sales.impl.SalesSystemImpl","sales","sales","test.EObjectMOP") @Operation init() self.accountsSystem := AccountsSystem() end @Operation addAccount(cid:String) accountsSystem.getAccounts().add(Account(cid)) end @Operation checkNameExists(name:String):Boolean accountsSystem.accounts->exists(a | a.cid = name) end end OCL 09 20
  • 21. Implementing the DSL 21 OCL 09
  • 22. Example @MSpecsuccessfulPlaceOrder[placeOrder](name,amount) pre accountsSystem.accounts->exists(a | a.cid = name) do run post accountsSystem.getAccount(name).items->exists(...) and ... end @Operation successfulPlaceOrder(.args) let name = args->at(0) amount = args->at(1) in let preSelf = self.deepCopy() in if accountsSystem.accounts->exists(a | a.cid = name) then let result = self.send(“placeOrder”,Seq{name,amount}) in if accountsSystem.getAccount(name).items->exists(...) and ... then CallSucceeds(result,”placeOrder”,args) else PostFails(“placeOrder”,args) end end else PreFails(“placeOrder”,args) end end end end OCL 09 22