package fr.norsys.mapper.jndi;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import junit.framework.TestCase;
import fr.norsys.mapper.core.MapperException;
import fr.norsys.mapper.manager.MapperManager;
import fr.norsys.mapper.xml.XMLConfigurator;
import fr.norsys.mapper.xml.XMLConfiguratorException;
/**
* Integration testing class for JNDI configuration.
* This class executes a simple user creation, modification and deletion
* scenario using the mappings defined in the file
* <code>jndi-sample-habilitations.xml</code>. The backend
* used is a mock object.
* @author nono
*
*/
public class JNDIIntegrationTest extends TestCase {
private XMLConfigurator xc;
private MapperManager mgr;
protected void setUp() throws Exception {
super.setUp();
this.xc = new XMLConfigurator();
this.mgr = new MapperManager();
}
public void test01Base() throws MapperException, XMLConfiguratorException {
// parse XML configuration file
xc.parse(Thread.currentThread().getContextClassLoader().getResourceAsStream("jndi-sample-habilitation.xml"));
// configure manager
this.xc.configure(this.mgr);
this.mgr.set("ldifsource","canam.ldif");
this.mgr.setConfigured();
this.mgr.start();
// creer un utilisateur
SearchMapper sm = (SearchMapper)this.mgr.getMapper("searchUser");
Map input = new HashMap();
input.put("id","ut011107");
input.put("libelle","");
List l = sm.search(input,null);
assertTrue(!l.isEmpty());
}
}