avalon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From blorit...@apache.org
Subject cvs commit: jakarta-avalon-excalibur/util/src/test/org/apache/excalibur/util/test DelegateTestCase.java
Date Thu, 03 Oct 2002 14:50:08 GMT
bloritsch    2002/10/03 07:50:08

  Modified:    util/src/test/org/apache/excalibur/util/test
                        DelegateTestCase.java
  Log:
  Prove Delegates work with statics--unfortunately it requires an instance object.
  
  Revision  Changes    Path
  1.4       +23 -15    jakarta-avalon-excalibur/util/src/test/org/apache/excalibur/util/test/DelegateTestCase.java
  
  Index: DelegateTestCase.java
  ===================================================================
  RCS file: /home/cvs/jakarta-avalon-excalibur/util/src/test/org/apache/excalibur/util/test/DelegateTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DelegateTestCase.java	3 Oct 2002 14:08:52 -0000	1.3
  +++ DelegateTestCase.java	3 Oct 2002 14:50:08 -0000	1.4
  @@ -65,24 +65,24 @@
           super( name );
       }
   
  -    public static final class Echo
  +    public String echo( String message )
       {
  -        public String echo( String message )
  -        {
  -            return "Echo: " + message;
  -        }
  +        return "Echo: " + message;
  +    }
   
  -        public String otherEcho( String message )
  -        {
  -            return "OtherEcho: " + message;
  -        }
  +    public String otherEcho( String message )
  +    {
  +        return "OtherEcho: " + message;
       }
   
  -    private final Echo m_echo = new Echo();
  +    public static String staticEcho( String message )
  +    {
  +        return "static: " + message;
  +    }
   
       public void testDelegate()
       {
  -        EchoDelegate delegate = (EchoDelegate) Delegate.newDelegate( m_echo, "echo", EchoDelegate.class
);
  +        EchoDelegate delegate = (EchoDelegate) Delegate.newDelegate( this, "echo", EchoDelegate.class
);
   
           assertTrue( delegate.echo( MESSAGE ).startsWith( "Echo: " ) );
       }
  @@ -90,14 +90,21 @@
       public void testDifferentDelegate()
       {
           EchoDelegate delegate =
  -                (EchoDelegate) Delegate.newDelegate( m_echo, "echo", EchoDelegate.class
);
  +                (EchoDelegate) Delegate.newDelegate( this, "echo", EchoDelegate.class );
           EchoDelegate otherDelegate =
  -                (EchoDelegate) Delegate.newDelegate( m_echo, "otherEcho", EchoDelegate.class
);
  +                (EchoDelegate) Delegate.newDelegate( this, "otherEcho", EchoDelegate.class
);
   
           assertTrue( delegate.echo( MESSAGE ).startsWith( "Echo: " ) );
           assertTrue( otherDelegate.echo( MESSAGE ).startsWith( "OtherEcho: " ) );
       }
   
  +    public void testStaticDelegate()
  +    {
  +        EchoDelegate delegate = (EchoDelegate) Delegate.newDelegate( this, "staticEcho",
EchoDelegate.class );
  +
  +        assertTrue( delegate.echo( MESSAGE ).startsWith( "static: " ) );
  +    }
  +
       protected void checkDelegate( EchoDelegate delegate )
       {
           String answer = delegate.echo( MESSAGE );
  @@ -107,7 +114,8 @@
   
       public void testExpectedUse()
       {
  -        checkDelegate( (EchoDelegate) Delegate.newDelegate( m_echo, "echo", EchoDelegate.class
) );
  -        checkDelegate( (EchoDelegate) Delegate.newDelegate( m_echo, "otherEcho", EchoDelegate.class
) );
  +        checkDelegate( (EchoDelegate) Delegate.newDelegate( this, "echo", EchoDelegate.class
) );
  +        checkDelegate( (EchoDelegate) Delegate.newDelegate( this, "otherEcho", EchoDelegate.class
) );
  +        checkDelegate( (EchoDelegate) Delegate.newDelegate( this, "staticEcho", EchoDelegate.class
) );
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:avalon-cvs-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:avalon-cvs-help@jakarta.apache.org>


Mime
View raw message