hivemind-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject cvs commit: jakarta-hivemind/framework/src/java/org/apache/hivemind/test HiveMindTestCase.java
Date Thu, 19 Aug 2004 23:24:55 GMT
hlship      2004/08/19 16:24:55

  Modified:    framework/src/test/hivemind/test/parse
                        TestDescriptorParser.java
               framework/src/java/org/apache/hivemind/parse
                        ParseStrings.properties ParseMessages.java
                        DescriptorParser.java
               .        status.xml
               framework/src/java/org/apache/hivemind/test
                        HiveMindTestCase.java
  Added:       framework/src/test/hivemind/test/parse MissingSubModule.xml
  Log:
  [HIVEMIND-34] Check for <sub-module> references that do not exist.
  
  Revision  Changes    Path
  1.18      +38 -1     jakarta-hivemind/framework/src/test/hivemind/test/parse/TestDescriptorParser.java
  
  Index: TestDescriptorParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/parse/TestDescriptorParser.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- TestDescriptorParser.java	10 Aug 2004 22:19:26 -0000	1.17
  +++ TestDescriptorParser.java	19 Aug 2004 23:24:54 -0000	1.18
  @@ -22,13 +22,19 @@
   
   import junit.framework.AssertionFailedError;
   
  +import org.apache.commons.logging.Log;
   import org.apache.hivemind.ApplicationRuntimeException;
   import org.apache.hivemind.Attribute;
   import org.apache.hivemind.Element;
  +import org.apache.hivemind.ErrorHandler;
  +import org.apache.hivemind.Location;
   import org.apache.hivemind.Occurances;
  +import org.apache.hivemind.Resource;
  +import org.apache.hivemind.impl.RegistryAssemblyImpl;
   import org.apache.hivemind.parse.ConfigurationPointDescriptor;
   import org.apache.hivemind.parse.ContributionDescriptor;
   import org.apache.hivemind.parse.CreateInstanceDescriptor;
  +import org.apache.hivemind.parse.DescriptorParser;
   import org.apache.hivemind.parse.ImplementationDescriptor;
   import org.apache.hivemind.parse.InterceptorDescriptor;
   import org.apache.hivemind.parse.ModuleDescriptor;
  @@ -283,7 +289,7 @@
           InvokeParentRule rule5 = (InvokeParentRule) rl.get(4);
   
           assertEquals("addElement", rule5.getMethodName());
  -}
  +    }
   
       public void testParametersSchema() throws Exception
       {
  @@ -462,5 +468,36 @@
           PushAttributeRule rule = (PushAttributeRule) rules.get(0);
   
           assertEquals("foo", rule.getAttributeName());
  +    }
  +
  +    private String _errorHandlerMessage;
  +
  +    private class ErrorHandlerFixture implements ErrorHandler
  +    {
  +
  +        public void error(Log log, String message, Location location, Throwable cause)
  +        {
  +            _errorHandlerMessage = message;
  +        }
  +    }
  +
  +    public void testMissingSubModule() throws Exception
  +    {
  +        Resource location = getResource("MissingSubModule.xml");
  +
  +        ErrorHandler eh = new ErrorHandlerFixture();
  +
  +        RegistryAssemblyImpl assembly = new RegistryAssemblyImpl(eh);
  +
  +        DescriptorParser p = new DescriptorParser(eh, assembly);
  +
  +        p.parse(location, _resolver);
  +
  +        assembly.performPostProcessing();
  +
  +        assertRegexp(
  +            "Sub-module .*?/DoesNotExist\\.xml does not exist\\.",
  +            _errorHandlerMessage);
  +
       }
   }
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/hivemind/test/parse/MissingSubModule.xml
  
  Index: MissingSubModule.xml
  ===================================================================
  <?xml version="1.0"?>
  <!-- 
     Copyright 2004 The Apache Software Foundation
  
     Licensed under the Apache License, Version 2.0 (the "License");
     you may not use this file except in compliance with the License.
     You may obtain a copy of the License at
  
         http://www.apache.org/licenses/LICENSE-2.0
  
     Unless required by applicable law or agreed to in writing, software
     distributed under the License is distributed on an "AS IS" BASIS,
     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     See the License for the specific language governing permissions and
     limitations under the License.
  -->
  
  <module id="hivemind.test.parse" version="1.0.0">
    <sub-module descriptor="DoesNotExist.xml"/>
  </module>
  
  
  
  1.6       +1 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseStrings.properties
  
  Index: ParseStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseStrings.properties,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ParseStrings.properties	25 Jun 2004 23:26:42 -0000	1.5
  +++ ParseStrings.properties	19 Aug 2004 23:24:55 -0000	1.6
  @@ -26,6 +26,7 @@
   bad-rule-class=Unable to create instance of Rule class {0} (at {1}): {2}
   error-reading-descriptor=Unable to read descriptor {0}: {1}
   missing-resource=Unable to locate {0}.
  +sub-module-does-not-exist=Sub-module {0} does not exist.
   
   unexpected-element=Unexpected element {0} within {1}.
   
  
  
  
  1.8       +5 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseMessages.java
  
  Index: ParseMessages.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/ParseMessages.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ParseMessages.java	25 Jun 2004 23:26:42 -0000	1.7
  +++ ParseMessages.java	19 Aug 2004 23:24:55 -0000	1.8
  @@ -119,4 +119,9 @@
               "invalid-attribute-format",
               new Object[] { attributeName, value, elementPath, inputValueFormat });
       }
  +
  +    public static String subModuleDoesNotExist(Resource subModuleDescriptor)
  +    {
  +        return _formatter.format("sub-module-does-not-exist", subModuleDescriptor);
  +    }
   }
  
  
  
  1.31      +10 -0     jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java
  
  Index: DescriptorParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/parse/DescriptorParser.java,v
  retrieving revision 1.30
  retrieving revision 1.31
  diff -u -r1.30 -r1.31
  --- DescriptorParser.java	19 Aug 2004 22:24:00 -0000	1.30
  +++ DescriptorParser.java	19 Aug 2004 23:24:55 -0000	1.31
  @@ -1114,6 +1114,16 @@
   
           Resource subModuleDescriptor = getResource().getRelativeResource(path);
   
  +        if (subModuleDescriptor.getResourceURL() == null)
  +        {
  +            _errorHandler.error(
  +                LOG,
  +                ParseMessages.subModuleDoesNotExist(subModuleDescriptor),
  +                getLocation(),
  +                null);
  +            return;
  +        }
  +
           _registryAssembly.enqueueModuleParse(subModuleDescriptor, _resolver);
       }
   
  
  
  
  1.51      +3 -0      jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- status.xml	19 Aug 2004 22:28:56 -0000	1.50
  +++ status.xml	19 Aug 2004 23:24:55 -0000	1.51
  @@ -80,6 +80,9 @@
           Fix broken synchronization in ThreadedServiceModel and PooledServiceModel that
