Beispiel #1
0
  @Test
  public void testArrayValue() throws Exception {
    Value[] v = new Value[7];

    for (int i = 0; i < v.length; i++) {
      v[i] = ValueFactory.createValue(i);
    }

    ValueCollection av = ValueFactory.createValue(v);

    for (int i = 0; i < v.length; i++) {
      v[i] = ValueFactory.createValue(i);
    }

    ValueCollection av2 = ValueFactory.createValue(v);

    assertTrue((av.equals(av2)).getAsBoolean());
    assertEquals(av.hashCode(), av2.hashCode());

    for (int i = 0; i < 7; i++) {
      assertTrue((av.get(i).equals(ValueFactory.createValue(i))).getAsBoolean());
    }
  }
Beispiel #2
0
  /** Tests the NullValues operations */
  @Test
  public void testNullValueOperations() throws Exception {
    Value n = ValueFactory.createNullValue();

    ValueCollection b = ValueFactory.createValue(new Value[0]);
    assertTrue((b.equals(n)).isNull());
    assertTrue(b.notEquals(n).isNull());

    Value v = ValueFactory.createValue(true);
    v.and(n);
    v.or(n);
    // SQL UNKNOWN
    assertNull((v.equals(n)).getAsBoolean());
    assertNull((v.notEquals(n)).getAsBoolean());

    Value i = ValueFactory.createValue(1);
    i.equals(n);
    i.notEquals(n);
    assertTrue((i.less(n)).isNull());
    assertTrue((i.lessEqual(n)).isNull());
    assertTrue((i.greater(n)).isNull());
    assertTrue((i.greaterEqual(n)).isNull());

    Value s = ValueFactory.createValue("test");
    assertTrue((s.equals(n)).isNull());
    assertTrue((s.notEquals(n)).isNull());
    assertTrue((s.less(n)).isNull());
    assertTrue((s.lessEqual(n)).isNull());
    assertTrue((s.greater(n)).isNull());
    assertTrue((s.greaterEqual(n)).isNull());
    s.matches(n);

    Value d = ValueFactory.createValue(new Date());
    assertTrue((d.equals(n)).isNull());
    assertTrue((d.notEquals(n)).isNull());
    assertTrue((d.less(n)).isNull());
    assertTrue((d.lessEqual(n)).isNull());
    assertTrue((d.greater(n)).isNull());
    assertTrue((d.greaterEqual(n)).isNull());

    Value t = ValueFactory.createValue(new Time(12));
    assertTrue((t.equals(n)).isNull());
    assertTrue((t.notEquals(n)).isNull());
    assertTrue((t.less(n)).isNull());
    assertTrue((t.lessEqual(n)).isNull());
    assertTrue((t.greater(n)).isNull());
    assertTrue((t.greaterEqual(n)).isNull());

    Value ts = ValueFactory.createValue(new Timestamp(12));
    assertTrue((ts.equals(n)).isNull());
    assertTrue((ts.notEquals(n)).isNull());
    assertTrue((ts.less(n)).isNull());
    assertTrue((ts.lessEqual(n)).isNull());
    assertTrue((ts.greater(n)).isNull());
    assertTrue((ts.greaterEqual(n)).isNull());

    assertTrue((n.equals(n)).isNull());
    assertTrue((n.notEquals(n)).isNull());
    assertTrue((n.less(n)).isNull());
    assertTrue((n.lessEqual(n)).isNull());
    assertTrue((n.greater(n)).isNull());
    assertTrue((n.greaterEqual(n)).isNull());
    n.matches(n);
  }