geronimo-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chris Opacki <chris_opa...@yahoo.com>
Subject Re: [PATCH] JSR-88 DeploymentFactoryManager + Test
Date Fri, 15 Aug 2003 17:38:24 GMT
Hi Arron,
I've been working on the DDBean and the class that
loads them. In the spec examples it shows that a
DDBean is grabbing data directly from the xml
document. I was thinking that i would load the DDBeans
from elsewhere holding the required data in the
DDBeanImpl. I am creating one DDBean implementation,
one DDBeanRoot implementation and a Loader that is
responsible for parsing a zip file, reading an entry
and writing it to a temp file. I am also assuming that
we will grab child dd beans based on a relative path
from root. I'm not sure if you have started that
DDConfigBean implementations yet, but I thought it
would be good that you know what I am doing. Is anyone
else actively working on JSR88? There haven't been a
whole lot of activity on our threads. Any thoughts?
Chris

--- Aaron Mulder <ammulder@alumni.princeton.edu>
wrote:
> 	Here are two patches to:
> 
>  - update the deployment factory manager so that it
> throws an 
> IllegalArgumentException for bad arguments, and
> doesn't re-register an 
> identical factory more than once.
> 
>  - update the DFM tests to refer to the actual
> Geronimo DeploymentFactory
> implementation instead of the "Mock" impls, actually
> test the 
> DeploymentFactory registration and lookup, and
> revise the tests a bit 
> (don't rely on previous tests having run and set up
> static objects, etc.)
> 
> 	In addition, when these are applied, we should
> remove the classes
> 
>
modules/core/src/test/javax/enterprise/deploy/spi/MockDeploymentManager
> 
> 	and
> 
>
modules/core/src/test/javax/enterprise/deploy/spi/factories/MockDeploymentFactory
> 
> 	Because those were only used by the tests, and now
> the tests use 
> the real thing instead of the "Mock" versions.
> 
> Aaron
> > Index:
>
specs/jsr88/src/java/javax/enterprise/deploy/shared/factories/DeploymentFactoryManager.java
>
===================================================================
> RCS file:
>
/home/cvspublic/incubator-geronimo/specs/jsr88/src/java/javax/enterprise/deploy/shared/factories/DeploymentFactoryManager.java,v
> retrieving revision 1.1
> diff -c -r1.1 DeploymentFactoryManager.java
> ***
>
specs/jsr88/src/java/javax/enterprise/deploy/shared/factories/DeploymentFactoryManager.java
> 14 Aug 2003 16:12:52 -0000	1.1
> ---
>
specs/jsr88/src/java/javax/enterprise/deploy/shared/factories/DeploymentFactoryManager.java
> 15 Aug 2003 17:14:01 -0000
> ***************
> *** 68,128 ****
>   public class DeploymentFactoryManager {
>       private static DeploymentFactoryManager
> instance;
>   
> -     private ArrayList deploymentFactories = new
> ArrayList();
> - 
>       public static DeploymentFactoryManager
> getInstance() {
> !         if (instance == null) {
>               instance = new
> DeploymentFactoryManager();
>           }
>           return instance;
>       }
>   
>       public void
> registerDeploymentFactory(DeploymentFactory factory)
> {
> !           // apparently we dont care about null
> values, the Sun RI even adds the null
> !           // to the list. So after
> registerDeploymentFactory(null)
> getDeploymentFactories()
> !           // return an array with length 1.
> !           deploymentFactories.add(factory);
> !       }
>   
>       public DeploymentFactory[]
> getDeploymentFactories() {
> !         return (DeploymentFactory[])
> deploymentFactories.toArray(new
> DeploymentFactory[]{});
>       }
>   
>       public DeploymentManager
> getDeploymentManager(String uri, String username,
> String password) throws
> DeploymentManagerCreationException {
> !         // RI doesn't care about uri being null,
> neither do we
> ! 
> !         for (Iterator i =
> deploymentFactories.iterator(); i.hasNext();) {
> !             DeploymentFactory factory =
> (DeploymentFactory) i.next();
> !             if (factory != null) {
> !                 if (factory.handlesURI(uri)) {
> !                     try {
> !                         return
> factory.getDeploymentManager(uri, username,
> password);
> !                     } catch
> (DeploymentManagerCreationException e) {
> !                         // Just like the RI we
> throw a new exception with a generic message
> !                         throw new
> DeploymentManagerCreationException("Could not get
> DeploymentManager");
>                       }
>                   }
>               }
>           }
> !         throw new
> DeploymentManagerCreationException("Could not get
> DeploymentManager");
>       }
>   
>       public DeploymentManager
> getDisconnectedDeploymentManager(String uri) throws
> DeploymentManagerCreationException {
> !         // RI doesn't care about uri being null,
> neither do we
> ! 
> !         for (Iterator i =
> deploymentFactories.iterator(); i.hasNext();) {
> !             DeploymentFactory factory =
> (DeploymentFactory) i.next();
> !             if (factory != null) {
> !                 if (factory.handlesURI(uri)) {
> !                     try {
> !                         return
> factory.getDisconnectedDeploymentManager(uri);
> !                     } catch
> (DeploymentManagerCreationException e) {
> !                         // Just like the RI we
> throw a new exception with a generic message
> !                         throw new
> DeploymentManagerCreationException("Could not get
> DeploymentManager");
>                       }
>                   }
>               }
>           }
> !         throw new
> DeploymentManagerCreationException("Could not get
> DeploymentManager");
>       }
>   }
> --- 68,137 ----
>   public class DeploymentFactoryManager {
>       private static DeploymentFactoryManager
> instance;
>   
>       public static DeploymentFactoryManager
> getInstance() {
> !         if(instance == null) {
>               instance = new
> DeploymentFactoryManager();
>           }
>           return instance;
>       }
>   
> +     private ArrayList deploymentFactories = new
> ArrayList();
> + 
> +     private DeploymentFactoryManager() {
> +     }
> + 
>       public void
> registerDeploymentFactory(DeploymentFactory factory)
> {
> !         if(factory == null) {
> !             throw new
> IllegalArgumentException("DeploymentFactory to
> register should not be null");
> !         }
> !         if(!deploymentFactories.contains(factory))
> {
> !             deploymentFactories.add(factory);
> !         }
> !     }
>   
>       public DeploymentFactory[]
> getDeploymentFactories() {
> !         return
> (DeploymentFactory[])deploymentFactories.toArray(new
> DeploymentFactory[deploymentFactories.size()]);
>       }
>   
>       public DeploymentManager
> getDeploymentManager(String uri, String username,
> String password) throws
> DeploymentManagerCreationException {
> !         if(uri == null) {
> !             throw new
> IllegalArgumentException("URI for DeploymentManager
> should not be null");
> !         }
> !         DeploymentManager manager = null;
> !         for(Iterator i =
> deploymentFactories.iterator(); i.hasNext();) {
> !             DeploymentFactory factory =
> (DeploymentFactory)i.next();
> !             if(factory.handlesURI(uri)) {
> !                 try {
> !                     manager =
> factory.getDeploymentManager(uri, username,
> password);
> !                     if(manager != null) {
> !                         return manager;
>                       }
> +                 }
> catch(DeploymentManagerCreationException e) {
> +                     throw new
> DeploymentManagerCreationException("Could not get
> DeploymentManager: "+e.getMessage());
>                   }
>               }
>           }
> !         throw new
> DeploymentManagerCreationException("Could not get
> DeploymentManager; No registered DeploymentFactory
> handles this URI");
>       }
>   
>       public DeploymentManager
> getDisconnectedDeploymentManager(String uri) throws
> DeploymentManagerCreationException {
> !         if(uri == null) {
> !             throw new
> IllegalArgumentException("URI for DeploymentManager
> should not be null");
> !         }
> !         DeploymentManager manager = null;
> !         for(Iterator i =
> deploymentFactories.iterator(); 
=== message truncated ===> Index:
>
modules/core/src/test/javax/enterprise/deploy/shared/factories/DeploymentFactoryManagerTest.java
>
===================================================================
> RCS file:
>
/home/cvspublic/incubator-geronimo/modules/core/src/test/javax/enterprise/deploy/shared/factories/DeploymentFactoryManagerTest.java,v
> retrieving revision 1.1
> diff -c -r1.1 DeploymentFactoryManagerTest.java
> ***
>
modules/core/src/test/javax/enterprise/deploy/shared/factories/DeploymentFactoryManagerTest.java
> 14 Aug 2003 09:14:05 -0000	1.1
> ---
>
modules/core/src/test/javax/enterprise/deploy/shared/factories/DeploymentFactoryManagerTest.java
> 15 Aug 2003 17:13:45 -0000
> ***************
> *** 58,66 ****
>   import junit.framework.TestCase;
>   
>   import
>
javax.enterprise.deploy.spi.factories.DeploymentFactory;
> - import
>
javax.enterprise.deploy.spi.factories.MockDeploymentFactory;
>   import
>
javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
>   import
> javax.enterprise.deploy.spi.DeploymentManager;
>   
>   /**
>    * Low level tests on the
> DeploymentFactoryManager.
> --- 58,66 ----
>   import junit.framework.TestCase;
>   
>   import
>
javax.enterprise.deploy.spi.factories.DeploymentFactory;
>   import
>
javax.enterprise.deploy.spi.exceptions.DeploymentManagerCreationException;
>   import
> javax.enterprise.deploy.spi.DeploymentManager;
> + import
>
org.apache.geronimo.enterprise.deploy.provider.GeronimoDeploymentFactory;
>   
>   /**
>    * Low level tests on the
> DeploymentFactoryManager.
> ***************
> *** 80,107 ****
>   
>       public void
>
testGetDeploymentManagerWithoutAnyRegisteredFactories()
> {
>           try {
> !            
> factoryManager.getDeploymentManager(null, null,
> null);
>           } catch
> (DeploymentManagerCreationException e) {
> !             assertEquals("Could not get
> DeploymentManager", e.getMessage());
> !             return;
>           }
> -         fail("Expected a
> DeploymentManagerCreationException");
>       }
>   
>       public void
>
testDisconnectedGetDeploymentManagerWithoutAnyRegisteredFactories()
> {
>           try {
> !            
>
factoryManager.getDisconnectedDeploymentManager(null);
>           } catch
> (DeploymentManagerCreationException e) {
> !             assertEquals("Could not get
> DeploymentManager", e.getMessage());
> !             return;
>           }
> -         fail("Expected a
> DeploymentManagerCreationException");
>       }
>   
>       public void testRegisterDeploymentFactory() {
>           int initialNumberOfFactories =
> factoryManager.getDeploymentFactories().length;
>   
> !         DeploymentFactory factory = new
> MockDeploymentFactory();
>          
> factoryManager.registerDeploymentFactory(factory);
>   
>           int expectedNumberOfFactories =
> initialNumberOfFactories + 1;
> --- 80,133 ----
>   
>       public void
>
testGetDeploymentManagerWithoutAnyRegisteredFactories()
> {
>           try {
> !            
> factoryManager.getDeploymentManager("invalid-uri",
> null, null);
> !             fail("Expected a
> DeploymentManagerCreationException");
>           } catch
> (DeploymentManagerCreationException e) {
> !            
> assertTrue(e.getMessage().startsWith("Could not get
> DeploymentManager"));
>           }
>       }
>   
>       public void
>
testDisconnectedGetDeploymentManagerWithoutAnyRegisteredFactories()
> {
>           try {
> !            
>
factoryManager.getDisconnectedDeploymentManager("invalid-uri");
> !             fail("Expected a
> DeploymentManagerCreationException");
>           } catch
> (DeploymentManagerCreationException e) {
> !            
> assertTrue(e.getMessage().startsWith("Could not get
> DeploymentManager"));
> !         }
> !     }
> ! 
> !     public void
> testGetDeploymentManagerWithNullURI() {
> !         try {
> !            
> factoryManager.getDeploymentManager(null, null,
> null);
> !             fail("Expected an
> IllegalArgumentException");
> !         } catch (IllegalArgumentException e) {
> !         } catch(DeploymentManagerCreationException
> e) {
> !             fail("Unexpected Exception:
> "+e.getMessage());
> !         }
> !     }
> ! 
> !     public void
> testDisconnectedGetDeploymentManagerWithNullURI() {
> !         try {
> !            
>
factoryManager.getDisconnectedDeploymentManager(null);
> !             fail("Expected an
> IllegalArgumentException");
> !         } catch (IllegalArgumentException e) {
> !         } catch(DeploymentManagerCreationException
> e) {
> !             fail("Unexpected Exception:
> "+e.getMessage());
> !         }
> !     }
> ! 
> !     public void testRegisterNull() {
> !         try {
> !            
> factoryManager.registerDeploymentFactory(null);
> !             fail("Should have gotten an
> IllegalArgumentException");
> !         } catch(IllegalArgumentException e) {
>           }
>       }
>   
>       public void testRegisterDeploymentFactory() {
>           int initialNumberOfFactories =
> factoryManager.getDeploymentFactories().length;
>   
> !         DeploymentFactory factory = new
> GeronimoDeploymentFactory();
>          
> factoryManager.registerDeploymentFactory(factory);
>   
>           int expectedNumberOfFactories =
> initialNumberOfFactories + 1;
> ***************
> *** 110,151 ****
>           assertEquals(expectedNumberOfFactories,
> currentNumberOfFactories);
>       }
>   
> -     /**
> -      * Relies on succesful completion of @link
> #testRegisterDeploymentFactory()
> -      * bacause we need a registered
> DeploymentManager for this test.
> -      */
>       public void testGetDeploymentManager() {
> !         int numberOfFactories =
> factoryManager.getDeploymentFactories().length;
> !         assertTrue("We should have a registered
> MockDeploymentFactory", numberOfFactories > 0);
>   
>           DeploymentManager deploymentManager =
> null;
>           try {
> !             deploymentManager =
> factoryManager.getDeploymentManager(null, null,
> null);
> 
=== message truncated ===


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com

Mime
View raw message