/*
 * $Id: TestHighWireHtmlFilterFactory.java,v 1.2 2012-09-26 20:59:28 alexandraohlson Exp $
 */

/*

Copyright (c) 2000-2006 Board of Trustees of Leland Stanford Jr. University,
all rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
STANFORD UNIVERSITY BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name of Stanford University shall not
be used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Stanford University.

*/

package org.lockss.plugin.highwire;

import java.io.*;

import org.lockss.util.*;
import org.lockss.test.*;

public class TestHighWireHtmlFilterFactory extends LockssTestCase {
  static String ENC = Constants.DEFAULT_ENCODING;

  private HighWireHtmlFilterFactory fact;
  private MockArchivalUnit mau;

  public void setUp() throws Exception {
    super.setUp();
    fact = new HighWireHtmlFilterFactory();
    mau = new MockArchivalUnit();
  }

  private static final String inst1 = "<FONT SIZE=\"-2\" FACE=\"verdana,arial,helvetica\">\n	<NOBR><STRONG>Institution: Periodicals Department/Lane Library</STRONG></NOBR>\n	<NOBR><A TARGET=\"_top\" HREF=\"/cgi/login?uri=%2Fcgi%2Fcontent%2Ffull%2F4%2F1%2F121\">Sign In as Personal Subscriber</A></NOBR>";

  private static final String inst2 = "<FONT SIZE=\"-2\" FACE=\"verdana,arial,helvetica\">\n	<NOBR><STRONG>Institution: Stanford University Libraries</STRONG></NOBR>\n	<NOBR><A TARGET=\"_top\" HREF=\"/cgi/login?uri=%2Fcgi%2Fcontent%2Ffull%2F4%2F1%2F121\">Sign In as Personal Subscriber</A></NOBR>";

  private static final String inst3 = "<FONT SIZE=\"-2\" FACE=\"verdana,arial,helvetica\">\n    <NOBR><STRONG>Institution: Stanford University Libraries</STRONG></NOBR>\n      <NOBR><A TARGET=\"_top\" HREF=\"/cgi/login?uri=%2Fcgi%2Fcontent%2Ffull%2F4%2F1%2F121\">Sign In as SOMETHING SOMETHING</A></NOBR>";

  public void testFiltering() throws Exception {
    InputStream inA;
    InputStream inB;

    inA = fact.createFilteredInputStream(mau,
        new StringInputStream(inst1), ENC);
    inB = fact.createFilteredInputStream(mau,
        new StringInputStream(inst2), ENC);
    assertEquals(StringUtil.fromInputStream(inA),
        StringUtil.fromInputStream(inB));

    inA = fact.createFilteredInputStream(mau,
        new StringInputStream(inst1), ENC);
    inB = fact.createFilteredInputStream(mau,
        new StringInputStream(inst3), ENC);
    assertEquals(StringUtil.fromInputStream(inA),
        StringUtil.fromInputStream(inB));
  }

}

@@ -47,45 +47,39 @@
 v 1.
-2
+3
  201
-2-09-26 20:59:28 alexandraohlson
+3-08-02 23:00:34 etenbrink
  Exp
@@ -1973,32 +1973,43 @@
 ,helvetica%5C%22%3E%5Cn%09
+%22 +%0A      %22
 %3CNOBR%3E%3CSTRONG%3EIn
@@ -2065,32 +2065,43 @@
 TRONG%3E%3C/NOBR%3E%5Cn%09
+%22 +%0A      %22
 %3CNOBR%3E%3CA TARGET=
@@ -2163,32 +2163,43 @@
 2F4%252F1%252F121%5C%22%3E
+%22 +%0A      %22
 Sign In as Perso
@@ -2316,24 +2316,35 @@
 vetica%5C%22%3E%5Cn%09
+%22 +%0A      %22
 %3CNOBR%3E%3CSTRON
@@ -2406,16 +2406,27 @@
 NOBR%3E%5Cn%09
+%22 +%0A      %22
 %3CNOBR%3E%3CA
@@ -2496,32 +2496,43 @@
 2F4%252F1%252F121%5C%22%3E
+%22 +%0A      %22
 Sign In as Perso
@@ -2652,24 +2652,35 @@
 ica%5C%22%3E%5Cn    
+%22 +%0A      %22
 %3CNOBR%3E%3CSTRON
@@ -2747,16 +2747,27 @@
 %5Cn      
+%22 +%0A      %22
 %3CNOBR%3E%3CA
@@ -2845,16 +2845,27 @@
 2F121%5C%22%3E
+%22 +%0A      %22
 Sign In 

Wrap long strings, preparation for other changes