CVS: Tapestry/junit/src/net/sf/tapestry/junit Properties.properties,NONE,1.1.2.1 BindingsTestCase.java,1.6,1.6.2.1 TestPropertySource.java,1.2,1.2.2.1

Howard Lewis Ship <[email protected]>
Newsgroups gmane.comp.java.tapestry.cvs
Message-ID <[email protected]>
Update of /cvsroot/tapestry/Tapestry/junit/src/net/sf/tapestry/junit
In directory sc8-pr-cvs1:/tmp/cvs-serv3134/junit/src/net/sf/tapestry/junit

Modified Files:
      Tag: hship-2-3
	BindingsTestCase.java TestPropertySource.java 
Added Files:
      Tag: hship-2-3
	Properties.properties 
Log Message:
Add tests for <listener-binding>

--- NEW FILE: Properties.properties ---
# $Id: Properties.properties,v 1.1.2.1 2003/01/04 02:49:07 hship Exp $

fred=flintstone
barney=rubble

Index: BindingsTestCase.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/junit/src/net/sf/tapestry/junit/BindingsTestCase.java,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -C2 -d -r1.6 -r1.6.2.1
*** BindingsTestCase.java	27 Nov 2002 17:58:43 -0000	1.6
--- BindingsTestCase.java	4 Jan 2003 02:49:06 -0000	1.6.2.1
***************
*** 17,20 ****
--- 17,21 ----
  import net.sf.tapestry.binding.ExpressionBinding;
  import net.sf.tapestry.binding.FieldBinding;
+ import net.sf.tapestry.binding.ListenerBinding;
  import net.sf.tapestry.binding.StaticBinding;
  
***************
*** 33,37 ****
  
      public static final Object NULL_FIELD = null;
!     
      private IResourceResolver _resolver = new DefaultResourceResolver();
  
--- 34,38 ----
  
      public static final Object NULL_FIELD = null;
! 
      private IResourceResolver _resolver = new DefaultResourceResolver();
  
***************
*** 58,62 ****
          private double _doubleValue;
          private Object _objectValue;
!         
          public boolean getBooleanValue()
          {
--- 59,63 ----
          private double _doubleValue;
          private Object _objectValue;
! 
          public boolean getBooleanValue()
          {
***************
*** 99,103 ****
          }
  
!     }    
  
      public BindingsTestCase(String name)
--- 100,104 ----
          }
  
!     }
  
      public BindingsTestCase(String name)
