Package org.jboss.dna.graph.property

Examples of org.jboss.dna.graph.property.Reference


    }

    @Test
    public void shouldCreateBinaryFromReference() throws UnsupportedEncodingException {
        UUID uuid = UUID.randomUUID();
        Reference value = new UuidReference(uuid);
        assertThat(factory.create(value), hasContent(uuid.toString()));
    }
View Full Code Here


        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));
    }
View Full Code Here

        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();
        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);

        Property prop2b = createProperty("p2");
        Property prop3b = createProperty("p3", "v3");
        String binaryValueStr2 = binaryValueStr + " but modified";
View Full Code Here

        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();
        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);

        // Serialize the properties (and verify they're serialized properly) ...
        Property[] props = new Property[] {prop1, prop2, prop3, prop4, prop5, prop6, prop7, prop8};
        byte[] content = serialize(serializer, props);
        List<Property> properties = deserialize(serializer, content);
        assertThat(properties, hasItems(props));

        // Define the old-to-new UUID mapping ...
        UUID newUuid7 = UUID.randomUUID();
        Map<String, String> oldToNewUuids = new HashMap<String, String>();
        oldToNewUuids.put(uuid7.toString(), newUuid7.toString());
        // note that 'uuid8' is not included, so 'ref8' should be untouched

        // Now update the references in the serialized properties ...
        ByteArrayInputStream bais = new ByteArrayInputStream(content);
        ObjectInputStream ois = new ObjectInputStream(bais);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ObjectOutputStream oos = new ObjectOutputStream(baos);
        try {
            serializer.adjustReferenceProperties(ois, oos, oldToNewUuids);
        } finally {
            baos.close();
            oos.close();
        }
        byte[] newContent = baos.toByteArray();

        // Now deserialize the updated content ...
        properties = deserialize(serializer, newContent);

        // Update a new 'prop7' ...
        Reference newRef7 = valueFactories.getReferenceFactory().create(newUuid7);
        Property newProp7 = createProperty("p7", newRef7);
        Property[] newProps = new Property[] {prop1, prop2, prop3, prop4, prop5, prop6, newProp7, prop8};

        // Finally verify that the updated content matches the expected new properties ...
        assertThat(properties, hasItems(newProps));
View Full Code Here

TOP

Related Classes of org.jboss.dna.graph.property.Reference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.