public void testEmptyBinaryFromFile() throws RepositoryException, IOException { File f = File.createTempFile("QValueFactoryImplTest", ".txt"); f.deleteOnExit(); QValue v = factory.create(f); assertEquals(PropertyType.BINARY, v.getType()); assertEquals(0, v.getLength()); assertEquals("", v.getString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); spool(out, v.getStream()); assertEquals("", new String(out.toByteArray())); }
public void testEmptyBinaryFromInputStream() throws RepositoryException, IOException { InputStream in = new ByteArrayInputStream(new byte[0]); QValue v = factory.create(in); assertEquals(PropertyType.BINARY, v.getType()); assertEquals(0, v.getLength()); assertEquals("", v.getString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); spool(out, v.getStream()); assertEquals("", new String(out.toByteArray())); }
public void testCreateFalseBooleanValue() throws RepositoryException { QValue v = factory.create(false); assertEquals("Boolean value must be false", Boolean.FALSE.toString(), v.getString()); assertEquals("Boolean value must be false", false, v.getBoolean()); }
public void testBinaryFromFile() throws RepositoryException, IOException { File f = File.createTempFile("QValueFactoryImplTest", ".txt"); f.deleteOnExit(); FileWriter fw = new FileWriter(f); fw.write("abc"); fw.close(); QValue v = factory.create(f); assertEquals(PropertyType.BINARY, v.getType()); assertEquals(3, v.getLength()); assertEquals("abc", v.getString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); spool(out, v.getStream()); assertEquals("abc", new String(out.toByteArray())); }
public void testBinaryFromInputStream() throws RepositoryException, IOException { InputStream in = new ByteArrayInputStream(new byte[] {'a', 'b', 'c'}); QValue v = factory.create(in); assertEquals(PropertyType.BINARY, v.getType()); assertEquals(3, v.getLength()); assertEquals("abc", v.getString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); spool(out, v.getStream()); assertEquals("abc", new String(out.toByteArray())); }
public void testBinaryFromByteArray() throws RepositoryException, IOException { QValue v = factory.create(new byte[] {'a', 'b', 'c'}); assertEquals(PropertyType.BINARY, v.getType()); assertEquals(3, v.getLength()); assertEquals("abc", v.getString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); spool(out, v.getStream()); assertEquals("abc", new String(out.toByteArray())); }
public void testEmptyBinaryFromByteArray() throws RepositoryException, IOException { QValue v = factory.create(new byte[0]); assertEquals(PropertyType.BINARY, v.getType()); assertEquals(0, v.getLength()); assertEquals("", v.getString()); ByteArrayOutputStream out = new ByteArrayOutputStream(); spool(out, v.getStream()); assertEquals("", new String(out.toByteArray())); }
public void testCreateTrueBooleanValue() throws RepositoryException { QValue v = factory.create(true); assertEquals("Boolean value must be true", Boolean.TRUE.toString(), v.getString()); assertEquals("Boolean value must be true", true, v.getBoolean()); }
public void testReferenceValueEquality() throws RepositoryException { if (reference != null) { QValue v = factory.create(reference, PropertyType.REFERENCE); QValue otherV = factory.create(reference, PropertyType.REFERENCE); assertEquals("Reference values created from the same string must be equal.", v, otherV); } else { log.warn("Configuration entry 'QValueFactoryTest.reference' is missing -> skip test 'testReferenceValueEquality'."); } }
public void testCreateTrueFromString() throws ValueFormatException, RepositoryException { QValue v = factory.create(Boolean.TRUE.toString(), PropertyType.STRING); assertEquals("Boolean value must be true", true, v.getBoolean()); }
/** * Test if creating Boolean QValue from boolean and from String with boolean * type return equal objects. * * @throws javax.jcr.RepositoryException */ public void testCreateBooleanValueFromString() throws RepositoryException { QValue v = factory.create(Boolean.TRUE.toString(), PropertyType.BOOLEAN); assertEquals("Creating boolean type QValue from boolean or String must be equal.", factory.create(true), v); v = factory.create(Boolean.FALSE.toString(), PropertyType.BOOLEAN); assertEquals("Creating boolean type QValue from boolean or String must be equal.", factory.create(false), v); }
public void testDateValueEquality() throws RepositoryException { QValue v = factory.create(CALENDAR); QValue otherV = factory.create(CALENDAR); assertEquals("Equality of date value must be calculated based on their String representation.", v, otherV); }
public void testCreateFalseFromString() throws ValueFormatException, RepositoryException { QValue v = factory.create("any", PropertyType.STRING); assertEquals("Boolean value must be false", false, v.getBoolean()); }
public void testDateValueEquality2() throws RepositoryException { QValue v = factory.create(CALENDAR); QValue otherV = factory.create(v.getString(), PropertyType.DATE); assertEquals("Equality of date value must be calculated based on their String representation.", v, otherV); }