com.evolveum.icf.dummy.resource
Class DummyResource

java.lang.Object
  extended by com.evolveum.icf.dummy.resource.DummyResource

public class DummyResource
extends java.lang.Object

Resource for use with dummy ICF connector. This is a simple Java object that pretends to be a resource. It has accounts and account schema. It has operations to manipulate accounts, execute scripts and so on almost like a real resource. The purpose is to simulate a real resource with avery little overhead. The resource is a singleton, therefore the resource instance can be shared by the connector and the test code. The usual story is like this: 1) test class fetches first instance of the resource (getInstance). This will cause loading of the resource class in the test (parent) classloader. 2) test class configures the connector (e.g. schema) usually by calling the populateWithDefaultSchema() method. 3) test class initializes IDM. This will cause connector initialization. The connector will fetch the instance of dummy resource. As it was loaded by the parent classloader, it will get the same instance as the test class. 4) test class invokes IDM operation. That will invoke connector and change the resource. 5) test class will access resource directly to see if the operation went OK. The dummy resource is a separate package (JAR) from the dummy connector. Connector has its own classloader. If the resource would be the same package as connector, it will get loaded by the connector classloader regardless whether it is already loaded by the parent classloader.

Author:
Radovan Semancik

Method Summary
 java.lang.String addAccount(DummyAccount newAccount)
           
 void deleteAccount(java.lang.String id)
           
 DummyAccount getAccountByUsername(java.lang.String username)
           
 DummyObjectClass getAccountObjectClass()
           
static DummyResource getInstance()
           
 java.util.List<java.lang.String> getScriptHistory()
          Returns script history ordered chronologically (oldest first).
 java.util.Collection<DummyAccount> listAccounts()
           
 void populateWithDefaultSchema()
          Populates the resource with some kind of "default" schema.
 void purgeScriptHistory()
          Clears the script history.
 void runScript(java.lang.String scriptCode)
          Pretend to run script on the resource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static DummyResource getInstance()

getAccountObjectClass

public DummyObjectClass getAccountObjectClass()

listAccounts

public java.util.Collection<DummyAccount> listAccounts()

getAccountByUsername

public DummyAccount getAccountByUsername(java.lang.String username)

addAccount

public java.lang.String addAccount(DummyAccount newAccount)
                            throws ObjectAlreadyExistsException
Throws:
ObjectAlreadyExistsException

deleteAccount

public void deleteAccount(java.lang.String id)
                   throws ObjectDoesNotExistException
Throws:
ObjectDoesNotExistException

getScriptHistory

public java.util.List<java.lang.String> getScriptHistory()
Returns script history ordered chronologically (oldest first).

Returns:
script history

purgeScriptHistory

public void purgeScriptHistory()
Clears the script history.


runScript

public void runScript(java.lang.String scriptCode)
Pretend to run script on the resource. The script is actually not executed, it is only recorded in the script history and can be fetched by getScriptHistory().

Parameters:
scriptCode - code of the script

populateWithDefaultSchema

public void populateWithDefaultSchema()
Populates the resource with some kind of "default" schema. This is a schema that should suit majority of basic test cases.



Copyright © 2011 evolveum. All Rights Reserved.