You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2025/05/11 08:01:46 UTC
(openoffice) 02/18: Integrate the i18n unit tests with their new test framework, eliminate most method order dependencies, and other test fixes.
This is an automated email from the ASF dual-hosted git repository.
damjan pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 2f709283d1bd576d3b419fe5eab3c9c4e094bc79
Author: Damjan Jovanovic <da...@apache.org>
AuthorDate: Thu May 8 04:39:39 2025 +0200
Integrate the i18n unit tests with their new test framework,
eliminate most method order dependencies, and other
test fixes.
Patch by: me
---
.../source/api/i18n/XBreakIteratorTest.java | 228 +++++++++------
test/testuno/source/api/i18n/XCalendarTest.java | 312 +++++++++------------
.../api/i18n/XCharacterClassificationTest.java | 122 +++++---
test/testuno/source/api/i18n/XCollatorTest.java | 108 ++++---
.../source/api/i18n/XExtendedCalendarTest.java | 61 ++--
.../api/i18n/XExtendedIndexEntrySupplierTest.java | 130 ++++++---
.../api/i18n/XExtendedTransliterationTest.java | 49 +++-
.../source/api/i18n/XIndexEntrySupplierTest.java | 64 ++++-
test/testuno/source/api/i18n/XLocaleDataTest.java | 175 +++++++-----
.../source/api/i18n/XNumberFormatCodeTest.java | 62 +++-
.../source/api/i18n/XTransliterationTest.java | 141 ++++++----
11 files changed, 899 insertions(+), 553 deletions(-)
diff --git a/test/testuno/source/api/i18n/XBreakIteratorTest.java b/test/testuno/source/api/i18n/XBreakIteratorTest.java
index 84aecc1c18..252793d006 100644
--- a/test/testuno/source/api/i18n/XBreakIteratorTest.java
+++ b/test/testuno/source/api/i18n/XBreakIteratorTest.java
@@ -21,14 +21,17 @@
-package ifc.i18n;
+package api.i18n;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
import java.util.Vector;
-import lib.MultiMethodTest;
-import lib.Status;
-import lib.StatusException;
-
+import com.sun.star.beans.PropertyState;
+import com.sun.star.beans.PropertyValue;
import com.sun.star.i18n.Boundary;
import com.sun.star.i18n.LineBreakHyphenationOptions;
import com.sun.star.i18n.LineBreakResults;
@@ -37,6 +40,19 @@ import com.sun.star.i18n.ScriptType;
import com.sun.star.i18n.WordType;
import com.sun.star.i18n.XBreakIterator;
import com.sun.star.lang.Locale;
+import com.sun.star.lang.XComponent;
+import com.sun.star.text.XTextDocument;
+import com.sun.star.text.XTextRange;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openoffice.test.common.Testspace;
+import org.openoffice.test.uno.UnoApp;
/**
* Testing <code>com.sun.star.i18n.XBreakIterator</code>
@@ -76,31 +92,55 @@ import com.sun.star.lang.Locale;
* <ul> <p>
* @see com.sun.star.i18n.XBreakIterator
*/
-public class _XBreakIterator extends MultiMethodTest {
+public class XBreakIteratorTest {
+ private static final UnoApp app = new UnoApp();
+ private static final String iteratorPath = "api/i18n/Iterator.sxw";
+ private static String UnicodeString;
+ private XComponentContext xContext = null;
public XBreakIterator oObj = null;
Locale locale = null;
- String UnicodeString = null;
short wordType = WordType.ANYWORD_IGNOREWHITESPACES;
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ app.start();
+ UnicodeString = readFileContents(iteratorPath);
+ }
+
+ @AfterClass
+ public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
+ {
+ app.close();
+ }
+
/**
* Retrieves object relations.
* @throws StatusException If one of relations not found.
*/
- protected void before() {
- locale = (Locale)tEnv.getObjRelation("Locale");
- if (locale == null) {
- throw new StatusException
- (Status.failed("Relation 'Locale' not found")) ;
- }
+ @Before
+ public void before() throws Exception {
+ xContext = app.getComponentContext();
+ oObj = UnoRuntime.queryInterface(
+ XBreakIterator.class,
+ xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.BreakIterator", xContext)
+ );
+
+ locale = new Locale("en", "US", "");
+ }
- UnicodeString = (String)tEnv.getObjRelation("UnicodeString");
- if (UnicodeString == null) {
- throw new StatusException(Status.failed
- ("Relation 'UnicodeString' not found")) ;
- }
+ private static String readFileContents(String path) throws Exception {
+ String sample = Testspace.prepareData(path);
+ PropertyValue[] properties = new PropertyValue[1];
+ properties[0] = new PropertyValue("Hidden", -1, true, PropertyState.DIRECT_VALUE);
+ XComponent docComponent = app.loadDocument(sample, properties);
+ XTextDocument textDocument = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, docComponent);
+ XTextRange xTextRange = (XTextRange)textDocument.getText();
+ return xTextRange.getString();
}
/**
@@ -109,6 +149,7 @@ public class _XBreakIterator extends MultiMethodTest {
* Has <b>OK</b> status if position after travel and traveled length
* has expected values.
*/
+ @Test
public void _nextCharacters() {
short nCharacterIteratorMode =
com.sun.star.i18n.CharacterIteratorMode.SKIPCHARACTER;
@@ -127,16 +168,16 @@ public class _XBreakIterator extends MultiMethodTest {
int[] lDone = new int[1];
long lRes = oObj.nextCharacters(UnicodeString, nextCharacters[i][0],
locale, nCharacterIteratorMode, nextCharacters[i][1], lDone);
- log.println("Expected result is: lRes = " + nextCharacters[i][2] +
+ System.out.println("Expected result is: lRes = " + nextCharacters[i][2] +
"; lDone = " + nextCharacters[i][3] );
- log.println("Actual result is: lRes = " + lRes +
+ System.out.println("Actual result is: lRes = " + lRes +
"; lDone = " + lDone[0] );
bRes = bRes && lRes == nextCharacters[i][2];
bRes = bRes && lDone[0] == nextCharacters[i][3];
}
- tRes.tested("nextCharacters()", bRes);
+ Assert.assertTrue("nextCharacters()", bRes);
}
/**
@@ -145,6 +186,7 @@ public class _XBreakIterator extends MultiMethodTest {
* Has <b>OK</b> status if position after travel and traveled length
* has expected values.
*/
+ @Test
public void _previousCharacters() {
short nCharacterIteratorMode =
com.sun.star.i18n.CharacterIteratorMode.SKIPCHARACTER;
@@ -163,42 +205,46 @@ public class _XBreakIterator extends MultiMethodTest {
previousCharacters[i][0],
locale, nCharacterIteratorMode,
previousCharacters[i][1], lDone);
- log.println("Expected result is: lRes = " + previousCharacters[i][2]
+ System.out.println("Expected result is: lRes = " + previousCharacters[i][2]
+ "; lDone = " + previousCharacters[i][3] );
- log.println("Actual result is: lRes = " + lRes
+ System.out.println("Actual result is: lRes = " + lRes
+ "; lDone = " + lDone[0]);
bRes = bRes && lRes == previousCharacters[i][2];
bRes = bRes && lDone[0] == previousCharacters[i][3];
}
- tRes.tested("previousCharacters()", bRes);
+ Assert.assertTrue("previousCharacters()", bRes);
}
- Vector vBounds = new Vector();
-
/**
* Saves bounds of all returned words for the future tests. <p>
* Has <b>OK</b> status.
*/
+ @Test
public void _nextWord() {
- int i = 0;
+ ArrayList<Boundary> vBounds = nextWord();
+ Assert.assertTrue("nextWord()", vBounds != null && vBounds.size() > 0);
+ }
+ private ArrayList<Boundary> nextWord() {
+ int i = 0;
+ ArrayList<Boundary> vBounds = new ArrayList<>();
while( i < UnicodeString.length() - 1 ) {
Boundary bounds = oObj.nextWord
(UnicodeString, i, locale, wordType);
if (bounds.endPos - bounds.startPos > 3) {
vBounds.add( bounds );
- log.println("Word " + vBounds.size() + "("
+ System.out.println("Word " + vBounds.size() + "("
+ bounds.startPos + "," + bounds.endPos + "): '" +
UnicodeString.substring(bounds.startPos,
bounds.endPos) + "'");
}
i = bounds.endPos - 1;
}
- log.println("In text there are " + vBounds.size()
+ System.out.println("In text there are " + vBounds.size()
+ " words, if count from left to right");
- tRes.tested("nextWord()", true);
+ return vBounds;
}
/**
@@ -206,26 +252,27 @@ public class _XBreakIterator extends MultiMethodTest {
* by the method _nextWord().<p>
* Has <b>OK</b> status if number of word bounds are equal.
*/
+ @Test
public void _previousWord() {
- requiredMethod("nextWord()");
+ ArrayList<Boundary> vBounds = nextWord();
int i = UnicodeString.length() - 1;
- Vector vPrevBounds = new Vector();
+ ArrayList<Boundary> vPrevBounds = new ArrayList<>();
while( i > 0 ) {
Boundary bounds =
oObj.previousWord(UnicodeString, i, locale, wordType);
if (bounds.endPos - bounds.startPos > 3) {
vPrevBounds.add( bounds );
- log.println("Word " + vPrevBounds.size() + "("
+ System.out.println("Word " + vPrevBounds.size() + "("
+ bounds.startPos + "," + bounds.endPos + "): '"
+ UnicodeString.substring(bounds.startPos, bounds.endPos)
+ "'");
}
i = bounds.startPos;
}
- log.println("In text there are " + vPrevBounds.size()
+ System.out.println("In text there are " + vPrevBounds.size()
+ " words, if count from right to left");
- tRes.tested("previousWord()", vPrevBounds.size() == vBounds.size() );
+ Assert.assertTrue("previousWord()", vPrevBounds.size() == vBounds.size() );
}
/**
@@ -235,8 +282,9 @@ public class _XBreakIterator extends MultiMethodTest {
* Has <b>OK</b> status if bounds calculated by <code>getWordBoundary()</code>
* method are the same as bounds obtained by <code>nextWord</code> method.
*/
+ @Test
public void _getWordBoundary() {
- requiredMethod("nextWord()");
+ ArrayList<Boundary> vBounds = nextWord();
boolean bRes = true;
@@ -247,9 +295,9 @@ public class _XBreakIterator extends MultiMethodTest {
+ iBounds.startPos;
Boundary bounds = oObj.getWordBoundary(UnicodeString, iPos,
locale, wordType, true);
- log.println("Expected result is: startPos = " + iBounds.startPos +
+ System.out.println("Expected result is: startPos = " + iBounds.startPos +
"; endPos = " + iBounds.endPos);
- log.println("Actual result is: startPos = " + bounds.startPos
+ System.out.println("Actual result is: startPos = " + bounds.startPos
+ "; endPos = " + bounds.endPos + " Word is: '"
+ UnicodeString.substring(bounds.startPos, bounds.endPos) + "'");
@@ -257,7 +305,7 @@ public class _XBreakIterator extends MultiMethodTest {
bRes = bRes && iBounds.endPos == bounds.endPos;
}
- tRes.tested("getWordBoundary()", bRes);
+ Assert.assertTrue("getWordBoundary()", bRes);
}
/**
@@ -266,8 +314,9 @@ public class _XBreakIterator extends MultiMethodTest {
*
* Has <b>OK</b> status if every word has type <code>WordType.ANY_WORD</code>
*/
+ @Test
public void _getWordType() {
- requiredMethod("nextWord()");
+ ArrayList<Boundary> vBounds = nextWord();
boolean bRes = true;
@@ -282,7 +331,7 @@ public class _XBreakIterator extends MultiMethodTest {
bRes = bRes && type == WordType.ANY_WORD;
}
- tRes.tested("getWordType()", bRes);
+ Assert.assertTrue("getWordType()", bRes);
}
/**
@@ -293,8 +342,9 @@ public class _XBreakIterator extends MultiMethodTest {
* Has <b>OK</b> status if in the first case <code>true</code>
* returned and in the second - <code>false</code> for every word.
*/
+ @Test
public void _isBeginWord() {
- requiredMethod("nextWord()");
+ ArrayList<Boundary> vBounds = nextWord();
boolean bRes = true;
@@ -303,17 +353,19 @@ public class _XBreakIterator extends MultiMethodTest {
boolean isBegin = oObj.isBeginWord(UnicodeString, iBounds.startPos,
locale, WordType.ANY_WORD);
bRes = bRes && isBegin;
+ Assert.assertTrue("isBeginWord is wrong at position " + iBounds.startPos + ", string len " + UnicodeString.length(), isBegin);
boolean isNotBegin = !oObj.isBeginWord(UnicodeString,
iBounds.startPos + 1, locale, WordType.ANY_WORD);
bRes = bRes && isNotBegin;
+ Assert.assertTrue("isBeginWord is wrong at position " + (iBounds.startPos + 1) + " for bounds (" + iBounds.startPos + "," + iBounds.endPos, isNotBegin);
- log.println("At position + " + iBounds.startPos
+ System.out.println("At position + " + iBounds.startPos
+ " isBeginWord? " + isBegin);
- log.println("At position + " + (iBounds.startPos + 1)
+ System.out.println("At position + " + (iBounds.startPos + 1)
+ " isBeginWord? " + !isNotBegin);
}
- tRes.tested("isBeginWord()", bRes);
+ Assert.assertTrue("isBeginWord()", bRes);
}
/**
@@ -325,8 +377,9 @@ public class _XBreakIterator extends MultiMethodTest {
* Has <b>OK</b> status if in the first case <code>true</code>
* returned and in the second - <code>false</code> for every word.
*/
+ @Test
public void _isEndWord() {
- requiredMethod("nextWord()");
+ ArrayList<Boundary> vBounds = nextWord();
boolean bRes = true;
@@ -339,13 +392,13 @@ public class _XBreakIterator extends MultiMethodTest {
iBounds.endPos - 1, locale, WordType.ANY_WORD);
bRes = bRes && isNotEnd;
- log.println("At position + " + iBounds.endPos
+ System.out.println("At position + " + iBounds.endPos
+ " isEndWord? " + isEnd);
- log.println("At position + " + (iBounds.endPos - 1)
+ System.out.println("At position + " + (iBounds.endPos - 1)
+ " isEndWord? " + !isNotEnd);
}
- tRes.tested("isEndWord()", bRes);
+ Assert.assertTrue("isEndWord()", bRes);
}
Vector vSentenceStart = new Vector();
@@ -356,6 +409,7 @@ public class _XBreakIterator extends MultiMethodTest {
*
* Has <b>OK</b> status if -1 is returned for wrong position arguments.
*/
+ @Test
public void _beginOfSentence() {
int iPos = 0;
while( iPos < UnicodeString.length() ) {
@@ -363,7 +417,7 @@ public class _XBreakIterator extends MultiMethodTest {
iPos, locale) );
if (start.intValue() >= 0 && !vSentenceStart.contains(start) ) {
vSentenceStart.add( start );
- log.println("Sentence " + vSentenceStart.size()
+ System.out.println("Sentence " + vSentenceStart.size()
+ " : start from position " + start);
}
iPos++;
@@ -375,10 +429,10 @@ public class _XBreakIterator extends MultiMethodTest {
UnicodeString.length() + 1, locale) == -1;
if (!bRes) {
- log.println("When invalid position, returned value isn't equal to -1");
+ System.out.println("When invalid position, returned value isn't equal to -1");
}
- tRes.tested("beginOfSentence()", bRes);
+ Assert.assertTrue("beginOfSentence()", bRes);
}
/**
@@ -391,13 +445,14 @@ public class _XBreakIterator extends MultiMethodTest {
* Has <b>OK</b> status if the end position of every sentence
* greater than starting and -1 returned for invalid arguments.
*/
+ @Test
public void _endOfSentence() {
boolean bRes = true;
for(int i = 0; i < vSentenceStart.size(); i++) {
int start = ((Integer)vSentenceStart.get(i)).intValue();
int end = oObj.endOfSentence(UnicodeString, start, locale);
bRes &= end > start;
- log.println("Sentence " + i + " range is [" + start + ", "
+ System.out.println("Sentence " + i + " range is [" + start + ", "
+ end + "]");
}
@@ -407,10 +462,10 @@ public class _XBreakIterator extends MultiMethodTest {
UnicodeString.length() + 1, locale) == -1;
if (!bInvRes) {
- log.println("When invalid position, returned value isn't equal to -1");
+ System.out.println("When invalid position, returned value isn't equal to -1");
}
- tRes.tested("endOfSentence()", bRes && bInvRes);
+ Assert.assertTrue("endOfSentence()", bRes && bInvRes);
}
/**
@@ -420,6 +475,7 @@ public class _XBreakIterator extends MultiMethodTest {
* Has <b>OK</b> status if non-zero break position was found and it is
* less or equal than position we trying to break.
*/
+ @Test
public void _getLineBreak() {
boolean bRes = true;
LineBreakResults lineBreakResults;
@@ -445,11 +501,11 @@ public class _XBreakIterator extends MultiMethodTest {
bRes = breakPos <= pos && breakPos > 0;
if (!bRes) {
- log.println("The last position was: " + pos
+ System.out.println("The last position was: " + pos
+ ", and the break position was: " + breakPos);
}
- tRes.tested("getLineBreak()", bRes);
+ Assert.assertTrue("getLineBreak()", bRes);
}
// Asian type script
@@ -464,14 +520,15 @@ public class _XBreakIterator extends MultiMethodTest {
* relatively to position passed. <p>
* Has <b>OK</b> status if the starting position of script is returned.
*/
+ @Test
public void _beginOfScript() {
String multiScript = "ab" + katakana ;
int pos = oObj.beginOfScript(multiScript, 3, ScriptType.ASIAN) ;
- log.println("Position = " + pos) ;
+ System.out.println("Position = " + pos) ;
- tRes.tested("beginOfScript()", pos == 2) ;
+ Assert.assertTrue("beginOfScript()", pos == 2) ;
}
/**
@@ -479,14 +536,15 @@ public class _XBreakIterator extends MultiMethodTest {
* relatively to position passed. <p>
* Has <b>OK</b> status if the end position of script is returned.
*/
+ @Test
public void _endOfScript() {
String multiScript = "ab" + katakana + "cd" ;
int pos = oObj.endOfScript(multiScript, 2, ScriptType.ASIAN) ;
- log.println("Position = " + pos) ;
+ System.out.println("Position = " + pos) ;
- tRes.tested("endOfScript()", pos == 4) ;
+ Assert.assertTrue("endOfScript()", pos == 4) ;
}
/**
@@ -494,14 +552,15 @@ public class _XBreakIterator extends MultiMethodTest {
* relatively to position passed. <p>
* Has <b>OK</b> status if the appropriate position is returned.
*/
+ @Test
public void _nextScript() {
String multiScript = "ab" + katakana + "cd" ;
int pos = oObj.nextScript(multiScript, 0, ScriptType.LATIN) ;
- log.println("Position = " + pos) ;
+ System.out.println("Position = " + pos) ;
- tRes.tested("nextScript()", pos == 4) ;
+ Assert.assertTrue("nextScript()", pos == 4) ;
}
/**
@@ -509,14 +568,15 @@ public class _XBreakIterator extends MultiMethodTest {
* relatively to position passed. <p>
* Has <b>OK</b> status if the appropriate position is returned.
*/
+ @Test
public void _previousScript() {
String multiScript = "ab" + katakana + "cd" ;
int pos = oObj.previousScript(multiScript, 5, ScriptType.ASIAN) ;
- log.println("Position = " + pos) ;
+ System.out.println("Position = " + pos) ;
- tRes.tested("previousScript()", pos == 2) ;
+ Assert.assertTrue("previousScript()", pos == 2) ;
}
/**
@@ -527,6 +587,7 @@ public class _XBreakIterator extends MultiMethodTest {
* codepoints and <code>WEAK</code> for codepoints from Arrows
* Unicode block.
*/
+ @Test
public void _getScriptType() {
boolean res = true ;
@@ -535,11 +596,9 @@ public class _XBreakIterator extends MultiMethodTest {
res &= oObj.getScriptType(arabic, 0) == ScriptType.COMPLEX ;
res &= oObj.getScriptType(arrows, 0) == ScriptType.WEAK ;
- tRes.tested("getScriptType()", res) ;
+ Assert.assertTrue("getScriptType()", res) ;
}
- boolean bCharBlockRes = true;
-
protected short getCharBlockType(int pos) {
short i = 1;
short cType = 0;
@@ -567,7 +626,13 @@ public class _XBreakIterator extends MultiMethodTest {
* has position 0 and the end of the last block is at the end
* of the whole string.
*/
+ @Test
public void _beginOfCharBlock() {
+ Assert.assertTrue("beginOfCharBlock()", beginOfCharBlock());
+ }
+
+ private boolean beginOfCharBlock() {
+ boolean bCharBlockRes = true;
int iPos = 0;
while( iPos < UnicodeString.length() && iPos > -1) {
@@ -578,7 +643,7 @@ public class _XBreakIterator extends MultiMethodTest {
locale, charType);
iPos = endPos;
vCharBlockBounds.add(new Boundary(startPos, endPos));
- log.println("" + vCharBlockBounds.size() + "). Bounds: ["
+ System.out.println("" + vCharBlockBounds.size() + "). Bounds: ["
+ startPos + "," + endPos + "]; Type = " + charType);
vCharBlockTypes.add(new Short(charType));
}
@@ -589,16 +654,16 @@ public class _XBreakIterator extends MultiMethodTest {
bCharBlockRes &= endPos == startPos;
}
- log.println("Testing for no intersections : " + bCharBlockRes);
+ System.out.println("Testing for no intersections : " + bCharBlockRes);
int startPos = ((Boundary)vCharBlockBounds.get(0)).startPos;
bCharBlockRes &= startPos == 0;
int endPos = ((Boundary)vCharBlockBounds.get
(vCharBlockBounds.size() - 1)).endPos;
bCharBlockRes &= endPos == UnicodeString.length();
- log.println("Regions should starts with 0 and ends with "
+ System.out.println("Regions should starts with 0 and ends with "
+ UnicodeString.length());
- tRes.tested("beginOfCharBlock()", bCharBlockRes);
+ return bCharBlockRes;
}
/**
@@ -608,8 +673,7 @@ public class _XBreakIterator extends MultiMethodTest {
* Has the status same as <code>beginOfCharBlock()</code> method status.
*/
public void _endOfCharBlock() {
- requiredMethod("beginOfCharBlock()");
- tRes.tested("endOfCharBlock()", bCharBlockRes);
+ Assert.assertTrue("endOfCharBlock()", beginOfCharBlock());
}
/**
@@ -622,7 +686,7 @@ public class _XBreakIterator extends MultiMethodTest {
* equal to this block boundary start.
*/
public void _nextCharBlock() {
- requiredMethod("beginOfCharBlock()");
+ beginOfCharBlock();
boolean bRes = true;
for(int i = 0; i < vCharBlockBounds.size(); i++) {
@@ -633,14 +697,14 @@ public class _XBreakIterator extends MultiMethodTest {
locale, type.shortValue());
if (iPos != bounds.startPos) {
bRes = false;
- log.println("nextCharBlock(UnicodeString, "
+ System.out.println("nextCharBlock(UnicodeString, "
+ (bounds.startPos - 1) + ", locale, " + type
+ ") should return " + bounds.startPos);
- log.println("... and actual value is " + iPos);
+ System.out.println("... and actual value is " + iPos);
}
}
- tRes.tested("nextCharBlock()", bRes);
+ Assert.assertTrue("nextCharBlock()", bRes);
}
/**
@@ -653,7 +717,7 @@ public class _XBreakIterator extends MultiMethodTest {
* equal to this block boundary start.
*/
public void _previousCharBlock() {
- requiredMethod("beginOfCharBlock()");
+ beginOfCharBlock();
boolean bRes = true;
for(int i = 0; i < vCharBlockBounds.size(); i++) {
@@ -663,14 +727,14 @@ public class _XBreakIterator extends MultiMethodTest {
bounds.endPos + 1, locale, type.shortValue());
if (iPos != bounds.startPos) {
bRes = false;
- log.println("previousCharBlock(UnicodeString, "
+ System.out.println("previousCharBlock(UnicodeString, "
+ (bounds.endPos + 1) + ", locale, " + type
+ ") should return " + bounds.startPos);
- log.println("... and actual value is " + iPos);
+ System.out.println("... and actual value is " + iPos);
}
}
- tRes.tested("previousCharBlock()", bRes);
+ Assert.assertTrue("previousCharBlock()", bRes);
}
}
diff --git a/test/testuno/source/api/i18n/XCalendarTest.java b/test/testuno/source/api/i18n/XCalendarTest.java
index 6c3acd102a..1c63861032 100644
--- a/test/testuno/source/api/i18n/XCalendarTest.java
+++ b/test/testuno/source/api/i18n/XCalendarTest.java
@@ -21,9 +21,7 @@
-package ifc.i18n;
-
-import lib.MultiMethodTest;
+package api.i18n;
import com.sun.star.i18n.CalendarDisplayIndex;
import com.sun.star.i18n.CalendarFieldIndex;
@@ -33,6 +31,14 @@ import com.sun.star.i18n.XLocaleData;
import com.sun.star.lang.Locale;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openoffice.test.uno.UnoApp;
/**
* Testing <code>com.sun.star.i18n.XCalendar</code>
@@ -62,42 +68,61 @@ import com.sun.star.uno.UnoRuntime;
* Test is <b> NOT </b> multithread compliant. <p>
* @see com.sun.star.i18n.XCalendar
*/
-public class _XCalendar extends MultiMethodTest {
+public class XCalendarTest {
+ private static final UnoApp app = new UnoApp();
+
+ private XComponentContext xContext = null;
private boolean debug = false;
public XCalendar oObj = null;
- public String[][] calendars;
- public int[] count;
public double newDTime = 1000.75;
public short newValue = 2;
- public short firstDay = 2;
+ public final short firstDay = 2;
public short mdfw = 3;
double aOriginalDTime = 0;
Locale[] installed_locales;
- public void before() {
- XLocaleData locData = null;
- try {
- locData = (XLocaleData) UnoRuntime.queryInterface(
- XLocaleData.class,
- ((XMultiServiceFactory)tParam.getMSF()).createInstance(
- "com.sun.star.i18n.LocaleData"));
- } catch (com.sun.star.uno.Exception e) {
+ static class CalendarData {
+ String[][] calendars;
+ int[] count;
+ };
- }
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ app.start();
+ }
+
+ @AfterClass
+ public static void tearDown() throws Exception {
+ app.close();
+ }
+
+ @Before
+ public void before() throws Exception {
+ xContext = app.getComponentContext();
+
+ XLocaleData locData = null;
+ locData = UnoRuntime.queryInterface(
+ XLocaleData.class,
+ xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.LocaleData", xContext)
+ );
+ oObj = UnoRuntime.queryInterface(
+ XCalendar.class,
+ xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.LocaleCalendar", xContext)
+ );
installed_locales = locData.getAllInstalledLocaleNames();
- calendars = new String[installed_locales.length][];
- count = new int[installed_locales.length];
oObj.loadDefaultCalendar(installed_locales[0]);
aOriginalDTime = oObj.getDateTime();
- debug = tParam.getBool("DebugIsActive");
+ debug = false;
}
/**
* Restore the changed time during the test to the original value of the
* machine: has to be correct for the following interface tests.
*/
- public void after() {
+ @After
+ public void after() throws Exception {
oObj.loadDefaultCalendar(installed_locales[0]);
oObj.setDateTime(aOriginalDTime);
}
@@ -107,23 +132,15 @@ public class _XCalendar extends MultiMethodTest {
* Has <b> OK </b> status if method loads calendar, that is
* default for a given locale.
*/
+ @Test
public void _loadDefaultCalendar() {
- boolean res = true;
-
for (int i=0; i<installed_locales.length; i++) {
String lang = "Language: "+installed_locales[i].Language +
", Country: "+ installed_locales[i].Country +
- ", Variant: "+ installed_locales[i].Country;
+ ", Variant: "+ installed_locales[i].Variant;
oObj.loadDefaultCalendar(installed_locales[i]);
- if (oObj.getLoadedCalendar().Default) {
- //log.println(lang + " ... OK");
- } else {
- log.println(lang + " ... FAILED");
- }
- res &= oObj.getLoadedCalendar().Default;
+ Assert.assertTrue(lang, oObj.getLoadedCalendar().Default);
}
-
- tRes.tested("loadDefaultCalendar()", res);
}
/**
@@ -131,23 +148,24 @@ public class _XCalendar extends MultiMethodTest {
* Has <b> OK </b> status if the method returns more than zero calendars for
* every locale.
*/
+ @Test
public void _getAllCalendars() {
- boolean res = true;
+ getAllCalendars();
+ }
+ private CalendarData getAllCalendars() {
+ CalendarData data = new CalendarData();
+ data.calendars = new String[installed_locales.length][];
+ data.count = new int[installed_locales.length];
for (int i=0; i<installed_locales.length; i++) {
String lang = "Language: "+installed_locales[i].Language +
", Country: "+ installed_locales[i].Country +
- ", Variant: "+ installed_locales[i].Country;
- calendars[i] = oObj.getAllCalendars(installed_locales[i]);
- count[i] = calendars[i].length-1;
- if (calendars[i].length > 0) {
- //log.println(lang + " ... OK");
- } else {
- log.println(lang + " ... FAILED");
- }
- res &= (calendars[i].length > 0);
+ ", Variant: "+ installed_locales[i].Variant;
+ data.calendars[i] = oObj.getAllCalendars(installed_locales[i]);
+ data.count[i] = data.calendars[i].length-1;
+ Assert.assertTrue(lang, data.calendars[i].length > 0);
}
- tRes.tested("getAllCalendars()", res);
+ return data;
}
/**
@@ -160,24 +178,21 @@ public class _XCalendar extends MultiMethodTest {
* locale </li>
* </ul>
*/
+ @Test
public void _loadCalendar() {
- boolean res = true;
- requiredMethod("getAllCalendars()");
+ loadCalendar();
+ }
+ private CalendarData loadCalendar() {
+ CalendarData data = getAllCalendars();
for (int i=0; i<installed_locales.length; i++) {
String lang = "Language: "+installed_locales[i].Language +
", Country: "+ installed_locales[i].Country +
- ", Variant: "+ installed_locales[i].Country;
- oObj.loadCalendar(calendars[i][0], installed_locales[i]);
- if (calendars[i][0].equals(oObj.getLoadedCalendar().Name)) {
- //log.println(lang + " ... OK");
- } else {
- log.println(lang + " ... FAILED");
- }
- res &= calendars[i][0].equals(oObj.getLoadedCalendar().Name);
+ ", Variant: "+ installed_locales[i].Variant;
+ oObj.loadCalendar(data.calendars[i][0], installed_locales[i]);
+ Assert.assertEquals(lang, data.calendars[i][0], oObj.getLoadedCalendar().Name);
}
-
- tRes.tested("loadCalendar()", res);
+ return data;
}
/**
@@ -190,23 +205,16 @@ public class _XCalendar extends MultiMethodTest {
* and locale </li>
* </ul>
*/
+ @Test
public void _getLoadedCalendar() {
- boolean res = true;
-
- requiredMethod("loadCalendar()");
+ CalendarData data = loadCalendar();
for (int i=0; i<installed_locales.length; i++) {
String lang = "Language: "+installed_locales[i].Language +
", Country: "+ installed_locales[i].Country +
- ", Variant: "+ installed_locales[i].Country;
- oObj.loadCalendar(calendars[i][0], installed_locales[i]);
- if (calendars[i][0].equals(oObj.getLoadedCalendar().Name)) {
- //log.println(lang + " ... OK");
- } else {
- log.println(lang + " ... FAILED");
- }
- res &= calendars[i][0].equals(oObj.getLoadedCalendar().Name);
+ ", Variant: "+ installed_locales[i].Variant;
+ oObj.loadCalendar(data.calendars[i][0], installed_locales[i]);
+ Assert.assertEquals(lang, data.calendars[i][0], oObj.getLoadedCalendar().Name);
}
- tRes.tested("getLoadedCalendar()", res);
}
/**
@@ -219,23 +227,17 @@ public class _XCalendar extends MultiMethodTest {
* and locale </li>
* </ul>
*/
+ @Test
public void _getUniqueID() {
- boolean res = true;
+ CalendarData data = getAllCalendars();
for (int i=0; i<installed_locales.length; i++) {
String lang = "Language: "+installed_locales[i].Language +
", Country: "+ installed_locales[i].Country +
- ", Variant: "+ installed_locales[i].Country;
- oObj.loadCalendar(calendars[i][0], installed_locales[i]);
+ ", Variant: "+ installed_locales[i].Variant;
+ oObj.loadCalendar(data.calendars[i][0], installed_locales[i]);
String uID = oObj.getUniqueID();
- if (uID.equals(calendars[i][0])) {
- //log.println(lang + " ... OK");
- } else {
- log.println(lang + " ... FAILED");
- }
- res &= uID.equals(calendars[i][0]);
+ Assert.assertEquals(lang, uID, data.calendars[i][0]);
}
-
- tRes.tested("getUniqueID()",res);
}
/**
@@ -243,25 +245,16 @@ public class _XCalendar extends MultiMethodTest {
* Has <b> OK </b> status if the method returns value, that's equal to
* value set before. <p>
*/
-
+ @Test
public void _setDateTime() {
- boolean res = true;
-
for (int i=0; i<installed_locales.length; i++) {
String lang = "Language: "+installed_locales[i].Language +
", Country: "+ installed_locales[i].Country +
- ", Variant: "+ installed_locales[i].Country;
+ ", Variant: "+ installed_locales[i].Variant;
oObj.setDateTime(newDTime);
double aDTime = oObj.getDateTime();
- if (aDTime == newDTime) {
- //log.println(lang + " ... OK");
- } else {
- log.println(lang + " ... FAILED");
- }
- res &= (aDTime == newDTime);
+ Assert.assertTrue(lang, aDTime == newDTime);
}
-
- tRes.tested("setDateTime()", res);
}
/**
@@ -269,24 +262,16 @@ public class _XCalendar extends MultiMethodTest {
* Has <b> OK </b> status if the method returns value, that's equal to
* value set before. <p>
*/
-
+ @Test
public void _getDateTime() {
- boolean res = true;
-
for (int i=0; i<installed_locales.length; i++) {
String lang = "Language: "+installed_locales[i].Language +
", Country: "+ installed_locales[i].Country +
- ", Variant: "+ installed_locales[i].Country;
+ ", Variant: "+ installed_locales[i].Variant;
oObj.setDateTime(newDTime);
double aDTime = oObj.getDateTime();
- if (aDTime == newDTime) {
- //log.println(lang + " ... OK");
- } else {
- log.println(lang + " ... FAILED");
- }
- res &= (aDTime == newDTime);
+ Assert.assertTrue(lang, aDTime == newDTime);
}
- tRes.tested("getDateTime()", res);
}
/**
@@ -294,19 +279,19 @@ public class _XCalendar extends MultiMethodTest {
* Has <b> OK </b> status if the method returns value, that's equal to
* value set before. <p>
*/
-
+ @Test
public void _setValue() {
- boolean res = true;
+ CalendarData data = getAllCalendars();
for (int i=0; i<installed_locales.length; i++) {
String error = "";
String lang = "Language: "+installed_locales[i].Language +
", Country: "+ installed_locales[i].Country +
", Variant: "+ installed_locales[i].Variant +
- ", Name: "+calendars[i][count[i]];
+ ", Name: "+data.calendars[i][data.count[i]];
String[] names = new String[]{"DAY_OF_MONTH",
"HOUR","MINUTE","SECOND","MILLISECOND",
"YEAR","MONTH"};
- oObj.loadCalendar(calendars[i][count[i]],installed_locales[i]);
+ oObj.loadCalendar(data.calendars[i][data.count[i]],installed_locales[i]);
short[] fields = new short[]{CalendarFieldIndex.DAY_OF_MONTH,
CalendarFieldIndex.HOUR,
CalendarFieldIndex.MINUTE,
@@ -331,30 +316,22 @@ public class _XCalendar extends MultiMethodTest {
short get = oObj.getValue(fields[k]);
if (get != set) {
if (debug)
- log.println("ERROR occur: tried to set " + names[k] + " to value " + set);
- log.println("list of values BEFORE set " + names[k] + " to value " + set + ":");
+ System.out.println("ERROR occur: tried to set " + names[k] + " to value " + set);
+ System.out.println("list of values BEFORE set " + names[k] + " to value " + set + ":");
for (int n=0; n < oldValues.length; n++){
- log.println(names[n] + ":" + oldValues[n]);
+ System.out.println(names[n] + ":" + oldValues[n]);
}
- log.println("list of values AFTER set " + names[k] + " to value " + set + ":");
+ System.out.println("list of values AFTER set " + names[k] + " to value " + set + ":");
for (int n=0; n < fields.length;n++){
- log.println(names[n] + ":" + oObj.getValue(fields[n]));
+ System.out.println(names[n] + ":" + oObj.getValue(fields[n]));
}
error += "failed for "+names[k]+" expected "+
set+" gained "+get+" ; \n";
}
}
- if (error.equals("")) {
- log.println(lang + " ... OK");
- } else {
- log.println("*** "+lang + " ... FAILED ***");
- log.println(error);
- }
- res &= (error.equals(""));
+ Assert.assertTrue(error, error.equals(""));
}
-
- tRes.tested("setValue()", res);
}
/**
@@ -362,18 +339,14 @@ public class _XCalendar extends MultiMethodTest {
* Has <b> OK </b> status if the method returns value, that's equal to
* value set before. <p>
*/
-
+ @Test
public void _getValue() {
- boolean res = true;
-
- requiredMethod("setValue()");
+ _setValue();
short aValue = oObj.getValue(CalendarFieldIndex.MONTH);
- res &= (aValue == newValue);
- if (!res){
- log.println("the returned value is not the expected value:");
- log.println("expexted: " + newValue + " returned value: " + aValue);
- }
- tRes.tested("getValue()", res);
+ Assert.assertEquals(
+ "the returned value is not the expected value:" +
+ "expected: " + newValue + " returned value: " + aValue,
+ aValue, newValue);
}
/**
@@ -386,18 +359,15 @@ public class _XCalendar extends MultiMethodTest {
* <li> <code> getValue() </code> : gets the value of a field </li>
* </ul>
*/
+ @Test
public void _addValue() {
- boolean res = true;
-
- requiredMethod("getValue()");
+ _setValue();
oObj.addValue(CalendarFieldIndex.MONTH, 1);
short aValue = oObj.getValue(CalendarFieldIndex.MONTH);
- res &= (aValue > newValue);
- if (!res){
- log.println("the returned value is not the expected value:");
- log.println("expexted: " + newValue + " returned value: " + aValue);
- }
- tRes.tested("addValue()", res);
+ Assert.assertTrue(
+ "the returned value is not the expected value:" +
+ "expected: " + newValue + " returned value: " + aValue,
+ aValue > newValue);
}
/**
@@ -405,12 +375,9 @@ public class _XCalendar extends MultiMethodTest {
* Has <b> OK </b> status if the method successfully returns
* and no exceptions were thrown.
*/
+ @Test
public void _setFirstDayOfWeek() {
- boolean res = true;
-
oObj.setFirstDayOfWeek(firstDay);
- res &= true;
- tRes.tested("setFirstDayOfWeek()", res);
}
/**
@@ -423,13 +390,11 @@ public class _XCalendar extends MultiMethodTest {
* week</li>
* </ul>
*/
+ @Test
public void _getFirstDayOfWeek() {
- boolean res = true;
-
- requiredMethod("setFirstDayOfWeek()");
+ _setFirstDayOfWeek();
short aFirstDayOfWeek = oObj.getFirstDayOfWeek();
- res &= (aFirstDayOfWeek == firstDay);
- tRes.tested("getFirstDayOfWeek()", res);
+ Assert.assertEquals("getFirstDayOfWeek()", aFirstDayOfWeek, firstDay);
}
/**
@@ -437,12 +402,9 @@ public class _XCalendar extends MultiMethodTest {
* Has <b> OK </b> status if the method successfully returns
* and no exceptions were thrown.
*/
+ @Test
public void _setMinimumNumberOfDaysForFirstWeek() {
- boolean res = true;
-
oObj.setMinimumNumberOfDaysForFirstWeek(mdfw);
- res &= true;
- tRes.tested("setMinimumNumberOfDaysForFirstWeek()", res);
}
/**
@@ -455,75 +417,64 @@ public class _XCalendar extends MultiMethodTest {
* many days of a week must reside in the first week of a year</li>
* </ul>
*/
+ @Test
public void _getMinimumNumberOfDaysForFirstWeek() {
- boolean res = true;
-
- requiredMethod("setMinimumNumberOfDaysForFirstWeek()");
+ _setMinimumNumberOfDaysForFirstWeek();
short aShort = oObj.getMinimumNumberOfDaysForFirstWeek();
- res &= (aShort == mdfw);
- tRes.tested("getMinimumNumberOfDaysForFirstWeek()", res);
+ Assert.assertEquals("getMinimumNumberOfDaysForFirstWeek()", aShort, mdfw);
}
/**
* Test calls the method, then result is checked. <p>
* Has <b> OK </b> status if the method returns 12.
*/
+ @Test
public void _getNumberOfMonthsInYear() {
- boolean res = true;
short aShort = oObj.getNumberOfMonthsInYear();
-
- res &= (aShort == (short) 12);
- tRes.tested("getNumberOfMonthsInYear()", res);
+ Assert.assertTrue("getNumberOfMonthsInYear()", (aShort == (short) 12));
}
/**
* Test calls the method, then result is checked. <p>
* Has <b> OK </b> status if the method returns 7.
*/
+ @Test
public void _getNumberOfDaysInWeek() {
- boolean res = true;
short aShort = oObj.getNumberOfDaysInWeek();
-
- res &= (aShort == (short) 7);
- tRes.tested("getNumberOfDaysInWeek()", res);
+ Assert.assertTrue("getNumberOfDaysInWeek()", (aShort == (short) 7));
}
/**
* Test calls the method, then result is checked. <p>
* Has <b> OK </b> status if length of array, returned by the method is 12.
*/
+ @Test
public void _getMonths() {
- boolean res = true;
CalendarItem[] months = oObj.getMonths();
-
- res &= (months.length == 12);
- tRes.tested("getMonths()", res);
+ Assert.assertTrue("getMonths()", months.length == 12);
}
/**
* Test calls the method, then result is checked. <p>
* Has <b> OK </b> status if length of array, returned by the method is 7.
*/
+ @Test
public void _getDays() {
- boolean res = true;
CalendarItem[] Days = oObj.getDays();
-
- res &= (Days.length == 7);
- tRes.tested("getDays()", res);
+ Assert.assertTrue("getDays()", Days.length == 7);
}
/**
* After loading calendar, test calls the method, then result is checked.<p>
* Has <b> OK </b> status if length of string, returned by the method is 3.
*/
+ @Test
public void _getDisplayName() {
- boolean res = true;
-
- oObj.loadCalendar(calendars[0][0],installed_locales[0]);
+ CalendarData data = getAllCalendars();
+ oObj.loadCalendar(data.calendars[0][0],installed_locales[0]);
String DisplayName = oObj.getDisplayName(CalendarDisplayIndex.MONTH,
newValue, (short) 0);
- res &= (DisplayName.length() == 3);
- tRes.tested("getDisplayName()", res);
+ Assert.assertTrue("getDisplayName()", DisplayName.length() == 3);
}
@@ -533,16 +484,13 @@ public class _XCalendar extends MultiMethodTest {
* Has <b> OK </b> status if the method returns true when valid month is
* set, and if the method returns false when set month is not valid.
*/
+ @Test
public void _isValid() {
- boolean res = true;
-
oObj.loadDefaultCalendar(installed_locales[0]);
oObj.setValue(CalendarFieldIndex.MONTH, (short) 37);
- res &= !oObj.isValid();
+ Assert.assertTrue(!oObj.isValid());
oObj.setValue(CalendarFieldIndex.MONTH, (short) 10);
- res &= oObj.isValid();
-
- tRes.tested("isValid()", res);
+ Assert.assertTrue(oObj.isValid());
}
/**
diff --git a/test/testuno/source/api/i18n/XCharacterClassificationTest.java b/test/testuno/source/api/i18n/XCharacterClassificationTest.java
index 427f36cbb0..507a6c53f8 100644
--- a/test/testuno/source/api/i18n/XCharacterClassificationTest.java
+++ b/test/testuno/source/api/i18n/XCharacterClassificationTest.java
@@ -21,15 +21,22 @@
-package ifc.i18n;
-
-import lib.MultiMethodTest;
+package api.i18n;
import com.sun.star.i18n.KParseTokens;
import com.sun.star.i18n.KParseType;
import com.sun.star.i18n.ParseResult;
import com.sun.star.i18n.XCharacterClassification;
import com.sun.star.lang.Locale;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openoffice.test.uno.UnoApp;
/**
* Testing <code>com.sun.star.i18n.XCharacterClassification</code>
@@ -49,7 +56,10 @@ import com.sun.star.lang.Locale;
* Test is <b> NOT </b> multithread compliant. <p>
* @see com.sun.star.i18n.XCharacterClassification
*/
-public class _XCharacterClassification extends MultiMethodTest {
+public class XCharacterClassificationTest {
+ private static final UnoApp app = new UnoApp();
+
+ private XComponentContext xContext = null;
public XCharacterClassification oObj = null;
public String[] languages = new String[]{"de","en","es","fr","ja","ko","zh"};
public String[] countries = new String[]{"DE","US","ES","FR","JP","KR","CN"};
@@ -97,6 +107,28 @@ public class _XCharacterClassification extends MultiMethodTest {
"U_CJK_COMPATIBILITY_FORMS","U_SMALL_FORM_VARIANTS","U_ARABIC_PRESENTATION_FORMS_B",
"U_SPECIALS","U_HALFWIDTH_AND_FULLWIDTH_FORMS","U_CHAR_SCRIPT_COUNT","U_NO_SCRIPT"};
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ app.start();
+ }
+
+ @AfterClass
+ public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
+ {
+ app.close();
+ }
+
+ @Before
+ public void before() throws Exception {
+ xContext = app.getComponentContext();
+ oObj = UnoRuntime.queryInterface(
+ XCharacterClassification.class,
+ xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.CharacterClassification", xContext)
+ );
+ }
+
/**
* Test calls the method for different locales. Then each result is compared
* with a string, converted to a upper case using
@@ -104,6 +136,7 @@ public class _XCharacterClassification extends MultiMethodTest {
* Has <b> OK </b> status if string, returned by the method is equal to
* a string that is returned by String.toUpperCase() for all locales.
*/
+ @Test
public void _toUpper() {
boolean res = true;
char[] characters = new char[]{586,65,97,498,721,4588,772,8413,3404};
@@ -117,13 +150,13 @@ public class _XCharacterClassification extends MultiMethodTest {
new java.util.Locale(languages[i], countries[i]));
res &= get.equals(exp);
if (!res) {
- log.println("FAILED for: language=" + languages[i] +
+ System.out.println("FAILED for: language=" + languages[i] +
" ; country=" + countries[i]);
- log.println("Expected: " + exp);
- log.println("Gained : " + get);
+ System.out.println("Expected: " + exp);
+ System.out.println("Gained : " + get);
}
}
- tRes.tested("toUpper()", res);
+ Assert.assertTrue("toUpper()", res);
}
/**
@@ -133,6 +166,7 @@ public class _XCharacterClassification extends MultiMethodTest {
* Has <b> OK </b> status if string, returned by the method is equal to
* a string that is returned by String.toLowerCase() for all locales.
*/
+ @Test
public void _toLower() {
boolean res = true;
char[] characters = new char[]{586,65,97,498,721,4588,772,8413,3404};
@@ -146,13 +180,13 @@ public class _XCharacterClassification extends MultiMethodTest {
new java.util.Locale(languages[i],countries[i]));
res &= get.equals(exp);
if (!res) {
- log.println("FAILED for: language=" + languages[i]
+ System.out.println("FAILED for: language=" + languages[i]
+ " ; country=" + countries[i]);
- log.println("Expected: " + exp);
- log.println("Gained : " + get);
+ System.out.println("Expected: " + exp);
+ System.out.println("Gained : " + get);
}
}
- tRes.tested("toLower()", res);
+ Assert.assertTrue("toLower()", res);
}
/**
@@ -162,6 +196,7 @@ public class _XCharacterClassification extends MultiMethodTest {
* Has <b> OK </b> status if string, returned by the method is equal to
* a string that was converted using Character.toTitleCase() for all locales.
*/
+ @Test
public void _toTitle() {
boolean res = true;
String toCheck = new String(new char[]{8112});
@@ -174,13 +209,13 @@ public class _XCharacterClassification extends MultiMethodTest {
new char[]{Character.toTitleCase(toCheck.toCharArray()[0])});
res &= get.equals(exp);
if (!res) {
- log.println("FAILED for: language=" + languages[i]
+ System.out.println("FAILED for: language=" + languages[i]
+ " ; country=" + countries[i]);
- log.println("Expected: " + exp);
- log.println("Gained : " + get);
+ System.out.println("Expected: " + exp);
+ System.out.println("Gained : " + get);
}
}
- tRes.tested("toTitle()", res);
+ Assert.assertTrue("toTitle()", res);
}
/**
@@ -192,6 +227,7 @@ public class _XCharacterClassification extends MultiMethodTest {
* is equal to an element number.<p>
* @see com.sun.star.i18n.CharType
*/
+ @Test
public void _getType() {
boolean res = true;
char[] characters = new char[]{586,65,97,498,721,4588,772,8413,3404,
@@ -206,12 +242,12 @@ public class _XCharacterClassification extends MultiMethodTest {
int get = oObj.getType(toCheck, i);
res &= (charstyles_office[get] == charstyles_office[i]);
if (!res) {
- log.println("Code :" + Integer.toHexString(charsInt[i]));
- log.println("Gained: " + charstyles_office[get]);
- log.println("Expected : " + charstyles_office[i]);
+ System.out.println("Code :" + Integer.toHexString(charsInt[i]));
+ System.out.println("Gained: " + charstyles_office[get]);
+ System.out.println("Expected : " + charstyles_office[i]);
}
}
- tRes.tested("getType()", res);
+ Assert.assertTrue("getType()", res);
}
/**
@@ -220,6 +256,7 @@ public class _XCharacterClassification extends MultiMethodTest {
* Has <b> OK </b> status if the method returns type, expected for a given
* character and locale.
*/
+ @Test
public void _getCharacterType() {
boolean res = true;
String toCheck = "Ab0)";
@@ -230,15 +267,15 @@ public class _XCharacterClassification extends MultiMethodTest {
int get = oObj.getCharacterType(toCheck, i, getLocale(j));
res &= (get == expected[i]);
if (!res) {
- log.println("FAILED for: language=" + languages[j] +
+ System.out.println("FAILED for: language=" + languages[j] +
" ; country=" + countries[j]);
- log.println("Sysmbol :" + toCheck.toCharArray()[i]);
- log.println("Gained: " + get);
- log.println("Expected : " + expected[i]);
+ System.out.println("Sysmbol :" + toCheck.toCharArray()[i]);
+ System.out.println("Gained: " + get);
+ System.out.println("Expected : " + expected[i]);
}
}
}
- tRes.tested("getCharacterType()", res);
+ Assert.assertTrue("getCharacterType()", res);
}
/**
@@ -247,6 +284,7 @@ public class _XCharacterClassification extends MultiMethodTest {
* Has <b> OK </b> status if the method returns type, expected for a given
* string and locale.
*/
+ @Test
public void _getStringType() {
boolean res = true;
String[] toCheck = new String[]{"01234","AAAAA","bbbbb","AA()bb"};
@@ -258,14 +296,14 @@ public class _XCharacterClassification extends MultiMethodTest {
toCheck[j].length(), getLocale(i));
res &= (get == exp[j]);
if (!res) {
- log.println("FAILED for: language=" + languages[i] +
+ System.out.println("FAILED for: language=" + languages[i] +
" ; country=" + countries[i]);
- log.println("Expected: " + exp[j]);
- log.println("Gained : " + get);
+ System.out.println("Expected: " + exp[j]);
+ System.out.println("Gained : " + get);
}
}
}
- tRes.tested("getStringType()", res);
+ Assert.assertTrue("getStringType()", res);
}
/**
@@ -276,6 +314,7 @@ public class _XCharacterClassification extends MultiMethodTest {
* Has <b> OK </b> status if the method returns direction, that's equal to
* a symbol position in the string.
*/
+ @Test
public void _getCharacterDirection() {
boolean res = true;
String toCheck = new String(new char[]{65,1470,48,47,35,1632,44,10,
@@ -284,12 +323,12 @@ public class _XCharacterClassification extends MultiMethodTest {
short get = oObj.getCharacterDirection(toCheck, i);
res &= (get == i);
if (!res) {
- log.println("Code :" + toCheck.toCharArray()[i]);
- log.println("Gained: " + get);
- log.println("Expected: " + i);
+ System.out.println("Code :" + toCheck.toCharArray()[i]);
+ System.out.println("Gained: " + get);
+ System.out.println("Expected: " + i);
}
}
- tRes.tested("getCharacterDirection()", res);
+ Assert.assertTrue("getCharacterDirection()", res);
}
/**
@@ -303,6 +342,7 @@ public class _XCharacterClassification extends MultiMethodTest {
* since it hasn't the right neighborhood.<p>
* @see "http://ppewww.ph.gla.ac.uk/~flavell/unicode/unidata.html"
*/
+ @Test
public void _getScript() {
boolean res = true;
char[] characters = new char[]{65,128,256,384,592,750,773,924,1030,1331,1448,
@@ -328,13 +368,13 @@ public class _XCharacterClassification extends MultiMethodTest {
//neighborhood
if (toCheck.substring(i, i + 1).hashCode() == 55296) res = true;
if (!res) {
- log.println("-- " + toCheck.substring(i, i + 1).hashCode());
- log.println("Code: " + Integer.toHexString(charsInt[i]));
- log.println("Gained: " + unicode_script[get]);
- log.println("Expected: " + unicode_script[i]);
+ System.out.println("-- " + toCheck.substring(i, i + 1).hashCode());
+ System.out.println("Code: " + Integer.toHexString(charsInt[i]));
+ System.out.println("Gained: " + unicode_script[get]);
+ System.out.println("Expected: " + unicode_script[i]);
}
}
- tRes.tested("getScript()", res);
+ Assert.assertTrue("getScript()", res);
}
/**
@@ -344,6 +384,7 @@ public class _XCharacterClassification extends MultiMethodTest {
* Has <b> OK </b> status if the method returns right results all three
* times.
*/
+ @Test
public void _parseAnyToken() {
int nStartFlags = KParseTokens.ANY_ALPHA | KParseTokens.ASC_UNDERSCORE;
int nContFlags = KParseTokens.ANY_ALNUM | KParseTokens.ASC_UNDERSCORE
@@ -369,7 +410,7 @@ public class _XCharacterClassification extends MultiMethodTest {
&& (pRes.TokenType==1)
&& (pRes.Value==0.0) );
}
- tRes.tested("parseAnyToken()", res);
+ Assert.assertTrue("parseAnyToken()", res);
}
/**
@@ -378,6 +419,7 @@ public class _XCharacterClassification extends MultiMethodTest {
* checking result after every call. <p>
* Has <b> OK </b> status if the method returns right results.
*/
+ @Test
public void _parsePredefinedToken() {
int nStartFlags = KParseTokens.ANY_ALPHA | KParseTokens.ASC_UNDERSCORE;
int nContFlags = nStartFlags;
@@ -395,7 +437,7 @@ public class _XCharacterClassification extends MultiMethodTest {
&& (pRes.TokenType==4)
&& (pRes.Value==0.0) );
}
- tRes.tested("parsePredefinedToken()", res);
+ Assert.assertTrue("parsePredefinedToken()", res);
}
diff --git a/test/testuno/source/api/i18n/XCollatorTest.java b/test/testuno/source/api/i18n/XCollatorTest.java
index dbeea9ee6f..8e82411513 100644
--- a/test/testuno/source/api/i18n/XCollatorTest.java
+++ b/test/testuno/source/api/i18n/XCollatorTest.java
@@ -21,15 +21,21 @@
-package ifc.i18n;
+package api.i18n;
import java.text.Collator;
-import lib.MultiMethodTest;
-
import com.sun.star.i18n.CollatorOptions;
import com.sun.star.i18n.XCollator;
import com.sun.star.lang.Locale;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openoffice.test.uno.UnoApp;
/**
* Testing <code>com.sun.star.i18n.XCollator</code>
@@ -46,26 +52,52 @@ import com.sun.star.lang.Locale;
* Test is <b> NOT </b> multithread compliant. <p>
* @see com.sun.star.i18n.XCollator
*/
-public class _XCollator extends MultiMethodTest {
- public XCollator oObj = null;
+public class XCollatorTest {
+ private static final UnoApp app = new UnoApp();
+
+ private XComponentContext xContext = null;
+ private XCollator oObj = null;
private String[] alg = null ;
private int[] opt = null ;
Locale loc = new Locale("en", "EN", "");
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ app.start();
+ }
+
+ @AfterClass
+ public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
+ {
+ app.close();
+ }
+
+ @Before
+ public void before() throws Exception, java.lang.Exception
+ {
+ xContext = app.getComponentContext();
+ final Object object = xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.Collator", xContext);
+ oObj = UnoRuntime.queryInterface(XCollator.class, object);
+ alg = oObj.listCollatorAlgorithms(loc);
+ }
+
/**
* Just retrieves a list of algorithms. <p>
* Has <b>OK</b> status if non-zero length array returned.
*/
+ @Test
public void _listCollatorAlgorithms() {
- alg = oObj.listCollatorAlgorithms(loc) ;
- log.println("Collator algorithms :");
- if (alg != null) {
+ String[] algorithms = oObj.listCollatorAlgorithms(loc) ;
+ System.out.println("Collator algorithms :");
+ if (algorithms != null) {
for (int i = 0; i < alg.length; i++) {
- log.println(" '" + alg[i] + "'") ;
+ System.out.println(" '" + algorithms[i] + "'") ;
}
- tRes.tested("listCollatorAlgorithms()", alg.length > 0) ;
+ Assert.assertTrue("listCollatorAlgorithms()", algorithms.length > 0) ;
} else {
- tRes.tested("listCollatorAlgorithms()", false) ;
+ Assert.fail("listCollatorAlgorithms()");
}
}
@@ -78,17 +110,17 @@ public class _XCollator extends MultiMethodTest {
* algorithm name. </li>
* </ul>
*/
+ @Test
public void _listCollatorOptions() {
- requiredMethod("listCollatorAlgorithms()") ;
opt = oObj.listCollatorOptions(alg[0]) ;
- log.println("Collator '" + alg[0] + "' options :");
+ System.out.println("Collator '" + alg[0] + "' options :");
if (opt != null) {
for (int i = 0; i < opt.length; i++) {
- log.println(" " + opt[i]) ;
+ System.out.println(" " + opt[i]) ;
}
- tRes.tested("listCollatorOptions()", true) ;
+ Assert.assertTrue("listCollatorOptions()", true) ;
} else {
- tRes.tested("listCollatorOptions()", false) ;
+ Assert.fail("listCollatorOptions()") ;
}
}
@@ -97,13 +129,14 @@ public class _XCollator extends MultiMethodTest {
* compares strings.<p>
* Has <b>OK</b> status if compareString() returned correct values.
*/
+ @Test
public void _loadDefaultCollator() {
oObj.loadDefaultCollator(loc, 0);
boolean res = oObj.compareString("A", "a") != 0;
oObj.loadDefaultCollator(loc,
CollatorOptions.CollatorOptions_IGNORE_CASE);
res &= oObj.compareString("a", "A") == 0;
- tRes.tested("loadDefaultCollator()", res) ;
+ Assert.assertTrue("loadDefaultCollator()", res) ;
}
/**
@@ -116,14 +149,14 @@ public class _XCollator extends MultiMethodTest {
* algorithm name. </li>
* </ul>
*/
+ @Test
public void _loadCollatorAlgorithm() {
- requiredMethod("listCollatorAlgorithms()");
oObj.loadCollatorAlgorithm(alg[0], loc,
CollatorOptions.CollatorOptions_IGNORE_CASE);
boolean res = oObj.compareString("A", "a") == 0;
oObj.loadCollatorAlgorithm(alg[0], loc, 0);
res &= oObj.compareString("a", "A") != 0;
- tRes.tested("loadCollatorAlgorithm()", res);
+ Assert.assertTrue("loadCollatorAlgorithm()", res);
}
/**
@@ -136,15 +169,15 @@ public class _XCollator extends MultiMethodTest {
* algorithm name. </li>
* </ul>
*/
+ @Test
public void _loadCollatorAlgorithmWithEndUserOption() {
- requiredMethod("listCollatorAlgorithms()");
oObj.loadCollatorAlgorithmWithEndUserOption(alg[0], loc,
new int[] {0});
boolean res = oObj.compareString("A", "a") != 0;
oObj.loadCollatorAlgorithmWithEndUserOption(alg[0], loc,
new int[] {CollatorOptions.CollatorOptions_IGNORE_CASE});
res = oObj.compareString("A", "a") == 0;
- tRes.tested("loadCollatorAlgorithmWithEndUserOption()", res);
+ Assert.assertTrue("loadCollatorAlgorithmWithEndUserOption()", res);
}
/**
@@ -158,12 +191,13 @@ public class _XCollator extends MultiMethodTest {
* of two equal strings returns 0. The such comparing is performed
* for one character strings.
*/
+ @Test
public void _compareSubstring() {
boolean result = true ;
char[] chars = new char[2] ;
Collator col = null ;
- log.println(" #### Testing English locale ####") ;
+ System.out.println(" #### Testing English locale ####") ;
oObj.loadDefaultCollator(loc, 0) ;
col = Collator.getInstance(new java.util.Locale("en", "EN")) ;
for (char ch = 0x0020; ch < 0x007F; ch ++) {
@@ -171,7 +205,7 @@ public class _XCollator extends MultiMethodTest {
result &= testCompareSubstring(chars, col) ;
}
- log.println(" #### Testing Russian locale ####") ;
+ System.out.println(" #### Testing Russian locale ####") ;
oObj.loadDefaultCollator(
new com.sun.star.lang.Locale("ru", "RU", ""), 0) ;
col = Collator.getInstance(new java.util.Locale("ru", "RU")) ;
@@ -180,7 +214,7 @@ public class _XCollator extends MultiMethodTest {
result &= testCompareSubstring(chars, col) ;
}
- log.println(" #### Testing Japan locale ####") ;
+ System.out.println(" #### Testing Japan locale ####") ;
oObj.loadDefaultCollator(
new com.sun.star.lang.Locale("ja", "JP", ""), 0) ;
col = Collator.getInstance(new java.util.Locale("ja", "JP")) ;
@@ -189,7 +223,7 @@ public class _XCollator extends MultiMethodTest {
result &= testCompareSubstring(chars, col) ;
}
- log.println(" #### Testing China locale ####") ;
+ System.out.println(" #### Testing China locale ####") ;
oObj.loadDefaultCollator(new Locale("zh", "CN", ""), 0) ;
col = Collator.getInstance(new java.util.Locale("zh", "CN")) ;
for (char ch = 0x4E00; ch < 0x4EFD; ch ++) {
@@ -197,7 +231,7 @@ public class _XCollator extends MultiMethodTest {
result &= testCompareSubstring(chars, col) ;
}
- log.println(" #### Testing Korean locale ####") ;
+ System.out.println(" #### Testing Korean locale ####") ;
oObj.loadDefaultCollator(new Locale("ko", "KR", ""), 0) ;
col = Collator.getInstance(new java.util.Locale("ko", "KR")) ;
for (char ch = 0x4E00; ch < 0x4EFD; ch ++) {
@@ -205,7 +239,7 @@ public class _XCollator extends MultiMethodTest {
result &= testCompareSubstring(chars, col) ;
}
- tRes.tested("compareSubstring()", result) ;
+ Assert.assertTrue("compareSubstring()", result) ;
}
/**
@@ -219,11 +253,12 @@ public class _XCollator extends MultiMethodTest {
* of two equal strings returns 0. The such comparing is performed
* for one character strings.
*/
+ @Test
public void _compareString() {
boolean result = true ;
char[] chars = new char[2] ;
Collator col = null ;
- log.println(" #### Testing English locale ####") ;
+ System.out.println(" #### Testing English locale ####") ;
oObj.loadDefaultCollator(
new com.sun.star.lang.Locale("en", "EN", ""), 0) ;
col = Collator.getInstance(new java.util.Locale("en", "EN")) ;
@@ -232,7 +267,7 @@ public class _XCollator extends MultiMethodTest {
result &= testCompareString(chars, col) ;
}
- log.println(" #### Testing Russian locale ####") ;
+ System.out.println(" #### Testing Russian locale ####") ;
oObj.loadDefaultCollator(
new com.sun.star.lang.Locale("ru", "RU", ""), 0) ;
col = Collator.getInstance(new java.util.Locale("ru", "RU")) ;
@@ -241,7 +276,7 @@ public class _XCollator extends MultiMethodTest {
result &= testCompareString(chars, col) ;
}
- log.println(" #### Testing Japan locale ####") ;
+ System.out.println(" #### Testing Japan locale ####") ;
oObj.loadDefaultCollator(
new com.sun.star.lang.Locale("ja", "JP", ""), 0) ;
col = Collator.getInstance(new java.util.Locale("ja", "JP")) ;
@@ -250,7 +285,7 @@ public class _XCollator extends MultiMethodTest {
result &= testCompareString(chars, col) ;
}
- log.println(" #### Testing China locale ####") ;
+ System.out.println(" #### Testing China locale ####") ;
oObj.loadDefaultCollator(new Locale("zh", "CN", ""), 0) ;
col = Collator.getInstance(new java.util.Locale("zh", "CN")) ;
for (char ch = 0x4E00; ch < 0x4EFD; ch ++) {
@@ -258,7 +293,7 @@ public class _XCollator extends MultiMethodTest {
result &= testCompareString(chars, col) ;
}
- log.println(" #### Testing Korean locale ####") ;
+ System.out.println(" #### Testing Korean locale ####") ;
oObj.loadDefaultCollator(new Locale("ko", "KR", ""), 0) ;
col = Collator.getInstance(new java.util.Locale("ko", "KR")) ;
for (char ch = 0x4E00; ch < 0x4EFD; ch ++) {
@@ -266,10 +301,9 @@ public class _XCollator extends MultiMethodTest {
result &= testCompareString(chars, col) ;
}
- tRes.tested("compareString()", result) ;
+ Assert.assertTrue("compareString()", result) ;
}
-
/**
* Testing compareString() method. At first method is testing single chars
* comparing, then strings comparing.
@@ -347,12 +381,11 @@ public class _XCollator extends MultiMethodTest {
}
if (!result) {
- log.println(msg) ;
+ System.out.println(msg) ;
}
return result ;
}
-
/**
* Testing compareSubstring() method. Method is testing substrings comparing.
* @param locChar sequence of at list two characters of a given locale
@@ -402,12 +435,11 @@ public class _XCollator extends MultiMethodTest {
}
if (!result) {
- log.println(msg) ;
+ System.out.println(msg) ;
}
return result ;
}
-
/**
* Transforms string to unicode hex codes.
* @param str String to be transformed
diff --git a/test/testuno/source/api/i18n/XExtendedCalendarTest.java b/test/testuno/source/api/i18n/XExtendedCalendarTest.java
index 34f5b56603..bb9f24f482 100644
--- a/test/testuno/source/api/i18n/XExtendedCalendarTest.java
+++ b/test/testuno/source/api/i18n/XExtendedCalendarTest.java
@@ -20,7 +20,7 @@
*************************************************************/
-package ifc.i18n;
+package api.i18n;
import com.sun.star.i18n.CalendarDisplayCode;
import com.sun.star.i18n.NativeNumberMode;
@@ -29,32 +29,59 @@ import com.sun.star.i18n.XLocaleData;
import com.sun.star.lang.Locale;
import com.sun.star.lang.XMultiServiceFactory;
import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
-import lib.MultiMethodTest;
+import org.openoffice.test.uno.UnoApp;
+
/**
*
*/
-public class _XExtendedCalendar extends MultiMethodTest {
+public class XExtendedCalendarTest {
+ private static final UnoApp app = new UnoApp();
+
+ private XComponentContext xContext = null;
public XExtendedCalendar oObj = null;
boolean useUSENLocale = false;
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ app.start();
+ }
+
+ @AfterClass
+ public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
+ {
+ app.close();
+ }
+
/**
* Load a calendar
*/
- public void before() {
+ @Before
+ public void before() throws Exception {
+ xContext = app.getComponentContext();
Locale[] installed_locales = null;
XLocaleData locData = null;
- try {
- locData = (XLocaleData) UnoRuntime.queryInterface(
- XLocaleData.class,
- ((XMultiServiceFactory)tParam.getMSF()).createInstance(
- "com.sun.star.i18n.LocaleData"));
- } catch (com.sun.star.uno.Exception e) {
-
- }
+ locData = UnoRuntime.queryInterface(
+ XLocaleData.class,
+ xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.LocaleData", xContext)
+ );
+ oObj = UnoRuntime.queryInterface(
+ XExtendedCalendar.class,
+ xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.LocaleCalendar", xContext)
+ );
installed_locales = locData.getAllInstalledLocaleNames();
// use first Locale as fallback, if US-English is not found
Locale lo = installed_locales[0];
@@ -66,11 +93,11 @@ public class _XExtendedCalendar extends MultiMethodTest {
useUSENLocale = true;
}
}
- log.println("Choose Locale: '" + lo.Language + "', '" + lo.Country + "'");
+ System.out.println("Choose Locale: '" + lo.Language + "', '" + lo.Country + "'");
oObj.loadDefaultCalendar(lo);
}
-
+ @Test
public void _getDisplayString() {
// against regression: the current state is the right one.
boolean result = true;
@@ -113,18 +140,18 @@ public class _XExtendedCalendar extends MultiMethodTest {
if (useUSENLocale) {
locResult = displayString[i].equals(expectedStringResult[i]);
if (!locResult)
- log.println("getDisplayString() result " + i + ": '" + displayString[i]
+ System.out.println("getDisplayString() result " + i + ": '" + displayString[i]
+ "', expected: '" + expectedStringResult[i] + "'");
result &= locResult;
}
else { // no defaults for other locales, just expect a String
locResult &= displayString[i] != null;
if (!locResult)
- log.println("getDisplayString() result " + i + " was 'null'");
+ System.out.println("getDisplayString() result " + i + " was 'null'");
result &= locResult;
}
}
- tRes.tested("getDisplayString()", result);
+ Assert.assertTrue("getDisplayString()", result);
}
private SimpleDateFormat getSDF(String format){
diff --git a/test/testuno/source/api/i18n/XExtendedIndexEntrySupplierTest.java b/test/testuno/source/api/i18n/XExtendedIndexEntrySupplierTest.java
index 40214c846a..a55cc561d0 100644
--- a/test/testuno/source/api/i18n/XExtendedIndexEntrySupplierTest.java
+++ b/test/testuno/source/api/i18n/XExtendedIndexEntrySupplierTest.java
@@ -20,24 +20,58 @@
*************************************************************/
-package ifc.i18n;
+package api.i18n;
import com.sun.star.i18n.CollatorOptions;
import com.sun.star.i18n.XExtendedIndexEntrySupplier;
import com.sun.star.lang.Locale;
-
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openoffice.test.uno.UnoApp;
import java.util.HashMap;
-import lib.MultiMethodTest;
+public class XExtendedIndexEntrySupplierTest {
+ private static final UnoApp app = new UnoApp();
-public class _XExtendedIndexEntrySupplier extends MultiMethodTest {
+ private XComponentContext xContext = null;
public XExtendedIndexEntrySupplier oObj;
protected Locale[] locales = null;
- protected HashMap algorithms = new HashMap();
+ protected HashMap<Integer,String[]> algorithms = new HashMap<Integer,String[]>();
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ app.start();
+ }
+ @AfterClass
+ public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
+ {
+ app.close();
+ }
+
+ @Before
+ public void before() throws Exception {
+ xContext = app.getComponentContext();
+ oObj = UnoRuntime.queryInterface(
+ XExtendedIndexEntrySupplier.class,
+ xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.IndexEntrySupplier", xContext)
+ );
+ locales = oObj.getLocaleList();
+ algorithms = getAlgorithmList();
+ }
+
+ @Test
public void _compareIndexEntry() {
- requiredMethod("getIndexKey()");
+ getIndexKey();
Locale locale = new Locale("zh", "CN", "");
String val1 = new String(new char[]{UnicodeStringPair.getUnicodeValue(0), UnicodeStringPair.getUnicodeValue(1)});
String val2 = new String(new char[]{UnicodeStringPair.getUnicodeValue(1), UnicodeStringPair.getUnicodeValue(0)});
@@ -45,22 +79,21 @@ public class _XExtendedIndexEntrySupplier extends MultiMethodTest {
short result2 = oObj.compareIndexEntry(val1, "", locale, val2, "", locale);
short result3 = oObj.compareIndexEntry(val2, "", locale, val1, "", locale);
- tRes.tested("compareIndexEntry()", result1 == 0 && result2 + result3 == 0);
+ Assert.assertTrue("compareIndexEntry()", result1 == 0 && result2 + result3 == 0);
}
/*
* gets the list of all algorithms for each listed language
* is OK if everyone of the returned lists are filled
*/
+ @Test
public void _getAlgorithmList() {
- requiredMethod("getLocaleList()");
-
+ HashMap<Integer, String[]> algorithms = getAlgorithmList();
boolean result = true;
boolean locResult = false;
for (int i = 0; i < locales.length; i++) {
- String[] algNames = oObj.getAlgorithmList(locales[i]);
- algorithms.put(new Integer(i), algNames);
+ String[] algNames = algorithms.get(i);
locResult = algNames != null && algNames.length > 0;
System.out.println("Locale " + i + ": " + locales[i].Country+","+locales[i].Language);
@@ -70,52 +103,65 @@ public class _XExtendedIndexEntrySupplier extends MultiMethodTest {
}
if (!locResult) {
- log.println("No Algorithm found for " + locales[i].Country +
+ System.out.println("No Algorithm found for " + locales[i].Country +
"," + locales[i].Language);
}
result &= locResult;
}
- tRes.tested("getAlgorithmList()", result);
+ Assert.assertTrue("getAlgorithmList()", result);
+ }
+
+ private HashMap<Integer, String[]> getAlgorithmList() {
+ HashMap<Integer, String[]> algorithms = new HashMap<Integer, String[]>();
+ for (int i = 0; i < locales.length; i++) {
+ String[] algNames = oObj.getAlgorithmList(locales[i]);
+ algorithms.put(i, algNames);
+ }
+ return algorithms;
}
+ @Test
public void _getIndexKey() {
- requiredMethod("loadAlgorithm()");
+ Assert.assertTrue("getIndexKey()", getIndexKey());
+ }
+
+ private boolean getIndexKey() {
char[] characters = new char[] { 19968 };
String getIndexFor = new String(characters);
for (int i = 0; i < locales.length; i++) {
- log.println("Language: " + locales[i].Language);
+ System.out.println("Language: " + locales[i].Language);
for (int j = 0; j < algorithms.size(); j++) {
String[] algs = (String[])algorithms.get(new Integer(j));
for (int k=0;k<algs.length;k++) {
- log.println("\t Algorithm :" +
+ System.out.println("\t Algorithm :" +
algs[k]);
oObj.loadAlgorithm(locales[i], algs[k], CollatorOptions.CollatorOptions_IGNORE_CASE);
- log.println("\t\t Get: " +
+ System.out.println("\t\t Get: " +
oObj.getIndexKey(getIndexFor, "", locales[i]));
}
}
}
- tRes.tested("getIndexKey()", true);
+ return true;
}
/*
* gets a list of all locales, is OK if this list isn't empty
*/
+ @Test
public void _getLocaleList() {
- locales = oObj.getLocaleList();
- tRes.tested("getLocaleList()", locales.length > 0);
+ // they were fetched in before()
+ Assert.assertTrue("getLocaleList()", locales.length > 0);
}
/*
* gets one phonetic candidate for the chinese local
* is ok if 'yi' is returned as expected.
*/
+ @Test
public void _getPhoneticCandidate() {
- requiredMethod("getLocaleList()");
-
boolean res = true;
Locale loc = new Locale("zh", "CN", "");
@@ -129,14 +175,14 @@ public class _XExtendedIndexEntrySupplier extends MultiMethodTest {
boolean locResult = getting.equals(UnicodeStringPair.getExpectedPhoneticString(i));
if (!locResult) {
- log.println("Char: "+ c[0] + " (" + (int)c[0] + ")");
- log.println("Expected " + UnicodeStringPair.getExpectedPhoneticString(i));
- log.println("Getting " + getting);
+ System.out.println("Char: "+ c[0] + " (" + (int)c[0] + ")");
+ System.out.println("Expected " + UnicodeStringPair.getExpectedPhoneticString(i));
+ System.out.println("Getting " + getting);
}
res &= locResult;
- }
- tRes.tested("getPhoneticCandidate()", res);
+ }
+ Assert.assertTrue("getPhoneticCandidate()", res);
}
/*
@@ -144,55 +190,53 @@ public class _XExtendedIndexEntrySupplier extends MultiMethodTest {
* Is OK if no exception occurs and the method returns
* true for each valid algorithm and false otherwise
*/
+ @Test
public void _loadAlgorithm() {
- requiredMethod("getAlgorithmList()");
-
boolean res = true;
for (int i = 0; i < algorithms.size(); i++) {
String[] names = (String[]) algorithms.get(new Integer(i));
- log.println("loading algorithms for " + locales[i].Country +
+ System.out.println("loading algorithms for " + locales[i].Country +
"," + locales[i].Language);
for (int j = 0; j < names.length; j++) {
- log.println("\t Loading " + names[j]);
+ System.out.println("\t Loading " + names[j]);
boolean localres = oObj.loadAlgorithm(locales[i], names[j],
CollatorOptions.CollatorOptions_IGNORE_CASE);
if (!localres) {
- log.println("\t ... didn't work - FAILED");
+ System.out.println("\t ... didn't work - FAILED");
} else {
- log.println("\t ... worked - OK");
+ System.out.println("\t ... worked - OK");
}
res &= localres;
}
-/* log.println("\tTrying to load 'dummy' algorithm");
+/* System.out.println("\tTrying to load 'dummy' algorithm");
boolean localres = !oObj.loadAlgorithm(locales[i], "dummy",
CollatorOptions.CollatorOptions_IGNORE_WIDTH);
if (!localres) {
- log.println("\t ... didn't work as expected - FAILED");
+ System.out.println("\t ... didn't work as expected - FAILED");
} else {
- log.println("\t ... worked - OK");
+ System.out.println("\t ... worked - OK");
}
res &= localres;*/
}
- tRes.tested("loadAlgorithm()", res);
+ Assert.assertTrue("loadAlgorithm()", res);
}
/*
* checks the method usePhoneticEntry(). Only the languages ja, ko and zh
* should return true. Has OK state if exactly this is the case.
*/
+ @Test
public void _usePhoneticEntry() {
- requiredMethod("getLocaleList()");
-
boolean res = true;
for (int i = 0; i < locales.length; i++) {
@@ -207,15 +251,15 @@ public class _XExtendedIndexEntrySupplier extends MultiMethodTest {
boolean locResult = oObj.usePhoneticEntry(locales[i]) == expected;
if (!locResult) {
- log.println("Failure for language " + locales[i].Language);
- log.println("Expected " + expected);
- log.println("Getting " + oObj.usePhoneticEntry(locales[i]));
+ System.out.println("Failure for language " + locales[i].Language);
+ System.out.println("Expected " + expected);
+ System.out.println("Getting " + oObj.usePhoneticEntry(locales[i]));
}
res &= locResult;
}
- tRes.tested("usePhoneticEntry()", res);
+ Assert.assertTrue("usePhoneticEntry()", res);
}
/**
diff --git a/test/testuno/source/api/i18n/XExtendedTransliterationTest.java b/test/testuno/source/api/i18n/XExtendedTransliterationTest.java
index 8c023a2da0..200996c928 100644
--- a/test/testuno/source/api/i18n/XExtendedTransliterationTest.java
+++ b/test/testuno/source/api/i18n/XExtendedTransliterationTest.java
@@ -20,28 +20,59 @@
*************************************************************/
-package ifc.i18n;
+package api.i18n;
import com.sun.star.i18n.TransliterationModules;
import com.sun.star.i18n.XExtendedTransliteration;
import com.sun.star.lang.Locale;
-import lib.MultiMethodTest;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openoffice.test.uno.UnoApp;
/**
*
*/
-public class _XExtendedTransliteration extends MultiMethodTest {
+public class XExtendedTransliterationTest {
+ private static final UnoApp app = new UnoApp();
+
+ private XComponentContext xContext = null;
public XExtendedTransliteration oObj = null;
// private Locale loc = new Locale("ja", "JP", "") ;
private Locale loc = new Locale("en", "US", "") ;
-
- public void before() {
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ app.start();
+ }
+
+ @AfterClass
+ public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
+ {
+ app.close();
+ }
+
+ @Before
+ public void before() throws Exception {
+ xContext = app.getComponentContext();
+ oObj = UnoRuntime.queryInterface(
+ XExtendedTransliteration.class,
+ xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.Transliteration", xContext)
+ );
oObj.loadModule(TransliterationModules.LOWERCASE_UPPERCASE, loc);
}
/**
* Check lowercase - uppercase conversion of chars
*/
+ @Test
public void _transliterateChar2Char() {
boolean result = true;
char in = 'a';
@@ -54,9 +85,9 @@ public class _XExtendedTransliteration extends MultiMethodTest {
result &= out == '$';
}
catch(com.sun.star.i18n.MultipleCharsOutputException e) {
- e.printStackTrace((java.io.PrintWriter)log);
+ e.printStackTrace(System.out);
}
- tRes.tested("transliterateChar2Char()", result);
+ Assert.assertTrue("transliterateChar2Char()", result);
}
/**
@@ -71,7 +102,7 @@ public class _XExtendedTransliteration extends MultiMethodTest {
in = '$'; // should not be changed
out = oObj.transliterateChar2String(in) ;
result &= out.equals("$");
- tRes.tested("transliterateChar2String()", result);
+ Assert.assertTrue("transliterateChar2String()", result);
}
/**
@@ -86,6 +117,6 @@ public class _XExtendedTransliteration extends MultiMethodTest {
in = "$"; // should not be changed
out = oObj.transliterateString2String(in, 0, 1) ;
result &= out.equals("$");
- tRes.tested("transliterateString2String()", result);
+ Assert.assertTrue("transliterateString2String()", result);
}
}
diff --git a/test/testuno/source/api/i18n/XIndexEntrySupplierTest.java b/test/testuno/source/api/i18n/XIndexEntrySupplierTest.java
index 56d108668b..a12feb086c 100644
--- a/test/testuno/source/api/i18n/XIndexEntrySupplierTest.java
+++ b/test/testuno/source/api/i18n/XIndexEntrySupplierTest.java
@@ -21,12 +21,19 @@
-package ifc.i18n;
-
-import lib.MultiMethodTest;
+package api.i18n;
import com.sun.star.i18n.XIndexEntrySupplier;
import com.sun.star.lang.Locale;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openoffice.test.uno.UnoApp;
/**
* Testing <code>com.sun.star.i18n.XIndexEntrySupplier</code>
@@ -38,28 +45,54 @@ import com.sun.star.lang.Locale;
* Test is <b> NOT </b> multithread compliant. <p>
* @see com.sun.star.i18n.XIndexEntrySupplier
*/
-public class _XIndexEntrySupplier extends MultiMethodTest {
+public class XIndexEntrySupplierTest {
+ private static final UnoApp app = new UnoApp();
+
+ private XComponentContext xContext = null;
public XIndexEntrySupplier oObj = null;
public String[] languages = new String[]{"de","en","es","fr","ja","ko","zh"};
public String[] countries = new String[]{"DE","US","ES","FR","JP","KR","CN"};
public String[] onePage = new String[]{"f.","p."," s."," sv","p.","",""};
public String[] morePages = new String[]{"ff.","pp."," ss."," sv","pp.","",""};
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ app.start();
+ }
+
+ @AfterClass
+ public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
+ {
+ app.close();
+ }
+
+ @Before
+ public void before() throws Exception {
+ xContext = app.getComponentContext();
+ oObj = UnoRuntime.queryInterface(
+ XIndexEntrySupplier.class,
+ xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.IndexEntrySupplier", xContext)
+ );
+ }
+
/**
* Test calls the method, then result is checked. <p>
* Has <b> OK </b> status if the method returns right index for several
* locales and word.
*/
+ @Test
public void _getIndexCharacter() {
boolean res = true;
- log.println("getIndexCharacter('chapter', getLocale(i), '')");
+ System.out.println("getIndexCharacter('chapter', getLocale(i), '')");
for (int i=0; i<7; i++) {
- log.print("getIndexCharacter('chapter', " + countries[i] + ") :");
+ System.out.print("getIndexCharacter('chapter', " + countries[i] + ") :");
String get = oObj.getIndexCharacter("chapter", getLocale(i), "");
- log.println(get);
+ System.out.println(get);
res &= get.equals("C");
}
- tRes.tested("getIndexCharacter()", res);
+ Assert.assertTrue("getIndexCharacter()", res);
}
/**
@@ -67,26 +100,27 @@ public class _XIndexEntrySupplier extends MultiMethodTest {
* for several pages, after every call result is checked. <p>
* Has <b> OK </b> status if method returns right index for several locales.
*/
+ @Test
public void _getIndexFollowPageWord() {
boolean res = true;
for (int i=0; i<7; i++) {
String get = oObj.getIndexFollowPageWord(true, getLocale(i));
if (! get.equals(morePages[i]) ) {
- log.println("Language: " + languages[i]);
- log.println("Getting: #" + get + "#");
- log.println("Expected: #" + morePages[i] + "#");
+ System.out.println("Language: " + languages[i]);
+ System.out.println("Getting: #" + get + "#");
+ System.out.println("Expected: #" + morePages[i] + "#");
}
res &= get.equals(morePages[i]);
get = oObj.getIndexFollowPageWord(false,getLocale(i));
if (! get.equals(onePage[i]) ) {
- log.println("Language: " + languages[i]);
- log.println("Getting: #" + get + "#");
- log.println("Expected: #" + onePage[i] + "#");
+ System.out.println("Language: " + languages[i]);
+ System.out.println("Getting: #" + get + "#");
+ System.out.println("Expected: #" + onePage[i] + "#");
}
res &= get.equals(onePage[i]);
}
- tRes.tested("getIndexFollowPageWord()", res);
+ Assert.assertTrue("getIndexFollowPageWord()", res);
}
/**
diff --git a/test/testuno/source/api/i18n/XLocaleDataTest.java b/test/testuno/source/api/i18n/XLocaleDataTest.java
index 97e7c1e90b..641c9ab7ad 100644
--- a/test/testuno/source/api/i18n/XLocaleDataTest.java
+++ b/test/testuno/source/api/i18n/XLocaleDataTest.java
@@ -21,9 +21,7 @@
-package ifc.i18n;
-
-import lib.MultiMethodTest;
+package api.i18n;
import com.sun.star.i18n.Calendar;
import com.sun.star.i18n.Currency;
@@ -34,6 +32,14 @@ import com.sun.star.i18n.LanguageCountryInfo;
import com.sun.star.i18n.LocaleDataItem;
import com.sun.star.i18n.XLocaleData;
import com.sun.star.lang.Locale;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openoffice.test.uno.UnoApp;
/**
* Testing <code>com.sun.star.i18n.XLocaleData</code>
@@ -55,17 +61,41 @@ import com.sun.star.lang.Locale;
* Test is <b> NOT </b> multithread compliant. <p>
* @see com.sun.star.i18n.XLocaleData
*/
-public class _XLocaleData extends MultiMethodTest {
+public class XLocaleDataTest {
+ private static final UnoApp app = new UnoApp();
+
+ private XComponentContext xContext = null;
public XLocaleData oObj = null;
public String[] languages = new String[]{"de","en","es","fr","ja","ko","ko"};
public String[] countries = new String[]{"DE","US","ES","FR","JP","KR","KR"};
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ app.start();
+ }
+
+ @AfterClass
+ public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
+ {
+ app.close();
+ }
+
+ @Before
+ public void before() throws Exception, java.lang.Exception
+ {
+ xContext = app.getComponentContext();
+ final Object object = xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.LocaleData", xContext);
+ oObj = UnoRuntime.queryInterface(XLocaleData.class, object);
+ }
/**
* Test calls the method, then result is checked. <p>
* Has <b> OK </b> status if structure, returned by the method includes
* correct values of fields 'Language' and 'Country' for all given locales.
*/
+ @Test
public void _getLanguageCountryInfo() {
boolean res = true;
LanguageCountryInfo lci = null;
@@ -73,20 +103,20 @@ public class _XLocaleData extends MultiMethodTest {
for (int i=0;i<7;i++) {
lci = oObj.getLanguageCountryInfo(getLocale(i));
/* For debug purposes
- log.println("Using: language="+languages[i]+" ; country="+countries[i]);
- log.println("Getting: ");
- log.println("\t Language="+lci.Language);
- log.println("\t LanguageDefaultName="+lci.LanguageDefaultName);
- log.println("\t Country="+lci.Country);
- log.println("\t CountryDefaultName="+lci.CountryDefaultName);
+ System.out.println("Using: language="+languages[i]+" ; country="+countries[i]);
+ System.out.println("Getting: ");
+ System.out.println("\t Language="+lci.Language);
+ System.out.println("\t LanguageDefaultName="+lci.LanguageDefaultName);
+ System.out.println("\t Country="+lci.Country);
+ System.out.println("\t CountryDefaultName="+lci.CountryDefaultName);
boolean lang = ( lci.Language.equals(languages[i]) );
- if (!lang) log.println("getting false for language: "+lci.LanguageDefaultName);
+ if (!lang) System.out.println("getting false for language: "+lci.LanguageDefaultName);
lang = ( lci.Country.equals(countries[i]) );
- if (!lang) log.println("getting false for country: "+lci.CountryDefaultName);
+ if (!lang) System.out.println("getting false for country: "+lci.CountryDefaultName);
*/
res &= ( ( lci.Language.equals(languages[i]) ) && ( lci.Country.equals(countries[i]) ) );
}
- tRes.tested("getLanguageCountryInfo()",res);
+ Assert.assertTrue("getLanguageCountryInfo()",res);
}
/**
@@ -94,6 +124,7 @@ public class _XLocaleData extends MultiMethodTest {
* Has <b> OK </b> status if structure, returned by the method consists of
* non empty strings for all given locales.
*/
+ @Test
public void _getLocaleItem() {
boolean res = true;
LocaleDataItem ldi = null;
@@ -124,30 +155,30 @@ public class _XLocaleData extends MultiMethodTest {
if (!locRes) {
/* for debugging puposes
- log.println("FAILED for: language="+languages[i]+" ; country="+countries[i]);
- log.println("Getting: ");
- log.println("\t DateSeparator="+ldi.dateSeparator);
- log.println("\t decimalSeparator="+ldi.decimalSeparator);
- log.println("\t doubleQuotationEnd="+ldi.doubleQuotationEnd);
- log.println("\t doubleQuotationStart="+ldi.doubleQuotationStart);
- log.println("\t listSeparator="+ldi.listSeparator);
- log.println("\t LongDateDayOfWeekSeparator="+ldi.LongDateDayOfWeekSeparator+"end");
- log.println("\t LongDateDaySeparator="+ldi.LongDateDaySeparator+"end");
- log.println("\t LongDateMonthSeparator="+ldi.LongDateMonthSeparator+"end");
- log.println("\t LongDateYearSeparator="+ldi.LongDateYearSeparator+"end");
- log.println("\t measurementSystem="+ldi.measurementSystem);
- log.println("\t quotationEnd="+ldi.quotationEnd);
- log.println("\t quotationStart="+ldi.quotationStart);
- log.println("\t thousandSeparator="+ldi.thousandSeparator);
- log.println("\t time100SecSeparator="+ldi.time100SecSeparator);
- log.println("\t timeAM="+ldi.timeAM);
- log.println("\t timePM="+ldi.timePM);
- log.println("\t timeSeparator="+ldi.timeSeparator);
- log.println("\t unoID="+ldi.unoID);
+ System.out.println("FAILED for: language="+languages[i]+" ; country="+countries[i]);
+ System.out.println("Getting: ");
+ System.out.println("\t DateSeparator="+ldi.dateSeparator);
+ System.out.println("\t decimalSeparator="+ldi.decimalSeparator);
+ System.out.println("\t doubleQuotationEnd="+ldi.doubleQuotationEnd);
+ System.out.println("\t doubleQuotationStart="+ldi.doubleQuotationStart);
+ System.out.println("\t listSeparator="+ldi.listSeparator);
+ System.out.println("\t LongDateDayOfWeekSeparator="+ldi.LongDateDayOfWeekSeparator+"end");
+ System.out.println("\t LongDateDaySeparator="+ldi.LongDateDaySeparator+"end");
+ System.out.println("\t LongDateMonthSeparator="+ldi.LongDateMonthSeparator+"end");
+ System.out.println("\t LongDateYearSeparator="+ldi.LongDateYearSeparator+"end");
+ System.out.println("\t measurementSystem="+ldi.measurementSystem);
+ System.out.println("\t quotationEnd="+ldi.quotationEnd);
+ System.out.println("\t quotationStart="+ldi.quotationStart);
+ System.out.println("\t thousandSeparator="+ldi.thousandSeparator);
+ System.out.println("\t time100SecSeparator="+ldi.time100SecSeparator);
+ System.out.println("\t timeAM="+ldi.timeAM);
+ System.out.println("\t timePM="+ldi.timePM);
+ System.out.println("\t timeSeparator="+ldi.timeSeparator);
+ System.out.println("\t unoID="+ldi.unoID);
*/
}
}
- tRes.tested("getLocaleItem()",res);
+ Assert.assertTrue("getLocaleItem()",res);
}
/**
@@ -157,6 +188,7 @@ public class _XLocaleData extends MultiMethodTest {
* correct for all given locales. (boolean method goodCalendar() with a
* calendar as an argument returns true)
*/
+ @Test
public void _getAllCalendars() {
boolean res = true;
boolean printit = false;
@@ -170,10 +202,10 @@ public class _XLocaleData extends MultiMethodTest {
}
res &= goodCalendar(calendar[j]);
}
- if (printit) log.println("FAILED for: language="+languages[i]+" ; country="+countries[i]);
+ if (printit) System.out.println("FAILED for: language="+languages[i]+" ; country="+countries[i]);
printit = false;
}
- tRes.tested("getAllCalendars()", res);
+ Assert.assertTrue("getAllCalendars()", res);
}
/**
@@ -183,6 +215,7 @@ public class _XLocaleData extends MultiMethodTest {
* correct for all given locales. (boolean method goodCurrency() with a
* currency as an argument returns true)
*/
+ @Test
public void _getAllCurrencies() {
boolean res = true;
boolean printit = false;
@@ -196,10 +229,10 @@ public class _XLocaleData extends MultiMethodTest {
}
res &= goodCurrency(currency[j]);
}
- if (printit) log.println("FAILED for: language="+languages[i]+" ; country="+countries[i]);
+ if (printit) System.out.println("FAILED for: language="+languages[i]+" ; country="+countries[i]);
printit =false;
}
- tRes.tested("getAllCurrencies()",res);
+ Assert.assertTrue("getAllCurrencies()",res);
}
/**
@@ -209,6 +242,7 @@ public class _XLocaleData extends MultiMethodTest {
* correct for all given locales. (boolean method goodFormat() with a
* format as an argument returns true)
*/
+ @Test
public void _getAllFormats() {
boolean res = true;
boolean printit = false;
@@ -222,10 +256,10 @@ public class _XLocaleData extends MultiMethodTest {
}
res &= goodFormat(format[j]);
}
- if (printit) log.println("FAILED for: language="+languages[i]+" ; country="+countries[i]);
+ if (printit) System.out.println("FAILED for: language="+languages[i]+" ; country="+countries[i]);
printit =false;
}
- tRes.tested("getAllFormats()",res);
+ Assert.assertTrue("getAllFormats()",res);
}
/**
@@ -234,6 +268,7 @@ public class _XLocaleData extends MultiMethodTest {
* Has <b> OK </b> status if all structs, returned by the method have non
* empty field 'UnoID' for all given locales.
*/
+ @Test
public void _getCollatorImplementations() {
boolean res = true;
boolean printit = false;
@@ -247,11 +282,11 @@ public class _XLocaleData extends MultiMethodTest {
}
res &= (!impl[j].unoID.equals(""));
}
- if (printit) log.println("FAILED for: language=" + languages[i]
+ if (printit) System.out.println("FAILED for: language=" + languages[i]
+ " ; country=" + countries[i]);
printit = false;
}
- tRes.tested("getCollatorImplementations()", res);
+ Assert.assertTrue("getCollatorImplementations()", res);
}
/**
@@ -260,6 +295,7 @@ public class _XLocaleData extends MultiMethodTest {
* Has <b> OK </b> status if all strings, returned by the method are not
* empty for all given locales.
*/
+ @Test
public void _getSearchOptions() {
boolean res = true;
boolean printit = false;
@@ -273,11 +309,11 @@ public class _XLocaleData extends MultiMethodTest {
}
res &= (!str.equals(""));
}
- if (printit) log.println("FAILED for: language=" + languages[i]
+ if (printit) System.out.println("FAILED for: language=" + languages[i]
+ " ; country=" + countries[i]);
printit = false;
}
- tRes.tested("getSearchOptions()",res);
+ Assert.assertTrue("getSearchOptions()",res);
}
/**
@@ -286,6 +322,7 @@ public class _XLocaleData extends MultiMethodTest {
* Has <b> OK </b> status if all strings, returned by the method are not
* empty for all given locales.
*/
+ @Test
public void _getCollationOptions() {
boolean res = true;
boolean printit = false;
@@ -299,11 +336,11 @@ public class _XLocaleData extends MultiMethodTest {
}
res &= (!str.equals(""));
}
- if (printit) log.println("FAILED for: language=" + languages[i]
+ if (printit) System.out.println("FAILED for: language=" + languages[i]
+ " ; country=" + countries[i]);
printit = false;
}
- tRes.tested("getCollationOptions()", res);
+ Assert.assertTrue("getCollationOptions()", res);
}
/**
@@ -312,6 +349,7 @@ public class _XLocaleData extends MultiMethodTest {
* Has <b> OK </b> status if all strings, returned by the method are not
* empty for all given locales.
*/
+ @Test
public void _getTransliterations() {
boolean res = true;
boolean printit = false;
@@ -325,11 +363,11 @@ public class _XLocaleData extends MultiMethodTest {
}
res &= (!str.equals(""));
}
- if (printit) log.println("FAILED for: language=" + languages[i]
+ if (printit) System.out.println("FAILED for: language=" + languages[i]
+ " ; country=" + countries[i]);
printit = false;
}
- tRes.tested("getTransliterations()", res);
+ Assert.assertTrue("getTransliterations()", res);
}
/**
@@ -338,6 +376,7 @@ public class _XLocaleData extends MultiMethodTest {
* Has <b> OK </b> status if the method returns structure with non-empty
* fields for all given locales.
*/
+ @Test
public void _getForbiddenCharacters() {
boolean res = true;
ForbiddenCharacters fc = null;
@@ -347,10 +386,10 @@ public class _XLocaleData extends MultiMethodTest {
fc = oObj.getForbiddenCharacters(getLocale(i));
res &= !( fc.beginLine.equals("") || fc.endLine.equals("") );
if ( !res ) {
- log.println("FAILED for: language="+languages[i]+" ; country="+countries[i]);
+ System.out.println("FAILED for: language="+languages[i]+" ; country="+countries[i]);
}
}
- tRes.tested("getForbiddenCharacters()", res);
+ Assert.assertTrue("getForbiddenCharacters()", res);
}
@@ -360,6 +399,7 @@ public class _XLocaleData extends MultiMethodTest {
* Has <b> OK </b> status if all strings, returned by the method are not
* empty for all given locales.
*/
+ @Test
public void _getReservedWord() {
boolean res = true;
boolean printit = false;
@@ -373,11 +413,11 @@ public class _XLocaleData extends MultiMethodTest {
}
res &= (!str.equals(""));
}
- if (printit) log.println("FAILED for: language=" + languages[i]
+ if (printit) System.out.println("FAILED for: language=" + languages[i]
+ " ; country=" + countries[i]);
printit = false;
}
- tRes.tested("getReservedWord()", res);
+ Assert.assertTrue("getReservedWord()", res);
}
@@ -386,6 +426,7 @@ public class _XLocaleData extends MultiMethodTest {
* Has <b> OK </b> status if locale sequence, returned by the method contains
* given locales.
*/
+ @Test
public void _getAllInstalledLocaleNames() {
boolean res = true;
Locale[] locs = oObj.getAllInstalledLocaleNames();
@@ -394,7 +435,7 @@ public class _XLocaleData extends MultiMethodTest {
for (int i=0;i<7;i++) {
res &= contains(locs, getLocale(i));
}
- tRes.tested("getAllInstalledLocaleNames()",res);
+ Assert.assertTrue("getAllInstalledLocaleNames()",res);
}
@@ -414,34 +455,34 @@ public class _XLocaleData extends MultiMethodTest {
public boolean goodCalendar(Calendar calendar) {
boolean good = true;
for (int i=0;i<calendar.Days.length;i++) {
- //log.println("Day "+i+"(AbbrevName): "+calendar.Days[i].AbbrevName);
+ //System.out.println("Day "+i+"(AbbrevName): "+calendar.Days[i].AbbrevName);
good &= (! calendar.Days[i].AbbrevName.equals("") );
- //log.println("Day "+i+"(FullName): "+calendar.Days[i].FullName);
+ //System.out.println("Day "+i+"(FullName): "+calendar.Days[i].FullName);
good &= (! calendar.Days[i].FullName.equals("") );
- //log.println("Day "+i+"(ID): "+calendar.Days[i].ID);
+ //System.out.println("Day "+i+"(ID): "+calendar.Days[i].ID);
good &= (! calendar.Days[i].ID.equals("") );
}
for (int i=0;i<calendar.Months.length;i++) {
- //log.println("Day "+i+"(AbbrevName): "+calendar.Months[i].AbbrevName);
+ //System.out.println("Day "+i+"(AbbrevName): "+calendar.Months[i].AbbrevName);
good &= (! calendar.Months[i].AbbrevName.equals("") );
- //log.println("Day "+i+"(FullName): "+calendar.Months[i].FullName);
+ //System.out.println("Day "+i+"(FullName): "+calendar.Months[i].FullName);
good &= (! calendar.Months[i].FullName.equals("") );
- //log.println("Day "+i+"(ID): "+calendar.Months[i].ID);
+ //System.out.println("Day "+i+"(ID): "+calendar.Months[i].ID);
good &= (! calendar.Months[i].ID.equals("") );
}
for (int i=0;i<calendar.Eras.length;i++) {
- //log.println("Era "+i+"(AbbrevName): "+calendar.Eras[i].AbbrevName);
+ //System.out.println("Era "+i+"(AbbrevName): "+calendar.Eras[i].AbbrevName);
good &= (! calendar.Eras[i].AbbrevName.equals("") );
- //log.println("Era "+i+"(FullName): "+calendar.Eras[i].FullName);
+ //System.out.println("Era "+i+"(FullName): "+calendar.Eras[i].FullName);
good &= (! calendar.Eras[i].FullName.equals("") );
- //log.println("Era "+i+"(ID): "+calendar.Eras[i].ID);
+ //System.out.println("Era "+i+"(ID): "+calendar.Eras[i].ID);
good &= (! calendar.Eras[i].ID.equals("") );
}
- //log.println("Start of Week: "+calendar.StartOfWeek);
+ //System.out.println("Start of Week: "+calendar.StartOfWeek);
good &= (! calendar.StartOfWeek.equals("") );
- //log.println("MinimumNumberOfDaysForFirstWeek: "+calendar.MinimumNumberOfDaysForFirstWeek);
- //log.println("Default: "+calendar.Default);
- //log.println("Name: "+calendar.Name);
+ //System.out.println("MinimumNumberOfDaysForFirstWeek: "+calendar.MinimumNumberOfDaysForFirstWeek);
+ //System.out.println("Default: "+calendar.Default);
+ //System.out.println("Name: "+calendar.Name);
good &= (! calendar.Name.equals("") );
return good;
}
@@ -485,7 +526,7 @@ public class _XLocaleData extends MultiMethodTest {
break;
}
}
- if (!cont) log.println("Not contained: " + oneLoc.Language);
+ if (!cont) System.out.println("Not contained: " + oneLoc.Language);
return cont;
}
diff --git a/test/testuno/source/api/i18n/XNumberFormatCodeTest.java b/test/testuno/source/api/i18n/XNumberFormatCodeTest.java
index c2712fd34c..fba93b6744 100644
--- a/test/testuno/source/api/i18n/XNumberFormatCodeTest.java
+++ b/test/testuno/source/api/i18n/XNumberFormatCodeTest.java
@@ -21,9 +21,7 @@
-package ifc.i18n;
-
-import lib.MultiMethodTest;
+package api.i18n;
import com.sun.star.i18n.KNumberFormatType;
import com.sun.star.i18n.KNumberFormatUsage;
@@ -31,6 +29,16 @@ import com.sun.star.i18n.NumberFormatCode;
import com.sun.star.i18n.NumberFormatIndex;
import com.sun.star.i18n.XNumberFormatCode;
import com.sun.star.lang.Locale;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openoffice.test.uno.UnoApp;
+
/**
* Testing <code>com.sun.star.i18n.XNumberFormatCode</code>
@@ -44,19 +52,46 @@ import com.sun.star.lang.Locale;
* Test is <b> NOT </b> multithread compliant. <p>
* @see com.sun.star.i18n.XNumberFormatCode
*/
-public class _XNumberFormatCode extends MultiMethodTest {
+public class XNumberFormatCodeTest {
+ private static final UnoApp app = new UnoApp();
+
+ private XComponentContext xContext = null;
public XNumberFormatCode oObj = null;
public String[] languages = new String[]
{"de","en","es","fr","ko","ko","zh"};
public String[] countries = new String[]
{"DE","US","ES","FR","KR","KR","CN"};
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ app.start();
+ }
+
+ @AfterClass
+ public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
+ {
+ app.close();
+ }
+
+ @Before
+ public void before() throws Exception {
+ xContext = app.getComponentContext();
+ oObj = UnoRuntime.queryInterface(
+ XNumberFormatCode.class,
+ xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.NumberFormatCodeMapper", xContext)
+ );
+ }
+
+
/**
* Test calls the method twice with two different format types as
* parameters for each locale. Result is checked after every call.<p>
* Has <b> OK </b> status if both times returned structure's field 'Code'
* does not equal to empty string.
*/
+ @Test
public void _getDefault() {
boolean res = true;
NumberFormatCode nfc = null;
@@ -66,9 +101,9 @@ public class _XNumberFormatCode extends MultiMethodTest {
KNumberFormatUsage.DATE, getLocale(i));
String str = nfc.Code;
if (str.equals("")) {
- log.println("'NumberFormat.code.equals(\"\") = true' for"
+ System.out.println("'NumberFormat.code.equals(\"\") = true' for"
+ " language: " + languages[i]);
- log.println("Usage: oObj.getDefault(KNumberFormatType.SHORT,"
+ System.out.println("Usage: oObj.getDefault(KNumberFormatType.SHORT,"
+ " KNumberFormatUsage.DATE,new Locale(" + languages[i]
+ "," + countries[i] + ",\"\");");
}
@@ -78,15 +113,15 @@ public class _XNumberFormatCode extends MultiMethodTest {
KNumberFormatUsage.DATE,getLocale(i));
str = nfc.Code;
if (str.equals("")) {
- log.println("'NumberFormat.code.equals(\"\") = true' for "
+ System.out.println("'NumberFormat.code.equals(\"\") = true' for "
+ "language: " + languages[i]);
- log.println("Usage: oObj.getDefault(KNumberFormatType.LONG,"
+ System.out.println("Usage: oObj.getDefault(KNumberFormatType.LONG,"
+ " KNumberFormatUsage.DATE,new Locale(" + languages[i]
+ "," + countries[i] + ",\"\");");
}
res &= ( ! str.equals("") );
}
- tRes.tested("getDefault()", res);
+ Assert.assertTrue("getDefault()", res);
}
/**
@@ -95,6 +130,7 @@ public class _XNumberFormatCode extends MultiMethodTest {
* Has <b> OK </b> status if both times returned structure's field 'Code'
* does not equal to a empty string.
*/
+ @Test
public void _getFormatCode() {
boolean res = true;
NumberFormatCode nfc = null;
@@ -107,7 +143,7 @@ public class _XNumberFormatCode extends MultiMethodTest {
(NumberFormatIndex.DATE_SYSTEM_LONG,getLocale(i));
res &= ( ! nfc.Code.equals("") );
}
- tRes.tested("getFormatCode()", res);
+ Assert.assertTrue("getFormatCode()", res);
}
/**
@@ -116,6 +152,7 @@ public class _XNumberFormatCode extends MultiMethodTest {
* Has <b> OK </b> status if both times returned array's length does not
* equal to zero.
*/
+ @Test
public void _getAllFormatCode() {
boolean res = true;
NumberFormatCode[] nfc = null;
@@ -126,13 +163,14 @@ public class _XNumberFormatCode extends MultiMethodTest {
nfc = oObj.getAllFormatCode(KNumberFormatUsage.TIME, getLocale(i));
res &= ( nfc.length != 0 );
}
- tRes.tested("getAllFormatCode()", res);
+ Assert.assertTrue("getAllFormatCode()", res);
}
/**
* Test calls the method for each locale. <p>
* Has <b> OK </b> status if returned array's length does not equal to zero.
*/
+ @Test
public void _getAllFormatCodes() {
boolean res = true;
NumberFormatCode[] nfc = null;
@@ -141,7 +179,7 @@ public class _XNumberFormatCode extends MultiMethodTest {
nfc = oObj.getAllFormatCodes(getLocale(i));
res &= ( nfc.length != 0 );
}
- tRes.tested("getAllFormatCodes()", res);
+ Assert.assertTrue("getAllFormatCodes()", res);
}
/**
diff --git a/test/testuno/source/api/i18n/XTransliterationTest.java b/test/testuno/source/api/i18n/XTransliterationTest.java
index 36c9551ff9..8acce5a98d 100644
--- a/test/testuno/source/api/i18n/XTransliterationTest.java
+++ b/test/testuno/source/api/i18n/XTransliterationTest.java
@@ -21,15 +21,22 @@
-package ifc.i18n;
-
-import lib.MultiMethodTest;
+package api.i18n;
import com.sun.star.i18n.TransliterationModules;
import com.sun.star.i18n.TransliterationModulesNew;
import com.sun.star.i18n.TransliterationType;
import com.sun.star.i18n.XTransliteration;
import com.sun.star.lang.Locale;
+import com.sun.star.uno.UnoRuntime;
+import com.sun.star.uno.XComponentContext;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Assert;
+import org.junit.Test;
+import org.openoffice.test.uno.UnoApp;
/**
* Testing <code>com.sun.star.i18n.XTransliteration</code>
@@ -50,30 +57,56 @@ import com.sun.star.lang.Locale;
* Test is <b> NOT </b> multithread compliant. <p>
* @see com.sun.star.i18n.XTransliteration
*/
-public class _XTransliteration extends MultiMethodTest {
+public class XTransliterationTest {
+ private static final UnoApp app = new UnoApp();
+ private XComponentContext xContext = null;
public XTransliteration oObj = null;
private String[] mod = null ;
private Locale loc = new Locale("en", "EN", "") ;
+
+ // setup and close connections
+ @BeforeClass
+ public static void setUpConnection() throws Exception
+ {
+ app.start();
+ }
+
+ @AfterClass
+ public static void tearDownConnection() throws InterruptedException, com.sun.star.uno.Exception
+ {
+ app.close();
+ }
+
+ @Before
+ public void before() throws Exception {
+ xContext = app.getComponentContext();
+ oObj = UnoRuntime.queryInterface(
+ XTransliteration.class,
+ xContext.getServiceManager().createInstanceWithContext("com.sun.star.i18n.Transliteration", xContext)
+ );
+ }
+
/**
* Gets all available transliteration modules. <p>
* Has <b>OK</b> status if array returned has at least
* one module name.
*/
+ @Test
public void _getAvailableModules() {
mod = oObj.getAvailableModules(loc, TransliterationType.ONE_TO_ONE);
if (mod != null) {
- log.println("Available modules :") ;
+ System.out.println("Available modules :") ;
for (int i = 0; i < mod.length; i++) {
- log.println(" '" + mod[i] + "'") ;
+ System.out.println(" '" + mod[i] + "'") ;
}
} else {
- log.println("!!! NULL returned !!!") ;
+ System.out.println("!!! NULL returned !!!") ;
}
- tRes.tested("getAvailableModules()", mod != null && mod.length > 0) ;
+ Assert.assertTrue("getAvailableModules()", mod != null && mod.length > 0) ;
}
/**
@@ -82,15 +115,16 @@ public class _XTransliteration extends MultiMethodTest {
* Has <b>OK</b> status if the method <code>getName</code> returns the
* string "case ignore (generic)".
*/
+ @Test
public void _loadModule() {
- log.println("Load module IGNORE_CASE");
+ System.out.println("Load module IGNORE_CASE");
oObj.loadModule(TransliterationModules.IGNORE_CASE, loc);
String name = oObj.getName();
boolean res = name.equals("case ignore (generic)");
- log.println("getName return: " + name);
+ System.out.println("getName return: " + name);
- tRes.tested("loadModule()", res );
+ Assert.assertTrue("loadModule()", res );
}
/**
@@ -100,6 +134,7 @@ public class _XTransliteration extends MultiMethodTest {
* Has <b>OK</b> status if the name of the object is equals to
* 'lower_to_upper(generic)'
*/
+ @Test
public void _loadModuleNew() {
boolean result = true ;
@@ -109,9 +144,9 @@ public class _XTransliteration extends MultiMethodTest {
String name = oObj.getName();
result = name.equals("lower_to_upper(generic)");
- log.println("getName return: " + name);
+ System.out.println("getName return: " + name);
- tRes.tested("loadModuleNew()", result);
+ Assert.assertTrue("loadModuleNew()", result);
}
/**
@@ -120,15 +155,16 @@ public class _XTransliteration extends MultiMethodTest {
* Has <b>OK</b> status if the method <code>getName</code> returns the
* string "lower_to_upper(generic)".
*/
+ @Test
public void _loadModuleByImplName() {
- log.println("Load module LOWERCASE_UPPERCASE");
+ System.out.println("Load module LOWERCASE_UPPERCASE");
oObj.loadModuleByImplName("LOWERCASE_UPPERCASE", loc);
String name = oObj.getName();
boolean res = name.equals("lower_to_upper(generic)");
- log.println("getName return: " + name);
+ System.out.println("getName return: " + name);
- tRes.tested("loadModuleByImplName()", res);
+ Assert.assertTrue("loadModuleByImplName()", res);
}
/**
@@ -137,25 +173,27 @@ public class _XTransliteration extends MultiMethodTest {
* Has <b>OK</b> status if the method <code>getName</code> returns the
* string "upper_to_lower(generic)".
*/
+ @Test
public void _loadModulesByImplNames() {
- log.println("Load module UPPERCASE_LOWERCASE");
+ System.out.println("Load module UPPERCASE_LOWERCASE");
oObj.loadModulesByImplNames(new String[]{"UPPERCASE_LOWERCASE"}, loc);
String name = oObj.getName();
boolean res = name.equals("upper_to_lower(generic)");
- log.println("getName return: " + name);
+ System.out.println("getName return: " + name);
- tRes.tested("loadModulesByImplNames()", res);
+ Assert.assertTrue("loadModulesByImplNames()", res);
}
/**
* Loads <code>LOWERCASE_UPPERCASE</code> module and checks current type.
* <p>Has <b>OK</b> status if the type is <code>ONE_TO_ONE</code>
*/
+ @Test
public void _getType() {
oObj.loadModule(TransliterationModules.LOWERCASE_UPPERCASE, loc);
boolean result = oObj.getType() == TransliterationType.ONE_TO_ONE;
- tRes.tested("getType()", result);
+ Assert.assertTrue("getType()", result);
}
/**
@@ -165,14 +203,15 @@ public class _XTransliteration extends MultiMethodTest {
* Has <b>OK</b> status if the method <code>getName</code> returns the
* string "upper_to_lower(generic)".
*/
+ @Test
public void _getName() {
oObj.loadModule(TransliterationModules.LOWERCASE_UPPERCASE, loc);
String name = oObj.getName();
boolean res = name.equals("lower_to_upper(generic)");
- log.println("getName return: " + name);
+ System.out.println("getName return: " + name);
- tRes.tested("getName()", res);
+ Assert.assertTrue("getName()", res);
}
/**
@@ -183,6 +222,7 @@ public class _XTransliteration extends MultiMethodTest {
* elements are positions of substring characters in the source
* string.
*/
+ @Test
public void _transliterate() {
oObj.loadModule(TransliterationModules.LOWERCASE_UPPERCASE, loc);
@@ -196,7 +236,7 @@ public class _XTransliteration extends MultiMethodTest {
offs[0][2] == 3 &&
offs[0][3] == 4 ;
- tRes.tested("transliterate()", result) ;
+ Assert.assertTrue("transliterate()", result) ;
}
@@ -207,14 +247,15 @@ public class _XTransliteration extends MultiMethodTest {
* returned (not null, length = 4, with two ranges
* (a, i), (A, I) in any order).
*/
+ @Test
public void _transliterateRange() {
oObj.loadModule(TransliterationModules.IGNORE_CASE, loc);
String[] out = oObj.transliterateRange("a", "i") ;
- log.println("transliterateRange return:");
+ System.out.println("transliterateRange return:");
for(int i = 0; i < out.length; i++) {
- log.println(out[i]);
+ System.out.println(out[i]);
}
boolean bOK = out != null &&
@@ -225,14 +266,14 @@ public class _XTransliteration extends MultiMethodTest {
"A".equals(out[2]) && "I".equals(out[3])) ;
if (!bOK) {
- log.println("Unexpected range returned :");
+ System.out.println("Unexpected range returned :");
for (int i = 0; i < out.length; i++) {
- log.print("'" + out[i] +"', ");
+ System.out.print("'" + out[i] +"', ");
}
- log.println();
+ System.out.println();
}
- tRes.tested("transliterateRange()", bOK);
+ Assert.assertTrue("transliterateRange()", bOK);
}
/**
@@ -240,6 +281,7 @@ public class _XTransliteration extends MultiMethodTest {
* method so it indirectly tested in this method. <p>
* Always has <b>OK</b> status.
*/
+ @Test
public void _folding() {
oObj.loadModule(TransliterationModules.LOWERCASE_UPPERCASE, loc);
@@ -254,7 +296,7 @@ public class _XTransliteration extends MultiMethodTest {
offs[0][3] == 4 ;
- tRes.tested("folding()", result) ;
+ Assert.assertTrue("folding()", result) ;
}
@@ -263,6 +305,7 @@ public class _XTransliteration extends MultiMethodTest {
* Tries to compare two equal substrings. <p>
* Has <b>OK</b> status if the method returned <code>true</code>.
*/
+ @Test
public void _equals() {
oObj.loadModule(TransliterationModules.LOWERCASE_UPPERCASE, loc);
@@ -272,10 +315,10 @@ public class _XTransliteration extends MultiMethodTest {
boolean res = oObj.equals("aAbBcC", 1, 3, match1, "aAbBcC", 1,
3, match2) ;
- log.println("Returned : " + res + " Match1 = " + match1[0] +
+ System.out.println("Returned : " + res + " Match1 = " + match1[0] +
" Match2 = " + match2[0]) ;
- tRes.tested("equals()", res) ;
+ Assert.assertTrue("equals()", res) ;
}
/**
@@ -288,6 +331,7 @@ public class _XTransliteration extends MultiMethodTest {
* proper value according to lexicographical order and if
* comparisons with invalid parameters return none 0 value.
*/
+ @Test
public void _compareSubstring() {
oObj.loadModule(TransliterationModules.LOWERCASE_UPPERCASE, loc);
boolean result = true ;
@@ -311,7 +355,7 @@ public class _XTransliteration extends MultiMethodTest {
// testing with wrong offsets and lengths
- tRes.tested("compareSubstring()", result) ;
+ Assert.assertTrue("compareSubstring()", result) ;
}
/**
@@ -332,34 +376,34 @@ public class _XTransliteration extends MultiMethodTest {
try {
res = oObj.compareSubstring(str1, p1, len1, str2, p2, len2);
} catch (java.lang.NullPointerException e) {
- log.println("Exception while method calling occurs :" + e);
+ System.out.println("Exception while method calling occurs :" + e);
}
if (res != expRes) {
- log.print("Comparing FAILED; return: " + res + ", expected: " +
+ System.out.print("Comparing FAILED; return: " + res + ", expected: " +
expRes + " ");
ret = false ;
} else {
- log.print("Comparing OK : ");
+ System.out.print("Comparing OK : ");
}
- log.println("('" + str1 + "', " + p1 + ", " + len1 + ", '" +
+ System.out.println("('" + str1 + "', " + p1 + ", " + len1 + ", '" +
str2 + "', " + p2 + ", " + len2 + ")");
res = -666 ;
try {
res = oObj.compareSubstring(str2, p2, len2, str1, p1, len1);
} catch (java.lang.NullPointerException e) {
- log.println("Exception while method calling occurs :" + e);
+ System.out.println("Exception while method calling occurs :" + e);
}
if (res != -expRes) {
- log.print("Comparing FAILED; return: " + res + ", expected: " +
+ System.out.print("Comparing FAILED; return: " + res + ", expected: " +
-expRes + " ");
ret = false ;
} else {
- log.print("Comparing OK :");
+ System.out.print("Comparing OK :");
}
- log.println("('" + str2 + "', " + p2 + ", " + len2 + ", '" +
+ System.out.println("('" + str2 + "', " + p2 + ", " + len2 + ", '" +
str1 + "', " + p1 + ", " + len1 + ")");
return ret ;
@@ -373,6 +417,7 @@ public class _XTransliteration extends MultiMethodTest {
* always return 0 and if comparisons of none equal returns
* proper value according to lexicographical order .
*/
+ @Test
public void _compareString() {
oObj.loadModule(TransliterationModules.LOWERCASE_UPPERCASE, loc);
boolean result = true ;
@@ -392,7 +437,7 @@ public class _XTransliteration extends MultiMethodTest {
result &= testString("aaa\t\na", "aaa\t\na", 0) ;
result &= testString("aaa\t\nb", "aaa\t\na", 1) ;
- tRes.tested("compareString()", result) ;
+ Assert.assertTrue("compareString()", result) ;
}
/**
@@ -418,13 +463,13 @@ public class _XTransliteration extends MultiMethodTest {
try {
res = oObj.compareString(str1, str2);
} catch (java.lang.NullPointerException e) {
- log.println("Exception while method calling occurs :" + e);
+ System.out.println("Exception while method calling occurs :" + e);
}
if (res == expRes) {
- log.println("Comparing of '" + str1 + "' and '" + str2 + "' OK" );
+ System.out.println("Comparing of '" + str1 + "' and '" + str2 + "' OK" );
} else {
- log.println("Comparing of '" + str1 + "' and '" + str2 +
+ System.out.println("Comparing of '" + str1 + "' and '" + str2 +
"' FAILED; return: " + res + ", expected: " + expRes);
ret = false ;
}
@@ -435,13 +480,13 @@ public class _XTransliteration extends MultiMethodTest {
try {
res = oObj.compareString(str2, str1);
} catch (java.lang.NullPointerException e) {
- log.println("Exception while method calling occurs :" + e);
+ System.out.println("Exception while method calling occurs :" + e);
}
if (res == -expRes) {
- log.println("Comparing of '" + str2 + "' and '" + str1 + "' OK" );
+ System.out.println("Comparing of '" + str2 + "' and '" + str1 + "' OK" );
} else {
- log.println("Comparing of '" + str2 + "' and '" + str1 +
+ System.out.println("Comparing of '" + str2 + "' and '" + str1 +
"' FAILED; return: " + res + ", expected: " + -expRes);
ret = false ;
}