[lsc-changes] r285 - in lsc/trunk/src: main/java/org/lsc main/java/org/lsc/beans test/java/org/lsc test/resources

sbahloul at lsc-project.org sbahloul at lsc-project.org
Tue Jul 7 16:43:57 CEST 2009


Author: sbahloul
Date: 2009-07-07 16:43:57 +0200 (Tue, 07 Jul 2009)
New Revision: 285

Modified:
   lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java
   lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java
   lsc/trunk/src/test/java/org/lsc/Ldap2LdapSyncTest.java
   lsc/trunk/src/test/resources/lsc.properties
Log:
Fixing new LSC core without generation to fit tests

Modified: lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java	2009-07-07 11:17:58 UTC (rev 284)
+++ lsc/trunk/src/main/java/org/lsc/AbstractSynchronize.java	2009-07-07 14:43:57 UTC (rev 285)
@@ -172,15 +172,6 @@
         Map<String, Object> conditionObjects = null;
         
         AbstractBean taskBean;
-		try {
-			taskBean = taskBeanClass.newInstance();
-		} catch (InstantiationException e) {
-            LOGGER.error("Error while instanciating taskbean class: " + e, e);
-            return;
-		} catch (IllegalAccessException e) {
-            LOGGER.error("Error while instanciating taskbean class: " + e, e);
-            return;
-		}
         
         // Loop on all entries in the destination and delete them if they're not found in the source
         while (ids.hasNext()) {
@@ -189,6 +180,15 @@
             Entry<String, LscAttributes> id = ids.next();
 
             try {
+        		try {
+        			taskBean = taskBeanClass.newInstance();
+        		} catch (InstantiationException e) {
+                    LOGGER.error("Error while instanciating taskbean class: " + e, e);
+                    return;
+        		} catch (IllegalAccessException e) {
+                    LOGGER.error("Error while instanciating taskbean class: " + e, e);
+                    return;
+        		}
                 // Search for the corresponding object in the source
             	taskBean = srcService.getBean(taskBean, id);
 

Modified: lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java
===================================================================
--- lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java	2009-07-07 11:17:58 UTC (rev 284)
+++ lsc/trunk/src/main/java/org/lsc/beans/AbstractBean.java	2009-07-07 14:43:57 UTC (rev 285)
@@ -478,7 +478,14 @@
 		Attribute attribute = getAttributeById(id);
 		for (int i = 0; attribute != null && i < attribute.size(); i++)
 		{
-			resultsArray.add(attribute.get(i).toString());
+			Object value = attribute.get(i);
+			if( value instanceof String) {
+				resultsArray.add((String)value);
+			} else if ( value instanceof byte[]) {
+				resultsArray.add(new String((byte[])value));
+			} else {
+				resultsArray.add(value.toString());
+			}
 		}
 
 		return resultsArray;

Modified: lsc/trunk/src/test/java/org/lsc/Ldap2LdapSyncTest.java
===================================================================
--- lsc/trunk/src/test/java/org/lsc/Ldap2LdapSyncTest.java	2009-07-07 11:17:58 UTC (rev 284)
+++ lsc/trunk/src/test/java/org/lsc/Ldap2LdapSyncTest.java	2009-07-07 14:43:57 UTC (rev 285)
@@ -115,7 +115,7 @@
 
 		ISrcService srcService = new SimpleJndiSrcService(Configuration.getAsProperties("lsc.tasks." +  TASK_NAME + ".srcService"));
 		AbstractBean srcBean = srcService.getBean(new personBean(), ids.entrySet().iterator().next());
-		String userPassword = srcBean.getAttributeValueById("userPassword");
+		String userPassword = srcBean.getAttributeFirstValueById("userPassword");
 		
 		// OpenDS automatically hashes the password using seeded SHA,
 		// so we can't test the full value, just the beginning.

Modified: lsc/trunk/src/test/resources/lsc.properties
===================================================================
--- lsc/trunk/src/test/resources/lsc.properties	2009-07-07 11:17:58 UTC (rev 284)
+++ lsc/trunk/src/test/resources/lsc.properties	2009-07-07 14:43:57 UTC (rev 285)
@@ -27,11 +27,13 @@
 lsc.tasks.sampleTask.type = db2ldap
 lsc.tasks.sampleTask.srcService = org.lsc.service.InetOrgPersonJdbcService
 lsc.tasks.sampleTask.dstService = org.lsc.jndi.InetOrgPersonJndiService
-lsc.tasks.sampleTask.object = org.lsc.objects.inetOrgPerson
+# lsc.tasks.sampleTask.object = org.lsc.objects.inetOrgPerson
 lsc.tasks.sampleTask.bean = org.lsc.beans.inetOrgPersonBean
 
 lsc.syncoptions.sampleTask = org.lsc.beans.syncoptions.PropertiesBasedSyncOptions
 lsc.syncoptions.sampleTask.default.action = K
+lsc.syncoptions.sampleTask.objectClass.action = K
+lsc.syncoptions.sampleTask.objectClass.default_value = "inetOrgPerson", "organizationalPerson", "person", "top"
 lsc.syncoptions.sampleTask.sampleAttribute.action = K
 lsc.syncoptions.sampleTask.sampleAttribute.create_value = someSampleValue
 lsc.syncoptions.sampleTask.JsAttribute.action = F
@@ -40,7 +42,6 @@
 lsc.syncoptions.sampleTask.DelimitedAttribute.force_value = "a"$"b" 
 
 lsc.tasks.ldap2ldapTestTask.type = ldap2ldap
-lsc.tasks.ldap2ldapTestTask.object = org.lsc.objects.person
 lsc.tasks.ldap2ldapTestTask.bean = org.lsc.beans.personBean
 lsc.tasks.ldap2ldapTestTask.dn = "cn=" + srcBean.getAttributeValueById("cn") + ",ou=ldap2ldap2TestTaskDst,ou=Test Data"
 lsc.tasks.ldap2ldapTestTask.srcService = org.lsc.jndi.SimpleJndiSrcService
@@ -62,6 +63,7 @@
 lsc.syncoptions.ldap2ldapTestTask.description.action = M
 lsc.syncoptions.ldap2ldapTestTask.description.default_value = srcBean.getAttributeValueById("userPassword")
 lsc.syncoptions.ldap2ldapTestTask.objectclass.action = F
+lsc.syncoptions.ldap2ldapTestTask.objectclass.default_value = "person", "top"
 lsc.syncoptions.ldap2ldapTestTask.userPassword.action = F
 lsc.syncoptions.ldap2ldapTestTask.userPassword.force_value = "secret" + srcBean.getAttributeValueById("cn")
 lsc.syncoptions.ldap2ldapTestTask.telephoneNumber.action = M



More information about the lsc-changes mailing list