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/schema/rules TestNumericTranslators.java
Date Sun, 01 Aug 2004 17:57:58 GMT
hlship      2004/08/01 10:57:58

  Modified:    framework/src/java/org/apache/hivemind/impl
                        StrictErrorHandler.java
               .        status.xml
               framework/src/test/hivemind/test/sdl
                        TestSDLResourceParser.java
  Added:       framework/src/test/org/apache/hivemind/schema/rules
                        TestNumericTranslators.java
  Removed:     framework/src/test/hivemind/test/rules
                        TestNumericTranslators.java
  Log:
  HIVEMIND-26: Changed some unit tests to adapt to platform line endings.
  
  Revision  Changes    Path
  1.2       +10 -10    jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/StrictErrorHandler.java
  
  Index: StrictErrorHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/java/org/apache/hivemind/impl/StrictErrorHandler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StrictErrorHandler.java	25 Jul 2004 22:43:05 -0000	1.1
  +++ StrictErrorHandler.java	1 Aug 2004 17:57:57 -0000	1.2
  @@ -1,16 +1,16 @@
  -//Copyright 2004 The Apache Software Foundation
  +//  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
  +// 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
  +//     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.
  +// 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.
   
   package org.apache.hivemind.impl;
   
  
  
  
  1.35      +3 -0      jakarta-hivemind/status.xml
  
  Index: status.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/status.xml,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- status.xml	1 Aug 2004 17:40:36 -0000	1.34
  +++ status.xml	1 Aug 2004 17:57:58 -0000	1.35
  @@ -92,6 +92,9 @@
         <action type="fix" dev="HLS" fixes-bug="HIVEMIND-35">
           Made a number of changes to ensure HiveMind compatibility with JDK 1.3.
         </action>
  +      <action type="fix" dev="HLS" fixes-bug-"HIVEMIND-26">
  +        Changed some unit tests to adapt to platform line endings.
  +      </action>
       </release>
     
       <release version="1.0-beta-1" date="Jun 26 2004">
  
  
  
  1.5       +10 -3     jakarta-hivemind/framework/src/test/hivemind/test/sdl/TestSDLResourceParser.java
  
  Index: TestSDLResourceParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-hivemind/framework/src/test/hivemind/test/sdl/TestSDLResourceParser.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TestSDLResourceParser.java	16 Jul 2004 23:15:40 -0000	1.4
  +++ TestSDLResourceParser.java	1 Aug 2004 17:57:58 -0000	1.5
  @@ -17,6 +17,8 @@
   import java.net.URL;
   import java.util.List;
   
  +import javax.swing.border.LineBorder;
  +
   import org.apache.hivemind.Element;
   import org.apache.hivemind.Resource;
   import org.apache.hivemind.test.HiveMindTestCase;
  @@ -31,6 +33,7 @@
    */
   public class TestSDLResourceParser extends HiveMindTestCase
   {
  +    private static final String LINEBREAK = System.getProperty("line.separator");
   
       private Element parse(String file) throws Exception
       {
  @@ -137,7 +140,9 @@
           checkAttributes(e, new String[] { "pi", "3.14159", "sunday", "0", "profit", "-1.34"
});
   
           e = (Element) l.get(3);
  -        checkAttributes(e, new String[] { "user", "Fred Flintstone", "long", "Barney\r\nRubble"
});
  +        checkAttributes(
  +            e,
  +            new String[] { "user", "Fred Flintstone", "long", "Barney" + LINEBREAK + "Rubble"
});
   
           e = (Element) l.get(4);
           checkAttributes(
  @@ -168,9 +173,11 @@
           }
           catch (SAXParseException ex)
           {
  -            assertExceptionSubstring(
  +        	// The column may be 35 or 36 depending on line encoding.
  +        	
  +            assertExceptionRegexp(
                   ex,
  -                "sdl/missing-root.sdl: Encountered \"<EOF>\" at line 15, column 36.");
  +                "sdl/missing\\-root\\.sdl: Encountered \"<EOF>\" at line 15, column
3(5|6)\\.");
           }
       }
   
  
  
  
  1.1                  jakarta-hivemind/framework/src/test/org/apache/hivemind/schema/rules/TestNumericTranslators.java
  
  Index: TestNumericTranslators.java
  ===================================================================
  //  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.
  
  package org.apache.hivemind.schema.rules;
  
  import hivemind.test.FrameworkTestCase;
  
  import org.apache.hivemind.ApplicationRuntimeException;
  import org.apache.hivemind.schema.rules.DoubleTranslator;
  import org.apache.hivemind.schema.rules.IntTranslator;
  import org.apache.hivemind.schema.rules.LongTranslator;
  
  /**
   * Tests the numeric translators.
   *
   * @author Howard Lewis Ship
   */
  public class TestNumericTranslators extends FrameworkTestCase
  {
      /**
      * Tests {@link org.apache.hivemind.schema.rules.IntTranslator} with
      * the default constructor.
      */
      public void testIntTranslator()
      {
          IntTranslator t = new IntTranslator();
  
          assertEquals(new Integer(10), t.translate(null, null, "10", null));
      }
  
      public void testIntDefault()
      {
          IntTranslator t = new IntTranslator();
  
          assertEquals(new Integer(0), t.translate(null, null, null, null));
      }
  
      public void testIntLow()
      {
          IntTranslator t = new IntTranslator("min=5,max=200");
  
          try
          {
              t.translate(null, null, "3", null);
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(ex, RulesMessages.minIntValue("3", 5));
          }
      }
  
      public void testIntHigh()
      {
          IntTranslator t = new IntTranslator("min=5,max=200");
  
          try
          {
              t.translate(null, null, "50900", null);
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(ex, RulesMessages.maxIntValue("50900", 200));
          }
  
      }
  
      public void testIntDefaultValue()
      {
          IntTranslator t = new IntTranslator("default=7");
  
          assertEquals(new Integer(7), t.translate(null, null, null, null));
      }
  
      public void testIntInvalid()
      {
          IntTranslator t = new IntTranslator("default=13");
  
          try
          {
              t.translate(null, null, "qbert", null);
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
  
              assertExceptionSubstring(ex, "'qbert' is not an integer value.");
          }
      }
  
      public void testLongTranslator()
      {
          LongTranslator t = new LongTranslator();
  
          assertEquals(new Long(10), t.translate(null, null, "10", null));
      }
  
      public void testLongDefault()
      {
          LongTranslator t = new LongTranslator();
  
          assertEquals(new Long(0), t.translate(null, null, null, null));
      }
  
      public void testLongLow()
      {
          LongTranslator t = new LongTranslator("min=5,max=200");
  
          try
          {
  
              t.translate(null, null, "3", null);
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
  
              assertExceptionSubstring(ex, RulesMessages.minLongValue("3", 5));
          }
      }
  
      public void testLongHigh()
      {
  
          LongTranslator t = new LongTranslator("min=5,max=200");
  
          try
          {
  
              t.translate(null, null, "50900", null);
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
  
              assertExceptionSubstring(ex, RulesMessages.maxLongValue("50900", 200));
          }
      }
  
      public void testLongDefaultValue()
      {
          LongTranslator t = new LongTranslator("default=7");
  
          assertEquals(new Long(7), t.translate(null, null, null, null));
      }
  
      public void testLongInvalid()
      {
          LongTranslator t = new LongTranslator("default=13");
  
          try
          {
  
              t.translate(null, null, "qbert", null);
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(ex, "'qbert' is not a long value.");
          }
      }
  
      /**
       * Tests {@link org.apache.hivemind.schema.rules.IntTranslator} with
       * the default constructor.
       */
      public void testDoubleTranslator()
      {
          DoubleTranslator t = new DoubleTranslator();
  
          assertEquals(new Double(10.7), t.translate(null, null, "10.7", null));
      }
  
      public void testDoubleDefault()
      {
          DoubleTranslator t = new DoubleTranslator();
  
          assertEquals(new Double(0), t.translate(null, null, null, null));
      }
  
      public void testDoubleLow()
      {
          DoubleTranslator t = new DoubleTranslator("min=5.25,max=200");
  
          try
          {
              t.translate(null, null, "3", null);
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(ex, RulesMessages.minDoubleValue("3", 5.25));
          }
      }
  
      public void testDoubleHigh()
      {
          DoubleTranslator t = new DoubleTranslator("min=07,max=207.5");
  
          try
          {
              t.translate(null, null, "208.3", null);
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(ex, RulesMessages.maxDoubleValue("208.3", 207.5));
          }
      }
  
      public void testDoubleDefaultValue()
      {
          DoubleTranslator t = new DoubleTranslator("default=7.77");
  
          assertEquals(new Double(7.77), t.translate(null, null, null, null));
      }
  
      public void testDoubleInvalid()
      {
          DoubleTranslator t = new DoubleTranslator("default=13");
  
          try
          {
              t.translate(null, null, "qbert", null);
              unreachable();
          }
          catch (ApplicationRuntimeException ex)
          {
              assertExceptionSubstring(ex, "'qbert' is not a double value.");
          }
      }
  
  }
  
  
  

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