1003N/A/*
1003N/A * CDDL HEADER START
1003N/A *
1003N/A * The contents of this file are subject to the terms of the
1003N/A * Common Development and Distribution License (the "License").
1003N/A * You may not use this file except in compliance with the License.
1003N/A *
1003N/A * See LICENSE.txt included in this distribution for the specific
1003N/A * language governing permissions and limitations under the License.
1003N/A *
1003N/A * When distributing Covered Code, include this CDDL HEADER in each
1003N/A * file and include the License file at LICENSE.txt.
1003N/A * If applicable, add the following below this CDDL HEADER, with the
1003N/A * fields enclosed by brackets "[]" replaced with your own identifying
1003N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1003N/A *
1003N/A * CDDL HEADER END
1003N/A */
1003N/A
1003N/A/*
1003N/A * Copyright 2010 Sun Micosystems. All rights reserved.
1003N/A * Use is subject to license terms.
1003N/A */
1003N/A
1003N/Apackage org.opensolaris.opengrok.search;
1003N/A
1003N/Aimport org.apache.lucene.search.Query;
1003N/Aimport org.junit.Test;
1003N/Aimport org.opensolaris.opengrok.analysis.CompatibleAnalyser;
1003N/Aimport static org.junit.Assert.*;
1003N/A
1003N/A/**
1003N/A * Unit tests for the Summarizer class.
1003N/A */
1003N/Apublic class SummarizerTest {
1003N/A /**
1003N/A * If the last token in a text fragment is a token we're searching for,
1003N/A * and that token is also present earlier in the fragment, getSummary()
1003N/A * used to throw a StringIndexOutOfBoundsException. Bug #15858.
1003N/A */
1003N/A @Test
1003N/A public void bug15858() throws Exception {
1003N/A Query query = new QueryBuilder().setFreetext("beta").build();
1003N/A Summarizer instance = new Summarizer(query, new CompatibleAnalyser());
1003N/A // This call used to result in a StringIndexOutOfBoundsException
1003N/A assertNotNull(instance.getSummary("alpha beta gamma delta beta"));
1003N/A }
1003N/A}