[jsword-svn] r2051 - in trunk/jsword: .settings src/main/java/org/crosswire/common/diff src/main/java/org/crosswire/jsword/book src/test/java src/test/java/org/crosswire/common/diff src/test/java/org/crosswire/common/progress src/test/java/org/crosswire/jsword/book src/test/java/org/crosswire/jsword/passage
dmsmith at crosswire.org
dmsmith at crosswire.org
Thu Dec 9 12:09:05 MST 2010
Author: dmsmith
Date: 2010-12-09 12:09:05 -0700 (Thu, 09 Dec 2010)
New Revision: 2051
Modified:
trunk/jsword/.settings/org.eclipse.jdt.core.prefs
trunk/jsword/.settings/org.eclipse.jdt.ui.prefs
trunk/jsword/src/main/java/org/crosswire/common/diff/DifferenceEngine.java
trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
trunk/jsword/src/test/java/Bench.java
trunk/jsword/src/test/java/JSwordAllTests.java
trunk/jsword/src/test/java/org/crosswire/common/diff/BitapTest.java
trunk/jsword/src/test/java/org/crosswire/common/diff/DiffCleanupTest.java
trunk/jsword/src/test/java/org/crosswire/common/diff/DiffTest.java
trunk/jsword/src/test/java/org/crosswire/common/diff/DifferenceEngineTest.java
trunk/jsword/src/test/java/org/crosswire/common/diff/LineMapTest.java
trunk/jsword/src/test/java/org/crosswire/common/diff/PatchEntryTest.java
trunk/jsword/src/test/java/org/crosswire/common/progress/JobTest.java
trunk/jsword/src/test/java/org/crosswire/jsword/book/BookParentTst.java
trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java
trunk/jsword/src/test/java/org/crosswire/jsword/book/GatherAllReferences.java
trunk/jsword/src/test/java/org/crosswire/jsword/book/ReadEverything.java
trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java
trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTally2Test.java
trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java
Log:
JS-142: upgraded jsword's tests to Java 5
Modified: trunk/jsword/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- trunk/jsword/.settings/org.eclipse.jdt.core.prefs 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/.settings/org.eclipse.jdt.core.prefs 2010-12-09 19:09:05 UTC (rev 2051)
@@ -1,4 +1,4 @@
-#Thu Nov 11 22:11:21 EST 2010
+#Thu Dec 09 13:05:02 EST 2010
eclipse.preferences.version=1
org.eclipse.jdt.core.builder.cleanOutputFolder=clean
org.eclipse.jdt.core.builder.duplicateResourceTask=warning
@@ -16,6 +16,8 @@
org.eclipse.jdt.core.codeComplete.localSuffixes=
org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFinalFieldSuffixes=
org.eclipse.jdt.core.compiler.doc.comment.support=enabled
org.eclipse.jdt.core.compiler.maxProblemPerUnit=1000
org.eclipse.jdt.core.compiler.problem.invalidJavadoc=warning
Modified: trunk/jsword/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- trunk/jsword/.settings/org.eclipse.jdt.ui.prefs 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/.settings/org.eclipse.jdt.ui.prefs 2010-12-09 19:09:05 UTC (rev 2051)
@@ -1,6 +1,10 @@
-#Tue Jul 03 09:03:34 EDT 2007
+#Thu Dec 09 13:05:02 EST 2010
eclipse.preferences.version=1
formatter_profile=_JSword Style Formatting
formatter_settings_version=11
internal.default.compliance=user
+org.eclipse.jdt.ui.exception.name=e
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.overrideannotation=true
org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\n * Distribution License\:\n * JSword is free software; you can redistribute it and/or modify it under\n * the terms of the GNU Lesser General Public License, version 2.1 as published by\n * the Free Software Foundation. This program is distributed in the hope\n * that it will be useful, but WITHOUT ANY WARRANTY; without even the\n * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n * See the GNU Lesser General Public License for more details.\n *\n * The License is available on the internet at\:\n * http\://www.gnu.org/copyleft/lgpl.html\n * or by writing to\:\n * Free Software Foundation, Inc.\n * 59 Temple Place - Suite 330\n * Boston, MA 02111-1307, USA\n *\n * Copyright\: 2007\n * The copyright to this program is held by it's authors.\n *\n * ID\: $$Id\: org.eclipse.jdt.ui.prefs 1178 2006-11-06 12\:48\:02Z dmsmith $$\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n *\n *\n * @see gnu.lgpl.License for license details.<br>\n * The copyright to this program is held by it's authors.\n * @author DM Smith [dmsmith555 at yahoo dot com]\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="true" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment">/* (non-Javadoc)\n * ${see_to_overridden}\n */</template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
Modified: trunk/jsword/src/main/java/org/crosswire/common/diff/DifferenceEngine.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/common/diff/DifferenceEngine.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/main/java/org/crosswire/common/diff/DifferenceEngine.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -87,8 +87,8 @@
public List<Difference> generate() {
long msEnd = System.currentTimeMillis() + (long) (timeout * 1000);
int maxD = (source.length() + target.length()) / 2;
- List<HashSet<String>> vMap1 = new ArrayList<HashSet<String>>();
- List<HashSet<String>> vMap2 = new ArrayList<HashSet<String>>();
+ List<Set<String>> vMap1 = new ArrayList<Set<String>>();
+ List<Set<String>> vMap2 = new ArrayList<Set<String>>();
Map<Integer,Integer> v1 = new HashMap<Integer,Integer>();
Map<Integer,Integer> v2 = new HashMap<Integer,Integer>();
v1.put(Integer.valueOf(1), Integer.valueOf(0));
@@ -212,7 +212,7 @@
* New string fragment to be diffed
* @return List of Difference objects
*/
- protected List<Difference> path1(final List<HashSet<String>> vMap, final String newSource, final String newTarget) {
+ protected List<Difference> path1(final List<Set<String>> vMap, final String newSource, final String newTarget) {
List<Difference> path = new ArrayList<Difference>();
int x = newSource.length();
int y = newTarget.length();
@@ -268,7 +268,7 @@
* New string fragment to be diffed
* @return List of Difference objects
*/
- protected List<Difference> path2(final List<HashSet<String>> vMap, final String newSource, final String newTarget) {
+ protected List<Difference> path2(final List<Set<String>> vMap, final String newSource, final String newTarget) {
List<Difference> path = new ArrayList<Difference>();
int x = newSource.length();
int y = newTarget.length();
Modified: trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java
===================================================================
--- trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/main/java/org/crosswire/jsword/book/OSISUtil.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -583,7 +583,10 @@
}
assert content != null;
- return content.getContent();
+ if (content != null) {
+ return content.getContent();
+ }
+ return new ArrayList<Content>();
}
/**
Modified: trunk/jsword/src/test/java/Bench.java
===================================================================
--- trunk/jsword/src/test/java/Bench.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/Bench.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -1,4 +1,3 @@
-import java.util.Iterator;
import java.util.List;
import org.crosswire.jsword.book.Book;
@@ -26,7 +25,7 @@
System.exit(1);
}
- List dicts = Books.installed().getBooks(BookFilters.getOnlyBibles());
+ List<Book> dicts = Books.installed().getBooks(BookFilters.getOnlyBibles());
version = (Book) dicts.get(0);
Speed speed = new Speed(version);
@@ -51,9 +50,8 @@
*/
private static void versions() {
System.out.println(" Available versions:");
- List lbmds = Books.installed().getBooks();
- for (Iterator it = lbmds.iterator(); it.hasNext();) {
- Book book = (Book) it.next();
+ List<Book> lbmds = Books.installed().getBooks();
+ for (Book book : lbmds) {
System.out.println(" " + book.getName());
}
}
Modified: trunk/jsword/src/test/java/JSwordAllTests.java
===================================================================
--- trunk/jsword/src/test/java/JSwordAllTests.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/JSwordAllTests.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -39,6 +39,13 @@
public static Test suite() {
TestSuite suite = new TestSuite();
+ suite.addTest(org.crosswire.common.util.AllTests.suite());
+ suite.addTest(org.crosswire.common.progress.AllTests.suite());
+ suite.addTest(org.crosswire.common.diff.AllTests.suite());
+ suite.addTest(org.crosswire.common.history.AllTests.suite());
+ suite.addTest(org.crosswire.common.xml.AllTests.suite());
+ suite.addTest(org.crosswire.common.icu.AllTests.suite());
+
suite.addTestSuite(org.crosswire.jsword.passage.BibleInfoTest.class);
suite.addTestSuite(org.crosswire.jsword.passage.PassageConstantsTest.class);
suite.addTestSuite(org.crosswire.jsword.passage.PassageMixTest.class);
Modified: trunk/jsword/src/test/java/org/crosswire/common/diff/BitapTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/common/diff/BitapTest.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/common/diff/BitapTest.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -20,15 +20,15 @@
public void testAlphabet() {
// Initialise the bitmasks for Bitap
- Map bitmask;
- bitmask = new HashMap();
+ Map<Character,Integer> bitmask;
+ bitmask = new HashMap<Character,Integer>();
bitmask.put(Character.valueOf('a'), Integer.valueOf(4));
bitmask.put(Character.valueOf('b'), Integer.valueOf(2));
bitmask.put(Character.valueOf('c'), Integer.valueOf(1));
Bitap bitap = new Bitap("", "abc", 0);
bitap.alphabet();
assertEquals("match_alphabet: Unique.", bitmask, bitap.getAlphabet());
- bitmask = new HashMap();
+ bitmask = new HashMap<Character,Integer>();
bitmask.put(Character.valueOf('a'), Integer.valueOf(37));
bitmask.put(Character.valueOf('b'), Integer.valueOf(18));
bitmask.put(Character.valueOf('c'), Integer.valueOf(8));
Modified: trunk/jsword/src/test/java/org/crosswire/common/diff/DiffCleanupTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/common/diff/DiffCleanupTest.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/common/diff/DiffCleanupTest.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -14,104 +14,104 @@
public void testDiffCleanupMerge() {
// Cleanup a messy diff
- List diffs = diffList();
+ List<Difference> diffs = diffList();
DiffCleanup.cleanupMerge(diffs);
assertEquals("DiffCleanup.cleanupMerge: Null case.", diffList(), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "b"), new Difference(EditType.INSERT, "c")});
+ diffs = diffList(
+ new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "b"), new Difference(EditType.INSERT, "c"));
DiffCleanup.cleanupMerge(diffs);
assertEquals(
- "DiffCleanup.cleanupMerge: No change case.", diffList(new Object[] { new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "b"), new Difference(EditType.INSERT, "c")}), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.EQUAL, "a"), new Difference(EditType.EQUAL, "b"), new Difference(EditType.EQUAL, "c")});
+ "DiffCleanup.cleanupMerge: No change case.", diffList(new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "b"), new Difference(EditType.INSERT, "c")), diffs);
+ diffs = diffList(
+ new Difference(EditType.EQUAL, "a"), new Difference(EditType.EQUAL, "b"), new Difference(EditType.EQUAL, "c"));
DiffCleanup.cleanupMerge(diffs);
- assertEquals("DiffCleanup.cleanupMerge: Merge equalities.", diffList(new Object[] { new Difference(EditType.EQUAL, "abc")}), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "a"), new Difference(EditType.DELETE, "b"), new Difference(EditType.DELETE, "c")});
+ assertEquals("DiffCleanup.cleanupMerge: Merge equalities.", diffList(new Difference(EditType.EQUAL, "abc")), diffs);
+ diffs = diffList(
+ new Difference(EditType.DELETE, "a"), new Difference(EditType.DELETE, "b"), new Difference(EditType.DELETE, "c"));
DiffCleanup.cleanupMerge(diffs);
- assertEquals("DiffCleanup.cleanupMerge: Merge deletions.", diffList(new Object[] { new Difference(EditType.DELETE, "abc")}), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.INSERT, "a"), new Difference(EditType.INSERT, "b"), new Difference(EditType.INSERT, "c")});
+ assertEquals("DiffCleanup.cleanupMerge: Merge deletions.", diffList(new Difference(EditType.DELETE, "abc")), diffs);
+ diffs = diffList(
+ new Difference(EditType.INSERT, "a"), new Difference(EditType.INSERT, "b"), new Difference(EditType.INSERT, "c"));
DiffCleanup.cleanupMerge(diffs);
- assertEquals("DiffCleanup.cleanupMerge: Merge insertions.", diffList(new Object[] { new Difference(EditType.INSERT, "abc")}), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "b"), new Difference(EditType.DELETE, "c"), new Difference(EditType.INSERT, "d"), new Difference(EditType.EQUAL, "e"), new Difference(EditType.EQUAL, "f")});
+ assertEquals("DiffCleanup.cleanupMerge: Merge insertions.", diffList(new Difference(EditType.INSERT, "abc")), diffs);
+ diffs = diffList(
+ new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "b"), new Difference(EditType.DELETE, "c"), new Difference(EditType.INSERT, "d"), new Difference(EditType.EQUAL, "e"), new Difference(EditType.EQUAL, "f"));
DiffCleanup.cleanupMerge(diffs);
assertEquals(
- "DiffCleanup.cleanupMerge: Merge interweave.", diffList(new Object[] { new Difference(EditType.DELETE, "ac"), new Difference(EditType.INSERT, "bd"), new Difference(EditType.EQUAL, "ef")}), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "abc"), new Difference(EditType.DELETE, "dc")});
+ "DiffCleanup.cleanupMerge: Merge interweave.", diffList(new Difference(EditType.DELETE, "ac"), new Difference(EditType.INSERT, "bd"), new Difference(EditType.EQUAL, "ef")), diffs);
+ diffs = diffList(
+ new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "abc"), new Difference(EditType.DELETE, "dc"));
DiffCleanup.cleanupMerge(diffs);
assertEquals(
- "DiffCleanup.cleanupMerge: Prefix and suffix detection.", diffList(new Object[] { new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "d"), new Difference(EditType.INSERT, "b"), new Difference(EditType.EQUAL, "c")}), diffs);
+ "DiffCleanup.cleanupMerge: Prefix and suffix detection.", diffList( new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "d"), new Difference(EditType.INSERT, "b"), new Difference(EditType.EQUAL, "c")), diffs);
}
public void testDiffCleanupSemantic() {
// Cleanup semantically trivial equalities
- List diffs = diffList();
+ List<Difference> diffs = diffList();
DiffCleanup.cleanupSemantic(diffs);
assertEquals("DiffCleanup.cleanupSemantic: Null case.", diffList(), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "b"), new Difference(EditType.EQUAL, "cd"), new Difference(EditType.DELETE, "e")});
+ diffs = diffList(
+ new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "b"), new Difference(EditType.EQUAL, "cd"), new Difference(EditType.DELETE, "e"));
DiffCleanup.cleanupSemantic(diffs);
assertEquals(
- "DiffCleanup.cleanupSemantic: No elimination.", diffList(new Object[] { new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "b"), new Difference(EditType.EQUAL, "cd"), new Difference(EditType.DELETE, "e")}), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "a"), new Difference(EditType.EQUAL, "b"), new Difference(EditType.DELETE, "c")});
+ "DiffCleanup.cleanupSemantic: No elimination.", diffList(new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "b"), new Difference(EditType.EQUAL, "cd"), new Difference(EditType.DELETE, "e")), diffs);
+ diffs = diffList(
+ new Difference(EditType.DELETE, "a"), new Difference(EditType.EQUAL, "b"), new Difference(EditType.DELETE, "c"));
DiffCleanup.cleanupSemantic(diffs);
assertEquals(
- "DiffCleanup.cleanupSemantic: Simple elimination.", diffList(new Object[] { new Difference(EditType.DELETE, "abc"), new Difference(EditType.INSERT, "b")}), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "ab"), new Difference(EditType.EQUAL, "cd"), new Difference(EditType.DELETE, "e"), new Difference(EditType.EQUAL, "f"), new Difference(EditType.INSERT, "g")});
+ "DiffCleanup.cleanupSemantic: Simple elimination.", diffList(new Difference(EditType.DELETE, "abc"), new Difference(EditType.INSERT, "b")), diffs);
+ diffs = diffList(
+ new Difference(EditType.DELETE, "ab"), new Difference(EditType.EQUAL, "cd"), new Difference(EditType.DELETE, "e"), new Difference(EditType.EQUAL, "f"), new Difference(EditType.INSERT, "g"));
DiffCleanup.cleanupSemantic(diffs);
assertEquals(
- "DiffCleanup.cleanupSemantic: Backpass elimination.", diffList(new Object[] { new Difference(EditType.DELETE, "abcdef"), new Difference(EditType.INSERT, "cdfg")}), diffs);
+ "DiffCleanup.cleanupSemantic: Backpass elimination.", diffList(new Difference(EditType.DELETE, "abcdef"), new Difference(EditType.INSERT, "cdfg")), diffs);
}
public void testDiffCleanupEfficiency() {
// Cleanup operationally trivial equalities
DiffCleanup.setEditCost(4);
- List diffs = diffList();
+ List<Difference> diffs = diffList();
DiffCleanup.cleanupEfficiency(diffs);
assertEquals("DiffCleanup.cleanupEfficiency: Null case.", diffList(), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "ab"), new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "wxyz"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "34")});
+ diffs = diffList(
+ new Difference(EditType.DELETE, "ab"), new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "wxyz"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "34"));
DiffCleanup.cleanupEfficiency(diffs);
assertEquals(
- "DiffCleanup.cleanupEfficiency: No elimination.", diffList(new Object[] { new Difference(EditType.DELETE, "ab"), new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "wxyz"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "34")}), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "ab"), new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "xyz"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "34")});
+ "DiffCleanup.cleanupEfficiency: No elimination.", diffList( new Difference(EditType.DELETE, "ab"), new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "wxyz"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "34")), diffs);
+ diffs = diffList(
+ new Difference(EditType.DELETE, "ab"), new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "xyz"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "34"));
DiffCleanup.cleanupEfficiency(diffs);
assertEquals(
- "DiffCleanup.cleanupEfficiency: Four-edit elimination.", diffList(new Object[] { new Difference(EditType.DELETE, "abxyzcd"), new Difference(EditType.INSERT, "12xyz34")}), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "x"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "34")});
+ "DiffCleanup.cleanupEfficiency: Four-edit elimination.", diffList(new Difference(EditType.DELETE, "abxyzcd"), new Difference(EditType.INSERT, "12xyz34")), diffs);
+ diffs = diffList(
+ new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "x"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "34"));
DiffCleanup.cleanupEfficiency(diffs);
assertEquals(
- "DiffCleanup.cleanupEfficiency: Three-edit elimination.", diffList(new Object[] { new Difference(EditType.DELETE, "xcd"), new Difference(EditType.INSERT, "12x34")}), diffs);
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "ab"), new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "xy"), new Difference(EditType.INSERT, "34"), new Difference(EditType.EQUAL, "z"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "56")});
+ "DiffCleanup.cleanupEfficiency: Three-edit elimination.", diffList(new Difference(EditType.DELETE, "xcd"), new Difference(EditType.INSERT, "12x34")), diffs);
+ diffs = diffList(
+ new Difference(EditType.DELETE, "ab"), new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "xy"), new Difference(EditType.INSERT, "34"), new Difference(EditType.EQUAL, "z"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "56"));
DiffCleanup.cleanupEfficiency(diffs);
assertEquals(
- "DiffCleanup.cleanupEfficiency: Backpass elimination.", diffList(new Object[] { new Difference(EditType.DELETE, "abxyzcd"), new Difference(EditType.INSERT, "12xy34z56")}), diffs);
+ "DiffCleanup.cleanupEfficiency: Backpass elimination.", diffList(new Difference(EditType.DELETE, "abxyzcd"), new Difference(EditType.INSERT, "12xy34z56")), diffs);
DiffCleanup.setEditCost(5);
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "ab"), new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "wxyz"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "34")});
+ diffs = diffList(
+ new Difference(EditType.DELETE, "ab"), new Difference(EditType.INSERT, "12"), new Difference(EditType.EQUAL, "wxyz"), new Difference(EditType.DELETE, "cd"), new Difference(EditType.INSERT, "34"));
DiffCleanup.cleanupEfficiency(diffs);
assertEquals(
- "DiffCleanup.cleanupEfficiency: High cost elimination.", diffList(new Object[] { new Difference(EditType.DELETE, "abwxyzcd"), new Difference(EditType.INSERT, "12wxyz34")}), diffs);
+ "DiffCleanup.cleanupEfficiency: High cost elimination.", diffList(new Difference(EditType.DELETE, "abwxyzcd"), new Difference(EditType.INSERT, "12wxyz34")), diffs);
DiffCleanup.setEditCost(4);
}
// Private function for quickly building lists of diffs.
- private static List diffList() {
- return new ArrayList();
+ private static List<Difference> diffList() {
+ return new ArrayList<Difference>();
}
// Private function for quickly building lists of diffs.
- private static List diffList(Object[] diffs) {
- List myDiffList = new ArrayList();
- myDiffList.addAll(Arrays.asList(diffs));
- return myDiffList;
+ private static <T> List<T> diffList(T... items) {
+ List<T> list = new ArrayList<T>();
+ list.addAll(Arrays.asList(items));
+ return list;
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/common/diff/DiffTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/common/diff/DiffTest.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/common/diff/DiffTest.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -22,36 +22,36 @@
public void testDiffMain() {
// Perform a trivial diff
- List diffs = diffList(new Object[] {
- new Difference(EditType.EQUAL, "abc")});
+ List<Difference> diffs = diffList(
+ new Difference(EditType.EQUAL, "abc"));
assertEquals("diff_main: Null case.", diffs, new Diff("abc", "abc", false).compare());
- diffs = diffList(new Object[] {
- new Difference(EditType.EQUAL, "ab"), new Difference(EditType.INSERT, "123"), new Difference(EditType.EQUAL, "c")});
+ diffs = diffList(
+ new Difference(EditType.EQUAL, "ab"), new Difference(EditType.INSERT, "123"), new Difference(EditType.EQUAL, "c"));
assertEquals("diff_main: Simple insertion.", diffs, new Diff("abc", "ab123c", false).compare());
- diffs = diffList(new Object[] {
- new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "123"), new Difference(EditType.EQUAL, "bc")});
+ diffs = diffList(
+ new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "123"), new Difference(EditType.EQUAL, "bc"));
assertEquals("diff_main: Simple deletion.", diffs, new Diff("a123bc", "abc", false).compare());
- diffs = diffList(new Object[] {
- new Difference(EditType.EQUAL, "a"), new Difference(EditType.INSERT, "123"), new Difference(EditType.EQUAL, "b"), new Difference(EditType.INSERT, "456"), new Difference(EditType.EQUAL, "c")});
+ diffs = diffList(
+ new Difference(EditType.EQUAL, "a"), new Difference(EditType.INSERT, "123"), new Difference(EditType.EQUAL, "b"), new Difference(EditType.INSERT, "456"), new Difference(EditType.EQUAL, "c"));
assertEquals("diff_main: Two insertions.", diffs, new Diff("abc", "a123b456c", false).compare());
- diffs = diffList(new Object[] {
- new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "123"), new Difference(EditType.EQUAL, "b"), new Difference(EditType.DELETE, "456"), new Difference(EditType.EQUAL, "c")});
+ diffs = diffList(
+ new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "123"), new Difference(EditType.EQUAL, "b"), new Difference(EditType.DELETE, "456"), new Difference(EditType.EQUAL, "c"));
assertEquals("diff_main: Two deletions.", diffs, new Diff("a123b456c", "abc", false).compare());
// Perform a real diff
// Switch off the timeout.
// dmp.Diff_Timeout = 0;
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "b")});
+ diffs = diffList(
+ new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "b"));
assertEquals("diff_main: Simple case #1.", diffs, new Diff("a", "b", false).compare());
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "Apple"), new Difference(EditType.INSERT, "Banana"), new Difference(EditType.EQUAL, "s are a"), new Difference(EditType.INSERT, "lso"), new Difference(EditType.EQUAL, " fruit.")});
+ diffs = diffList(
+ new Difference(EditType.DELETE, "Apple"), new Difference(EditType.INSERT, "Banana"), new Difference(EditType.EQUAL, "s are a"), new Difference(EditType.INSERT, "lso"), new Difference(EditType.EQUAL, " fruit."));
assertEquals("diff_main: Simple case #2.", diffs, new Diff("Apples are a fruit.", "Bananas are also fruit.", false).compare());
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "1"), new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "y"), new Difference(EditType.EQUAL, "b"), new Difference(EditType.DELETE, "2"), new Difference(EditType.INSERT, "xab")});
+ diffs = diffList(
+ new Difference(EditType.DELETE, "1"), new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "y"), new Difference(EditType.EQUAL, "b"), new Difference(EditType.DELETE, "2"), new Difference(EditType.INSERT, "xab"));
assertEquals("diff_main: Overlap #1.", diffs, new Diff("1ayb2", "abxab", false).compare());
- diffs = diffList(new Object[] {
- new Difference(EditType.INSERT, "x"), new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "b"), new Difference(EditType.INSERT, "x"), new Difference(EditType.EQUAL, "c"), new Difference(EditType.DELETE, "y"), new Difference(EditType.INSERT, "xabc")});
+ diffs = diffList(
+ new Difference(EditType.INSERT, "x"), new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "b"), new Difference(EditType.INSERT, "x"), new Difference(EditType.EQUAL, "c"), new Difference(EditType.DELETE, "y"), new Difference(EditType.INSERT, "xabc"));
assertEquals("diff_main: Overlap #2.", diffs, new Diff("abcy", "xaxcxabc", false).compare());
// Test the linemode speedup
@@ -68,27 +68,27 @@
public void testDiffXIndex() {
// Translate a location in text1 to text2
- List diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "1234"), new Difference(EditType.EQUAL, "xyz")});
+ List<Difference> diffs = diffList(
+ new Difference(EditType.DELETE, "a"), new Difference(EditType.INSERT, "1234"), new Difference(EditType.EQUAL, "xyz"));
assertEquals("diff_xIndex: Translation on equality.", 5, new Diff("", "").xIndex(diffs, 2));
- diffs = diffList(new Object[] {
- new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "1234"), new Difference(EditType.EQUAL, "xyz")});
+ diffs = diffList(
+ new Difference(EditType.EQUAL, "a"), new Difference(EditType.DELETE, "1234"), new Difference(EditType.EQUAL, "xyz"));
assertEquals("diff_xIndex: Translation on deletion.", 1, new Diff("", "").xIndex(diffs, 3));
}
- private void assertArrayEquals(String error_msg, Object[] a, Object[] b) {
- List list_a = Arrays.asList(a);
- List list_b = Arrays.asList(b);
+ private <T> void assertArrayEquals(String error_msg, T[] a, T[] b) {
+ List<T> list_a = Arrays.asList(a);
+ List<T> list_b = Arrays.asList(b);
assertEquals(error_msg, list_a, list_b);
}
// Construct the two texts which made up the diff originally.
- private static String[] diff_rebuildtexts(List diffs) {
+ private static String[] diff_rebuildtexts(List<Difference> diffs) {
String[] text = {
"", ""};
- Iterator iter = diffs.iterator();
+ Iterator<Difference> iter = diffs.iterator();
while (iter.hasNext()) {
- Difference myDiff = (Difference) iter.next();
+ Difference myDiff = iter.next();
EditType editType = myDiff.getEditType();
if (!EditType.INSERT.equals(editType)) {
text[0] += myDiff.getText();
@@ -102,9 +102,9 @@
}
// Private function for quickly building lists of diffs.
- private static List diffList(Object[] diffs) {
- List myDiffList = new ArrayList();
- myDiffList.addAll(Arrays.asList(diffs));
- return myDiffList;
+ private static <T> List<T> diffList(T... items) {
+ List<T> list = new ArrayList<T>();
+ list.addAll(Arrays.asList(items));
+ return list;
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/common/diff/DifferenceEngineTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/common/diff/DifferenceEngineTest.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/common/diff/DifferenceEngineTest.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -24,82 +24,82 @@
// Single letters
// Trace a path from back to front.
DifferenceEngine generator = new DifferenceEngine();
- List v_map = new ArrayList();
- Set row_set = new HashSet();
+ List<Set<String>> v_map = new ArrayList<Set<String>>();
+ Set<String> row_set = new HashSet<String>();
row_set.add("0,0");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("0,1");row_set.add("1,0");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("0,2");row_set.add("2,0");row_set.add("2,2");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("0,3");row_set.add("2,3");row_set.add("3,0");row_set.add("4,3");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("0,4");row_set.add("2,4");row_set.add("4,0");row_set.add("4,4");row_set.add("5,3");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("0,5");row_set.add("2,5");row_set.add("4,5");row_set.add("5,0");row_set.add("6,3");row_set.add("6,5");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("0,6");row_set.add("2,6");row_set.add("4,6");row_set.add("6,6");row_set.add("7,5");
v_map.add(row_set);
- List diffs = diffList(new Object[] {
- new Difference(EditType.INSERT, "W"), new Difference(EditType.DELETE, "A"), new Difference(EditType.EQUAL, "1"), new Difference(EditType.DELETE, "B"), new Difference(EditType.EQUAL, "2"), new Difference(EditType.INSERT, "X"), new Difference(EditType.DELETE, "C"), new Difference(EditType.EQUAL, "3"), new Difference(EditType.DELETE, "D")});
+ List<Difference> diffs = diffList(
+ new Difference(EditType.INSERT, "W"), new Difference(EditType.DELETE, "A"), new Difference(EditType.EQUAL, "1"), new Difference(EditType.DELETE, "B"), new Difference(EditType.EQUAL, "2"), new Difference(EditType.INSERT, "X"), new Difference(EditType.DELETE, "C"), new Difference(EditType.EQUAL, "3"), new Difference(EditType.DELETE, "D"));
assertEquals("diff_path1: Single letters.", diffs, generator.path1(v_map, "A1B2C3D", "W12X3"));
// Trace a path from front to back.
v_map.remove(v_map.size() - 1);
- diffs = diffList(new Object[] {
- new Difference(EditType.EQUAL, "4"), new Difference(EditType.DELETE, "E"), new Difference(EditType.INSERT, "Y"), new Difference(EditType.EQUAL, "5"), new Difference(EditType.DELETE, "F"), new Difference(EditType.EQUAL, "6"), new Difference(EditType.DELETE, "G"), new Difference(EditType.INSERT, "Z")});
+ diffs = diffList(
+ new Difference(EditType.EQUAL, "4"), new Difference(EditType.DELETE, "E"), new Difference(EditType.INSERT, "Y"), new Difference(EditType.EQUAL, "5"), new Difference(EditType.DELETE, "F"), new Difference(EditType.EQUAL, "6"), new Difference(EditType.DELETE, "G"), new Difference(EditType.INSERT, "Z"));
assertEquals("diff_path2: Single letters.", diffs, generator.path2(v_map, "4E5F6G", "4Y56Z"));
// Double letters
// Trace a path from back to front.
- v_map = new ArrayList();
- row_set = new HashSet();
+ v_map = new ArrayList<Set<String>>();
+ row_set = new HashSet<String>();
row_set.add("0,0");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("0,1");row_set.add("1,0");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("0,2");row_set.add("1,1");row_set.add("2,0");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("0,3");row_set.add("1,2");row_set.add("2,1");row_set.add("3,0");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("0,4");row_set.add("1,3");row_set.add("3,1");row_set.add("4,0");row_set.add("4,4");
v_map.add(row_set);
- diffs = diffList(new Object[] {
- new Difference(EditType.INSERT, "WX"), new Difference(EditType.DELETE, "AB"), new Difference(EditType.EQUAL, "12")});
+ diffs = diffList(
+ new Difference(EditType.INSERT, "WX"), new Difference(EditType.DELETE, "AB"), new Difference(EditType.EQUAL, "12"));
assertEquals("diff_path1: Double letters.", diffs, generator.path1(v_map, "AB12", "WX12"));
// Trace a path from front to back.
- v_map = new ArrayList();
- row_set = new HashSet();
+ v_map = new ArrayList<Set<String>>();
+ row_set = new HashSet<String>();
row_set.add("0,0");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("0,1");row_set.add("1,0");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("1,1");row_set.add("2,0");row_set.add("2,4");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("2,1");row_set.add("2,5");row_set.add("3,0");row_set.add("3,4");
v_map.add(row_set);
- row_set = new HashSet();
+ row_set = new HashSet<String>();
row_set.add("2,6");row_set.add("3,5");row_set.add("4,4");
v_map.add(row_set);
- diffs = diffList(new Object[] {
- new Difference(EditType.DELETE, "CD"), new Difference(EditType.EQUAL, "34"), new Difference(EditType.INSERT, "YZ")});
+ diffs = diffList(
+ new Difference(EditType.DELETE, "CD"), new Difference(EditType.EQUAL, "34"), new Difference(EditType.INSERT, "YZ"));
assertEquals("diff_path2: Double letters.", diffs, generator.path2(v_map, "CD34", "34YZ"));
}
@@ -113,9 +113,9 @@
}
// Private function for quickly building lists of diffs.
- private static List diffList(Object[] diffs) {
- List myDiffList = new ArrayList();
- myDiffList.addAll(Arrays.asList(diffs));
- return myDiffList;
+ private static <T> List<T> diffList(T... items) {
+ List<T> list = new ArrayList<T>();
+ list.addAll(Arrays.asList(items));
+ return list;
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/common/diff/LineMapTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/common/diff/LineMapTest.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/common/diff/LineMapTest.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -21,7 +21,7 @@
public void testCompile() {
// Convert lines down to characters
- ArrayList list = new ArrayList();
+ ArrayList<String> list = new ArrayList<String>();
list.add("");
list.add("alpha\n");
list.add("beta\n");
@@ -43,26 +43,26 @@
public void testRestore() {
// Convert chars up to lines
- List diffs = diffList(new Object[] {
- new Difference(EditType.EQUAL, "\u0001\u0002\u0001"), new Difference(EditType.INSERT, "\u0002\u0001\u0002")});
- ArrayList list = new ArrayList();
+ List<Difference> diffs = diffList(
+ new Difference(EditType.EQUAL, "\u0001\u0002\u0001"), new Difference(EditType.INSERT, "\u0002\u0001\u0002"));
+ ArrayList<String> list = new ArrayList<String>();
list.add("");
list.add("alpha\n");
list.add("beta\n");
LineMap map = new LineMap("alpha\nbeta\nalpha\n", "beta\nalpha\nbeta\n");
map.restore(diffs);
assertEquals(
- "LineMap.restore:", diffList(new Object[] { new Difference(EditType.EQUAL, "alpha\nbeta\nalpha\n"), new Difference(EditType.INSERT, "beta\nalpha\nbeta\n")}).get(0), diffs.get(0));
+ "LineMap.restore:", diffList(new Difference(EditType.EQUAL, "alpha\nbeta\nalpha\n"), new Difference(EditType.INSERT, "beta\nalpha\nbeta\n")).get(0), diffs.get(0));
assertEquals(
- "LineMap.restore:", diffList(new Object[] { new Difference(EditType.EQUAL, "alpha\nbeta\nalpha\n"), new Difference(EditType.INSERT, "beta\nalpha\nbeta\n")}).get(diffs.size() - 1), diffs.get(diffs.size() - 1));
+ "LineMap.restore:", diffList(new Difference(EditType.EQUAL, "alpha\nbeta\nalpha\n"), new Difference(EditType.INSERT, "beta\nalpha\nbeta\n")).get(diffs.size() - 1), diffs.get(diffs.size() - 1));
assertEquals(
- "LineMap.restore:", diffList(new Object[] { new Difference(EditType.EQUAL, "alpha\nbeta\nalpha\n"), new Difference(EditType.INSERT, "beta\nalpha\nbeta\n")}), diffs);
+ "LineMap.restore:", diffList(new Difference(EditType.EQUAL, "alpha\nbeta\nalpha\n"), new Difference(EditType.INSERT, "beta\nalpha\nbeta\n")), diffs);
}
// Private function for quickly building lists of diffs.
- private static List diffList(Object[] diffs) {
- List myDiffList = new ArrayList();
- myDiffList.addAll(Arrays.asList(diffs));
- return myDiffList;
+ private static <T> List<T> diffList(T... items) {
+ List<T> list = new ArrayList<T>();
+ list.addAll(Arrays.asList(items));
+ return list;
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/common/diff/PatchEntryTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/common/diff/PatchEntryTest.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/common/diff/PatchEntryTest.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -25,9 +25,8 @@
p.setTargetStart(21);
p.setSourceLength(18);
p.setTargetLength(17);
- p
- .setDifferences(diffList(new Object[] {
- new Difference(EditType.EQUAL, "jump"), new Difference(EditType.DELETE, "s"), new Difference(EditType.INSERT, "ed"), new Difference(EditType.EQUAL, " over "), new Difference(EditType.DELETE, "the"), new Difference(EditType.INSERT, "a"), new Difference(EditType.EQUAL, " laz")}));
+ p.setDifferences(diffList(
+ new Difference(EditType.EQUAL, "jump"), new Difference(EditType.DELETE, "s"), new Difference(EditType.INSERT, "ed"), new Difference(EditType.EQUAL, " over "), new Difference(EditType.DELETE, "the"), new Difference(EditType.INSERT, "a"), new Difference(EditType.EQUAL, " laz")));
assertEquals("Patch: text1.", "jumps over the laz", p.getSourceText());
assertEquals("Patch: text2.", "jumped over a laz", p.getTargetText());
String strp = "@@ -21,18 +22,17 @@\n jump\n-s\n+ed\n over \n-the\n+a\n laz\n";
@@ -69,9 +68,9 @@
}
// Private function for quickly building lists of diffs.
- private static List diffList(Object[] diffs) {
- List myDiffList = new ArrayList();
- myDiffList.addAll(Arrays.asList(diffs));
- return myDiffList;
+ private static <T> List<T> diffList(T... items) {
+ List<T> list = new ArrayList<T>();
+ list.addAll(Arrays.asList(items));
+ return list;
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/common/progress/JobTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/common/progress/JobTest.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/common/progress/JobTest.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -58,50 +58,50 @@
job = JobManager.createJob(WIBBLE);
job.beginJob(WIBBLE);
- assertEquals(job.getJobName(), WIBBLE);
- assertEquals(job.isFinished(), false);
- assertEquals(job.isCancelable(), false);
- assertEquals(job.getSectionName(), WIBBLE);
- assertEquals(job.getWork(), 0);
+ assertEquals(WIBBLE, job.getJobName());
+ assertEquals(false, job.isFinished());
+ assertEquals(false, job.isCancelable());
+ assertEquals(WIBBLE, job.getSectionName());
+ assertEquals(0, job.getWork());
job.done();
- assertEquals(job.isFinished(), true);
- assertEquals(job.getWork(), 100);
+ assertEquals(true, job.isFinished());
+ assertEquals(100, job.getWork());
assertEquals(job.isCancelable(), false);
job = JobManager.createJob(WIBBLE, Thread.currentThread());
job.beginJob(WIBBLE);
- assertEquals(job.getJobName(), WIBBLE);
- assertEquals(job.isFinished(), false);
- assertEquals(job.isCancelable(), true);
- assertEquals(job.getSectionName(), WIBBLE);
- assertEquals(job.getWork(), 0);
+ assertEquals(WIBBLE, job.getJobName());
+ assertEquals(false, job.isFinished());
+ assertEquals(true, job.isCancelable());
+ assertEquals(WIBBLE, job.getSectionName());
+ assertEquals(0, job.getWork());
job.done();
- assertEquals(job.isFinished(), true);
- assertEquals(job.getWork(), 100);
+ assertEquals(true, job.isFinished());
+ assertEquals(100, job.getWork());
// assertEquals(job.isCancelable(), false);
job = JobManager.createJob(WIBBLE);
job.beginJob(WIBBLE, uri);
- assertEquals(job.getJobName(), WIBBLE);
- assertEquals(job.isFinished(), false);
- assertEquals(job.isCancelable(), false);
- assertEquals(job.getSectionName(), WIBBLE);
- assertEquals(job.getWork(), 0);
+ assertEquals(WIBBLE, job.getJobName());
+ assertEquals(false, job.isFinished());
+ assertEquals(false, job.isCancelable());
+ assertEquals(WIBBLE, job.getSectionName());
+ assertEquals(0, job.getWork());
job.done();
- assertEquals(job.isFinished(), true);
- assertEquals(job.getWork(), 100);
+ assertEquals(true, job.isFinished());
+ assertEquals(100, job.getWork());
// assertEquals(job.isCancelable(), false);
job = JobManager.createJob(WIBBLE, Thread.currentThread());
job.beginJob(WIBBLE, uri);
- assertEquals(job.getJobName(), WIBBLE);
- assertEquals(job.isFinished(), false);
- assertEquals(job.isCancelable(), true);
- assertEquals(job.getSectionName(), WIBBLE);
- assertEquals(job.getWork(), 0);
+ assertEquals(WIBBLE, job.getJobName());
+ assertEquals(false, job.isFinished());
+ assertEquals(true, job.isCancelable());
+ assertEquals(WIBBLE, job.getSectionName());
+ assertEquals(0, job.getWork());
job.done();
- assertEquals(job.isFinished(), true);
- assertEquals(job.getWork(), 100);
+ assertEquals(true, job.isFinished());
+ assertEquals(100, job.getWork());
// assertEquals(job.isCancelable(), false);
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/BookParentTst.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/BookParentTst.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/BookParentTst.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -21,7 +21,6 @@
*/
package org.crosswire.jsword.book;
-import java.util.Iterator;
import java.util.List;
import junit.framework.TestCase;
@@ -48,14 +47,13 @@
*/
@Override
protected void setUp() throws Exception {
- List lbmds = Books.installed().getBooks(BookFilters.getOnlyBibles());
+ List<Book> lbmds = Books.installed().getBooks(BookFilters.getOnlyBibles());
bibles = new Book[lbmds.size()];
bmds = new BookMetaData[lbmds.size()];
int i = 0;
- for (Iterator it = lbmds.iterator(); it.hasNext();) {
- bibles[i] = (Book) it.next();
- bmds[i] = bibles[i].getBookMetaData();
+ for (Book book : lbmds) {
+ bmds[i] = book.getBookMetaData();
i++;
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/BooksTest.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -21,7 +21,6 @@
*/
package org.crosswire.jsword.book;
-import java.util.Iterator;
import java.util.List;
import junit.framework.TestCase;
@@ -44,7 +43,7 @@
protected BookMetaData[] bmds = null;
protected Book[] bibles = null;
- protected Class[] ignorebibles = {};
+ //protected Class[] ignorebibles = {};
/*
* (non-Javadoc)
@@ -53,17 +52,17 @@
*/
@Override
protected void setUp() throws Exception {
- List lbmds = Books.installed().getBooks(BookFilters.getOnlyBibles());
+ List<Book> lbmds = Books.installed().getBooks(BookFilters.getOnlyBibles());
int numBibles = lbmds.size();
bibles = new Book[numBibles];
bmds = new BookMetaData[numBibles];
gen11 = new Key[numBibles];
int i = 0;
- for (Iterator it = lbmds.iterator(); it.hasNext();) {
- bibles[i] = (Book) it.next();
- bmds[i] = bibles[i].getBookMetaData();
- gen11[i] = bibles[i].getKey("Gen 1:1");
+ for (Book book : lbmds) {
+ bibles[i] = book;
+ bmds[i] = book.getBookMetaData();
+ gen11[i] = book.getKey("Gen 1:1");
i++;
}
}
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/GatherAllReferences.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/GatherAllReferences.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/GatherAllReferences.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -25,7 +25,6 @@
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.Iterator;
import java.util.List;
import java.util.Locale;
import java.util.ResourceBundle;
@@ -91,9 +90,8 @@
// Loop through all the Bookks
log.warn("*** Reading all known Books");
- List comments = Books.installed().getBooks();
- for (Iterator cit = comments.iterator(); cit.hasNext();) {
- Book book = (Book) cit.next();
+ List<Book> comments = Books.installed().getBooks();
+ for (Book book : comments) {
BookMetaData bmd = book.getBookMetaData();
// Skip PlainText as they do not have references marked up
@@ -118,9 +116,8 @@
0, 0
};
- Iterator it = set.iterator();
- while (it.hasNext()) {
- readKey(book, (Key) it.next(), stats);
+ for (Key key : set) {
+ readKey(book, key, stats);
}
log.warn(book.getInitials() + ':' + stats[0] + ':' + stats[1]);
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/book/ReadEverything.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/book/ReadEverything.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/book/ReadEverything.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -21,7 +21,6 @@
*/
package org.crosswire.jsword.book;
-import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
@@ -54,9 +53,8 @@
// Loop through all the Books
log.warn("*** Reading all installed Bibles");
BookFilter filter = BookFilters.getCustom("SourceType=TEI");
- List comments = Books.installed().getBooks(filter);
- for (Iterator cit = comments.iterator(); cit.hasNext();) {
- Book book = (Book) cit.next();
+ List<Book> comments = Books.installed().getBooks(filter);
+ for (Book book : comments) {
if (!book.isLocked()) {
log.warn("****** Reading: " + book.getInitials());
@@ -77,10 +75,8 @@
long start = System.currentTimeMillis();
int entries = 0;
- Iterator it = set.iterator();
boolean first = true;
- while (it.hasNext()) {
- Key key = (Key) it.next();
+ for (Key key : set) {
// skip the root of a TreeKey as it often is not addressable.
if (first) {
first = false;
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageParentTst.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -198,7 +198,7 @@
// stage.
// for (int i=0; i<12; i++)
{
- Iterator it = gen1_135.rangeIterator(RestrictionType.NONE);
+ Iterator<Key> it = gen1_135.rangeIterator(RestrictionType.NONE);
assertTrue(it.hasNext());
assertEquals(it.next(), VerseRangeFactory.fromString("Gen 1:1"));
assertTrue(it.hasNext());
@@ -214,7 +214,7 @@
public void testReadVerseIterator() throws Exception {
// for (int i=0; i<12; i++)
{
- Iterator it = gen1_135.iterator();
+ Iterator<Key> it = gen1_135.iterator();
assertTrue(it.hasNext());
assertEquals(it.next(), VerseFactory.fromString("Gen 1:1"));
assertTrue(it.hasNext());
@@ -538,7 +538,7 @@
}
public void testWriteRangeIterator() throws Exception {
- Iterator it = gen1_135.rangeIterator(RestrictionType.NONE);
+ Iterator<Key> it = gen1_135.rangeIterator(RestrictionType.NONE);
assertTrue(it.hasNext());
assertEquals(it.next(), VerseRangeFactory.fromString("Gen 1:1"));
assertTrue(it.hasNext());
@@ -579,7 +579,7 @@
}
public void testWriteVerseIterator() throws Exception {
- Iterator it = gen1_135.iterator();
+ Iterator<Key> it = gen1_135.iterator();
assertTrue(it.hasNext());
assertEquals(it.next(), VerseFactory.fromString("Gen 1:1"));
assertTrue(it.hasNext());
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTally2Test.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTally2Test.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/PassageTally2Test.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -171,7 +171,7 @@
}
public void testVerseIterator() throws Exception {
- Iterator it = tally.iterator();
+ Iterator<Key> it = tally.iterator();
assertTrue(it.hasNext());
assertEquals(it.next(), VerseFactory.fromString("Gen 1:1"));
assertTrue(it.hasNext());
@@ -190,7 +190,7 @@
}
public void testRangeIterator() throws Exception {
- Iterator it = tally.rangeIterator(RestrictionType.NONE);
+ Iterator<Key> it = tally.rangeIterator(RestrictionType.NONE);
assertTrue(it.hasNext());
assertEquals(it.next(), VerseRangeFactory.fromString("Gen 1:1"));
assertTrue(it.hasNext());
Modified: trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java
===================================================================
--- trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java 2010-12-09 15:31:45 UTC (rev 2050)
+++ trunk/jsword/src/test/java/org/crosswire/jsword/passage/VerseRangeTest.java 2010-12-09 19:09:05 UTC (rev 2051)
@@ -617,7 +617,7 @@
}
public void testVerseElements() {
- Iterator it = gen11_1.iterator();
+ Iterator<Key> it = gen11_1.iterator();
while (it.hasNext()) {
assertTrue(it.hasNext());
Verse v = (Verse) it.next();
More information about the jsword-svn
mailing list