dain        2005/06/23 00:28:03

  Modified:    modules/core/src/test/org/openejb/corba/compiler Foo.java
                        PortableStubCompilerTest.java
  Added:       modules/core/src/test/org/openejb/corba/compiler
                        BeanProperties.java
  Log:

  Added support for attribute name mangling
  
  Revision  Changes    Path
  1.2       +2 -8      
openejb/modules/core/src/test/org/openejb/corba/compiler/Foo.java
  
  Index: Foo.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/test/org/openejb/corba/compiler/Foo.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Foo.java  21 Jun 2005 01:22:14 -0000      1.1
  +++ Foo.java  23 Jun 2005 04:28:03 -0000      1.2
  @@ -53,12 +53,6 @@
   import org.openejb.corba.compiler.other.Donkey;
   import org.openejb.corba.compiler.other.DonkeyEx;
   import org.openejb.corba.compiler.other.Generic$Interface;
  -import org.openejb.corba.compiler.BooException;
  -import org.openejb.corba.compiler.other.BlahEx;
  -import org.openejb.corba.compiler.other.CheeseIDLEntity;
  -import org.openejb.corba.compiler.other.Donkey;
  -import org.openejb.corba.compiler.other.DonkeyEx;
  -import org.openejb.corba.compiler.other.Generic$Interface;
   
   /**
    * @version $Rev$ $Date$
  
  
  
  1.6       +32 -34    
openejb/modules/core/src/test/org/openejb/corba/compiler/PortableStubCompilerTest.java
  
  Index: PortableStubCompilerTest.java
  ===================================================================
  RCS file: 
/home/projects/openejb/scm/openejb/modules/core/src/test/org/openejb/corba/compiler/PortableStubCompilerTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- PortableStubCompilerTest.java     23 Jun 2005 00:56:43 -0000      1.5
  +++ PortableStubCompilerTest.java     23 Jun 2005 04:28:03 -0000      1.6
  @@ -46,6 +46,7 @@
   
   import java.io.File;
   import java.io.FileInputStream;
  +import java.io.IOException;
   import java.lang.reflect.Method;
   import java.util.HashSet;
   import java.util.Properties;
  @@ -59,45 +60,26 @@
   public class PortableStubCompilerTest extends TestCase {
       private static final File basedir = new 
File(System.getProperty("basedir", System.getProperty("user.dir")));
   
  -    public void testBasicNameMangler() throws Exception {
  -        Properties nameManglerProperties = new Properties();
  -        File file = new File(basedir, 
"src/test-resources/nameMangler.properties");
  -        nameManglerProperties.load(new FileInputStream(file));
  -
  -        Set methodSignatures = new HashSet();
  -        IiopOperation[] iiopOperations = 
PortableStubCompiler.createIiopOperations(Foo.class);
  -        for (int i = 0; i < iiopOperations.length; i++) {
  -            IiopOperation iiopOperation = iiopOperations[i];
  -            Method method = iiopOperation.getMethod();
  -            String methodSignature = method.getName() + "(";
  -
  -            Class[] parameterTypes = method.getParameterTypes();
  -            for (int j = 0; j < parameterTypes.length; j++) {
  -                Class parameterType = parameterTypes[j];
  -                String arrayBrackets = "";
  -                while (parameterType.isArray()) {
  -                    arrayBrackets += "[]";
  -                    parameterType = parameterType.getComponentType();
  -                }
  -                methodSignature += parameterType.getName() + arrayBrackets;
  -            }
  -            methodSignature += ")";
  -            methodSignatures.add(methodSignature);
  -
  -            assertTrue("Method not present in name mangler properties: " + 
methodSignature, nameManglerProperties.containsKey(methodSignature));
  -            assertEquals(nameManglerProperties.getProperty(methodSignature), 
iiopOperation.getName());
  -        }
  +    public void testBeanPropertiesNameMangler() throws Exception {
  +        
assertMangling("src/test-resources/beanPropertiesNameMangler.properties", 
BeanProperties.class);
  +    }
   
  -        assertEquals("Did not match all methods", 
nameManglerProperties.keySet(), methodSignatures);
  +    public void testBasicNameMangler() throws Exception {
  +        assertMangling("src/test-resources/nameMangler.properties", 
Foo.class);
       }
   
       public void testSpecialNameMangler() throws Exception {
  +        assertMangling("src/test-resources/specialNameMangler.properties", 
Special.class);
  +    }
  +
  +    private void assertMangling(String propertiesFile, Class intf) throws 
IOException {
           Properties nameManglerProperties = new Properties();
  -        File file = new File(basedir, 
"src/test-resources/specialNameMangler.properties");
  +        File file = new File(basedir, propertiesFile);
           nameManglerProperties.load(new FileInputStream(file));
   
           Set methodSignatures = new HashSet();
  -        IiopOperation[] iiopOperations = 
PortableStubCompiler.createIiopOperations(Special.class);
  +        IiopOperation[] iiopOperations = 
PortableStubCompiler.createIiopOperations(intf);
  +        boolean failed = false;
           for (int i = 0; i < iiopOperations.length; i++) {
               IiopOperation iiopOperation = iiopOperations[i];
               Method method = iiopOperation.getMethod();
  @@ -116,10 +98,26 @@
               methodSignature += ")";
               methodSignatures.add(methodSignature);
   
  -            assertTrue("Method not present in name mangler properties: " + 
methodSignature, nameManglerProperties.containsKey(methodSignature));
  -            assertEquals(nameManglerProperties.getProperty(methodSignature), 
iiopOperation.getName());
  +            String expected = 
nameManglerProperties.getProperty(methodSignature);
  +            String actual = iiopOperation.getName();
  +            if (expected == null || !expected.equals(actual)) {
  +                System.out.println("Expected: " + expected);
  +                System.out.println("  Actual: " + actual);
  +                System.out.println();
  +                failed = true;
  +            }
  +        }
  +
  +        if (!nameManglerProperties.keySet().equals(methodSignatures)) {
  +            Set extraProperties = new 
HashSet(nameManglerProperties.keySet());
  +            extraProperties.removeAll(methodSignatures);
  +            Set missingProperties = new HashSet(methodSignatures);
  +            missingProperties.removeAll(nameManglerProperties.keySet());
  +            fail("extraProperties=" + extraProperties + ", 
missingProperties=" + missingProperties);
           }
   
  -        assertEquals("Did not match all methods", 
nameManglerProperties.keySet(), methodSignatures);
  +        if (failed) {
  +            fail();
  +        }
       }
   }
  
  
  
  1.1                  
openejb/modules/core/src/test/org/openejb/corba/compiler/BeanProperties.java
  
  Index: BeanProperties.java
  ===================================================================
  /**
   * Redistribution and use of this software and associated documentation
   * ("Software"), with or without modification, are permitted provided
   * that the following conditions are met:
   *
   * 1. Redistributions of source code must retain copyright
   *    statements and notices.  Redistributions must also contain a
   *    copy of this document.
   *
   * 2. Redistributions in binary form must reproduce the
   *    above copyright notice, this list of conditions and the
   *    following disclaimer in the documentation and/or other
   *    materials provided with the distribution.
   *
   * 3. The name "OpenEJB" must not be used to endorse or promote
   *    products derived from this Software without prior written
   *    permission of The OpenEJB Group.  For written permission,
   *    please contact [EMAIL PROTECTED]
   *
   * 4. Products derived from this Software may not be called "OpenEJB"
   *    nor may "OpenEJB" appear in their names without prior written
   *    permission of The OpenEJB Group. OpenEJB is a registered
   *    trademark of The OpenEJB Group.
   *
   * 5. Due credit should be given to the OpenEJB Project
   *    (http://openejb.sf.net/).
   *
   * THIS SOFTWARE IS PROVIDED BY THE OPENEJB GROUP AND CONTRIBUTORS
   * ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT
   * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL
   * THE OPENEJB GROUP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
   * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
   * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
   * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
   * OF THE POSSIBILITY OF SUCH DAMAGE.
   *
   * Copyright 2005 (C) The OpenEJB Group. All Rights Reserved.
   *
   * $Id: BeanProperties.java,v 1.1 2005/06/23 04:28:03 dain Exp $
   */
  package org.openejb.corba.compiler;
  
  import java.math.BigDecimal;
  import java.rmi.Remote;
  import java.rmi.RemoteException;
  
  import org.openejb.corba.compiler.other.BlahEx;
  import org.openejb.corba.compiler.other.CheeseIDLEntity;
  import org.openejb.corba.compiler.other.Generic$Interface;
  
  /**
   * @version $Rev$ $Date: 2005/06/23 04:28:03 $
   */
  public interface BeanProperties extends Remote {
      public void setBooleanabcdef(boolean x) throws RemoteException;
      public void setCharabcdef(char x) throws RemoteException;
      public void setByteabcdef(byte x) throws RemoteException;
      public void setIntabcdef(int x) throws RemoteException;
      public void setLongabcdef(long x) throws RemoteException;
      public void setFloatabcdef(float x) throws RemoteException;
      public void setDoubleabcdef(double x) throws RemoteException;
      public void setBigDecimalabcdef(BigDecimal x) throws RemoteException;
      public void setClassObjectabcdef(Class x) throws RemoteException;
      public void setCORBA_Objectabcdef(org.omg.CORBA.Object x) throws 
RemoteException;
      public void setCORBA_Anyabcdef(org.omg.CORBA.Any x) throws 
RemoteException;
      public void setCORBA_TypeCodeabcdef(org.omg.CORBA.TypeCode x) throws 
RemoteException;
      public void setCheeseIDLEntityabcdef(CheeseIDLEntity x) throws 
RemoteException;
      public void setGenericInterfaceabcdef(Generic$Interface x) throws 
RemoteException;
      public void setBlahExceptionabcdef(BlahEx x) throws RemoteException;
      public void setBooExceptionabcdef(BooException x) throws RemoteException;
  
      public boolean isBooleanabcdef() throws RemoteException;
      public char getCharabcdef() throws RemoteException;
      public byte getByteabcdef() throws RemoteException;
      public int getIntabcdef() throws RemoteException;
      public long getLongabcdef() throws RemoteException;
      public float getFloatabcdef() throws RemoteException;
      public double getDoubleabcdef() throws RemoteException;
      public BigDecimal getBigDecimalabcdef() throws RemoteException;
      public Class getClassObjectabcdef() throws RemoteException;
      public org.omg.CORBA.Object getCORBA_Objectabcdef() throws 
RemoteException;
      public org.omg.CORBA.Any getCORBA_Anyabcdef() throws RemoteException;
      public org.omg.CORBA.TypeCode getCORBA_TypeCodeabcdef() throws 
RemoteException;
      public CheeseIDLEntity getCheeseIDLEntityabcdef() throws RemoteException;
      public Generic$Interface getGenericInterfaceabcdef() throws 
RemoteException;
      public BlahEx getBlahExceptionabcdef() throws RemoteException;
      public BooException getBooExceptionabcdef() throws RemoteException;
  
  
      // special
      public int getWithArgumentabcdef(int x) throws RemoteException;
  
      public int getWithSetReturningabcdef() throws RemoteException;
      public int setWithSetReturningabcdef(int x) throws RemoteException;
  
      public int getWithSetOfDifferentTypeabcdef() throws RemoteException;
      public void setWithSetOfDifferentTypeabcdef(long x) throws 
RemoteException;
  
      public int getThrowsUserExceptionabcdef() throws RemoteException, 
Exception;
      public void setThrowsUserExceptionabcdef(int x) throws RemoteException, 
Exception;
  
      public int getOverridenSetabcdef() throws RemoteException;
      public void setOverridenSetabcdef(int x) throws RemoteException;
      public void setOverridenSetabcdef(long x) throws RemoteException;
  
      public void setOnlyabcdef(int x) throws RemoteException;
  
      public int getOverridenGetabcdef() throws RemoteException;
      public int getOverridenGetabcdef(int x) throws RemoteException;
  
      public int getUPPERCASEabcdef() throws RemoteException;
  
      public int get() throws RemoteException;
  
      public int get_collisionabcdef() throws RemoteException;
  }
  
  
  

Reply via email to