alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Lucene example source code file (TestHtmlParser.java)

This example Lucene source code file (TestHtmlParser.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Lucene tags/keywords

exception, html, htmlparser, htmlparser, io, ioexception, reader, string, string, stringbuilder, stringreader, stringreader, summarize, summarize, util, w3c//dtd

The Lucene TestHtmlParser.java source code

package org.apache.lucene.benchmark.byTask.feeds.demohtml;

/**
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.Properties;

import org.apache.lucene.util.LuceneTestCase;

public class TestHtmlParser extends LuceneTestCase {

  public void testUnicode() throws Exception {
    String text = "<html>汉语";
    HTMLParser parser = new HTMLParser(new StringReader(text));
    assertReadsTo("汉语", parser);
  }
  
  public void testEntities() throws Exception {
    String text = "<html>汉语¥";
    HTMLParser parser = new HTMLParser(new StringReader(text));
    assertReadsTo("汉语¥", parser);
  }
  
  public void testComments() throws Exception {
    String text = "<html>foo";
    HTMLParser parser = new HTMLParser(new StringReader(text));
    assertReadsTo("foo", parser);
  }
  
  public void testScript() throws Exception {
    String text = "<html>