@@ -0,0 +1,3094 @@
+/*%0A * Copyright 2011 Splunk, Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22): you may%0A * not use this file except in compliance with the License. You may obtain%0A * a copy of the License at%0A *%0A *     http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A * License for the specific language governing permissions and limitations%0A * under the License.%0A */%0A%0A// parse%0A// typeahead%0A// timeparser%0A// jobs.create%0A//  - result kinds%0A// %0A%0Apackage com.splunk;%0A%0Aimport com.splunk.http.HTTPException;%0Aimport com.splunk.http.ResponseMessage;%0Aimport com.splunk.sdk.Command;%0A%0Aimport junit.framework.TestCase;%0Aimport org.junit.*;%0A%0Apublic class SearchTest extends TestCase %7B%0A    Command command;%0A%0A    public SearchTest() %7B%7D%0A%0A    Service connect() %7B%0A        return Service.connect(command.opts);%0A    %7D%0A%0A    @Before public void setUp() %7B%0A        command = Command.splunk(); // Pick up .splunkrc settings%0A    %7D%0A%0A    @Test public void testParse() %7B%0A        Args parseArgs;%0A        ResponseMessage response;%0A%0A        Service service = connect();%0A%0A        String query = %22search index=sdk-test * %7C head 1%22;%0A%0A        // Check simple parse.%0A        response = service.parse(query);%0A        assertEquals(response.getStatus(), 200);%0A%0A        // Check parse with parse_only argument.%0A        parseArgs = new Args(%22parse_only%22, true);%0A        service.parse(query, parseArgs); %0A        assertEquals(response.getStatus(), 200);%0A%0A        // Check parse with multiple arguments.%0A        parseArgs = new Args();%0A        parseArgs.put(%22parse_only%22, false);%0A        parseArgs.put(%22output_mode%22, %22json%22);%0A        parseArgs.put(%22enable_lookups%22, true);%0A        parseArgs.put(%22reload_macros%22, true);%0A        service.parse(query, parseArgs); %0A        assertEquals(response.getStatus(), 200);%0A    %7D%0A%0A    @Test public void testParseFail() %7B%0A        Service service = connect();%0A%0A        String query = %22syntax-error%22;%0A%0A        // Check for parse error.%0A        try %7B%0A            service.parse(query);%0A            fail(%22Expected a parse error%22);%0A        %7D%0A        catch (HTTPException e) %7B %0A            assertEquals(e.getStatus(), 400);%0A        %7D%0A%0A        // Check for parse error with args.%0A        try %7B%0A            Args parseArgs = new Args();%0A            parseArgs.put(%22parse_only%22, false);%0A            parseArgs.put(%22output_mode%22, %22json%22);%0A            parseArgs.put(%22enable_lookups%22, true);%0A            parseArgs.put(%22reload_macros%22, true);%0A            service.parse(query, parseArgs); %0A            fail(%22Expected a parse error%22);%0A        %7D%0A        catch (HTTPException e) %7B%0A            assertEquals(e.getStatus(), 400);%0A        %7D%0A%0A        // Check for argument error.%0A        try %7B%0A            Args parseArgs = new Args(%22babble%22, 42);%0A            service.parse(query, parseArgs);%0A        %7D%0A        catch (HTTPException e) %7B%0A            assertEquals(e.getStatus(), 400);%0A        %7D%0A    %7D%0A%7D%0A%0A

Add unit tests for Searvice.parse