Package org.teiid.test.framework

Examples of org.teiid.test.framework.ConfigPropertyLoader


public class ConnectionStrategyFactory {
 
   
      public static ConnectionStrategy createConnectionStrategy()  {

        ConfigPropertyLoader configLoader = ConfigPropertyLoader.getInstance();
   
      ConnectionStrategy strategy = null;
         Properties props = configLoader.getProperties();
          
          String type = props.getProperty(ConfigPropertyNames.CONNECTION_TYPE, ConfigPropertyNames.CONNECTION_TYPES.DRIVER_CONNECTION);
          if (type == null) {
            throw new TransactionRuntimeException("Property " + ConfigPropertyNames.CONNECTION_TYPE + " was specified");
          }
View Full Code Here


     
    public static void main(String[] args) {
      //NOTE: to run this test to validate the DataSourceMgr, do the following:
      //   ---  need 3 datasources,   Oracle, SqlServer and 1 other
     
      ConfigPropertyLoader config = ConfigPropertyLoader.getInstance();
     
      new DataSourceFactory(config);

    }
View Full Code Here

 
  public static void main(String[] args) {
    //NOTE: to run this test to validate the DataSourceMgr, do the following:
    //   ---  need 3 datasources,   Oracle, SqlServer and 1 other
   
    ConfigPropertyLoader config = ConfigPropertyLoader.getInstance();
   
    DataSourceFactory factory = new DataSourceFactory(config);

    try {
      if (factory.getDatasource("model1") == null) {
        throw new TransactionRuntimeException("No datasource was not found");
      }
     

    } catch (QueryTestFailedException e) {
      e.printStackTrace();
    }
   
    factory.cleanup();
   
    ConfigPropertyLoader.reset();

   
    // the following verifies that order of "use" datasources is applied to request for datasources.
    config = ConfigPropertyLoader.getInstance();
   
    config.setProperty(ConfigPropertyNames.USE_DATASOURCES_PROP, "oracle,sqlserver");
       
    factory = new DataSourceFactory(config);

    try {
     
      DataSource dsfind = factory.getDatasource( "model2");
      if (dsfind == null) {
        throw new TransactionRuntimeException("No datasource was not found as the 2nd datasource");
       
      }
     
      if (dsfind.getConnectorType() == null) {
        throw new TransactionRuntimeException("Connector types was not defined");
      }
     
      if (!dsfind.getName().equalsIgnoreCase("sqlserver")) {
        throw new TransactionRuntimeException("Sqlserver was not found as the 2nd datasource");
       
      }
     
      dsfind = factory.getDatasource( "model1");
      if (dsfind == null) {
        throw new TransactionRuntimeException("No datasource was not found as the 2nd datasource");
       
      }
      if (!dsfind.getName().equalsIgnoreCase("oracle")) {
        throw new TransactionRuntimeException("Oracle was not found as the 2nd datasource");
       
      }
      System.out.println("Datasource :" + dsfind.getName() + " was found");
     
     
      // the following test verifies that a sqlserver datasource is not
      // returned (excluded)
      factory.cleanup();
   
      ConfigPropertyLoader.reset();


      config = ConfigPropertyLoader.getInstance();
      config.setProperty(ConfigPropertyNames.EXCLUDE_DATASBASE_TYPES_PROP, "sqlserver");

     
      factory = new DataSourceFactory(config);

      int n = factory.getNumberAvailableDataSources();
      TestLogger.log("Num avail datasources: " + n);

      for (int i=0; i<n; i++) {
       
        String k = String.valueOf(i);
        DataSource ds1 = factory.getDatasource( "model" + k);
        if (ds1 == null) {
          throw new TransactionRuntimeException("No datasource was found for: model:" + k);
         
        } if (ds1.getDBType().equalsIgnoreCase(DataSourceFactory.DataBaseTypes.SQLSERVER)) {
          throw new TransactionRuntimeException("sqlserver dbtype should have been excluded");
        }
      }
       
       
        DataSource reuse = factory.getDatasource( "model1");
        if (reuse != null) {
         
        } else {
          throw new TransactionRuntimeException("The process was not able to reassign an already used datasource");
         
        }
       
        factory.cleanup();
       
        ConfigPropertyLoader.reset();

       
        // test required database types
        // test 1 source

        config = ConfigPropertyLoader.getInstance();
       
        config.setModelAssignedToDatabaseType("pm1", DataSourceFactory.DataBaseTypes.ORACLE);
     
        factory = new DataSourceFactory(config);

        DataSource ds1 = factory.getDatasource("pm1");
        if (!ds1.getDBType().equalsIgnoreCase(DataSourceFactory.DataBaseTypes.ORACLE)) {
          throw new TransactionRuntimeException("Required DB Type of oracle for model pm1 is :" + ds1.getDBType());
        }
       
        TestLogger.log("Test1 Required DS1 " + ds1.getDBType());
        factory.cleanup();
       
        ConfigPropertyLoader.reset();

        // test required database types
        // test 2 sources, 1 required and other ANY
        config = ConfigPropertyLoader.getInstance();
     
       
        config.setModelAssignedToDatabaseType("pm2", DataSourceFactory.DataBaseTypes.SQLSERVER);
        config.setModelAssignedToDatabaseType("pm1", DataSourceFactory.DataBaseTypes.ANY);
     
        factory = new DataSourceFactory(config);

        DataSource ds2 = factory.getDatasource("pm2");
        if (!ds2.getDBType().equalsIgnoreCase(DataSourceFactory.DataBaseTypes.SQLSERVER)) {
          throw new TransactionRuntimeException("Required DB Type of sqlserver for model pm2 is :" + ds2.getDBType());
        }
        TestLogger.log("Test2 Required DS2 " + ds2.getDBType());
     
        factory.cleanup();
        ConfigPropertyLoader.reset();

       
        // test required database types
        // test 2 sources, 2 required
        config = ConfigPropertyLoader.getInstance();
     
       
        config.setModelAssignedToDatabaseType("pm2", DataSourceFactory.DataBaseTypes.SQLSERVER);
        config.setModelAssignedToDatabaseType("pm1", DataSourceFactory.DataBaseTypes.ORACLE);
     
        factory = new DataSourceFactory(config);

        DataSource ds3a = factory.getDatasource("pm2");
        if (!ds3a.getDBType().equalsIgnoreCase(DataSourceFactory.DataBaseTypes.SQLSERVER)) {
View Full Code Here

    public static void main(String[] args) {
  System.setProperty(ConfigPropertyNames.CONFIG_FILE,
    "ctc-bqt-test.properties");

  ConfigPropertyLoader _instance = ConfigPropertyLoader.getInstance();
  Properties p = _instance.getProperties();
  if (p == null || p.isEmpty()) {
      throw new RuntimeException("Failed to load config properties file");

  }

  _instance.setProperty(PROP_QUERY_FILES_ROOT_DIR, new File(
    "src/main/resources/").getAbsolutePath());

  try {
      XMLQueryReader reader = new XMLQueryReader("scenario_id",  _instance.getProperties());
      Iterator<String> it = reader.getQuerySetIDs().iterator();
      while (it.hasNext()) {
    String querySetID = it.next();

    List<QueryTest> queries = reader.getQueries(querySetID);
View Full Code Here

  }
   
  public static void main(String[] args) {
    System.setProperty(ConfigPropertyNames.CONFIG_FILE, "ctc-bqt-test.properties");

    ConfigPropertyLoader _instance = ConfigPropertyLoader.getInstance();
    Properties p = _instance.getProperties();
    if (p == null || p.isEmpty()) {
      throw new RuntimeException("Failed to load config properties file");

    }
   
    QueryScenario set = ClassFactory.createQueryScenario("testscenario");

   
    _instance.setProperty(XMLQueryReader.PROP_QUERY_FILES_ROOT_DIR, new File("src/main/resources/").getAbsolutePath() );
   

   

    try {
View Full Code Here

TOP

Related Classes of org.teiid.test.framework.ConfigPropertyLoader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.