1196N/A/*
1196N/A * CDDL HEADER START
1185N/A *
1185N/A * The contents of this file are subject to the terms of the
1185N/A * Common Development and Distribution License (the "License").
1185N/A * You may not use this file except in compliance with the License.
1185N/A *
1196N/A * See LICENSE.txt included in this distribution for the specific
1196N/A * language governing permissions and limitations under the License.
1196N/A *
1185N/A * When distributing Covered Code, include this CDDL HEADER in each
1185N/A * file and include the License file at LICENSE.txt.
1185N/A * If applicable, add the following below this CDDL HEADER, with the
1185N/A * fields enclosed by brackets "[]" replaced with your own identifying
1185N/A * information: Portions Copyright [yyyy] [name of copyright owner]
1196N/A *
1196N/A * CDDL HEADER END
1185N/A */
1220N/A
1185N/A/*
1185N/A * Copyright 2009 - 2011 Jens Elkner.
1185N/A */
1185N/Apackage org.opensolaris.opengrok.analysis.document;
1185N/A
1185N/A
1384N/Aimport static org.junit.Assert.assertNotNull;
1384N/Aimport static org.junit.Assert.fail;
1384N/A
1185N/Aimport java.io.ByteArrayInputStream;
1185N/Aimport java.io.CharArrayWriter;
1185N/Aimport java.io.File;
1185N/Aimport java.io.IOException;
1185N/Aimport java.io.StringWriter;
1185N/A
1185N/Aimport org.apache.lucene.document.Document;
1185N/Aimport org.junit.After;
1185N/Aimport org.junit.AfterClass;
1185N/Aimport org.junit.Before;
1185N/Aimport org.junit.BeforeClass;
1185N/Aimport org.junit.Ignore;
1185N/Aimport org.junit.Test;
1384N/Aimport org.opensolaris.opengrok.analysis.XrefWriter;
1185N/Aimport org.opensolaris.opengrok.web.Util;
1185N/A
1185N/A/**
1185N/A * @author Jens Elkner
1185N/A * @version $Revision$
1185N/A */
1185N/Apublic class TroffAnalyzerTest {
1185N/A private static TroffAnalyzerFactory factory;
1185N/A private static TroffAnalyzer analyzer;
1185N/A private static String content;
1185N/A
1185N/A /**
1185N/A * Test method for {@link org.opensolaris.opengrok.analysis.document
1185N/A * .TroffAnalyzer#TroffAnalyzer(org.opensolaris.opengrok.analysis.FileAnalyzerFactory)}.
1185N/A */
1185N/A @BeforeClass
1185N/A public static void setUpBeforeClass() {
1185N/A factory = new TroffAnalyzerFactory();
1185N/A assertNotNull(factory);
1185N/A analyzer = new TroffAnalyzer(factory);
1185N/A assertNotNull(analyzer);
1185N/A String file = System.getProperty("opengrok.test.troff.doc",
1185N/A "testdata/sources/document/foobar.1");
1185N/A File f = new File(file);
1185N/A if (!(f.canRead() && f.isFile())) {
1185N/A fail("troff testfile " + f + " not found");
1185N/A }
1185N/A CharArrayWriter w = new CharArrayWriter((int)f.length());
1185N/A Util.dump(w, f, false);
1185N/A content = w.toString();
1185N/A }
1185N/A
1185N/A /**
1185N/A * @throws java.lang.Exception
1185N/A */
1185N/A @AfterClass
1185N/A public static void tearDownAfterClass() throws Exception {
1185N/A }
1185N/A
1185N/A /**
1185N/A * @throws java.lang.Exception
1185N/A */
1185N/A @Before
1185N/A public void setUp() throws Exception {
1185N/A }
1185N/A
1185N/A /**
1185N/A * @throws java.lang.Exception
1185N/A */
1185N/A @After
1185N/A public void tearDown() throws Exception {
1185N/A }
1185N/A
1185N/A /**
1185N/A * Test method for {@link org.opensolaris.opengrok.analysis.document
1185N/A * .TroffAnalyzer#analyze(org.apache.lucene.document.Document,
1185N/A * java.io.InputStream)}.
1185N/A * @throws IOException
1185N/A */
1185N/A @Test
1185N/A public void testAnalyze() throws IOException {
1185N/A Document doc = new Document();
1185N/A analyzer.analyze(doc, new ByteArrayInputStream(content.getBytes()));
1185N/A }
1185N/A
1185N/A /**
1185N/A * Test method for {@link org.opensolaris.opengrok.analysis.document
1185N/A * .TroffAnalyzer#writeXref(java.io.Writer)}.
1185N/A * @throws IOException
1185N/A */
1185N/A @Test
1185N/A public void testWriteXrefWriter() throws IOException {
1185N/A testAnalyze();
1185N/A StringWriter out = new StringWriter(content.length() + 1024);
1384N/A analyzer.writeXref(new XrefWriter(out));
1185N/A }
1185N/A
1185N/A /**
1185N/A * Test method for {@link org.opensolaris.opengrok.analysis.document
1185N/A * .TroffAnalyzer#tokenStream(java.lang.String, java.io.Reader)}.
1185N/A */
1185N/A @Ignore
1185N/A public void testTokenStreamStringReader() {
1185N/A fail("Not yet implemented");
1185N/A }
1185N/A
1185N/A /**
1185N/A * Test method for {@link org.opensolaris.opengrok.analysis.document
1185N/A * .TroffAnalyzer#writeXref(java.io.Reader, java.io.Writer,
1185N/A * org.opensolaris.opengrok.analysis.Definitions,
1185N/A * org.opensolaris.opengrok.history.Annotation,
1185N/A * org.opensolaris.opengrok.configuration.Project)}.
1185N/A */
1185N/A @Ignore
1185N/A public void xtestWriteXrefReaderWriterDefinitionsAnnotationProject() {
1185N/A fail("Not yet implemented");
1185N/A }
1185N/A}