You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by hl...@apache.org on 2003/08/11 19:45:28 UTC

cvs commit: jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/impl test.properties

hlship      2003/08/11 10:45:28

  Modified:    hivemind/src/java/org/apache/commons/hivemind/service/impl
                        AbstractLoggingInterceptor.java
               hivemind/src/test/hivemind/test/services TestServices.java
               hivemind/src/java/org/apache/commons/hivemind/impl
                        ExtensionPointImpl.java
                        InvokeFactoryServiceConstructor.java
               hivemind/src/test/hivemind/test/config
                        TestExtensionPoint.java Symbols.xml
               hivemind/src/test/hivemind/test/parse
                        TestDescriptorParser.java
               hivemind/src/META-INF hivemodule.xml
               hivemind/src/test/hivemind/test HiveMindTestCase.java
               hivemind/src/test/hivemind/test/rules
                        TestClassTranslator.java
                        TestEnumerationTranslator.java
                        TestExtensionPointTranslator.java
               hivemind/src/test/hivemind/test/config/impl test.properties
  Added:       hivemind/src/java/org/apache/commons/hivemind/service/impl
                        FactoryDefaultsSymbolSource.java
                        FactoryDefault.java
               hivemind/src/test/hivemind/test/services ArrayResult.xml
                        ArrayService.java
               hivemind/src/test/hivemind/test/services/impl
                        ArrayServiceImpl.java
  Log:
  Add a "FactoryDefaults" extension point for registering values for symbols.
  Improve how the LoggingInterceptor logs Object arrays (as parameters or result values).
  
  Revision  Changes    Path
  1.2       +43 -3     jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/AbstractLoggingInterceptor.java
  
  Index: AbstractLoggingInterceptor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/AbstractLoggingInterceptor.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- AbstractLoggingInterceptor.java	9 Jul 2003 11:27:24 -0000	1.1
  +++ AbstractLoggingInterceptor.java	11 Aug 2003 17:45:27 -0000	1.2
  @@ -95,7 +95,7 @@
               if (i > 0)
                   buffer.append(", ");
   
  -            buffer.append(arg);
  +            convert(buffer, arg);
           }
   
           buffer.append(")");
  @@ -103,6 +103,44 @@
           _log.debug(buffer.toString());
       }
   
  +    private void convert(StringBuffer buffer, Object input)
  +    {
  +        if (input == null)
  +        {
  +            buffer.append("<null>");
  +            return;
  +        }
  +
  +        // Primitive types, and non-object arrays
  +        // use toString().  Less than ideal for int[], etc., but
  +        // that's a lot of work for a rare case.
  +
  +        if (!(input instanceof Object[]))
  +        {
  +            buffer.append(input.toString());
  +            return;
  +        }
  +
  +        buffer.append("(");
  +        buffer.append(ClassFabUtils.getJavaClassName(input.getClass()));
  +        buffer.append("){");
  +
  +        Object[] array = (Object[]) input;
  +        int count = array.length;
  +
  +        for (int i = 0; i < count; i++)
  +        {
  +            if (i > 0)
  +                buffer.append(", ");
  +
  +            // We use convert() again, because it could be a multi-dimensional array
  +            // (god help us) where each element must be converted.
  +            convert(buffer, array[i]);
  +        }
  +
  +        buffer.append("}");
  +    }
  +
       protected void _logExit(String methodName, Object result)
       {
           StringBuffer buffer = new StringBuffer(BUFFER_SIZE);
  @@ -110,7 +148,9 @@
           buffer.append("END ");
           buffer.append(methodName);
           buffer.append("() [");
  -        buffer.append(result);
  +
  +        convert(buffer, result);
  +
           buffer.append("]");
   
           _log.debug(buffer.toString());
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/FactoryDefaultsSymbolSource.java
  
  Index: FactoryDefaultsSymbolSource.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 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 end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``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 APACHE SOFTWARE FOUNDATION 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.hivemind.service.impl;
  
  import java.util.HashMap;
  import java.util.List;
  import java.util.Map;
  
  import org.apache.commons.hivemind.Initializable;
  import org.apache.commons.hivemind.ServiceExtensionPoint;
  import org.apache.commons.hivemind.SymbolSource;
  import org.apache.commons.hivemind.impl.BaseLocatable;
  
  /**
   * Implementation of {@link org.apache.commons.hivemind.SymbolSource} driven
   * off of the <code>hivemind.FactoryDefaults</code> extension point.
   *
   * @author Howard Lewis Ship
   * @version $Id: FactoryDefaultsSymbolSource.java,v 1.1 2003/08/11 17:45:27 hlship Exp $
   */
  public class FactoryDefaultsSymbolSource
      extends BaseLocatable
      implements SymbolSource, Initializable
  {
      private List _factoryDefaults;
      private Map _symbols = new HashMap();
  
      public String valueForSymbol(String name)
      {
          return (String) _symbols.get(name);
      }
  
      public void initializeService(ServiceExtensionPoint point, Object service)
      {
          int count = _factoryDefaults.size();
          for (int i = 0; i < count; i++)
          {
              FactoryDefault fd = (FactoryDefault) _factoryDefaults.get(i);
  
              _symbols.put(fd.getSymbol(), fd.getValue());
          }
      }
  
      public List getFactoryDefaults()
      {
          return _factoryDefaults;
      }
  
      public void setFactoryDefaults(List list)
      {
          _factoryDefaults = list;
      }
  
  }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/service/impl/FactoryDefault.java
  
  Index: FactoryDefault.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 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 end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``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 APACHE SOFTWARE FOUNDATION 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package org.apache.commons.hivemind.service.impl;
  
  /**
   * Default symbol value defined by the 
   * <code>hivemind.FactoryDefaults</code> extension point.
   *
   * @author Howard Lewis Ship
   * @version $Id: FactoryDefault.java,v 1.1 2003/08/11 17:45:27 hlship Exp $
   */
  public class FactoryDefault
  {
  	private String _symbol;
  	private String _value;
  	
      public String getSymbol()
      {
          return _symbol;
      }
  
      public String getValue()
      {
          return _value;
      }
  
      public void setSymbol(String string)
      {
          _symbol = string;
      }
  
      public void setValue(String string)
      {
          _value = string;
      }
  
  }
  
  
  
  1.19      +25 -6     jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/TestServices.java
  
  Index: TestServices.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/TestServices.java,v
  retrieving revision 1.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- TestServices.java	8 Aug 2003 13:51:10 -0000	1.18
  +++ TestServices.java	11 Aug 2003 17:45:27 -0000	1.19
  @@ -371,11 +371,12 @@
           assertEquals("ToStringImpl of toString()", ts.toString());
   
           List events = getInterceptedLogEvents();
  -        checkLoggingEvent("hivemind.test.services.ToString", "BEGIN toString\\(\\)", events);
  +        checkLoggingEvent("hivemind.test.services.ToString", "BEGIN toString()", events, true);
           checkLoggingEvent(
               "hivemind.test.services.ToString",
  -            "END toString\\(\\) \\[ToStringImpl of toString\\(\\)\\]",
  -            events);
  +            "END toString() [ToStringImpl of toString()]",
  +            events,
  +            true);
   
       }
   
  @@ -396,7 +397,7 @@
   
           s.logMessage("This is a test.");
   
  -        checkLoggingEvent("hivemind.test.services.BuilderAccess", "This is a test\\.");
  +        checkLoggingEvent("hivemind.test.services.BuilderAccess", "This is a test.", true);
       }
   
       public void testBuilderAccessFailure() throws Exception
  @@ -414,6 +415,24 @@
   
           checkLoggingEvent(
               BuilderFactory.class.getName(),
  -            "Unable to set property EVIL of hivemind\\.test\\.services\\.impl\\.BuilderAccessImpl@.*: Unknown property 'EVIL'");
  +            "Unable to set property EVIL of hivemind\\.test\\.services\\.impl\\.BuilderAccessImpl@.*: Unknown property 'EVIL'",
  +            false);
       }
  +
  +    public void testArrayResult() throws Exception
  +    {
  +        Registry r = buildRegistry("ArrayResult.xml");
  +
  +        ArrayService s =
  +            (ArrayService) r.getService("hivemind.test.services.ArrayResult", ArrayService.class);
  +
  +        interceptLogging("hivemind.test.services.ArrayResult");
  +
  +        String[] result = s.returnArrayType();
  +
  +        checkList(new String[] { "alpha", "beta" }, result);
  +
  +        checkLoggingEvent(null, "END returnArrayType() [(java.lang.String[]){alpha, beta}]", true);
  +    }
  +
   }
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/ArrayResult.xml
  
  Index: ArrayResult.xml
  ===================================================================
  <?xml version="1.0" encoding="UTF-8"?>
  <!-- $Id: ArrayResult.xml,v 1.1 2003/08/11 17:45:27 hlship Exp $ -->
  <module
  	id="hivemind.test.services" 
  	version="1.0.0">
  	<service id="ArrayResult" interface="hivemind.test.services.ArrayService">
  	  <create-instance class="hivemind.test.services.impl.ArrayServiceImpl"/>
  	  <interceptor service-id="hivemind.LoggingInterceptor"/>
  	</service>
  </module>
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/ArrayService.java
  
  Index: ArrayService.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 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 end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``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 APACHE SOFTWARE FOUNDATION 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package hivemind.test.services;
  
  /**
   * Used to test code that ensures a return type that is an array works properly.
   *
   * @author Howard Lewis Ship
   * @version $Id: ArrayService.java,v 1.1 2003/08/11 17:45:27 hlship Exp $
   */
  public interface ArrayService
  {
      public String[] returnArrayType();
  }
  
  
  
  1.5       +18 -10    jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ExtensionPointImpl.java
  
  Index: ExtensionPointImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/ExtensionPointImpl.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ExtensionPointImpl.java	8 Aug 2003 13:51:08 -0000	1.4
  +++ ExtensionPointImpl.java	11 Aug 2003 17:45:27 -0000	1.5
  @@ -98,12 +98,28 @@
           builder.append("schema", _schema);
       }
   
  +    /**
  +     * Returns the number of contributions; it is expected
  +     * that each top-level {@link org.apache.commons.hivemind.Element}
  +     * in each {@link Extension} will convert to one element instance;
  +     * the value returned is the total number of top-level elements
  +     * in all contributed Extensions. 
  +     */
       public int getContributionCount()
       {
           if (_extensions == null)
               return 0;
   
  -        return _extensions.size();
  +        int total = 0;
  +
  +        int count = _extensions.size();
  +        for (int i = 0; i < count; i++)
  +        {
  +            Extension e = (Extension) _extensions.get(i);
  +            total += e.getElements().size();
  +        }
  +
  +        return total;
       }
   
       public void addExtension(Extension extension)
  @@ -112,14 +128,6 @@
               _extensions = new ArrayList();
   
           _extensions.add(extension);
  -    }
  -
  -    public void addExtensions(List extensions)
  -    {
  -        if (_extensions == null)
  -            _extensions = new ArrayList(extensions);
  -        else
  -            _extensions.addAll(extensions);
       }
   
       public Occurances getExpectedCount()
  
  
  
  1.3       +6 -4      jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/InvokeFactoryServiceConstructor.java
  
  Index: InvokeFactoryServiceConstructor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/java/org/apache/commons/hivemind/impl/InvokeFactoryServiceConstructor.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InvokeFactoryServiceConstructor.java	8 Aug 2003 13:51:08 -0000	1.2
  +++ InvokeFactoryServiceConstructor.java	11 Aug 2003 17:45:27 -0000	1.3
  @@ -89,10 +89,12 @@
       {
           Registry registry = _contributingModule.getRegistry();
   
  -        String factoryModuleId = RegistryImpl.split(_factoryServiceId);
  +        String qualifiedFactoryId = HiveMind.qualify(_contributingModule, _factoryServiceId);
  +
  +        String factoryModuleId = RegistryImpl.split(qualifiedFactoryId);
           Module factoryModule = registry.getModule(factoryModuleId);
           ServiceExtensionPoint factoryPoint =
  -            factoryModule.getServiceExtensionPoint(_factoryServiceId);
  +            factoryModule.getServiceExtensionPoint(qualifiedFactoryId);
   
           ServiceImplementationFactory factory =
               (ServiceImplementationFactory) factoryPoint.getService(
  @@ -100,7 +102,7 @@
   
           if (factory == null)
               throw new ApplicationRuntimeException(
  -                HiveMind.format("InvokeFactoryDescriptor.factory-is-null", _factoryServiceId),
  +                HiveMind.format("InvokeFactoryDescriptor.factory-is-null", qualifiedFactoryId),
                   getLocation(),
                   null);
   
  
  
  
  1.7       +38 -25    jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/TestExtensionPoint.java
  
  Index: TestExtensionPoint.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/TestExtensionPoint.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestExtensionPoint.java	5 Aug 2003 15:41:44 -0000	1.6
  +++ TestExtensionPoint.java	11 Aug 2003 17:45:28 -0000	1.7
  @@ -201,7 +201,8 @@
   
           checkLoggingEvent(
               BooleanTranslator.class.getName(),
  -            "'maybe' \\(in element flag at .*\\) is not a boolean value");
  +            "'maybe' \\(in element flag at .*\\) is not a boolean value",
  +            false);
   
           assertEquals(3, l.size());
   
  @@ -226,12 +227,21 @@
   
           List events = getInterceptedLogEvents();
   
  -        checkLoggingEvent(null, "Value 2 \\(at .*\\) is less than minimum value 5\\.", events);
  -        checkLoggingEvent(null, "Value 12 \\(at .*\\) is greater than maximum value 10\\.", events);
  +        checkLoggingEvent(
  +            null,
  +            "Value 2 \\(at .*\\) is less than minimum value 5\\.",
  +            events,
  +            false);
  +        checkLoggingEvent(
  +            null,
  +            "Value 12 \\(at .*\\) is greater than maximum value 10\\.",
  +            events,
  +            false);
           checkLoggingEvent(
               null,
               "'fred' \\(in element int at .*\\) is not an integer value\\.",
  -            events);
  +            events,
  +            false);
   
           assertEquals(5, l.size());
   
  @@ -245,14 +255,14 @@
           h = (IntHolder) l.get(2);
   
           assertEquals(10, h.getValue());
  -        
  -        h = (IntHolder)l.get(3);
  -        
  +
  +        h = (IntHolder) l.get(3);
  +
  +        assertEquals(6, h.getValue());
  +
  +        h = (IntHolder) l.get(3);
  +
           assertEquals(6, h.getValue());
  -        
  -		h = (IntHolder)l.get(3);
  -        
  -		assertEquals(6, h.getValue());        
   
       }
   
  @@ -297,7 +307,10 @@
           assertEquals("work", d.getKey());
           assertEquals("${work}", d.getValue());
   
  -        checkLoggingEvent(RegistryImpl.class.getName(), "No value available for symbol 'work'");
  +        checkLoggingEvent(
  +            RegistryImpl.class.getName(),
  +            "No value available for symbol 'work'",
  +            true);
       }
   
       public void testNoSchema() throws Exception
  @@ -334,24 +347,24 @@
           assertEquals("message", d.getKey());
           assertEquals("Some Damn Thing", d.getValue());
       }
  -    
  +
       public void testTranslatorClass() throws Exception
  -	  {
  -		  Registry r = buildRegistry("TranslatorClass.xml");
  +    {
  +        Registry r = buildRegistry("TranslatorClass.xml");
   
  -		  List l = r.getExtensionPointElements("hivemind.test.config.TranslatorClass");
  +        List l = r.getExtensionPointElements("hivemind.test.config.TranslatorClass");
   
  -		  assertEquals(2, l.size());
  +        assertEquals(2, l.size());
   
  -		  Datum d = (Datum) l.get(0);
  +        Datum d = (Datum) l.get(0);
   
  -		  assertEquals("key1", d.getKey());
  -		  assertEquals("VALUE1", d.getValue());
  -		  assertNotNull(d.getLocation());
  +        assertEquals("key1", d.getKey());
  +        assertEquals("VALUE1", d.getValue());
  +        assertNotNull(d.getLocation());
   
  -		  d = (Datum) l.get(1);
  +        d = (Datum) l.get(1);
   
  -		  assertEquals("key2", d.getKey());
  -		  assertEquals("VALUE2", d.getValue());
  -	  }
  +        assertEquals("key2", d.getKey());
  +        assertEquals("VALUE2", d.getValue());
  +    }
   }
  
  
  
  1.5       +6 -1      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/Symbols.xml
  
  Index: Symbols.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/Symbols.xml,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Symbols.xml	31 Jul 2003 21:06:25 -0000	1.4
  +++ Symbols.xml	11 Aug 2003 17:45:28 -0000	1.5
  @@ -24,4 +24,9 @@
   	<extension point-id="hivemind.SymbolSource">
   		<source class="hivemind.test.config.impl.MockSymbolSource"/>
   	</extension>
  +	
  +	<extension point-id="hivemind.FactoryDefaults">
  +		<default symbol="dog" value="dino"/>
  +		<default symbol="friend" value="george"/>	
  +	</extension>
   </module>
  
  
  
  1.1                  jakarta-commons-sandbox/hivemind/src/test/hivemind/test/services/impl/ArrayServiceImpl.java
  
  Index: ArrayServiceImpl.java
  ===================================================================
  /*
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 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 end-user documentation included with the redistribution, if
   *    any, must include the following acknowlegement:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowlegement may appear in the software itself,
   *    if and wherever such third-party acknowlegements normally appear.
   *
   * 4. The names "The Jakarta Project", "Commons", and "Apache Software
   *    Foundation" must not be used to endorse or promote products derived
   *    from this software without prior written permission. For written
   *    permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache"
   *    nor may "Apache" appear in their names without prior written
   *    permission of the Apache Group.
   *
   * THIS SOFTWARE IS PROVIDED ``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 APACHE SOFTWARE FOUNDATION 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.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   *
   */
  
  package hivemind.test.services.impl;
  
  import hivemind.test.services.ArrayService;
  
  /**
   * Used to test code that ensures a return type that is an array works properly.
   *
   * @author Howard Lewis Ship
   * @version $Id: ArrayServiceImpl.java,v 1.1 2003/08/11 17:45:28 hlship Exp $
   */
  public class ArrayServiceImpl implements ArrayService
  {
  
      public String[] returnArrayType()
      {
          return new String[] { "alpha", "beta" };
      }
  }
  
  
  
  1.20      +3 -2      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/TestDescriptorParser.java
  
  Index: TestDescriptorParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/parse/TestDescriptorParser.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- TestDescriptorParser.java	8 Aug 2003 13:51:10 -0000	1.19
  +++ TestDescriptorParser.java	11 Aug 2003 17:45:28 -0000	1.20
  @@ -359,7 +359,8 @@
   
           checkLoggingEvent(
               DescriptorParser.class.getName(),
  -            "Unknown attribute 'bad-attribute' in element module/extension-point/schema \\(at .*\\)");
  +            "Unknown attribute 'bad-attribute' in element module/extension-point/schema \\(at .*\\)",
  +            false);
   
       }
   
  
  
  
  1.14      +57 -1     jakarta-commons-sandbox/hivemind/src/META-INF/hivemodule.xml
  
  Index: hivemodule.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/META-INF/hivemodule.xml,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- hivemodule.xml	7 Aug 2003 15:51:43 -0000	1.13
  +++ hivemodule.xml	11 Aug 2003 17:45:28 -0000	1.14
  @@ -40,6 +40,62 @@
   		
   	</extension-point>
   	
  +	<extension point-id="SymbolSource">
  +		
  +		<source order="1000000" service-id="FactoryDefaultsSymbolSource"/>
  +		
  +	</extension>
  +	
  +	<extension-point id="FactoryDefaults">
  +	
  +		<description>
  +		Extension point for setting "factory defaults" for symbol values.
  +		</description>	
  +		
  +		<schema>
  +		
  +			<element name="default">
  +			
  +				<description>
  +				Provides a default symbol value.
  +				</description>	
  +				
  +				<attribute name="symbol" required="true">
  +					<description>
  +					The id of the symbol to define a default value for.	
  +					</description>	
  +				</attribute>
  +				
  +				<attribute name="value" required="true">
  +					<description>
  +					The value for the symbol.	
  +					</description>	
  +				</attribute>
  +				
  +				<rules>
  +					<create-object class="org.apache.commons.hivemind.service.impl.FactoryDefault"/>
  +					<read-attribute attribute="symbol" property="symbol"/>
  +					<read-attribute attribute="value" property="value"/>
  +					<invoke-parent method="addElement"/>	
  +				</rules>
  +			</element>	
  +		
  +		</schema>
  +		
  +	</extension-point>
  +	
  +	<service id="FactoryDefaultsSymbolSource" interface="org.apache.commons.hivemind.SymbolSource">
  +		<description>
  +		SymbolSource implementation driven by the FactoryDefaults extension point.	
  +		</description>
  +		
  +		<invoke-factory service-id="BuilderFactory">
  +			<construct class="org.apache.commons.hivemind.service.impl.FactoryDefaultsSymbolSource">
  +			  <set-extension-point point-id="FactoryDefaults" property="factoryDefaults"/>
  +			</construct>
  +		</invoke-factory>
  +	</service>
  +	
   	
   	<service id="ClassFactory" interface="org.apache.commons.hivemind.service.ClassFactory">
   		<description>Wrapper around Javassist used to dynamically create classes such as service interceptors.</description>
  
  
  
  1.16      +17 -6     jakarta-commons-sandbox/hivemind/src/test/hivemind/test/HiveMindTestCase.java
  
  Index: HiveMindTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/HiveMindTestCase.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- HiveMindTestCase.java	8 Aug 2003 13:51:09 -0000	1.15
  +++ HiveMindTestCase.java	11 Aug 2003 17:45:28 -0000	1.16
  @@ -277,25 +277,28 @@
       /**
        * Checks to see if any logging event matches a given regexp pattern.
        */
  -    protected void checkLoggingEvent(String name, String pattern) throws Exception
  +    protected void checkLoggingEvent(String name, String pattern, boolean exact) throws Exception
       {
  -        checkLoggingEvent(name, pattern, getInterceptedLogEvents());
  +        checkLoggingEvent(name, pattern, getInterceptedLogEvents(), exact);
       }
   
       /**
        * Checks to see if any LoggingEvent in the list of events matches the name and message pattern.
        * @param name logger name to match or null to match all
  -     * @param pattern regexp pattern to search for
  +     * @param pattern regexp pattern or string to search for
        * @param event list of LoggingEvent to search.
  +     * @param exact if true, then the actual message must exactly match the pattern (which is NOT a regexp pattern). If true,
  +     * the message must match against pattern as a regexp pattern.
        */
  -    protected void checkLoggingEvent(String name, String pattern, List events) throws Exception
  +    protected void checkLoggingEvent(String name, String pattern, List events, boolean exact)
  +        throws Exception
       {
           if (_compiler == null)
               _compiler = new Perl5Compiler();
   
           Pattern compiled = null;
   
  -        if (_matcher == null)
  +        if (_matcher == null & !exact)
               _matcher = new Perl5Matcher();
   
           int count = events.size();
  @@ -308,6 +311,14 @@
                   continue;
   
               String eventMessage = e.getMessage().toString();
  +
  +            if (exact)
  +            {
  +                if (eventMessage.indexOf(pattern) >= 0)
  +                    return;
  +
  +                continue;
  +            }
   
               if (compiled == null)
                   compiled = _compiler.compile(pattern);
  
  
  
  1.5       +5 -3      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/rules/TestClassTranslator.java
  
  Index: TestClassTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/rules/TestClassTranslator.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestClassTranslator.java	8 Aug 2003 13:51:10 -0000	1.4
  +++ TestClassTranslator.java	11 Aug 2003 17:45:28 -0000	1.5
  @@ -107,7 +107,8 @@
   
           checkLoggingEvent(
               null,
  -            "'bad.class.Name' is not a valid class name \\(at .*\\): Could not load class bad.class.Name");
  +            "'bad.class.Name' is not a valid class name \\(at .*\\): Could not load class bad.class.Name",
  +            false);
       }
   
       public void testLocatable() throws Exception
  @@ -137,6 +138,7 @@
   
           checkLoggingEvent(
               RuleUtils.class.getName(),
  -            "Unable to set property value of hivemind\\.test\\.config\\.impl\\.Datum@.* to {} \\(at datum/value\\): ");
  +            "Unable to set property value of hivemind\\.test\\.config\\.impl\\.Datum@.* to {} \\(at datum/value\\): ",
  +            false);
       }
   }
  
  
  
  1.3       +5 -3      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/rules/TestEnumerationTranslator.java
  
  Index: TestEnumerationTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/rules/TestEnumerationTranslator.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestEnumerationTranslator.java	8 Aug 2003 13:51:10 -0000	1.2
  +++ TestEnumerationTranslator.java	11 Aug 2003 17:45:28 -0000	1.3
  @@ -144,7 +144,8 @@
   
           checkLoggingEvent(
               EnumerationTranslator.class.getName(),
  -            "'fred' \\(at .*\\) is not a recognized enumerated value\\.");
  +            "'fred' \\(at .*\\) is not a recognized enumerated value\\.",
  +            false);
   
       }
   
  @@ -161,7 +162,8 @@
   
           checkLoggingEvent(
               EnumerationTranslator.class.getName(),
  -            "Unable to obtain value for static field java\\.lang\\.Boolean\\.HONEST_TO_GOD_TRUE:");
  +            "Unable to obtain value for static field java.lang.Boolean.HONEST_TO_GOD_TRUE:",
  +            true);
       }
   
   }
  
  
  
  1.2       +3 -2      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/rules/TestExtensionPointTranslator.java
  
  Index: TestExtensionPointTranslator.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/rules/TestExtensionPointTranslator.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestExtensionPointTranslator.java	5 Aug 2003 00:50:36 -0000	1.1
  +++ TestExtensionPointTranslator.java	11 Aug 2003 17:45:28 -0000	1.2
  @@ -111,7 +111,8 @@
           checkLoggingEvent(
               ExtensionPointTranslator.class.getName(),
               "Error accessing extension point hivemind\\.test\\.rules\\.missing \\(at .*\\): "
  -                + "Extension point hivemind\\.test\\.rules\\.missing does not exist\\.");
  +                + "Extension point hivemind\\.test\\.rules\\.missing does not exist\\.",
  +            false);
   
           assertNull(h.getDatums());
       }
  
  
  
  1.2       +1 -2      jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/impl/test.properties
  
  Index: test.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/hivemind/src/test/hivemind/test/config/impl/test.properties,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- test.properties	29 Jul 2003 22:20:49 -0000	1.1
  +++ test.properties	11 Aug 2003 17:45:28 -0000	1.2
  @@ -3,4 +3,3 @@
   wife=wilma
   husband=fred
   friend=barney
  -dog=dino
  
  
  

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