IndexerTest.java revision 377
0N/A/*
0N/A * CDDL HEADER START
0N/A *
0N/A * The contents of this file are subject to the terms of the
0N/A * Common Development and Distribution License (the "License").
0N/A * You may not use this file except in compliance with the License.
0N/A *
0N/A * See LICENSE.txt included in this distribution for the specific
0N/A * language governing permissions and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL HEADER in each
0N/A * file and include the License file at LICENSE.txt.
0N/A * If applicable, add the following below this CDDL HEADER, with the
0N/A * fields enclosed by brackets "[]" replaced with your own identifying
0N/A * information: Portions Copyright [yyyy] [name of copyright owner]
0N/A *
0N/A * CDDL HEADER END
0N/A */
0N/A
0N/A/*
1054N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
0N/A * Use is subject to license terms.
0N/A */
65N/Apackage org.opensolaris.opengrok.index;
125N/A
125N/Aimport java.io.IOException;
58N/Aimport org.junit.After;
77N/Aimport org.junit.AfterClass;
125N/Aimport org.junit.Before;
125N/Aimport org.junit.BeforeClass;
125N/Aimport org.junit.Test;
1092N/Aimport org.opensolaris.opengrok.configuration.RuntimeEnvironment;
1016N/Aimport org.opensolaris.opengrok.util.TestRepository;
125N/A
1092N/A/**
261N/A *
261N/A * @author Trond Norbye
583N/A */
312N/Apublic class IndexerTest {
1062N/A TestRepository repository;
312N/A
467N/A public IndexerTest() {
428N/A }
126N/A
1088N/A @BeforeClass
58N/A public static void setUpClass() throws Exception {
394N/A }
8N/A
77N/A @AfterClass
0N/A public static void tearDownClass() throws Exception {
0N/A }
0N/A
0N/A @Before
0N/A public void setUp() throws IOException {
0N/A repository = new TestRepository();
491N/A repository.create(IndexerTest.class.getResourceAsStream("source.zip"));
439N/A }
491N/A
465N/A @After
465N/A public void tearDown() {
491N/A repository.destroy();
491N/A }
491N/A
886N/A /**
886N/A * Test of doIndexerExecution method, of class Indexer.
886N/A */
886N/A @Test
886N/A public void testIndexGeneration() throws Exception {
886N/A System.out.println("Generating index by using the class methods");
491N/A RuntimeEnvironment env = RuntimeEnvironment.getInstance();
491N/A env.setCtags(System.getProperty("org.opensolaris.opengrok.configuration.ctags", "ctags"));
491N/A if (env.validateExuberantCtags()) {
491N/A env.setSourceRootFile(repository.getSourceRoot());
65N/A env.setDataRoot(repository.getDataRoot());
65N/A env.setVerbose(true);
65N/A Indexer.getInstance().prepareIndexer(env, true, true, "/c", null, false, false, false, null, null);
65N/A Indexer.getInstance().doIndexerExecution(true, 1, null, null);
464N/A } else {
0N/A System.out.println("Skipping test. Could not find a ctags I could use in path.");
58N/A }
312N/A }
312N/A
260N/A /**
491N/A * Test of doIndexerExecution method, of class Indexer.
428N/A */
376N/A @Test
376N/A public void testMain() throws IOException {
0N/A System.out.println("Generate index by using command line options");
11N/A RuntimeEnvironment env = RuntimeEnvironment.getInstance();
0N/A env.setCtags(System.getProperty("org.opensolaris.opengrok.configuration.ctags", "ctags"));
240N/A if (env.validateExuberantCtags()) {
1016N/A String[] argv = { "-S", "-P", "-p", "/c", "-H", "-Q", "off", "-s", repository.getSourceRoot().getAbsolutePath(), "-d", repository.getDataRoot().getAbsolutePath(), "-v"};
58N/A Indexer.main(argv);
58N/A } else {
58N/A System.out.println("Skipping test. Could not find a ctags I could use in path.");
58N/A }
77N/A }
207N/A}