|
From: <bra...@us...> - 2010-03-20 01:11:59
|
Revision: 2990
http://archive-access.svn.sourceforge.net/archive-access/?rev=2990&view=rev
Author: bradtofel
Date: 2010-03-20 01:11:51 +0000 (Sat, 20 Mar 2010)
Log Message:
-----------
INITIAL REV: tests for 2 transformers.
Added Paths:
-----------
trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/
trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/transformer/
trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/transformer/JSStringTransformerTest.java
trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/transformer/MetaRefreshUrlStringTransformerTest.java
Added: trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/transformer/JSStringTransformerTest.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/transformer/JSStringTransformerTest.java (rev 0)
+++ trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/transformer/JSStringTransformerTest.java 2010-03-20 01:11:51 UTC (rev 2990)
@@ -0,0 +1,82 @@
+/* JSStringTransformerTest
+ *
+ * $Id$:
+ *
+ * Created on Dec 10, 2009.
+ *
+ * Copyright (C) 2006 Internet Archive.
+ *
+ * This file is part of Wayback.
+ *
+ * Wayback is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * any later version.
+ *
+ * Wayback is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser Public License
+ * along with Wayback; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package org.archive.wayback.replay.html.transformer;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+
+import org.archive.wayback.replay.html.ContextResultURIConverterFactory;
+import org.archive.wayback.replay.html.ReplayParseContext;
+
+import junit.framework.TestCase;
+
+/**
+ * @author brad
+ *
+ */
+public class JSStringTransformerTest extends TestCase {
+
+ /**
+ * Test method for {@link org.archive.wayback.replay.html.transformer.JSStringTransformer#transform(org.archive.wayback.replay.html.ReplayParseContext, java.lang.String)}.
+ * @throws MalformedURLException
+ */
+ public void testTransform() throws MalformedURLException {
+ RecordingReplayParseContext rc = new RecordingReplayParseContext(null, new URL("http://foo.com/"), null);
+ String input = "'<a href=\'http://www.gavelgrab.org\' target=\'_blank\'>Learn more in Gavel Grab</a>'";
+ JSStringTransformer jst = new JSStringTransformer();
+ jst.transform(rc, input);
+ assertEquals(1,rc.got.size());
+ assertEquals("http://www.gavelgrab.org",rc.got.get(0));
+
+ input = "'<a href=\'http://www.gavelgrab.org/foobla/blah\' target=\'_blank\'>Learn more in Gavel Grab</a>'";
+ rc = new RecordingReplayParseContext(null, new URL("http://foo.com/"), null);
+ jst.transform(rc, input);
+ assertEquals(1,rc.got.size());
+ assertEquals("http://www.gavelgrab.org",rc.got.get(0));
+
+ }
+ public class RecordingReplayParseContext extends ReplayParseContext {
+ ArrayList<String> got = null;
+ /**
+ * @param uriConverterFactory
+ * @param baseUrl
+ * @param datespec
+ */
+ public RecordingReplayParseContext(
+ ContextResultURIConverterFactory uriConverterFactory,
+ URL baseUrl, String datespec) {
+ super(uriConverterFactory, baseUrl, datespec);
+ got = new ArrayList<String>();
+ // TODO Auto-generated constructor stub
+ }
+ public String contextualizeUrl(String url) {
+ got.add(url);
+ return url;
+ }
+
+ }
+}
Property changes on: trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/transformer/JSStringTransformerTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Revision Id
Added: trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/transformer/MetaRefreshUrlStringTransformerTest.java
===================================================================
--- trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/transformer/MetaRefreshUrlStringTransformerTest.java (rev 0)
+++ trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/transformer/MetaRefreshUrlStringTransformerTest.java 2010-03-20 01:11:51 UTC (rev 2990)
@@ -0,0 +1,64 @@
+/* MetaRefreshUrlStringTransformerTest
+ *
+ * $Id$:
+ *
+ * Created on Jan 12, 2010.
+ *
+ * Copyright (C) 2006 Internet Archive.
+ *
+ * This file is part of Wayback.
+ *
+ * Wayback is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * any later version.
+ *
+ * Wayback is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser Public License
+ * along with Wayback; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package org.archive.wayback.replay.html.transformer;
+
+import junit.framework.TestCase;
+
+/**
+ * @author brad
+ *
+ */
+public class MetaRefreshUrlStringTransformerTest extends TestCase {
+
+ /**
+ * Test method for {@link org.archive.wayback.replay.html.transformer.MetaRefreshUrlStringTransformer#transform(org.archive.wayback.replay.html.ReplayParseContext, java.lang.String)}.
+ */
+ public void testTransform() {
+// cmpT("0; url=http://foo.com/bar","0; url=(((http://foo.com/bar)))");
+// cmpT("0; url=/bar","0; url=(((/bar)))");
+// cmpT("0; url =/bar","0; url =(((/bar)))");
+// cmpT("0; url =/bar","0; url =(((/bar)))");
+// cmpT("; url =/bar","; url =/bar");
+// cmpT("0; URL =/bar","0; URL =(((/bar)))");
+//
+// cmpT("0; URL = /bar","0; URL = (((/bar)))");
+// cmpT("0; URL = /bar ","0; URL = (((/bar))) ");
+// cmpT("0; URL = /bar ","0; URL = (((/bar))) ");
+// cmpT("0; URL = /baz foo","0; URL = (((/baz foo)))");
+// cmpT("0; URL = /baz foo ","0; URL = (((/baz foo))) ");
+// cmpT("0; URL=/baz foo ","0; URL=(((/baz foo))) ");
+//
+// cmpT("0; UrL=/baz foo ","0; UrL=(((/baz foo))) ");
+// cmpT("0; UrL=/baZefoo ","0; UrL=(((/baZefoo))) ");
+
+ }
+ private void cmpT(String source, String want) {
+ MetaRefreshUrlStringTransformer m = new MetaRefreshUrlStringTransformer();
+ String got = m.transform(null,source);
+ assertEquals(want, got);
+ }
+
+}
Property changes on: trunk/archive-access/projects/wayback/wayback-core/src/test/java/org/archive/wayback/replay/html/transformer/MetaRefreshUrlStringTransformerTest.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Revision Id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|