***************
*** 108,113 ****
      public void testGetObject()
      {
!         IBinding binding =
!             new FieldBinding(_resolver, "net.sf.tapestry.junit.BindingsTestCase.STRING_FIELD");
  
          assertEquals("Object", STRING_FIELD, binding.getObject());
--- 109,113 ----
      public void testGetObject()
      {
!         IBinding binding = new FieldBinding(_resolver, "net.sf.tapestry.junit.BindingsTestCase.STRING_FIELD");
  
          assertEquals("Object", STRING_FIELD, binding.getObject());
***************
*** 116,121 ****
      public void testToString()
      {
!         IBinding binding =
!             new FieldBinding(_resolver, "net.sf.tapestry.junit.BindingsTestCase.STRING_FIELD");
  
          assertEquals(
--- 116,120 ----
      public void testToString()
      {
!         IBinding binding = new FieldBinding(_resolver, "net.sf.tapestry.junit.BindingsTestCase.STRING_FIELD");
  
          assertEquals(
***************
*** 160,165 ****
      public void testMissingField()
      {
!         IBinding binding =
!             new FieldBinding(_resolver, "net.sf.tapestry.junit.BindingsTestCase.MISSING_FIELD");
  
          try
--- 159,163 ----
      public void testMissingField()
      {
!         IBinding binding = new FieldBinding(_resolver, "net.sf.tapestry.junit.BindingsTestCase.MISSING_FIELD");
  
          try
***************
*** 181,186 ****
      public void testInstanceAccess()
      {
!         IBinding binding =
!             new FieldBinding(_resolver, "net.sf.tapestry.junit.BindingsTestCase.INSTANCE_FIELD");
  
          try
--- 179,183 ----
      public void testInstanceAccess()
      {
!         IBinding binding = new FieldBinding(_resolver, "net.sf.tapestry.junit.BindingsTestCase.INSTANCE_FIELD");
  
          try
***************
*** 500,525 ****
          }
      }
!     
      public void testExpressionBinding()
      {
          IPage page = new MockPage();
!         
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "page");
!         
          assertEquals("Expression property", "page", binding.getExpression());
!         assertEquals("Root property", page, binding.getRoot()); 
!         assertEquals("Object property", page, binding.getObject());              
      }
!     
      public void testMalformedOGNLExpression()
      {
          IPage page = new MockPage();
!         
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "zip flob boff");
!         
          try
          {
              binding.getObject();
!             
              throw new AssertionFailedError("Unreachable.");
          }
--- 497,522 ----
          }
      }
! 
      public void testExpressionBinding()
      {
          IPage page = new MockPage();
! 
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "page");
! 
          assertEquals("Expression property", "page", binding.getExpression());
!         assertEquals("Root property", page, binding.getRoot());
!         assertEquals("Object property", page, binding.getObject());
      }
! 
      public void testMalformedOGNLExpression()
      {
          IPage page = new MockPage();
! 
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "zip flob boff");
! 
          try
          {
              binding.getObject();
! 
              throw new AssertionFailedError("Unreachable.");
          }
***************
*** 530,544 ****
          }
      }
!     
      public void testUnknownProperty()
      {
          IPage page = new MockPage();
!         
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "tigris");
!         
          try
          {
              binding.getObject();
!             
              throw new AssertionFailedError("Unreachable.");
          }
--- 527,541 ----
          }
      }
! 
      public void testUnknownProperty()
      {
          IPage page = new MockPage();
! 
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "tigris");
! 
          try
          {
              binding.getObject();
! 
              throw new AssertionFailedError("Unreachable.");
          }
***************
*** 549,563 ****
          }
      }
!     
      public void testUpdateReadonlyProperty()
      {
!          IPage page = new MockPage();
!         
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "bindings");
!         
          try
          {
              binding.setObject(new HashMap());
!             
              throw new AssertionFailedError("Unreachable.");
          }
--- 546,560 ----
          }
      }
! 
      public void testUpdateReadonlyProperty()
      {
!         IPage page = new MockPage();
! 
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "bindings");
! 
          try
          {
              binding.setObject(new HashMap());
! 
              throw new AssertionFailedError("Unreachable.");
          }
***************
*** 567,619 ****
              checkException(ex, "bindings");
          }
!        
      }
!     
      public void testUpdateBoolean()
      {
          BoundPage page = new BoundPage();
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "booleanValue");
!         
          binding.setBoolean(true);
!         
          assertEquals(true, page.getBooleanValue());
!         
          binding.setBoolean(false);
!         
          assertEquals(false, page.getBooleanValue());
      }
!     
      public void testUpdateInt()
      {
          BoundPage page = new BoundPage();
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "intValue");
!         
          binding.setInt(275);
!         
          assertEquals(275, page.getIntValue());
      }
!     
      public void testUpdateDouble()
      {
          BoundPage page = new BoundPage();
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "doubleValue");
!         
          binding.setDouble(3.14);
!         
          assertEquals(3.14, page.getDoubleValue(), 0.0);
      }
!     
      public void testUpdateObject()
      {
          BoundPage page = new BoundPage();
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "objectValue");
!         
          Object object = new HashMap();
!         
          binding.setObject(object);
!         
          assertEquals(object, page.getObjectValue());
!     }            
!     
!     
  }
--- 564,664 ----
              checkException(ex, "bindings");
          }
! 
      }
