@Before
  public void setUp() throws Exception {
    try {
      FileReader reader = new FileReader("inventory.txt");
      BufferedReader br = new BufferedReader(reader);

      String row = br.readLine();
      while (row != null) {
        String articleinfo[] = row.split(":");

        char barcode[] = articleinfo[0].toCharArray();
        String name = articleinfo[1];
        int amount = Integer.parseInt(articleinfo[2]);
        double price = Double.parseDouble(articleinfo[3]);
        boolean food = Boolean.parseBoolean(articleinfo[4]);

        tempInventory.add(new cashRegisterSystem.inventoryArticle(barcode, name, amount, price));
        row = br.readLine();
      }

      br.close();
    } catch (IOException e) {
      System.out.println("Error" + e.getMessage());
      System.out.println("Error reading File");
    }

    CRS.newItem(Long.parseLong(sBarcode), sArticleName, dPrice, iAmountInventory, isFood);
    CRS.writeInventory();
  }
 @Before
 public void setUp() {
   if (!Boolean.parseBoolean(System.getProperty("test.solr.verbose"))) {
     java.util.logging.Logger.getLogger("org.apache.solr")
         .setLevel(java.util.logging.Level.SEVERE);
     Utils.setLog4jLogLevel(org.apache.log4j.Level.WARN);
   }
   testDataParentPath = System.getProperty("test.data.path");
   testConfigFname = System.getProperty("test.config.file");
   // System.out.println("-----testDataParentPath = "+testDataParentPath);
 }
 @Test
 public void eventBusElementTrueMBeans() {
   BeanDefinition beanDefinition = beanFactory.getBeanDefinition("eventBusTrueMBeans");
   assertNotNull("Bean definition not created", beanDefinition);
   assertEquals(
       "Wrong bean class", SimpleEventBus.class.getName(), beanDefinition.getBeanClassName());
   assertEquals(
       "wrong amount of constructor arguments",
       1,
       beanDefinition.getConstructorArgumentValues().getArgumentCount());
   Object constructorValue =
       beanDefinition.getConstructorArgumentValues().getArgumentValue(0, Boolean.class).getValue();
   assertTrue("constructor value is wrong", Boolean.parseBoolean((String) constructorValue));
   SimpleEventBus eventBus = beanFactory.getBean("eventBusTrueMBeans", SimpleEventBus.class);
   assertNotNull(eventBus);
 }
示例#4
0
  /**
   * This sets up a Bitronix PoolingDataSource.
   *
   * @return PoolingDataSource that has been set up but _not_ initialized.
   */
  public static PoolingDataSource setupPoolingDataSource(
      Properties dsProps, String datasourceName, boolean startServer) {
    PoolingDataSource pds = new PoolingDataSource();

    // The name must match what's in the persistence.xml!
    pds.setUniqueName(datasourceName);

    pds.setClassName(dsProps.getProperty("className"));

    pds.setMaxPoolSize(Integer.parseInt(dsProps.getProperty("maxPoolSize")));
    pds.setAllowLocalTransactions(
        Boolean.parseBoolean(dsProps.getProperty("allowLocalTransactions")));
    for (String propertyName : new String[] {"user", "password"}) {
      pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
    }

    String driverClass = dsProps.getProperty("driverClassName");
    if (driverClass.startsWith("org.h2")) {
      if (startServer) {
        h2Server.start();
      }
      for (String propertyName : new String[] {"url", "driverClassName"}) {
        pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
      }
    } else {
      pds.setClassName(dsProps.getProperty("className"));

      if (driverClass.startsWith("oracle")) {
        pds.getDriverProperties().put("driverType", "thin");
        pds.getDriverProperties().put("URL", dsProps.getProperty("url"));
      } else if (driverClass.startsWith("com.ibm.db2")) {
        // http://docs.codehaus.org/display/BTM/JdbcXaSupportEvaluation#JdbcXaSupportEvaluation-IBMDB2
        pds.getDriverProperties().put("databaseName", dsProps.getProperty("databaseName"));
        pds.getDriverProperties().put("driverType", "4");
        pds.getDriverProperties().put("serverName", dsProps.getProperty("serverName"));
        pds.getDriverProperties().put("portNumber", dsProps.getProperty("portNumber"));
      } else if (driverClass.startsWith("com.microsoft")) {
        for (String propertyName : new String[] {"serverName", "portNumber", "databaseName"}) {
          pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
        }
        pds.getDriverProperties().put("URL", dsProps.getProperty("url"));
        pds.getDriverProperties().put("selectMethod", "cursor");
        pds.getDriverProperties().put("InstanceName", "MSSQL01");
      } else if (driverClass.startsWith("com.mysql")) {
        for (String propertyName :
            new String[] {"databaseName", "serverName", "portNumber", "url"}) {
          pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
        }
      } else if (driverClass.startsWith("com.sybase")) {
        for (String propertyName : new String[] {"databaseName", "portNumber", "serverName"}) {
          pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
        }
        pds.getDriverProperties().put("REQUEST_HA_SESSION", "false");
        pds.getDriverProperties().put("networkProtocol", "Tds");
      } else if (driverClass.startsWith("org.postgresql")) {
        for (String propertyName : new String[] {"databaseName", "portNumber", "serverName"}) {
          pds.getDriverProperties().put(propertyName, dsProps.getProperty(propertyName));
        }
      } else {
        throw new RuntimeException("Unknown driver class: " + driverClass);
      }
    }

    return pds;
  }