geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From djen...@apache.org
Subject cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/ejb BaseEjbJarTest.java EjbValidator.java SessionBeanTests.java
Date Thu, 12 Feb 2004 08:19:27 GMT
djencks     2004/02/12 00:19:27

  Modified:    modules/core/src/java/org/apache/geronimo/validator
                        AbstractValidator.java ValidationContext.java
                        ValidationTest.java Validator.java
               modules/core/src/java/org/apache/geronimo/validator/ejb
                        BaseEjbJarTest.java EjbValidator.java
                        SessionBeanTests.java
  Log:
  convert verifier framework to xmlbeans
  
  Revision  Changes    Path
  1.2       +16 -9     incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/AbstractValidator.java
  
  Index: AbstractValidator.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/AbstractValidator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractValidator.java	2 Sep 2003 17:04:19 -0000	1.1
  +++ AbstractValidator.java	12 Feb 2004 08:19:27 -0000	1.2
  @@ -56,15 +56,22 @@
   package org.apache.geronimo.validator;
   
   import java.io.PrintWriter;
  -import java.util.*;
  +import java.lang.reflect.InvocationTargetException;
   import java.lang.reflect.Method;
   import java.lang.reflect.Modifier;
  -import java.lang.reflect.InvocationTargetException;
  +import java.util.HashMap;
  +import java.util.HashSet;
  +import java.util.Iterator;
  +import java.util.Map;
  +import java.util.Set;
  +
   import javax.enterprise.deploy.shared.ModuleType;
  +
  +import org.apache.commons.jxpath.JXPathContext;
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogFactory;
  -import org.apache.commons.jxpath.JXPathContext;
  -import org.apache.geronimo.deployment.model.DeploymentDescriptor;
  +import org.apache.xmlbeans.XmlObject;
  +import org.apache.xmlbeans.SchemaType;
   
   /**
    * The base class for actual validators.  Each validator groups all the tests
  @@ -92,7 +99,7 @@
        * @return <tt>true</tt>, since this implementation doesn't actually check
        *         anything.
        */
  -    public boolean initialize(PrintWriter out, String moduleName, ClassLoader loader, ModuleType
type, DeploymentDescriptor[] standardDD, Object[] serverDD) {
  +    public boolean initialize(PrintWriter out, String moduleName, ClassLoader loader, ModuleType
type, XmlObject[] standardDD, Object[] serverDD) {
           context = new ValidationContext(loader, moduleName, out, serverDD, standardDD,
type);
           return true;
       }
  @@ -117,8 +124,8 @@
           Class[] classes = getTestClasses();
           Map map = new HashMap();
           for(int i = 0; i < context.standardDD.length; i++) {
  -            DeploymentDescriptor object = context.standardDD[i];
  -            map.put(object.getFileName(), object);
  +            XmlObject object = context.standardDD[i];
  +            map.put(object.schemaType(), object);
           }
           Set missing = new HashSet();
           masterLoop:
  @@ -129,7 +136,7 @@
               }
               try {
                   ValidationTest test = (ValidationTest)cls.newInstance();
  -                String dd = test.getStandardDDName();
  +                SchemaType dd = test.getSchemaType();
                   String xpath = test.getXpath();
                   if(dd == null) { // Call this once per module
                       ValidationResult temp = executeTest(cls, test, context);
  
  
  
  1.2       +6 -4      incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/ValidationContext.java
  
  Index: ValidationContext.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/ValidationContext.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ValidationContext.java	2 Sep 2003 17:04:19 -0000	1.1
  +++ ValidationContext.java	12 Feb 2004 08:19:27 -0000	1.2
  @@ -56,8 +56,10 @@
   package org.apache.geronimo.validator;
   
   import java.io.PrintWriter;
  +
   import javax.enterprise.deploy.shared.ModuleType;
  -import org.apache.geronimo.deployment.model.DeploymentDescriptor;
  +
  +import org.apache.xmlbeans.XmlObject;
   
   /**
    * Holds all the context information for the current validation process.
  @@ -69,12 +71,12 @@
       public final String moduleName;
       public final ClassLoader loader;
       public final ModuleType type;
  -    public final DeploymentDescriptor[] standardDD;
  +    public final XmlObject[] standardDD;
       public final Object[] serverDD;
       private Object currentStandardDD;
       private Object currentNode;
   
  -    public ValidationContext(ClassLoader loader, String moduleName, PrintWriter out, Object[]
serverDD, DeploymentDescriptor[] standardDD, ModuleType type) {
  +    public ValidationContext(ClassLoader loader, String moduleName, PrintWriter out, Object[]
serverDD, XmlObject[] standardDD, ModuleType type) {
           this.loader = loader;
           this.moduleName = moduleName;
           this.out = out;
  
  
  
  1.2       +5 -3      incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/ValidationTest.java
  
  Index: ValidationTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/ValidationTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ValidationTest.java	2 Sep 2003 17:04:19 -0000	1.1
  +++ ValidationTest.java	12 Feb 2004 08:19:27 -0000	1.2
  @@ -55,6 +55,8 @@
    */
   package org.apache.geronimo.validator;
   
  +import org.apache.xmlbeans.SchemaType;
  +
   /**
    * The base class for all validation tests.  They will work similarly to JUnit
    * tests, in that any method beginning with "test" will be executed.  The test
  @@ -83,7 +85,7 @@
        *          as "ejb-jar.xml"), or <tt>null</tt> to be invoked with
        *         no particular DD context.
        */
  -    public abstract String getStandardDDName();
  +    public abstract SchemaType getSchemaType();
   
       /**
        * Any given test class can be associated with a specific XPath in its
  @@ -95,7 +97,7 @@
        *
        * @return An Xpath of interest to this test class, or <tt>null</tt> if
        *         the class should be invoked once on the entire deployment
  -     *         descriptor or module.  If getStandardDDName returns null,
  +     *         descriptor or module.  If getSchemaType returns null,
        *         this method nust return null as well.
        */
       public abstract String getXpath();
  
  
  
  1.2       +5 -3      incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/Validator.java
  
  Index: Validator.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/Validator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Validator.java	2 Sep 2003 17:04:19 -0000	1.1
  +++ Validator.java	12 Feb 2004 08:19:27 -0000	1.2
  @@ -56,8 +56,10 @@
   package org.apache.geronimo.validator;
   
   import java.io.PrintWriter;
  +
   import javax.enterprise.deploy.shared.ModuleType;
  -import org.apache.geronimo.deployment.model.DeploymentDescriptor;
  +
  +import org.apache.xmlbeans.XmlObject;
   
   /**
    * The main interface for all application validators.  To use one, you
  @@ -93,7 +95,7 @@
        *         validator does not handle this module type, the expected
        *         deployment descriptors are missing, etc.
        */
  -    public boolean initialize(PrintWriter out, String moduleName, ClassLoader loader, ModuleType
type, DeploymentDescriptor[] standardDD, Object[] serverDD);
  +    public boolean initialize(PrintWriter out, String moduleName, ClassLoader loader, ModuleType
type, XmlObject[] standardDD, Object[] serverDD);
   
       /**
        *
  
  
  
  1.2       +11 -9     incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/ejb/BaseEjbJarTest.java
  
  Index: BaseEjbJarTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/ejb/BaseEjbJarTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BaseEjbJarTest.java	2 Sep 2003 17:04:20 -0000	1.1
  +++ BaseEjbJarTest.java	12 Feb 2004 08:19:27 -0000	1.2
  @@ -56,11 +56,13 @@
   package org.apache.geronimo.validator.ejb;
   
   import javax.enterprise.deploy.shared.ModuleType;
  -import org.apache.geronimo.validator.ValidationTest;
  -import org.apache.geronimo.validator.ValidationResult;
  +
   import org.apache.geronimo.validator.ValidationContext;
  -import org.apache.geronimo.deployment.model.ejb.EjbJar;
  -import org.apache.geronimo.deployment.model.ejb.EjbJarDocument;
  +import org.apache.geronimo.validator.ValidationResult;
  +import org.apache.geronimo.validator.ValidationTest;
  +import org.apache.geronimo.xbeans.j2ee.EjbJarType;
  +import org.apache.geronimo.xbeans.j2ee.EjbJarDocument;
  +import org.apache.xmlbeans.SchemaType;
   
   /**
    * Barely worth having, but this implements one method to return the name of
  @@ -70,17 +72,17 @@
    * @version $Revision$ $Date$
    */
   public abstract class BaseEjbJarTest extends ValidationTest {
  -    protected EjbJar ejbJar;
  +    protected EjbJarType ejbJar;
   
  -    public String getStandardDDName() {
  -        return "ejb-jar.xml";
  +    public SchemaType getSchemaType() {
  +        return EjbJarDocument.type;
       }
   
       public ValidationResult initialize(ValidationContext context) {
           if(context.type != ModuleType.EJB) {
               return ValidationResult.FAILED;
           } else {
  -            ejbJar = ((EjbJarDocument) context.getCurrentStandardDD()).getEjbJar();
  +            ejbJar = ((org.apache.geronimo.xbeans.j2ee.EjbJarDocument) context.getCurrentStandardDD()).getEjbJar();
               return ValidationResult.PASSED;
           }
       }
  
  
  
  1.4       +6 -13     incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/ejb/EjbValidator.java
  
  Index: EjbValidator.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/ejb/EjbValidator.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EjbValidator.java	22 Jan 2004 08:47:26 -0000	1.3
  +++ EjbValidator.java	12 Feb 2004 08:19:27 -0000	1.4
  @@ -63,15 +63,11 @@
   import java.net.URLClassLoader;
   
   import javax.enterprise.deploy.shared.ModuleType;
  -import javax.xml.parsers.DocumentBuilder;
  -import javax.xml.parsers.DocumentBuilderFactory;
   
  -import org.apache.geronimo.deployment.model.DeploymentDescriptor;
  -import org.apache.geronimo.deployment.model.ejb.EjbJarDocument;
   import org.apache.geronimo.validator.AbstractValidator;
   import org.apache.geronimo.validator.Validator;
  -import org.apache.geronimo.xml.deployment.EjbJarLoader;
  -import org.w3c.dom.Document;
  +import org.apache.geronimo.xbeans.j2ee.EjbJarDocument;
  +import org.apache.xmlbeans.XmlObject;
   
   /**
    * The validator class for validating an EJB JAR.  Right now just does enough
  @@ -93,13 +89,10 @@
           try {
               ClassLoader loader = new URLClassLoader(new URL[]{new File(args[0]).toURL()});
               InputStream in = loader.getResourceAsStream("META-INF/ejb-jar.xml");
  -            DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
  -            DocumentBuilder builder = factory.newDocumentBuilder();
  -            Document doc = builder.parse(in);
  -            EjbJarLoader jarLoader = new EjbJarLoader();
  -            EjbJarDocument jar = jarLoader.load(doc);
  +
  +            EjbJarDocument jar = EjbJarDocument.Factory.parse(in);
               Validator v =new EjbValidator();
  -            v.initialize(new PrintWriter(new OutputStreamWriter(System.out), true), args[0],
loader, ModuleType.EJB, new DeploymentDescriptor[]{jar}, null);
  +            v.initialize(new PrintWriter(new OutputStreamWriter(System.out), true), args[0],
loader, ModuleType.EJB, new XmlObject[]{jar}, null);
               System.out.println("Validation Result: "+v.validate());
           } catch(Exception e) {
               e.printStackTrace();
  
  
  
  1.3       +6 -6      incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/ejb/SessionBeanTests.java
  
  Index: SessionBeanTests.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/modules/core/src/java/org/apache/geronimo/validator/ejb/SessionBeanTests.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SessionBeanTests.java	17 Sep 2003 01:47:15 -0000	1.2
  +++ SessionBeanTests.java	12 Feb 2004 08:19:27 -0000	1.3
  @@ -60,7 +60,7 @@
   import javax.ejb.SessionBean;
   import org.apache.geronimo.validator.ValidationResult;
   import org.apache.geronimo.validator.ValidationContext;
  -import org.apache.geronimo.deployment.model.ejb.Session;
  +import org.apache.geronimo.xbeans.j2ee.SessionBeanType;
   
   /**
    * Some basic tests for session beans.  Right now this is not exhaustive, but
  @@ -69,7 +69,7 @@
    * @version $Revision$ $Date$
    */
   public class SessionBeanTests extends BaseEjbJarTest {
  -    protected Session bean;
  +    protected SessionBeanType bean;
   
       /**
        * Get called for each session bean element in the standard DD.
  @@ -82,7 +82,7 @@
        * Trap the actual bean to examine.
        */
       public ValidationResult initialize(ValidationContext context) {
  -        bean = (Session) context.getCurrentNode();
  +        bean = (SessionBeanType) context.getCurrentNode();
           return super.initialize(context);
       }
   
  @@ -91,7 +91,7 @@
        * criteria.
        */
       public ValidationResult testBeanImplementationClass() {
  -        Class cls = loadClass(bean.getEJBClass(), "Session Bean Implementation Class");
  +        Class cls = loadClass(bean.getEjbClass().getStringValue(), "Session Bean Implementation
Class");
           ValidationResult result = ValidationResult.PASSED;
           if(!Modifier.isPublic(cls.getModifiers())) {
               result = error("ejb.impl.not.public", result);
  @@ -132,7 +132,7 @@
           if(bean.getHome() == null) {
               return result;
           }
  -        Class cls = loadClass(bean.getHome(), "Session Bean Home Class");
  +        Class cls = loadClass(bean.getHome().getStringValue(), "Session Bean Home Class");
           if(!EJBHome.class.isAssignableFrom(cls)) {
               result = error("ejb.home.wrong.superclass", result);
           }
  
  
  

Mime
View raw message