! 
      public void testUpdateBoolean()
      {
          BoundPage page = new BoundPage();
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "booleanValue");
! 
          binding.setBoolean(true);
! 
          assertEquals(true, page.getBooleanValue());
! 
          binding.setBoolean(false);
! 
          assertEquals(false, page.getBooleanValue());
      }
! 
      public void testUpdateInt()
      {
          BoundPage page = new BoundPage();
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "intValue");
! 
          binding.setInt(275);
! 
          assertEquals(275, page.getIntValue());
      }
! 
      public void testUpdateDouble()
      {
          BoundPage page = new BoundPage();
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "doubleValue");
! 
          binding.setDouble(3.14);
! 
          assertEquals(3.14, page.getDoubleValue(), 0.0);
      }
! 
      public void testUpdateObject()
      {
          BoundPage page = new BoundPage();
          ExpressionBinding binding = new ExpressionBinding(_resolver, page, "objectValue");
! 
          Object object = new HashMap();
! 
          binding.setObject(object);
! 
          assertEquals(object, page.getObjectValue());
!     }
! 
!     /**
!      *  Test error cases for {@link net.sf.tapestry.binding.ListenerBinding}.
!      * 
!      *  @since 2.4
!      * 
!      **/
! 
!     public void testListenerBindingInt()
!     {
!         IBinding b = new ListenerBinding(null, null, null, null);
! 
!         try
!         {
!             b.getInt();
! 
!             unreachable();
!         }
!         catch (BindingException ex)
!         {
!             checkException(ex, "Inappropriate invocation of getInt() on instance of ListenerBinding.");
!         }
!     }
! 
!     /** @since 2.4 **/
! 
!     public void testListenerBindingDouble()
!     {
!         IBinding b = new ListenerBinding(null, null, null, null);
! 
!         try
!         {
!             b.getDouble();
! 
!             unreachable();
!         }
!         catch (BindingException ex)
!         {
!             checkException(ex, "Inappropriate invocation of getDouble() on instance of ListenerBinding.");
!         }
!     }
! 
!     /**  @since 2.4 **/
! 
!     public void testListenerBindingObject()
!     {
!         IBinding b = new ListenerBinding(null, null, null, null);
! 
!         assertSame(b, b.getObject());
!     }
  }

Index: TestPropertySource.java
===================================================================
RCS file: /cvsroot/tapestry/Tapestry/junit/src/net/sf/tapestry/junit/TestPropertySource.java,v
retrieving revision 1.2
retrieving revision 1.2.2.1
diff -C2 -d -r1.2 -r1.2.2.1
*** TestPropertySource.java	27 Nov 2002 17:58:43 -0000	1.2
--- TestPropertySource.java	4 Jan 2003 02:49:07 -0000	1.2.2.1
***************
*** 1,4 ****
--- 1,5 ----
  package net.sf.tapestry.junit;
  
+ import java.util.ResourceBundle;
  import javax.servlet.ServletConfig;
  
***************
*** 11,14 ****
--- 12,16 ----
  import net.sf.tapestry.util.DelegatingPropertySource;
  import net.sf.tapestry.util.PropertyHolderPropertySource;
+ import net.sf.tapestry.util.ResourceBundlePropertySource;
  import net.sf.tapestry.util.ServletContextPropertySource;
  import net.sf.tapestry.util.ServletPropertySource;
***************
*** 97,100 ****
--- 99,113 ----
          expect(source, "alpha", "bravo");
          expect(source, "gamma", null);
+     }
+     
+     public void testResourceBundle()
+     {
+         ResourceBundle bundle = ResourceBundle.getBundle("net.sf.tapestry.junit.Properties");
+         
+         ResourceBundlePropertySource source = new ResourceBundlePropertySource(bundle);
+         
+         expect(source, "fred", "flintstone");
+         expect(source, "barney", "rubble");
+         expect(source, "wilma", null);
      }
  }



-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.