You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by pr...@apache.org on 2002/03/09 08:27:37 UTC

cvs commit: jakarta-commons-sandbox/periodicity/src/xml itip-validation.xml

prickett    02/03/08 23:27:37

  Added:       periodicity/src/java/org/apache/commons/periodicity/test/usertype
                        ValidUserTypeTest.java
               periodicity/src/xml itip-validation.xml
  Log:
  JUnit test that tests for all valid calendar user types (Submitted by Mike
  George).
  
  An xml document that mirrors the validation tables in RFC 2446. The first cut
  includes validation data for most of the VToDo methods.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/periodicity/src/java/org/apache/commons/periodicity/test/usertype/ValidUserTypeTest.java
  
  Index: ValidUserTypeTest.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2002 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 acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *     "Apache Jetspeed" 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" or
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * 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.periodicity.test.usertype;
  
  import org.apache.commons.periodicity.parameters.UserType;
  import org.apache.commons.periodicity.util.ICalendarException;
  import junit.framework.TestCase;
  import java.lang.reflect.Array;
  
  /**
   * This class tests to ensure that a CUTYPE value passed into
   * the UserType class (org\apache\commons\periodicity\parameters\UserType)
   * is stored correctly and is valid when retrieved.
   * Valid user types include "INDIVIDUAL", "GROUP", "RESOURCE", "ROOM",
   * X-types and "UNKNOWN".
   * CUTYPE is covered in RFC2445 Section 4.2.3.
   * @author Mike George
   * <a href="mailto:javajoe2975@comcast.net">javajoe2975@comcast.net</a>
   */
  
  public class ValidUserTypeTest extends TestCase
  {
      private static final String[] VALUES = new String[]
      {
          "INDIVIDUAL", "GROUP", "RESOURCE", "ROOM", "UNKNOWN"
      };
  
      /**
        * This public constructor passes a String to the TestCase
        * constructor.
        * @param A name that helps uniquely identify the test, i.e. a date, test#.
        */
      public ValidUserTypeTest(String name) throws Throwable
      {
          super("ValidUserTypeTest:" + name);
          runTest();
      }
  
      /**
        * This method passes a valid CUTYPE value to a UserType object using
        * the single parameter constructor in the UserType class.
        */
      protected void useSingleArgConstructor() throws ICalendarException
      {
          final int length = Array.getLength(VALUES);
  
          for (int i = 0; i < length; i++)
          {
              UserType test = new UserType(VALUES[i]);
              assertEquals(test.getValue(), VALUES[i]);
          }
      }
      
      /**
        * This method uses the setvalue method directly to pass in a valid
        * CUTYPE value.
        */
      protected void useSetValue() throws ICalendarException
      {
          final int length = Array.getLength(VALUES);
          UserType test = new UserType();
          
          for (int i = 0; i < length; i++)
          {
              test.setValue(VALUES[i]);
              assertEquals(test.getValue(), VALUES[i]);
          }
      }
      
      /**
        * This method tests to make sure that if a null value is 
        * passed in, a null value is returned.
        */
      protected void setNullValue() throws ICalendarException
      {   
          //Using no-arg constructor
          UserType test = new UserType();
          assertEquals(test.getValue(), null);
      }
      
      /**
        * This method passes in a valid parameter and then uses
        * the get<CUTYPE> method to validate the parameter.
        */
      protected void testValidValue() throws ICalendarException
      {
          UserType test1 = new UserType("INDIVIDUAL");
          assertEquals(test1.isIndividual(), true);
          assertEquals(test1.isGroup(), false);
          assertEquals(test1.isResource(), false);
          assertEquals(test1.isRoom(), false);
          assertEquals(test1.isUnknown(), false);
          
          UserType test2 = new UserType("GROUP");
          assertEquals(test2.isIndividual(), false);
          assertEquals(test2.isGroup(), true);
          assertEquals(test2.isResource(), false);
          assertEquals(test2.isRoom(), false);
          assertEquals(test2.isUnknown(), false);
          
          UserType test3 = new UserType("RESOURCE");
          assertEquals(test3.isIndividual(), false);
          assertEquals(test3.isGroup(), false);
          assertEquals(test3.isResource(), true);
          assertEquals(test3.isRoom(), false);
          assertEquals(test3.isUnknown(), false);
        
          UserType test4 = new UserType("ROOM");
          assertEquals(test4.isIndividual(), false);
          assertEquals(test4.isGroup(), false);
          assertEquals(test4.isResource(), false);
          assertEquals(test4.isRoom(), true);
          assertEquals(test4.isUnknown(), false);   
          
          UserType test5 = new UserType("UNKNOWN");
          assertEquals(test5.isIndividual(), false);
          assertEquals(test5.isGroup(), false);
          assertEquals(test5.isResource(), false);
          assertEquals(test5.isRoom(), false);
          assertEquals(test5.isUnknown(), true);
          
          UserType test6 = new UserType();
          assertEquals(test6.isIndividual(), false);
          assertEquals(test6.isGroup(), false);
          assertEquals(test6.isResource(), false);
          assertEquals(test6.isRoom(), false);
          assertEquals(test6.isUnknown(), false);        
      }
      
      /**
        * This method tests to make sure that an X-value can be set
        * and retrieved using both the single-arg and no-arg constructors
        */
      protected void setXName() throws ICalendarException
      {
          UserType test1 = new UserType();
          test1.setValue("X-newOne");
          assertEquals(test1.getValue(), "X-newOne");
          
          UserType test2 = new UserType("X-newTwo");
          assertEquals(test2.getValue(), "X-newTwo");
      }
         
      /**
        * This method runs the test.
        */
      protected void runTest() throws Throwable
      {
          useSingleArgConstructor();
          useSetValue();
          setNullValue();
          testValidValue();
          setXName();
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/periodicity/src/xml/itip-validation.xml
  
  Index: itip-validation.xml
  ===================================================================
  <Apache-iTIP-validation>
     <ICAL>
        <CALSCALE presence="01"/>
        <PRODID presence="1"/>
        <VERSION presence="1"/>
     </ICAL>
     <VTIMEZONE presence="0+">
        <DAYLIGHT presence="0+"/>
           <COMMENT presence="01"/>
           <DTSTART presence="1"/>
           <RDATE presence="0+"/>
           <RRULE presence="0+"/>
           <TZNAME presence="01"/>
           <TZOFFSET presence="1"/>
           <TZOFFSETFROM presence="1"/>
           <TZOFFSETTO presence="1"/>
        </DAYLIGHT>
        <STANDARD>
           <COMMENT presence="01"/>
           <DTSTART presence="1"/>
           <RDATE presence="0+"/>
           <RRULE presence="0+"/>
           <TZNAME presence="01"/>
           <TZOFFSETFROM presence="1"/>
           <TZOFFSETTO presence="1"/>
        </STANDARD>
        <TZID presence="1"/>
        <TZURL presence="01"/>
        <LAST-MODIFIED presence="01"/>
     </VTIMEZONE>   
     <VEVENT method="PUBLISH">
        <DTSTAMP presence="1"/>
        <DTSTART presence="1"/>
        <ORGANIZER presence="1"/>
        <SUMMARY presence="1"/>
        <UID presence="1"/>
        <RECURRENCE-ID presence="01"/>
        <SEQUENCE presence="01"/>
        <ATTACH presence="0+"/>
        <CATEGORIES presence="01"/>
        <CLASS presence="01"/>
        <COMMENT presence="01"/>
        <CONTACT presence="01"/>
        <CREATED presence="01"/>
        <DESCRIPTION presence="01"/>
        <DTEND presence="01"/>
        <DURATION presence="01"/>
        <EXDATE presence="0+"/>
        <EXRULE presence="0+"/>
        <GEO presence="01"/>
        <LAST-MODIFIED presence="01"/>
        <LOCATION presence="01"/>
        <PRIORITY presence="01"/>
        <RDATE presence="0+"/>
        <RELATED-TO presence="0+"/>
        <RESOURCES presence="01"/>
        <RRULE presence="0+"/>
        <STATUS presence="01"/>
        <TRANSP presence="01"/>
        <URL presence="01"/>
        <ATTENDEE presence="0"/>
        <REQUEST-STATUS presence="0"/>
        <VALARM presence="0+"/>
        <VFREEBUSY presence="0"/>
        <VJOURNAL presence="0"/>
        <VTODO presence="0"/>
        <VTIMEZONE presence="0+"/>
     </VEVENT>
     <VEVENT method="REQUEST" presence="1+">
        <ATTENDEE presence="1+"/>
        <DTSTAMP presence="1"/>
        <DTSTART presence="1"/>
        <ORGANIZER presence="1"/>
        <SEQUENCE presence="01"/>
        <SUMMARY presence="1"/>
        <UID presence="1"/>
        <ATTACH presence="0+"/>
        <CATEGORIES presence="01"/>
        <CLASS presence="01"/>
        <COMMENT presence="01"/>
        <CONTACT presence="0+"/>
        <CREATED presence="01"/>
        <DESCRIPTION presence="01"/>
        <DTEND presence="01"/>
        <DURATION presence="01"/>
        <EXDATE presence="0+"/>
        <EXRULE presence="0+"/>
        <GEO presence="01"/>
        <LAST-MODIFIED presence="01"/>
        <LOCATION presence="01"/>
        <PRIORITY presence="01"/>
        <RDATE presence="0+"/>
        <RECURRENCE-ID presence="01"/>
        <RELATED-TO presence="0+"/>
        <REQUEST-STATUS presence="0+"/>
        <RESOURCES presence="01"/>
        <RRULE presence="0+"/>
        <STATUS presence="01"/>
        <TRANSP presence="01"/>
        <URL presence="01"/>
        <VALARM presence="0+"/>
        <VTIMEZONE presence="0+"/>
        <VFREEBUSY presence="0+"/>
        <VJOURNAL presence="0+"/>
        <VTODO presence="0+"/>
     </VEVENT>
     <VEVENT method="REPLY" presence="1+">
        <ATTENDEE presence="1"/>
        <DTSTAMP presence="1"/>
        <ORGANIZER presence="1"/>
        <RECURRENCE-ID presence="01"/>
        <UID presence="1"/>
        <SEQUENCE presence="01"/>
        <ATTACH presence="0+"/>
        <CATEGORIES presence="01"/>
        <CLASS presence="01"/>
        <COMMENT presence="01"/>
        <CONTACT presence="0+"/>
        <CREATED presence="01"/>
        <DESCRIPTION presence="01"/>
        <DTEND presence="01"/>
        <DTSTART presence="01"/>
        <DURATION presence="01"/>
        <EXDATE presence="0+"/>
        <EXRULE presence="0+"/>
        <GEO presence="01"/>
        <LAST-MODIFIED presence="01"/>
        <LOCATION presence="01"/>
        <PRIORITY presence="01"/>
        <RDATE presence="0+"/>
        <RELATED-TO presence="0+"/>
        <RESOURCES presence="01"/>
        <REQUEST-STATUS presence="0+"/>
        <RRULE presence="0+"/>
        <STATUS presence="01"/>
        <SUMMARY presence="01"/>
        <TRANSP presence="01"/>
        <URL presence="01"/>
        <VTIMEZONE presence="01"/>
        <VALARM presence="0"/>
        <VFREEBUSY presence="0"/>
        <VJOURNAL presence="0"/>
        <VTODO presence="0"/>
     </VEVENT>
     <VEVENT method="ADD" presence="1">
        <DTSTAMP presence="1"/>
        <DTSTART presence="1"/>
        <ORGANIZER presence="1"/>
        <SEQUENCE presence="1"/>
        <SUMMARY presence="1"/>
        <UID presence="1"/>
        <ATTACH presence="0+"/>
        <ATTENDEE presence="0+"/>
        <CATEGORIES presence="01"/>
        <CLASS presence="01"/>
        <COMMENT presence="01"/>
        <CONTACT presence="0+"/>
        <CREATED presence="01"/>
        <DESCRIPTION presence="01"/>
        <DTEND presence="01"/>
        <DURATION presence="01"/>
        <EXDATE presence="0+"/>
        <EXRULE presence="0+"/>
        <GEO presence="01"/>
        <LAST-MODIFIED presence="01"/>
        <LOCATION presence="01"/>
        <PRIORITY presence="01"/>
        <RDATE presence="0+"/>
        <RELATED-TO presence="0+"/>
        <RESOURCES presence="01"/>
        <RRULE presence="0+"/>
        <STATUS presence="01"/>
        <TRANSP presence="01"/>
        <URL presence="01"/>
        <RECURRENCE-ID presence="0"/>
        <REQUEST-STATUS presence="0"/>
        <VALARM presence="0+"/>
        <VTIMEZONE presence="0+"/>
        <VFREEBUSY presence="0"/>
        <VTODO presence="0"/>
        <VJOURNAL presence="0"/>
     </VEVENT>
     <VEVENT method="CANCEL" presence="1+">
        <ATTENDEE presence="0+"/>
        <DTSTAMP presence="1"/>
        <ORGANIZER presence="1"/>
        <SEQUENCE presence="1"/>
        <UID presence="1"/>
        <COMMENT presence="01"/>
        <ATTACH presence="0+"/>
        <CATEGORIES presence="01"/>
        <CLASS presence="01"/>
        <CONTACT presence="0+"/>
        <CREATED presence="01"/>
        <DESCRIPTION presence="01"/>
        <DTEND presence="01"/>
        <DTSTART presence="01"/>
        <DURATION presence="01"/>
        <EXDATE presence="0+"/>
        <EXRULE presence="0+"/>
        <GEO presence="01"/>
        <LAST-MODIFIED presence="01"/>
        <LOCATION presence="01"/>
        <PRIORITY presence="01"/>
        <RDATE presence="0+"/>
        <RECURRENCE-ID presence="01"/>
        <RELATED-TO presence="0+"/>
        <RESOURCES presence="01"/>
        <RRULE presence="0+"/>
        <STATUS presence="01"/>
        <SUMMARY presence="01"/>
        <TRANSP presence="01"/>
        <URL presence="01"/>
        <REQUEST-STATUS presence="0"/>
        <VTIMEZONE presence="0+"/>
        <VTODO presence="0"/>
        <VJOURNAL presence="0"/>
        <VFREEBUSY presence="0"/>
        <VALARM presence="0"/>
     </VEVENT>   
     <VEVENT method="REFRESH" presence="1">
        <ATTENDEE presence="1"/>
        <DTSTAMP presence="1"/>
        <ORGANIZER presence="1"/>
        <UID presence="1"/>
        <COMMENT presence="01"/>
        <RECURRENCE-ID presence="01"/>
        <ATTACH presence="0"/>
        <CATEGORIES presence="0"/>
        <CLASS presence="0"/>
        <CONTACT presence="0"/>
        <CREATED presence="0"/>
        <DESCRIPTION presence="0"/>
        <DTEND presence="0"/>
        <DTSTART presence="0"/>
        <DURATION presence="0"/>
        <EXDATE presence="0"/>
        <EXRULE presence="0"/>
        <GEO presence="0"/>
        <LAST-MODIFIED presence="0"/>
        <LOCATION presence="0"/>
        <PRIORITY presence="0"/>
        <RDATE presence="0"/>
        <RELATED-TO presence="0"/>
        <REQUEST-STATUS presence="0"/>
        <RESOURCES presence="0"/>
        <RRULE presence="0"/>
        <SEQUENCE presence="0"/>
        <STATUS presence="0"/>
        <SUMMARY presence="0"/>
        <TRANSP presence="0"/>
        <URL presence="0"/>
        <VTODO presence="0"/>
        <VJOURNAL presence="0"/>
        <VFREEBUSY presence="0"/>
        <VTIMEZONE presence="0"/>
        <VALARM presence="0"/>
     </VEVENT>
     <VEVENT 
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>