KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > summary > test > HtmlSummarizerTest


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.summary.test;
17
18 import junit.framework.TestCase;
19 import org.outerj.daisy.summary.HtmlSummarizer;
20
21 import java.io.ByteArrayInputStream JavaDoc;
22
23 public class HtmlSummarizerTest extends TestCase {
24     public void testSummarizer() throws Exception JavaDoc {
25         String JavaDoc input, summary;
26
27         input = "<html><body>abc</body></html>";
28         summary = HtmlSummarizer.extractSummary(new ByteArrayInputStream JavaDoc(input.getBytes("UTF-8")), 300);
29         assertEquals("abc", summary);
30
31         input = " <html> <body>abc</body> </html> ";
32         summary = HtmlSummarizer.extractSummary(new ByteArrayInputStream JavaDoc(input.getBytes("UTF-8")), 300);
33         assertEquals("abc", summary);
34
35         input = " <html> <body><p>abc</p></body> </html> ";
36         summary = HtmlSummarizer.extractSummary(new ByteArrayInputStream JavaDoc(input.getBytes("UTF-8")), 300);
37         assertEquals("abc", summary);
38
39         input = " <html> <body><p>Bla bla bla</p></body> </html> ";
40         summary = HtmlSummarizer.extractSummary(new ByteArrayInputStream JavaDoc(input.getBytes("UTF-8")), 10);
41         assertEquals("Bla bla...", summary);
42     }
43 }
44
Popular Tags