Package org.infinispan.schematic.document

Examples of org.infinispan.schematic.document.Document


    }

    protected void assertRoundtrip( Document input,
                                    boolean compareToOtherImpls ) {
        assert input != null;
        Document output = writeThenRead(input, compareToOtherImpls);
        if (print) {
            System.out.println("********************************************************************************");
            System.out.println("INPUT :  " + input);
            System.out.println();
            System.out.println("OUTPUT:  " + output);
View Full Code Here


            long start = System.nanoTime();
            byte[] bytes = writer.write(object);
            long writeTime = System.nanoTime() - start;

            start = System.nanoTime();
            Document result = reader.read(new ByteArrayInputStream(bytes));
            long readTime = System.nanoTime() - start;

            if (compareToOtherImpls) {
                // Convert to MongoDB, write to bytes, and compare ...
                BSONObject mongoData = createMongoData(object);
                start = System.nanoTime();
                byte[] mongoBytes = new BasicBSONEncoder().encode(mongoData);
                long mongoWriteTime = System.nanoTime() - start;
                assertSame(bytes, mongoBytes, "BSON   ", "Mongo  ");

                // FYI: The Jackson BSON library writes several of the types incorrectly,
                // whereas the MongoDB library seems to write things per the spec.

                // // Convert to Jackson BSON, write to bytes, and compare ...
                // ByteArrayOutputStream stream2 = new ByteArrayOutputStream();
                // ObjectMapper om = new ObjectMapper(new BsonFactory());
                // Map<String, Object> jacksonData = createJacksonData(object);
                // om.writeValue(stream2, jacksonData);
                // byte[] jacksonBytes = stream2.toByteArray();
                // assertSame(bytes, jacksonBytes, "BSON   ", "Jackson");

                start = System.nanoTime();
                new BasicBSONDecoder().decode(bytes, new BasicBSONCallback());
                long mongoReadTime = System.nanoTime() - start;

                Document fromMongo = reader.read(new ByteArrayInputStream(mongoBytes));
                if (!fromMongo.equals(result)) {
                    System.out.println("from Schematic: " + result);
                    System.out.println("from Mongo:     " + fromMongo);
                    assert false : "Document read from bytes written by Mongo did not match expected document: " + result;
                }
View Full Code Here

        Changes changes = editor.getChanges();
        engine.update(config.getName(), changes).get(); // don't forget to wait!

        // Verify the configuration was changed successfully ...
        RepositoryConfiguration config2 = engine.getRepositoryConfiguration(config.getName());
        Document sequencerA2 = (Document)config2.getDocument()
                                                .getDocument(FieldName.SEQUENCING)
                                                .getDocument(FieldName.SEQUENCERS)
                                                .get("CND sequencer");
        List<?> exprs2 = sequencerA2.getArray(FieldName.PATH_EXPRESSIONS);
        assertThat(exprs2.size(), is(2));
        assertThat((String)exprs2.get(0), is("//*.ddl"));
        assertThat((String)exprs2.get(1), is("//*.xml"));
    }
View Full Code Here

            return children;
        }
        List<?> childrenArray = federatedDocument.getArray(DocumentTranslator.CHILDREN);
        for (Object child : childrenArray) {
            assert child instanceof Document;
            Document childDocument = (Document)child;
            String childId = translator.getKey(childDocument);
            Name childName = translator.getNameFactory().create(childDocument.get(DocumentTranslator.NAME));
            children.put(childId, childName);
        }
        return children;
    }
View Full Code Here

        assert obj.equals(value);
    }

    @Test
    public void shouldParseDocumentWithCodeAndSscope() throws Exception {
        Document scope = (Document)parser("{ \"foo\" : 32 }").parseValue();
        CodeWithScope obj = new CodeWithScope("foo", scope);
        // String str = writer.write(obj);
        // print = true;
        // print(str);
        value = parser(writer.write(obj)).parseValue();
View Full Code Here

        String configFileName = getClass().getSimpleName() + ".json";
        String configFilePath = "config/" + configFileName;
        InputStream configStream = getClass().getClassLoader().getResourceAsStream(configFilePath);
        assertThat("Unable to find configuration file '" + configFilePath, configStream, is(notNullValue()));

        Document configDoc = Json.read(configStream);

        STARTUP.start();
        INFINISPAN_STARTUP.start();
        config = new RepositoryConfiguration(configDoc, configFileName);
        INFINISPAN_STARTUP.stop();
View Full Code Here

     * @return the modified document if system property variables were found, or the <code>doc</code> instance if no such
     *         variables were found
     */
    protected static Document replaceSystemPropertyVariables( Document doc ) {
        if (doc.isEmpty()) return doc;
        Document modified = doc.withVariablesReplacedWithSystemProperties();
        if (modified == doc) return doc;

        // Otherwise, we changed some values. Note that the system properties can only be used in
        // string values, whereas the schema may expect non-string values. Therefore, we need to validate
        // the document against the schema and possibly perform some conversions of values ...
View Full Code Here

     * @return the parsed repository configuration; never null
     * @throws ParsingException if the content could not be parsed as a valid JSON document
     */
    public static RepositoryConfiguration read( URL url ) throws ParsingException {
        CheckArg.isNotNull(url, "url");
        Document doc = Json.read(url);
        return new RepositoryConfiguration(doc, withoutExtension(url.getFile()));
    }
View Full Code Here

     * @throws ParsingException if the content could not be parsed as a valid JSON document
     * @throws FileNotFoundException if the file could not be found
     */
    public static RepositoryConfiguration read( File file ) throws ParsingException, FileNotFoundException {
        CheckArg.isNotNull(file, "file");
        Document doc = Json.read(new FileInputStream(file));
        return new RepositoryConfiguration(doc, withoutExtension(file.getName()));
    }
View Full Code Here

     */
    public static RepositoryConfiguration read( InputStream stream,
                                                String name ) throws ParsingException, FileNotFoundException {
        CheckArg.isNotNull(stream, "stream");
        CheckArg.isNotNull(name, "name");
        Document doc = Json.read(stream);
        return new RepositoryConfiguration(doc, withoutExtension(name));
    }
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.