You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2004/08/10 05:42:30 UTC

cvs commit: ws-axis/java/test/saaj TestSOAPElement.java

dims        2004/08/09 20:42:30

  Added:       java/test/message TestText.java
               java/test/saaj TestSOAPElement.java
  Log:
  OOPS!!!
  
  Revision  Changes    Path
  1.1                  ws-axis/java/test/message/TestText.java
  
  Index: TestText.java
  ===================================================================
  /*=============================================================================*
   *  Confidential Copyright (c) 2004 Hewlett-Packard Development Company, L.P.  *
   *=============================================================================*/
  package test.message;
  
  import junit.framework.TestCase;
  
  import org.apache.axis.message.Text;
  
  /**
   * Test case for {@link Text}.
   *
   * @author Ian P. Springer
   */
  public class TestText extends TestCase
  {
  
      private static final String VANILLA = "vanilla";
      private static final String CHOCOLATE = "chocolate";
      private static final String NULL = null;
  
      private Text vanillaText;
      private Text chocolateText;
      private Text nullText;
      private Text vanillaText2;
  
      protected void setUp() throws Exception
      {
          vanillaText = new org.apache.axis.message.Text( VANILLA );
          vanillaText2 = new org.apache.axis.message.Text( VANILLA );
          chocolateText = new org.apache.axis.message.Text( CHOCOLATE );
          nullText = new org.apache.axis.message.Text( NULL );
      }
  
      /**
       * Test for {@link org.apache.axis.message.Text#toString()}.
       *
       * @throws Exception on error
       */
      public void testToString() throws Exception
      {
          assertEquals( VANILLA, vanillaText.toString() );
          assertEquals( NULL, nullText.toString() );
      }
  
      /**
       * Test for {@link org.apache.axis.message.Text#hashCode()}.
       *
       * @throws Exception on error
       */
      public void testHashCode() throws Exception
      {
          assertEquals( VANILLA.hashCode(), vanillaText.hashCode() );
          assertEquals( 0, nullText.hashCode() );
      }
  
      /**
       * Test for {@link org.apache.axis.message.Text#equals(Object)}.
       *
       * @throws Exception on error
       */
      public void testEquals() throws Exception
      {
          assertEquals( vanillaText, vanillaText2 );
          assertEquals( vanillaText2, vanillaText );
          assertTrue( !vanillaText.equals( chocolateText ) );
          assertTrue( !chocolateText.equals( vanillaText ) );
          assertTrue( !vanillaText.equals( null ) );
          assertTrue( !vanillaText.equals( VANILLA ) );
      }
  
  }
  
  
  
  1.1                  ws-axis/java/test/saaj/TestSOAPElement.java
  
  Index: TestSOAPElement.java
  ===================================================================
  /*=============================================================================*
   *  Confidential Copyright (c) 2004 Hewlett-Packard Development Company, L.P.  *
   *=============================================================================*/
  package test.saaj;
  
  import junit.framework.TestCase;
  
  import javax.xml.soap.Node;
  import javax.xml.soap.SOAPElement;
  import javax.xml.soap.SOAPFactory;
  import javax.xml.soap.Text;
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  /**
   * Test case for Axis impl of SAAJ {@link SOAPElement} interface ({@link org.apache.axis.message.MessageElement}).
   *
   * @author Ian P. Springer
   */
  public class TestSOAPElement extends TestCase
  {
      private SOAPElement soapElem;
  
      protected void setUp() throws Exception
      {
          soapElem = SOAPFactory.newInstance().createElement( "Test", "test", "http://test.apache.org/" );
      }
  
      /**
       * Test for Axis impl of {@link SOAPElement#addTextNode(String)}.
       *
       * @throws Exception on error
       */
      public void testAddTextNode() throws Exception
      {
          assertNotNull( soapElem );
          final String value = "foo";
          soapElem.addTextNode( value );
          assertEquals( value, soapElem.getValue() );
          Text text = assertContainsText( soapElem );
          assertEquals( value, text.getValue() );
      }
  
      private Text assertContainsText( SOAPElement soapElem )
      {
          assertTrue( soapElem.hasChildNodes() );
          List childElems = toList( soapElem.getChildElements() );
          assertTrue( childElems.size() == 1 );
          Node node = (Node) childElems.get( 0 );
          assertTrue( node instanceof Text );
          return (Text) node;
      }
  
      private List toList( Iterator iter )
      {
          List list = new ArrayList();
          while ( iter.hasNext() )
          {
              list.add( iter.next() );
          }
          return list;
      }
  
  }