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/test/org/apache/hivemind/impl TestSchemaProcessor.java
Date Wed, 11 Aug 2004 18:47:57 GMT
hlship      2004/08/11 11:47:57

  Modified:    framework/src/java/org/apache/hivemind/impl
                        ImplStrings.properties ImplMessages.java
                        SchemaProcessorImpl.java
               .        status.xml
               framework/src/test/org/apache/hivemind/impl
                        TestSchemaProcessor.java
  Log:
  HIVEMIND-41: Check array bounds on the SchemaProcessor stack.
  
  Revision  Changes    Path
  1.8       +3 -1      jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties
  
  Index: ImplStrings.properties
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplStrings.properties,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ImplStrings.properties	11 Aug 2004 11:41:34 -0000	1.7
  +++ ImplStrings.properties	11 Aug 2004 18:47:56 -0000	1.8
  @@ -62,4 +62,6 @@
   interceptor-contribution=interceptor contribution
   registry-already-started=The HiveMind Registry has already been started.
   
  -incomplete-translator=Translator contribution ''{0}'' must specify either the service-id
or class attribute.
  \ No newline at end of file
  +incomplete-translator=Translator contribution ''{0}'' must specify either the service-id
or class attribute.
  +
  +schema-stack-violation=The rules for processing element {0} have incorrectly manipulated
the schema processor object stack.
  \ No newline at end of file
  
  
  
  1.14      +5 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplMessages.java
  
  Index: ImplMessages.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/ImplMessages.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- ImplMessages.java	11 Aug 2004 11:41:34 -0000	1.13
  +++ ImplMessages.java	11 Aug 2004 18:47:56 -0000	1.14
  @@ -343,4 +343,9 @@
       {
           return _formatter.format("incomplete-translator", c.getName());
       }
  +
  +    public static String schemaStackViolation(SchemaProcessor processor)
  +    {
  +        return _formatter.format("schema-stack-violation", processor.getElementPath());
  +    }
   }
  
  
  
  1.9       +8 -0      jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java
  
  Index: SchemaProcessorImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/SchemaProcessorImpl.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SchemaProcessorImpl.java	29 Jul 2004 13:18:49 -0000	1.8
  +++ SchemaProcessorImpl.java	11 Aug 2004 18:47:56 -0000	1.9
  @@ -97,6 +97,9 @@
   
       public Object pop()
       {
  +        if (_stack.isEmpty())
  +            throw new ArrayIndexOutOfBoundsException(ImplMessages.schemaStackViolation(this));
  +
           return _stack.remove(_stack.size() - 1);
       }
   
  @@ -108,6 +111,11 @@
       public Object peek(int depth)
       {
           int count = _stack.size();
  +
  +        int position = count - 1 - depth;
  +
  +        if (position < 0)
  +            throw new ArrayIndexOutOfBoundsException(ImplMessages.schemaStackViolation(this));
   
           return _stack.get(count - 1 - depth);
       }
  
  
  
  1.44      +3 -0      jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- status.xml	11 Aug 2004 11:41:34 -0000	1.43
  +++ status.xml	11 Aug 2004 18:47:56 -0000	1.44
  @@ -57,6 +57,9 @@
           Add ability to mark attributes of an element as unique, such that
           duplicate values in contributions result in errors.
         </action>      
  +      <action type="fix" dev="HLS" fixes-bug="HIVEMIND-41">
  +        Add checks to SchemaProcessorImpl for empty stack conditions
  +      </action>
       </release>
     
       <release version="1.0-beta-2" date="Aug 1 2004">
  
  
  
  1.6       +33 -0     jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java
  
  Index: TestSchemaProcessor.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/org/apache/hivemind/impl/TestSchemaProcessor.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestSchemaProcessor.java	29 Jul 2004 13:18:50 -0000	1.5
  +++ TestSchemaProcessor.java	11 Aug 2004 18:47:57 -0000	1.6
  @@ -21,6 +21,7 @@
   import java.util.List;
   
   import org.apache.hivemind.internal.Module;
  +import org.apache.hivemind.schema.SchemaProcessor;
   import org.apache.hivemind.schema.impl.AttributeModelImpl;
   import org.apache.hivemind.schema.impl.ElementModelImpl;
   import org.apache.hivemind.schema.impl.SchemaImpl;
  @@ -200,5 +201,37 @@
           assertEquals("wilma", h.getValue());
   
           verifyControls();
  +    }
  +
  +    /**
  +     * Tests for when the stack is empty.
  +     */
  +    public void testStackEmpty()
  +    {
  +        SchemaProcessor sp = new SchemaProcessorImpl(null, null, null);
  +
  +		// The sp is pushed onto the stack itself
  +		
  +		sp.pop();
  +
  +        try
  +        {
  +            sp.pop();
  +            unreachable();
  +        }
  +        catch (ArrayIndexOutOfBoundsException ex)
  +        {
  +
  +        }
  +
  +        try
  +        {
  +            sp.peek();
  +            unreachable();
  +        }
  +        catch (ArrayIndexOutOfBoundsException ex)
  +        {
  +        }
  +
       }
   }
  
  
  

---------------------------------------------------------------------
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