45d862b9c655542aa44c02958011065f6994f512Trond Norbye/*
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * CDDL HEADER START
45d862b9c655542aa44c02958011065f6994f512Trond Norbye *
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * The contents of this file are subject to the terms of the
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * Common Development and Distribution License (the "License").
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * You may not use this file except in compliance with the License.
45d862b9c655542aa44c02958011065f6994f512Trond Norbye *
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * See LICENSE.txt included in this distribution for the specific
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * language governing permissions and limitations under the License.
45d862b9c655542aa44c02958011065f6994f512Trond Norbye *
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * When distributing Covered Code, include this CDDL HEADER in each
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * file and include the License file at LICENSE.txt.
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * If applicable, add the following below this CDDL HEADER, with the
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * fields enclosed by brackets "[]" replaced with your own identifying
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * information: Portions Copyright [yyyy] [name of copyright owner]
45d862b9c655542aa44c02958011065f6994f512Trond Norbye *
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * CDDL HEADER END
45d862b9c655542aa44c02958011065f6994f512Trond Norbye */
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye/*
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * Use is subject to license terms.
45d862b9c655542aa44c02958011065f6994f512Trond Norbye */
45d862b9c655542aa44c02958011065f6994f512Trond Norbyepackage org.opensolaris.opengrok.index;
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbyeimport java.io.IOException;
45d862b9c655542aa44c02958011065f6994f512Trond Norbyeimport java.util.Iterator;
45d862b9c655542aa44c02958011065f6994f512Trond Norbyeimport org.junit.After;
45d862b9c655542aa44c02958011065f6994f512Trond Norbyeimport org.junit.AfterClass;
45d862b9c655542aa44c02958011065f6994f512Trond Norbyeimport org.junit.Before;
45d862b9c655542aa44c02958011065f6994f512Trond Norbyeimport org.junit.BeforeClass;
45d862b9c655542aa44c02958011065f6994f512Trond Norbyeimport org.junit.Test;
45d862b9c655542aa44c02958011065f6994f512Trond Norbyeimport static org.junit.Assert.*;
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye/**
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * Check the CommandLineOption class
45d862b9c655542aa44c02958011065f6994f512Trond Norbye *
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * @author Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye */
45d862b9c655542aa44c02958011065f6994f512Trond Norbyepublic class CommandLineOptionsTest {
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye public CommandLineOptionsTest() {
45d862b9c655542aa44c02958011065f6994f512Trond Norbye }
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye @BeforeClass
45d862b9c655542aa44c02958011065f6994f512Trond Norbye public static void setUpClass() throws Exception {
45d862b9c655542aa44c02958011065f6994f512Trond Norbye }
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye @AfterClass
45d862b9c655542aa44c02958011065f6994f512Trond Norbye public static void tearDownClass() throws Exception {
45d862b9c655542aa44c02958011065f6994f512Trond Norbye }
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye @Before
45d862b9c655542aa44c02958011065f6994f512Trond Norbye public void setUp() {
45d862b9c655542aa44c02958011065f6994f512Trond Norbye }
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye @After
45d862b9c655542aa44c02958011065f6994f512Trond Norbye public void tearDown() {
45d862b9c655542aa44c02958011065f6994f512Trond Norbye }
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye /**
45d862b9c655542aa44c02958011065f6994f512Trond Norbye * Test of getCommandString method, of class CommandLineOptions.
45d862b9c655542aa44c02958011065f6994f512Trond Norbye */
45d862b9c655542aa44c02958011065f6994f512Trond Norbye @Test
a937449043f1e649320ccb609d9d1de16f6a9208Knut Anders Hatlen public void testCommandLineOptions() throws IOException {
45d862b9c655542aa44c02958011065f6994f512Trond Norbye CommandLineOptions instance = new CommandLineOptions();
45d862b9c655542aa44c02958011065f6994f512Trond Norbye String cmdString = instance.getCommandString();
45d862b9c655542aa44c02958011065f6994f512Trond Norbye assertNotNull(cmdString);
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye int ii = 0;
45d862b9c655542aa44c02958011065f6994f512Trond Norbye while (ii < cmdString.length()) {
45d862b9c655542aa44c02958011065f6994f512Trond Norbye char c = cmdString.charAt(ii);
45d862b9c655542aa44c02958011065f6994f512Trond Norbye if (c != ':') {
45d862b9c655542aa44c02958011065f6994f512Trond Norbye assertNotNull(instance.getCommandUsage(c));
45d862b9c655542aa44c02958011065f6994f512Trond Norbye }
45d862b9c655542aa44c02958011065f6994f512Trond Norbye ++ii;
45d862b9c655542aa44c02958011065f6994f512Trond Norbye }
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye Iterator<CommandLineOptions.Option> iter = instance.getOptionsIterator();
45d862b9c655542aa44c02958011065f6994f512Trond Norbye while (iter.hasNext()) {
45d862b9c655542aa44c02958011065f6994f512Trond Norbye CommandLineOptions.Option o = iter.next();
45d862b9c655542aa44c02958011065f6994f512Trond Norbye assertNotNull(o.description);
45d862b9c655542aa44c02958011065f6994f512Trond Norbye }
45d862b9c655542aa44c02958011065f6994f512Trond Norbye
45d862b9c655542aa44c02958011065f6994f512Trond Norbye assertNotNull(instance.getUsage());
a937449043f1e649320ccb609d9d1de16f6a9208Knut Anders Hatlen assertNotNull(instance.getManPage());
45d862b9c655542aa44c02958011065f6994f512Trond Norbye }
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye @Test
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye public void bug3042() {
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye CommandLineOptions instance = new CommandLineOptions();
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye String cmdString = instance.getCommandString();
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye int idx = cmdString.indexOf("?");
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye assertTrue(idx != -1);
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye assertEquals("-?\n\tHelp", instance.getCommandUsage('?'));
654c8ccb7fb16112a271048b7ee2d6f46cd746d6Trond Norbye }
f0ca07e08967a974684daffd32316cc9f9b98150Trond Norbye
f0ca07e08967a974684daffd32316cc9f9b98150Trond Norbye @Test
f0ca07e08967a974684daffd32316cc9f9b98150Trond Norbye public void rfe3041() {
f0ca07e08967a974684daffd32316cc9f9b98150Trond Norbye CommandLineOptions instance = new CommandLineOptions();
f0ca07e08967a974684daffd32316cc9f9b98150Trond Norbye String cmdString = instance.getCommandString();
f0ca07e08967a974684daffd32316cc9f9b98150Trond Norbye int idx = cmdString.indexOf("V");
f0ca07e08967a974684daffd32316cc9f9b98150Trond Norbye assertTrue(idx != -1);
f0ca07e08967a974684daffd32316cc9f9b98150Trond Norbye assertEquals("-V\n\tPrint version and quit", instance.getCommandUsage('V'));
f0ca07e08967a974684daffd32316cc9f9b98150Trond Norbye }
54ba62a2c6e74332ffc742cb23faf21615b5d39fLubos Kosco}