1 17 package javax.xml.registry; 18 19 import java.util.Collection; 20 import java.util.Properties; 21 22 import junit.framework.TestCase; 23 import org.apache.ws.scout.registry.ConnectionFactoryImpl; 24 25 28 public class ConnectionFactoryTest extends TestCase { 29 private static final String CONNECTIONFACTORYCLASS_PROPERTY = "javax.xml.registry.ConnectionFactoryClass"; 30 31 private Properties originalProperties; 32 private Properties props; 33 34 public void testNewInstanceWithDefault() throws JAXRException { 35 ConnectionFactory factory = ConnectionFactory.newInstance(); 36 assertEquals(ConnectionFactoryImpl.class, factory.getClass()); 37 } 38 39 public void testNewInstanceWithClass() throws JAXRException { 40 System.setProperty(CONNECTIONFACTORYCLASS_PROPERTY, MockFactory.class.getName()); 41 ConnectionFactory factory = ConnectionFactory.newInstance(); 42 assertEquals(MockFactory.class, factory.getClass()); 43 } 44 45 protected void setUp() throws Exception { 46 super.setUp(); 47 originalProperties = System.getProperties(); 48 props = new Properties(originalProperties); 49 props.remove(CONNECTIONFACTORYCLASS_PROPERTY); 50 System.setProperties(props); 51 } 52 53 protected void tearDown() throws Exception { 54 System.setProperties(originalProperties); 55 super.tearDown(); 56 } 57 58 public static class MockFactory extends ConnectionFactory { 59 public Connection createConnection() throws JAXRException { 60 throw new UnsupportedOperationException(); 61 } 62 63 public FederatedConnection createFederatedConnection(Collection connections) throws JAXRException { 64 throw new UnsupportedOperationException(); 65 } 66 67 public Properties getProperties() throws JAXRException { 68 throw new UnsupportedOperationException(); 69 } 70 71 public void setProperties(Properties properties) throws JAXRException { 72 throw new UnsupportedOperationException(); 73 } 74 } 75 } 76 | Popular Tags |