public void test() {
   // Convert back to a string
   byteString =
       (String)
           ConversionManager.getDefaultManager().convertObject(byteArray, ClassConstants.STRING);
   byteOString =
       (String)
           ConversionManager.getDefaultManager().convertObject(byteOArray, ClassConstants.STRING);
   charString =
       (String)
           ConversionManager.getDefaultManager().convertObject(charArray, ClassConstants.STRING);
   charOString =
       (String)
           ConversionManager.getDefaultManager().convertObject(charOArray, ClassConstants.STRING);
 }
 public void setup() {
   // Convert to an array first
   byteArray =
       (byte[])
           ConversionManager.getDefaultManager().convertObject(hexString, ClassConstants.APBYTE);
   byteOArray =
       (Byte[])
           ConversionManager.getDefaultManager().convertObject(hexString, ClassConstants.ABYTE);
   charArray =
       (char[])
           ConversionManager.getDefaultManager().convertObject(testString, ClassConstants.APCHAR);
   charOArray =
       (Character[])
           ConversionManager.getDefaultManager().convertObject(testString, ClassConstants.ACHAR);
 }
Exemplo n.º 3
0
  protected void setup() {
    // save current null values for later restoration
    saveDefaultDefaultNullValues = ConversionManager.getDefaultManager().getDefaultNullValues();
    saveDefaultNullValues =
        getSession().getLogin().getPlatform().getConversionManager().getDefaultNullValues();
    getSession()
        .getLogin()
        .getPlatform()
        .getConversionManager()
        .setDefaultNullValues(new Hashtable());
    getSession().getLogin().setDefaultNullValue(String.class, "null");
    getSession().getLogin().setDefaultNullValue(int.class, new Integer(-1));
    // Reinit mappings.
    for (DatabaseMapping mapping : getSession().getDescriptor(Address.class).getMappings()) {
      if (mapping.isDirectToFieldMapping()) {
        mapping.preInitialize(getAbstractSession());
      }
    }
    getAbstractSession().beginTransaction();

    employee = new Employee();
    employee.setFirstName("Fred");
    employee.setLastName("Flintstone");
    employee.setSalary(22);
    employee.setGender("Male");
    Address address = new Address();
    address.setCity(null);
    employee.setAddress(address);

    getAbstractSession().writeObject(employee);
    // force the salary to be NULL
    getSession()
        .executeNonSelectingCall(
            new SQLCall("update SALARY set SALARY = null where EMP_ID = " + employee.getId()));
  }
Exemplo n.º 4
0
 public void reset() {
   getAbstractSession().rollbackTransaction();
   getSession().getIdentityMapAccessor().initializeAllIdentityMaps();
   getSession()
       .getLogin()
       .getPlatform()
       .getConversionManager()
       .setDefaultNullValues(saveDefaultNullValues);
   ConversionManager.getDefaultManager().setDefaultNullValues(saveDefaultDefaultNullValues);
 }
Exemplo n.º 5
0
 protected void verify() {
   if (results.size() != expectedResults.size()) {
     throw new TestErrorException("ReportQuery test failed: The result size are different");
   }
   BigDecimal expected =
       (BigDecimal) ((ReportQueryResult) expectedResults.firstElement()).getByIndex(0);
   BigDecimal result =
       (BigDecimal)
           ConversionManager.getDefaultManager()
               .convertObject(
                   ((ReportQueryResult) results.firstElement()).getByIndex(0), BigDecimal.class);
   if (!Helper.compareBigDecimals(expected, result)) {
     throw new TestErrorException(
         "ReportQuery test failed: The results did not match (" + expected + ", " + result + ")");
   }
 }
 /** getObject. */
 public void test() throws Exception {
   PreparedStatement statement = connection.prepareStatement(sql);
   ResultSet result = statement.executeQuery();
   int size = result.getMetaData().getColumnCount();
   Vector rows = new Vector();
   while (result.next()) {
     Vector row = new Vector(size);
     for (int column = 1; column <= size; column++) {
       Object value = result.getObject(column);
       value = ConversionManager.getDefaultManager().convertObject(value, ClassConstants.SQLDATE);
       row.add(value);
     }
     rows.add(row);
   }
   result.close();
   statement.close();
 }