public On<Conjunction<Graph>> to( InputStream stream, long approximateLength ) { Binary value = getContext().getValueFactories().getBinaryFactory().create(stream, approximateLength); return toValue(value); }
public On<Conjunction<Graph>> to( Reader reader, long approximateLength ) { Binary value = getContext().getValueFactories().getBinaryFactory().create(reader, approximateLength); return toValue(value); }
public On<BatchConjunction> to( InputStream stream, long approximateLength ) { Binary value = getContext().getValueFactories().getBinaryFactory().create(stream, approximateLength); return toValue(value); }
public On<BatchConjunction> to( Reader reader, long approximateLength ) { Binary value = getContext().getValueFactories().getBinaryFactory().create(reader, approximateLength); return toValue(value); }
@Test public void shouldCompareBinaryAndStringValues() { String strValue = "Jack and Jill went up the hill"; Binary binaryValue = factories.getBinaryFactory().create(strValue); Binary binarySpy = spy(binaryValue); // The values should compare to each other ... assertThat(ValueComparators.OBJECT_COMPARATOR.compare(strValue, binarySpy), is(0)); assertThat(ValueComparators.OBJECT_COMPARATOR.compare(binarySpy, strValue), is(0)); // Verify that the binary value was not obtained, but that we just used the hash verify(binarySpy, times(0)).getBytes(); verify(binarySpy, times(0)).getStream(); verify(binarySpy, atLeastOnce()).getHash(); }
@Test public void shouldSerializeAndDeserializeSmallBinaryProperty() throws Exception { String value = "v1"; Property prop = createProperty("p1", valueFactories.getBinaryFactory().create(value)); assertSerializableAndDeserializable(serializer, prop); assertThat(largeValues.getCount(), is(0)); }
@Test public void shouldSerializeAndDeserializeLargeBinaryProperty() throws Exception { String value = "really really long string that will be converted to a binary value and tested like that"; Property prop = createProperty("p1", valueFactories.getBinaryFactory().create(value)); assertSerializableAndDeserializable(serializer, prop); assertThat(largeValues.getCount(), is(1)); }
Property prop3 = createProperty("p3", "v2"); Property prop4 = createProperty("p4", new String(value)); // make sure it's a different String object Property prop5 = createProperty("p5", valueFactories.getBinaryFactory().create("something")); String binaryValueStr = "really really long string that will be converted to a binary value and tested like that"; Binary binaryValue = valueFactories.getBinaryFactory().create(binaryValueStr); Property prop6 = createProperty("p6", binaryValue); UUID uuid7 = UUID.randomUUID();
@Test public void shouldSerializeAndDeserializeMixtureOfSmallAndLargeProperties() throws Exception { Property prop1 = createProperty("p1", "v1"); String value = "v234567890123456789012345678901234567890"; Property prop2 = createProperty("p2", value); Property prop3 = createProperty("p3", "v2"); Property prop4 = createProperty("p4", new String(value)); // make sure it's a different String object Property prop5 = createProperty("p5", valueFactories.getBinaryFactory().create("something")); String binaryValue = "really really long string that will be converted to a binary value and tested like that"; Property prop6 = createProperty("p6", valueFactories.getBinaryFactory().create(binaryValue)); UUID uuid7 = UUID.randomUUID(); Reference ref7 = valueFactories.getReferenceFactory().create(uuid7); Property prop7 = createProperty("p7", ref7); UUID uuid8 = UUID.randomUUID(); Reference ref8 = valueFactories.getReferenceFactory().create(uuid8); Property prop8 = createProperty("p8", ref8); assertSerializableAndDeserializable(serializer, prop1, prop2, prop3, prop4, prop5, prop6, prop7, prop8); assertThat(largeValues.getCount(), is(2)); }
InputStream stream = null; Throwable firstError = null; Binary binary = factories.getBinaryFactory().create(sequencedProperty.getFirstValue()); binary.acquire(); try {
@FixFor( "MODE-966" ) @Test public void shouldStoreLargeBinaryValue() throws Exception { File file = new File("src/test/resources/testdata/test1.xmi"); assertThat(file.exists(), is(true)); BinaryFactory binaryFactory = context.getValueFactories().getBinaryFactory(); Binary binaryValue = binaryFactory.create(file); graph.batch() .create("/someFile.xmi") .with("jcr:primaryType", "nt:file") .and() .create("/someFile.xmi/jcr:content") .with("jcr:priamryType", "nt:resource") .and("jcr:data", binaryValue) .and() .execute(); // Now read the content back out ... Property data = graph.getProperty("jcr:data").on("/someFile.xmi/jcr:content"); Binary readValue = binaryFactory.create(data.getFirstValue()); // and verify the content matches ... assertThat(binaryValue.getHash(), is(readValue.getHash())); assertThat(binaryValue.getBytes(), is(readValue.getBytes())); }
Property prop3 = createProperty("p3", "v2"); Property prop4 = createProperty("p4", new String(value)); // make sure it's a different String object Property prop5 = createProperty("p5", valueFactories.getBinaryFactory().create("something")); String binaryValueStr = "really really long string that will be converted to a binary value and tested like that"; Binary binaryValue = valueFactories.getBinaryFactory().create(binaryValueStr); Property prop6 = createProperty("p6", binaryValue); UUID uuid7 = UUID.randomUUID(); Property prop3b = createProperty("p3", "v3"); String binaryValueStr2 = binaryValueStr + " but modified"; Binary binaryValue2 = valueFactories.getBinaryFactory().create(binaryValueStr2); Property prop6b = createProperty("p6", binaryValue2);