test_class.declarator: logger = LoggerFactory.getLogger(DataSourceManagerTest.class)
test_class.modifier: private static final
test_class.original_string: private static final Logger logger = LoggerFactory.getLogger(DataSourceManagerTest.class);
test_class.type: Logger
test_class.var_name: logger
test_class.file: ch-commons-sql/src/test/java/com/cloudhopper/commons/sql/DataSourceManagerTest.java
test_class.identifier: DataSourceManagerTest
test_case.body: @Test
      public void createFailsWithMissingDefaultProperties() throws Exception {
          DataSourceConfiguration config = new DataSourceConfiguration();
  
          try {
              DataSourceManager.create(config);
              Assert.fail("create() should have failed");
          } catch (SQLConfigurationException e) {
              // correct
          }
  
          config.setUsername("test");
          try {
              DataSourceManager.create(config);
              Assert.fail("create() should have failed");
          } catch (SQLConfigurationException e) {
              // correct
          }
  
          config.setPassword("test");
          try {
              DataSourceManager.create(config);
              Assert.fail("create() should have failed");
          } catch (SQLConfigurationException e) {
              // correct
          }
  
          config.setName("test");
          try {
              DataSourceManager.create(config);
              Assert.fail("create() should have failed");
          } catch (SQLConfigurationException e) {
              // correct
          }
  
          // last required property, now it should succeed
          config.setUrl("jdbc:mysql://localhost:3306/stratus001");
      }
test_case.class_method_signature: DataSourceManagerTest.createFailsWithMissingDefaultProperties()
test_case.full_signature: @Test public void createFailsWithMissingDefaultProperties()
test_case.identifier: createFailsWithMissingDefaultProperties
test_case.invocations: create fail setUsername create fail setPassword create fail setName create fail setUrl
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void createFailsWithMissingDefaultProperties()
focal_class.declarator: logger = LoggerFactory.getLogger(DataSourceManager.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger logger = LoggerFactory.getLogger(DataSourceManager.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.file: ch-commons-sql/src/main/java/com/cloudhopper/commons/sql/DataSourceManager.java
focal_class.identifier: DataSourceManager
focal_class.class_method_signature: DataSourceManager.DataSourceManager()
focal_class.full_signature: private  DataSourceManager()
focal_class.identifier: DataSourceManager
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.signature:  DataSourceManager()
focal_class.class_method_signature: DataSourceManager.verify(DataSource ds)
focal_class.full_signature: public static void verify(DataSource ds)
focal_class.identifier: verify
focal_class.modifiers: public static
focal_class.parameters: (DataSource ds)
focal_class.return: void
focal_class.signature: void verify(DataSource ds)
focal_class.class_method_signature: DataSourceManager.create(DataSourceConfiguration configuration)
focal_class.full_signature: public static DataSource create(DataSourceConfiguration configuration)
focal_class.identifier: create
focal_class.modifiers: public static
focal_class.parameters: (DataSourceConfiguration configuration)
focal_class.return: DataSource
focal_class.signature: DataSource create(DataSourceConfiguration configuration)
focal_method.body: public static DataSource create(DataSourceConfiguration configuration) throws SQLMissingDependencyException, SQLConfigurationException {
          // verify all required properties are configured and set
          configuration.validate();
  
          // clone the configuration so we can save the properties used to create the ds
          DataSourceConfiguration config = (DataSourceConfiguration)configuration.clone();
  
          // verify database driver exists and try to register the database driver
          try {
              // create a new instance
              Driver driver = (Driver)Class.forName(config.getDriver()).newInstance();
              // put out some properties to save 'em?
          } catch (Exception e) {
              throw new SQLMissingDependencyException("Database driver '" + config.getDriver() + "' failed to load. Perhaps missing jar file?", e);
          }
  
          // get the class responsible for creating the datasource
          String adapterClass = config.getProvider().getAdapter();
  
          // create a new instance of the adapter
          DataSourceAdapter adapter = null;
          try {
              adapter = (DataSourceAdapter)Class.forName(adapterClass).newInstance();
          } catch (Exception e) {
              //throw new SQLConfigurationException("Invalid DataSourceAdapter class specified. Should be impossible error?");
              throw new SQLMissingDependencyException("DataSourceAdapter '" + adapterClass + "' failed to load. Perhaps missing jar file?", e);
          }
  
          // delegate creating the new datasource to the adapter
          ManagedDataSource mds = adapter.create(config);
  
          // if the user requested this datasource to be added to jmx
          if (config.getJmx()) {
              // hmm... if jmx is turned on, let's register the MBean
              MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
              try {
                  ObjectName name = new ObjectName(config.getJmxDomain() + ":type=ManagedDataSource,name=" + config.getName());
                  mbs.registerMBean(mds, name);
              } catch (Exception e) {
                  // log the error, but don't throw an exception for this datasource
                  logger.error("Error while attempting to register ManagedDataSourceMBean '" + config.getName() + "'", e);
              }
          }
  
          // return the datasource
          return mds.getDataSource();
      }
focal_method.class_method_signature: DataSourceManager.create(DataSourceConfiguration configuration)
focal_method.full_signature: public static DataSource create(DataSourceConfiguration configuration)
focal_method.identifier: create
focal_method.invocations: validate clone newInstance forName getDriver getDriver getAdapter getProvider newInstance forName create getJmx getPlatformMBeanServer getJmxDomain getName registerMBean error getName getDataSource
focal_method.modifiers: public static
focal_method.parameters: (DataSourceConfiguration configuration)
focal_method.return: DataSource
focal_method.signature: DataSource create(DataSourceConfiguration configuration)