throw new IllegalArgumentException("test input can not be parsed");
}
MockRepositoryPropertyList pl = new MockRepositoryPropertyList(jo);
{
MockRepositoryProperty testProp = pl.getProperty("xyzzy");
Property testJCRProp = new MockJcrProperty(testProp);
Assert.assertEquals("skeedle", testJCRProp.getString());
Assert.assertEquals(PropertyType.STRING, testJCRProp.getType());
}
{
MockRepositoryProperty testProp = pl.getProperty("baz");
Property testJCRProp = new MockJcrProperty(testProp);
Assert.assertEquals(42, testJCRProp.getLong());
Assert.assertEquals(PropertyType.LONG, testJCRProp.getType());
}
{
MockRepositoryProperty testProp = pl.getProperty("abc");
Property testJCRProp = new MockJcrProperty(testProp);
try {
testJCRProp.getLong();
// shouldn't get here - previous line should throw exception
Assert.assertFalse(true);
} catch (Exception e) {
// Specifically, ValueFormatException should be thrown
Assert.assertTrue(e instanceof ValueFormatException);
}
Value[] vs = testJCRProp.getValues();
Assert.assertEquals(PropertyType.LONG, testJCRProp.getType());
Assert.assertEquals(5, vs.length);
Assert.assertEquals(2, vs[0].getLong());
Assert.assertEquals(3, vs[1].getLong());
Assert.assertEquals(5, vs[2].getLong());
Assert.assertEquals(7, vs[3].getLong());
Assert.assertEquals(11, vs[4].getLong());
Assert.assertEquals(PropertyType.LONG, vs[4].getType());
}
{
MockRepositoryProperty testProp = pl.getProperty("def");
Property testJCRProp = new MockJcrProperty(testProp);
Value[] vs = testJCRProp.getValues();
Assert.assertEquals(PropertyType.DATE, testJCRProp.getType());
Assert.assertEquals(3, vs.length);
Calendar date = vs[0].getDate();
Calendar expected = Calendar.getInstance();
expected.setTimeInMillis(10 * 1000);
Assert.assertTrue(date.equals(expected));
}
{
MockRepositoryProperty testProp = pl.getProperty("ghi");
Property testJCRProp = new MockJcrProperty(testProp);
Value[] vs = testJCRProp.getValues();
Assert.assertEquals(PropertyType.LONG, testJCRProp.getType());
Assert.assertEquals(0, vs.length);
}