Package org.neo4j.shell.tools

Source Code of org.neo4j.shell.tools.Asserts

package org.neo4j.shell.tools;

import org.neo4j.helpers.collection.IteratorUtil;
import org.neo4j.shell.ShellClient;
import org.neo4j.shell.ShellException;
import org.neo4j.shell.impl.CollectingOutput;

import java.rmi.RemoteException;
import java.util.Iterator;

import static org.junit.Assert.assertEquals;
import static org.neo4j.helpers.collection.Iterables.join;

/**
* Created by mh on 12.07.13.
*/
public class Asserts {
    public static void assertCommand(ShellClient client, String command, String... expected) throws RemoteException, ShellException {
        CollectingOutput out = new CollectingOutput();
        client.evaluate(command, out);
        assertEquals("command: "+join("\n",out.iterator()),expected.length, IteratorUtil.count(out.iterator()));
        Iterator<String> it = out.iterator();
        for (String s : expected) {
            String output = it.next().trim();
            if (s.isEmpty()) continue;
            assertEquals(output+" should contain "+s,true,output.contains(s));
        }
    }
}
TOP

Related Classes of org.neo4j.shell.tools.Asserts

TOP
Copyright © 2018 www.massapi.com. 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.