Fixes ClassLoader testcase
authorIván Perdomo <ivan.perdomo@openbravo.com>
Mon, 13 Dec 2010 16:50:47 +0100
changeset 9103 cf8a679bf9fc
parent 9102 b8ec45242e12
child 9104 354ce81fe5da
Fixes ClassLoader testcase
- Fixes ClassLoaderTest to check the registered ad_model_object separately
- Fixes a registered but removed class in selector module
modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/AD_MODEL_OBJECT.xml
src-test/org/openbravo/test/model/ClassLoaderTest.java
--- a/modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Mon Dec 13 16:46:57 2010 +0100
+++ b/modules/org.openbravo.userinterface.selector/src-db/database/sourcedata/AD_MODEL_OBJECT.xml	Mon Dec 13 16:50:47 2010 +0100
@@ -96,18 +96,6 @@
 <!--9499049ACBF74F20A17AAC318D501BC8-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
 <!--9499049ACBF74F20A17AAC318D501BC8--></AD_MODEL_OBJECT>
 
-<!--AF7E3379D2C848AB817DD027CE7FE114--><AD_MODEL_OBJECT>
-<!--AF7E3379D2C848AB817DD027CE7FE114-->  <AD_MODEL_OBJECT_ID><![CDATA[AF7E3379D2C848AB817DD027CE7FE114]]></AD_MODEL_OBJECT_ID>
-<!--AF7E3379D2C848AB817DD027CE7FE114-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
-<!--AF7E3379D2C848AB817DD027CE7FE114-->  <AD_ORG_ID><![CDATA[0]]></AD_ORG_ID>
-<!--AF7E3379D2C848AB817DD027CE7FE114-->  <ISACTIVE><![CDATA[Y]]></ISACTIVE>
-<!--AF7E3379D2C848AB817DD027CE7FE114-->  <ACTION><![CDATA[P]]></ACTION>
-<!--AF7E3379D2C848AB817DD027CE7FE114-->  <CLASSNAME><![CDATA[org.openbravo.userinterface.selector.SelectorFieldCallOut]]></CLASSNAME>
-<!--AF7E3379D2C848AB817DD027CE7FE114-->  <ISDEFAULT><![CDATA[N]]></ISDEFAULT>
-<!--AF7E3379D2C848AB817DD027CE7FE114-->  <AD_CALLOUT_ID><![CDATA[2D5D283AB1404E0683E389E4210E473D]]></AD_CALLOUT_ID>
-<!--AF7E3379D2C848AB817DD027CE7FE114-->  <OBJECT_TYPE><![CDATA[S]]></OBJECT_TYPE>
-<!--AF7E3379D2C848AB817DD027CE7FE114--></AD_MODEL_OBJECT>
-
 <!--E2B2B73069734E0285BCB6E42E24999C--><AD_MODEL_OBJECT>
 <!--E2B2B73069734E0285BCB6E42E24999C-->  <AD_MODEL_OBJECT_ID><![CDATA[E2B2B73069734E0285BCB6E42E24999C]]></AD_MODEL_OBJECT_ID>
 <!--E2B2B73069734E0285BCB6E42E24999C-->  <AD_CLIENT_ID><![CDATA[0]]></AD_CLIENT_ID>
--- a/src-test/org/openbravo/test/model/ClassLoaderTest.java	Mon Dec 13 16:46:57 2010 +0100
+++ b/src-test/org/openbravo/test/model/ClassLoaderTest.java	Mon Dec 13 16:50:47 2010 +0100
@@ -25,6 +25,7 @@
 import org.hibernate.criterion.Expression;
 import org.openbravo.dal.service.OBCriteria;
 import org.openbravo.dal.service.OBDal;
+import org.openbravo.dal.service.OBQuery;
 import org.openbravo.model.ad.domain.ModelImplementation;
 import org.openbravo.test.base.BaseTest;
 
@@ -47,9 +48,6 @@
 
     setSystemAdministratorContext();
 
-    OBCriteria<ModelImplementation> obc = OBDal.getInstance().createCriteria(
-        ModelImplementation.class);
-
     // "S" - "Servlet"
     // "C" - "ContextParam"
     // "L" - "Listener"
@@ -57,27 +55,50 @@
     // "F" - "Filter"
     // "R" - "Resource"
 
-    final String[] in = { "S", "L", "F" };
+    final String[] in = { "L", "F" };
 
+    // Checking listener and filters classes
+    OBCriteria<ModelImplementation> obc = OBDal.getInstance().createCriteria(
+        ModelImplementation.class);
     obc.add(Expression.in(ModelImplementation.PROPERTY_OBJECTTYPE, in));
 
     for (ModelImplementation mi : obc.list()) {
       try {
-
-        if (mi.getId().equals("801180")) {
-          // Ugly hack!!!
-          // Check issue
-          // https://issues.openbravo.com/view.php?id=12429
-          continue;
-        }
-
-        // Testing if the defined class can be loaded
         Class.forName(mi.getJavaClassName());
-
       } catch (ClassNotFoundException e) {
         notFoundClasses.add(mi.getId() + " : " + mi.getJavaClassName());
       }
     }
+
+    // Checking manual servlets
+    obc = OBDal.getInstance().createCriteria(ModelImplementation.class);
+    obc.add(Expression.eq(ModelImplementation.PROPERTY_OBJECTTYPE, "S"));
+    obc.add(Expression.isNull(ModelImplementation.PROPERTY_TAB));
+
+    for (ModelImplementation mi : obc.list()) {
+      try {
+        if (mi.getId().equals("801180")) {
+          // Ugly hack! check issue https://issues.openbravo.com/view.php?id=12429
+          continue;
+        }
+        Class.forName(mi.getJavaClassName());
+      } catch (ClassNotFoundException e) {
+        notFoundClasses.add(mi.getId() + " : " + mi.getJavaClassName());
+      }
+    }
+
+    // Checking servlets associated to tabs
+    OBQuery<ModelImplementation> obq = OBDal.getInstance().createQuery(ModelImplementation.class,
+        "objectType = 'S' and tab is not null and tab.active = true and tab.window.active = true");
+
+    for (ModelImplementation mi : obq.list()) {
+      try {
+        Class.forName(mi.getJavaClassName());
+      } catch (ClassNotFoundException e) {
+        notFoundClasses.add(mi.getId() + " : " + mi.getJavaClassName());
+      }
+    }
+
     if (notFoundClasses.size() > 0) {
       for (String nf : notFoundClasses) {
         log.error(nf);