String url = myClassLoader.getResource("test.txt").toString();
url = url.substring(0, url.length()-8);
// Contribute the SCA contribution
TestModelResolver myResolver = new TestModelResolver(myClassLoader);
ContributionService contributionService = domain.getContributionService();
Contribution contribution = contributionService.contribute("http://test/contribution", new URL(url), myResolver, false);
assertNotNull(contribution);
// Decide which SCA composite I want to deploy
Composite myComposite = myResolver.getComposite(new QName("http://sample/crud", "crud"));
// Add the deployable composite to the domain
EmbeddedSCADomain.DomainCompositeHelper domainHelper = domain.getDomainCompositeHelper();
domainHelper.addComposite(myComposite);
// Start the components in my composite
domainHelper.startComposite(myComposite);
// At this point the domain contains my contribution, my composite and
// it's started, my application code can start using it
// Get the CRUDServiceComponent service
CRUD service = domain.getService(CRUD.class, "CRUDServiceComponent");
// Invoke the service
String id = service.create("ABC");
Object result = service.retrieve(id);
assertEquals("ABC", result);
service.update(id, "EFG");
result = service.retrieve(id);
assertEquals("EFG", result);
service.delete(id);
result = service.retrieve(id);
assertNull(result);
// Stop my composite
domainHelper.stopComposite(myComposite);
// Remove my composite
domainHelper.removeComposite(myComposite);
// Remove my contribution
contributionService.remove("http://test/contribution");
// Stop the domain
domain.stop();
}