You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by jv...@apache.org on 2002/03/10 20:35:28 UTC

cvs commit: jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/project BaseObject.java Developer.java Project.java TestProjectRoundTrip.java project.xml

jvanzyl     02/03/10 11:35:28

  Added:       betwixt/src/test/org/apache/commons/betwixt/project
                        BaseObject.java Developer.java Project.java
                        TestProjectRoundTrip.java project.xml
  Log:
  Placing the project tests in a package of their own.
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/project/BaseObject.java
  
  Index: BaseObject.java
  ===================================================================
  package org.apache.commons.betwixt.project;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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 Maven" 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",
   *    "Apache Maven", 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/>.
   */
  
   /**
   * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
   * @version $Id: BaseObject.java,v 1.1 2002/03/10 19:35:28 jvanzyl Exp $
   */
  public class BaseObject
  {
      /**
       * Display name to use for this object.
       */
      private String name;
  
      /**
       * Id to use for this object.
       */
      private String id;
  
      /**
       * Sets the name attribute of the BaseObject object
       */
      public void setName(String name)
      {
          this.name = name;
      }
  
      /**
       * Gets the name attribute of the BaseObject object
       */
      public String getName()
      {
          return name;
      }
  
      /**
       * Sets the id attribute of the BaseObject object
       */
      public void setId(String id)
      {
          this.id = id;
      }
  
      /**
       * Gets the id attribute of the BaseObject object
       */
      public String getId()
      {
          return id;
      }
  
      /**
       * Description of the Method
       */
      public String toString()
      {
          return name;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/project/Developer.java
  
  Index: Developer.java
  ===================================================================
  package org.apache.commons.betwixt.project;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 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 Maven" 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",
   *    "Apache Maven", 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/>.
   */
  
  /**
   * @author <a href="mailto:jvanzyl@apache.org">Jason van Zyl</a>
   * @version $Id: Developer.java,v 1.1 2002/03/10 19:35:28 jvanzyl Exp $
   */
  public class Developer
       extends BaseObject
  {
      /**
       * Developer's email address. NOTE: there may eventually be more than
       * one email address.
       */
      private String email;
  
      /**
       * Developer's organziation.
       */
      private String organization;
  
      /**
       * Constructor for the Developer object
       */
      public Developer()
      {
      }
  
      /**
       * Sets the email attribute of the Developer object
       */
      public void setEmail(String email)
      {
          this.email = email;
      }
  
      /**
       * Gets the email attribute of the Developer object
       */
      public String getEmail()
      {
          return email;
      }
  
      /**
       * Sets the organization attribute of the Developer object
       */
      public void setOrganization(String organization)
      {
          this.organization = organization;
      }
  
      /**
       * Gets the organization attribute of the Developer object
       */
      public String getOrganization()
      {
          return organization;
      }
  }
  
  
  
  1.1                  jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/project/Project.java
  
  Index: Project.java
  ===================================================================
  /*
   * $Header: /home/cvs/jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/project/Project.java,v 1.1 2002/03/10 19:35:28 jvanzyl Exp $
   * $Revision: 1.1 $
   * $Date: 2002/03/10 19:35:28 $
   *
   * ====================================================================
   *
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 1999-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 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/>.
   * 
   * $Id: Project.java,v 1.1 2002/03/10 19:35:28 jvanzyl Exp $
   */
  package org.apache.commons.betwixt.project;
  
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.Enumeration;
  import java.util.Iterator;
  import java.util.List;
  import java.util.Map;
  
  import org.apache.commons.collections.IteratorEnumeration;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /** <p><code>Project</code> is a sample bean for use by the test cases.</p>
    *
    * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
    * @version $Revision: 1.1 $
    */
  public class Project
      implements Serializable {
  
      /** Logger */
      private static final Log log = LogFactory.getLog( Project.class );
      
      private String description;
      private String projectPackage;
      private ArrayList developerList;
      
      public Project() {
          developerList = new ArrayList();
      }
  
      public void setDescription(String description) {
          this.description = description;
      }        
      
      public String getDescription() {
          return description;
      }
  
      public void setPackage(String projectPackage) {
          this.projectPackage = projectPackage;
      }        
      
      public String getPackage() {
          return projectPackage;
      }
  
      public void addDeveloper(Developer developer)
      {
          developerList.add(developer);
      }        
  
      public void setDeveloperList(ArrayList developerList)
      {
          this.developerList = developerList;
      }
      
      public ArrayList getDeveloperList()
      {
          return developerList;
      }        
  }
  
  
  
  1.1                  jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/project/TestProjectRoundTrip.java
  
  Index: TestProjectRoundTrip.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   * 
   * $Id: TestProjectRoundTrip.java,v 1.1 2002/03/10 19:35:28 jvanzyl Exp $
   */
  package org.apache.commons.betwixt.project;
  
  import java.io.InputStream;
  import java.io.IOException;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import junit.textui.TestRunner;
  
  import org.apache.commons.betwixt.io.BeanReader;
  import org.apache.commons.betwixt.io.BeanWriter;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.commons.logging.impl.SimpleLog;
  
  
  /** Test harness for the BeanReader that deals with project definitions.
    *
    * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
    * @version $Revision: 1.1 $
    */
  public class TestProjectRoundTrip extends TestCase {
      
      public static void main( String[] args ) {
          TestRunner.run( suite() );
      }
      
      public static Test suite() {
          return new TestSuite(TestProjectRoundTrip.class);
      }
      
      public TestProjectRoundTrip(String testName) {
          super(testName);
      }
      
      public void testBeanWriter() throws Exception {
          
          BeanReader reader = new BeanReader();
          reader.registerBeanClass( getBeanClass() );
          InputStream in = getXMLInput();
          
          try {
  
              Project bean = (Project) reader.parse( in );
              assertEquals("org.apache.maven", bean.getPackage());
              assertEquals("jason@zenplex.com", 
                  ((Developer)bean.getDeveloperList().get(0)).getEmail());
              //writeBean( bean );
          }
          catch (Exception e)
          {
              e.printStackTrace();
              fail();
          }            
          finally {
              in.close();
          }
      }
      
      public void writeBean(Object bean) throws Exception {
          BeanWriter writer = new BeanWriter();
          writer.enablePrettyPrint();
          writer.write( bean );
      }
      
      /** @return the bean class to use as the root */
      public Class getBeanClass() {
          return Project.class;
      }
      
      protected InputStream getXMLInput() throws IOException {
          return getClass().getResourceAsStream( "project.xml" );
      }
      
  }
  
  
  
  
  1.1                  jakarta-commons-sandbox/betwixt/src/test/org/apache/commons/betwixt/project/project.xml
  
  Index: project.xml
  ===================================================================
  <?xml version="1.0"?>
  <Project>
    
    <name>jakarta-turbine-maven</name>
    <id>maven</id>
    <currentVersion>0.1</currentVersion>
    <organization>Apache Software Foundation</organization>
    <inceptionYear>2001</inceptionYear>
    <package>org.apache.maven</package>
    <shortDescription>Project Management Tools</shortDescription>
  
    <developerList>
      <Developer>
        <name>Jason van Zyl</name>
        <email>jason@zenplex.com</email>
      </Developer>
    </developerList>
  
    <description>
        Maven: a person who has special knowledge or experience; an expert
        or connoisseur. In short, Maven strives to be a Java project expert. The
        entire concept of Maven is based around an object model for a project.
    </description>
  
    <url>http://jakarta.apache.org/turbine/maven/</url>
    <cvsWebUrl>http://cvs.apache.org/viewcvs/jakarta-turbine-maven/</cvsWebUrl>
    
    <mailingLists>
      <mailingList>
        <name>Turbine User List</name>
        <subscribe>turbine-user-subscribe@jakarta.apache.org</subscribe>
        <unsubscribe>turbine-user-unsubscribe@jakarta.apache.org</unsubscribe>
        <archive>http://www.mail-archive.com/turbine-user@jakarta.apache.org/</archive>
      </mailingList>
      <mailingList>
        <name>Turbine Developer List</name>
        <subscribe>mailto:turbine-dev-subscribe@jakarta.apache.org</subscribe>
        <unsubscribe>mailto:turbine-dev-unsubscribe@jakarta.apache.org</unsubscribe>
        <archive>http://www.mail-archive.com/turbine-dev@jakarta.apache.org/</archive>
      </mailingList>
    </mailingLists>
  </Project>
  
  
  
  

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