Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2648 - development/main/transit/core/handler/src/test/net/dpml/transit/manager

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2648 - development/main/transit/core/handler/src/test/net/dpml/transit/manager
  • Date: Sun, 22 May 2005 00:26:20 +0000

Author: mcconnell AT dpml.net
Date: Sun May 22 00:26:15 2005
New Revision: 2648

Modified:

development/main/transit/core/handler/src/test/net/dpml/transit/manager/ProxyManagerTestCase.java
Log:
Switch to listener based testing.

Modified:
development/main/transit/core/handler/src/test/net/dpml/transit/manager/ProxyManagerTestCase.java
==============================================================================
---
development/main/transit/core/handler/src/test/net/dpml/transit/manager/ProxyManagerTestCase.java
(original)
+++
development/main/transit/core/handler/src/test/net/dpml/transit/manager/ProxyManagerTestCase.java
Sun May 22 00:26:15 2005
@@ -21,6 +21,7 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.net.PasswordAuthentication;
import java.util.Date;
import java.util.logging.Logger;
import java.util.prefs.Preferences;
@@ -31,6 +32,8 @@
import net.dpml.transit.model.RepositoryModel;
import net.dpml.transit.model.CacheModel;
import net.dpml.transit.model.RegistryModel;
+import net.dpml.transit.model.ProxyChangeEvent;
+import net.dpml.transit.model.ProxyListener;

/**
* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
@@ -92,6 +95,8 @@
public void testProxyAuthentication() throws Exception
{
Preferences prefs = m_prefs.node( "proxy" );
+ TestProxyAuthListener listener = new TestProxyAuthListener();
+ m_manager.getProxyModel().addProxyListener( listener );
try
{
String username = "peter";
@@ -103,13 +108,6 @@
prefs.put( "password", password );
prefs.putLong( "modified", new Date().getTime() );
prefs.flush();
- assertEquals(
- "username", username,
-
m_manager.getProxyModel().getProxyAuthentication().getUserName() );
- String pwd =
- new String(
-
m_manager.getProxyModel().getProxyAuthentication().getPassword() );
- assertEquals( "password", password, pwd );
}
finally
{
@@ -120,10 +118,12 @@
public void testProxyExcludes() throws Exception
{
Preferences prefs = m_prefs.node( "proxy" );
+ TestProxyExcludesListener listener = new TestProxyExcludesListener();
+ m_manager.getProxyModel().addProxyListener( listener );
+
Preferences excludes = prefs.node( "excludes" );
excludes.put( "http://www.osm.net";, "" );
excludes.put( "http://repository.dpml.net";, "" );
- excludes.flush();
try
{
prefs.put( "host", "http://proxy.dpml.net"; );
@@ -131,23 +131,6 @@
prefs.put( "prompt", "a-prompt" );
prefs.putLong( "modified", new Date().getTime() );
prefs.flush();
-
- String expected =
"http://www.osm.net|http://repository.dpml.net";;
- String result = m_manager.getProxyModel().getProxyExcludes();
-
- if( false == expected.equals( result ) )
- {
- // get some info about what is happening
-
- System.out.println( "# BAD RESULT ON EXCLUDES" );
- System.out.println( "# Expected: " + expected );
- System.out.println( "# Actual: " + result );
- System.out.println( "# Excludes node: ");
- excludes.exportNode( System.out );
- }
-
- assertEquals(
- "excludes", expected, result );
}
finally
{
@@ -156,5 +139,29 @@
prefs.flush();
}
}
+
+ public class TestProxyExcludesListener implements ProxyListener
+ {
+ public void proxySettingsChanged( ProxyChangeEvent event )
+ {
+ m_manager.getProxyModel().removeProxyListener( this );
+ String expected =
"http://www.osm.net|http://repository.dpml.net";;
+ String result = event.getProxyExcludes();
+ assertEquals( "excludes", expected, result );
+ }
+ }
+
+ public class TestProxyAuthListener implements ProxyListener
+ {
+ public void proxySettingsChanged( ProxyChangeEvent event )
+ {
+ m_manager.getProxyModel().removeProxyListener( this );
+ PasswordAuthentication auth = event.getPasswordAuthentication();
+ assertNotNull( "auth", auth );
+ assertEquals( "username", "peter", auth.getUserName() );
+ String pwd = new String( auth.getPassword() );
+ assertEquals( "password", "rabbit", pwd );
+ }
+ }
}




  • svn commit: r2648 - development/main/transit/core/handler/src/test/net/dpml/transit/manager, mcconnell, 05/21/2005

Archive powered by MHonArc 2.6.24.

Top of Page