@@ -0,0 +1,3759 @@
+/* This file is part of VoltDB.%0A * Copyright (C) 2020 VoltDB Inc.%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining%0A * a copy of this software and associated documentation files (the%0A * %22Software%22), to deal in the Software without restriction, including%0A * without limitation the rights to use, copy, modify, merge, publish,%0A * distribute, sublicense, and/or sell copies of the Software, and to%0A * permit persons to whom the Software is furnished to do so, subject to%0A * the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be%0A * included in all copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND,%0A * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF%0A * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.%0A * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR%0A * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,%0A * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR%0A * OTHER DEALINGS IN THE SOFTWARE.%0A */%0Apackage org.voltdb.test.utils;%0A%0Aimport static org.junit.Assert.fail;%0A%0Aimport java.util.Arrays;%0Aimport java.util.Iterator;%0Aimport java.util.concurrent.atomic.AtomicInteger;%0A%0Aimport org.voltdb.client.Client;%0Aimport org.voltdb.client.ClientResponse;%0Aimport org.voltdb.client.ProcedureCallback;%0A%0Apublic class ClientTestUtils %7B%0A    /**%0A     * Call a procedure one time for each value returned by %7B@code arguments%7D. If any invocation fails an%0A     * %7B@link org.junit.Assert#fail()%7D will be called with results of the failure. If no failures occur this method will%0A     * return once the result of all invocations has been received.%0A     *%0A     * @param client        to use to make invocations%0A     * @param procedureName of the procedure to invoke%0A     * @param arguments     %7B@link Iterator%7D for the arguments to be used for each invocation%0A     * @throws Exception When an error occurrs%0A     */%0A    public static void callProcedureRepeatedly(Client client, String procedureName, Iterator%3CObject%5B%5D%3E arguments)%0A            throws Exception %7B%0A        ResultCollector callback = new ResultCollector();%0A%0A        while (arguments.hasNext()) %7B%0A            callback.sendingRequest();%0A            client.callProcedure(callback, procedureName, arguments.next());%0A        %7D%0A%0A        callback.waitForAllOrError();%0A    %7D%0A%0A    /**%0A     * %7B@link ProcedureCallback%7D which is used to determine if all results were successful or not.%0A     */%0A    public static class ResultCollector implements ProcedureCallback %7B%0A        AtomicInteger outstandingResponses = new AtomicInteger();%0A        ClientResponse errorResponse = null;%0A%0A        @Override%0A        public void clientCallback(ClientResponse clientResponse) %7B%0A            if (clientResponse.getStatus() != ClientResponse.SUCCESS) %7B%0A                synchronized (this) %7B%0A                    if (errorResponse == null) %7B%0A                        errorResponse = clientResponse;%0A                        notifyAll();%0A                    %7D%0A                %7D%0A            %7D%0A            if (outstandingResponses.decrementAndGet() == 0) %7B%0A                synchronized (this) %7B%0A                    notifyAll();%0A                %7D%0A            %7D%0A        %7D%0A%0A        void sendingRequest() %7B%0A            outstandingResponses.getAndIncrement();%0A        %7D%0A%0A        synchronized void waitForAllOrError() throws Exception %7B%0A            while (errorResponse == null && outstandingResponses.get() != 0) %7B%0A                wait();%0A            %7D%0A%0A            if (errorResponse != null) %7B%0A                fail(errorResponse.getStatusString() + '%5Cn' + Arrays.toString(errorResponse.getResults()));%0A            %7D%0A        %7D%0A    %7D%0A%7D%0A

Add new utility class for using the client in a test