could make them
           randomly fail when creating a service by invoking a factory.
         </action>
  +      <action type="fix" dev="HLS" due-to="Johan Lindquist" fixes-bug="HIVEMIND-34">
  +        Check for &lt;sub-module&gt; references that do not exist.
  +      </action>
       </release>
     
       <release version="1.0-beta-2" date="Aug 1 2004">
  
  
  
  1.12      +23 -10    jakarta-hivemind/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java
  
  Index: HiveMindTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/test/HiveMindTestCase.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- HiveMindTestCase.java	19 Aug 2004 22:24:00 -0000	1.11
  +++ HiveMindTestCase.java	19 Aug 2004 23:24:55 -0000	1.12
  @@ -149,8 +149,8 @@
        */
       protected void tearDown() throws Exception
       {
  -    	super.tearDown();
  -    	
  +        super.tearDown();
  +
           if (_appender != null)
           {
               _appender = null;
  @@ -201,6 +201,19 @@
                   + "].");
       }
   
  +    protected void assertRegexp(String pattern, String actual) throws Exception
  +    {
  +        setupMatcher();
  +
  +        Pattern compiled = _compiler.compile(pattern);
  +
  +        if (_matcher.contains(actual, compiled))
  +            return;
  +
  +        throw new AssertionFailedError(
  +            "\"" + actual + "\" does not contain regular expression[" + pattern + "].");
  +    }
  +
       /**
        * Digs down through (potentially) a stack of ApplicationRuntimeExceptions until it
        * reaches the originating exception, which is returned.
  @@ -442,18 +455,18 @@
       protected Location fabricateLocation(int line)
       {
           String path = "/" + getClass().getName().replace('.', '/');
  -    
  +
           Resource r = new ClasspathResource(new DefaultClassResolver(), path);
  -    
  +
           return new LocationImpl(r, line);
       }
  -    
  +
       protected boolean matches(String input, String pattern) throws Exception
       {
  -    	setupMatcher();
  -    	
  -    	Pattern compiled = _compiler.compile(pattern);
  -    	
  -    	return _matcher.matches(input, compiled);
  +        setupMatcher();
  +
  +        Pattern compiled = _compiler.compile(pattern);
  +
  +        return _matcher.matches(input, compiled);
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: hivemind-cvs-unsubscribe@jakarta.apache.org
For additional commands, e-mail: hivemind-cvs-help@jakarta.apache.org


Mime
View raw message