Package org.infinispan.schematic.document

Examples of org.infinispan.schematic.document.Document


            final String repositoryName = repositoryName();

            // Get the binary storage configuration ...
            BinaryStorage binaryStorageConfig = binaryStorageInjector.getValue();
            assert binaryStorageConfig != null;
            Document binaryConfig = binaryStorageConfig.getBinaryConfiguration();
            assert binaryConfig != null;

            // Create a new configuration document ...
            EditableDocument config = Schematic.newDocument(repositoryConfiguration.getDocument());
View Full Code Here


        final String key = "key";
        runTest("JsonReader.read(String," + introspectStringValues + ")", numberOfRuns, testData.length(), print, new Runnable() {
            @Override
            public void run() {
                try {
                    Document doc = reader.read(testData, introspectStringValues);
                    if (getValue) doc.get(key);
                } catch (Exception t) {
                    error.compareAndSet(null, t);
                }
            }
        });
View Full Code Here

                                                                  int numberOfRuns,
                                                                  final boolean getValue,
                                                                  final boolean introspectStringValues ) throws Exception {
        assert testData != null;
        // Read the JSON into in-memory ...
        Document doc = new JsonReader().read(testData, introspectStringValues);

        // Write the in-memory out to BSON ...
        ByteArrayOutputStream bytes = new ByteArrayOutputStream();
        new BsonWriter().write(doc, bytes);
        final byte[] bsonBytes = bytes.toByteArray();

        final BsonReader bsonReader = new BsonReader();
        final AtomicReference<Exception> error = new AtomicReference<Exception>();
        final String key = "key";
        runTest("BsonReader.read(InputStream)", numberOfRuns, testData.length(), print, new Runnable() {
            @Override
            public void run() {
                try {
                    ByteArrayInputStream input = new ByteArrayInputStream(bsonBytes);
                    Document doc = bsonReader.read(input);
                    doc.get(key);
                } catch (Exception t) {
                    error.compareAndSet(null, t);
                }
            }
        });
View Full Code Here

        return this.getClass().getClassLoader().getResourceAsStream(path);
    }

    @Test
    public void shouldMergeTwoDocuments() throws Exception {
        Document doc1 = Json.read(stream("json/merge-1.json"));
        Document doc2 = Json.read(stream("json/merge-2.json"));
        Document doc3 = Json.read(stream("json/merge-3.json"));
        EditableDocument editor = new DocumentEditor((MutableDocument)doc1);
        assertThat(Json.writePretty(editor).equals(Json.writePretty(doc3)), is(false));
        editor.merge(doc2);
        assertThat(Json.writePretty(editor).equals(Json.writePretty(doc3)), is(true));
    }
View Full Code Here

    }

    protected void assertRoundTripJsonDocument( String resourcePath ) throws Exception {
        InputStream stream = getClass().getClassLoader().getResourceAsStream(resourcePath);
        assertThat(stream, is(notNullValue()));
        Document doc = Json.read(stream);
        byte[] bytes = marshall(doc);
        Document newDoc = (Document)unmarshall(bytes);
        assertThat(newDoc, is(doc));
    }
View Full Code Here

        if (obj instanceof Iterable) {
            // Probably an array
            return false;
        }
        if (obj instanceof Document) {
            Document that = (Document)obj;
            if (this.size() != that.size()) {
                return false;
            }
            for (Field thisField : fields()) {
                Object thisValue = thisField.getValue();
                Object thatValue = that.get(thisField.getName());
                if (!BsonUtils.valuesAreEqual(thisValue, thatValue)) {
                    return false;
                }
            }
            return true;
        }
        if (obj instanceof Map) {
            Map<?, ?> that = (Map<?, ?>)obj;
            if (this.size() != that.size()) {
                return false;
            }
            if (!this.keySet().equals(that.keySet())) {
                return false;
            }
            for (Field thisField : fields()) {
                Object thisValue = thisField.getValue();
                Object thatValue = that.get(thisField.getName());
                if (!BsonUtils.valuesAreEqual(thisValue, thatValue)) {
                    return false;
                }
            }
            return true;
View Full Code Here

        assertRoundtrip(input);
    }

    @Test
    public void shouldRoundTripSimpleBsonObjectWithCodeWithScope() {
        Document scope = new BasicDocument("baz", "bam", "bak", "bat");
        input = new BasicDocument("foo", new CodeWithScope("bar", scope));
        assertRoundtrip(input);
    }
View Full Code Here

        assertRoundtrip(input);
    }

    @Test
    public void shouldRoundTripLargeModeShapeDocument() throws Exception {
        Document doc = Json.read(TestUtil.resource("json/sample-large-modeshape-doc.json"));
        // OutputStream os = new FileOutputStream("src/test/resources/json/sample-large-modeshape-doc2.json");
        // Json.writePretty(doc, os);
        // os.flush();
        // os.close();
        assertRoundtrip(doc);
View Full Code Here

    @Test
    @FixFor( "MODE-2074" )
    public void shouldRoundTripBsonWithLargeStringField() throws Exception {
        //use a string which overflows the default buffer BufferCache.MINIMUM_SIZE
        final String largeString = readFile("json/sample-large-modeshape-doc3.json");
        Document document = new BasicDocument("largeString", largeString);
        assertRoundtrip(document);
    }
View Full Code Here

        ExecutorService executorService = Executors.newFixedThreadPool(threadCount);
        for (int i = 0; i < threadCount; i++) {
            results.add(executorService.submit(new Callable<Void>() {
                @Override
                public Void call() throws Exception {
                    Document document = new BasicDocument("largeString", largeString);
                    assertRoundtrip(document);
                    return null;
                }
            }));
        }
View Full Code Here

TOP

Related Classes of org.infinispan.schematic.document.Document

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.