summaryrefslogtreecommitdiff
path: root/sw/qa/complex/writer/TextPortionEnumerationTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'sw/qa/complex/writer/TextPortionEnumerationTest.java')
-rwxr-xr-xsw/qa/complex/writer/TextPortionEnumerationTest.java645
1 files changed, 279 insertions, 366 deletions
diff --git a/sw/qa/complex/writer/TextPortionEnumerationTest.java b/sw/qa/complex/writer/TextPortionEnumerationTest.java
index 2eda02bfa518..114359bc3581 100755
--- a/sw/qa/complex/writer/TextPortionEnumerationTest.java
+++ b/sw/qa/complex/writer/TextPortionEnumerationTest.java
@@ -27,7 +27,6 @@
package complex.writer;
-import complexlib.ComplexTestCase;
import com.sun.star.uno.UnoRuntime;
import com.sun.star.uno.AnyConverter;
import com.sun.star.uno.XComponentContext;
@@ -70,6 +69,13 @@ import com.sun.star.rdf.XMetadatable;
import com.sun.star.rdf.Statement;
import com.sun.star.rdf.XDocumentRepository;
import com.sun.star.rdf.XRepositorySupplier;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.openoffice.test.OfficeConnection;
+import static org.junit.Assert.*;
import java.util.Map;
import java.util.HashMap;
@@ -432,10 +438,8 @@ class FuzzyTester
private Stack<Pair<TreeNode, TreeNodeEnum>> m_StackActual;
private List<TreeNode> m_BufferExpected;
private List<TreeNode> m_BufferActual;
- private share.LogWriter m_Log;
- FuzzyTester(share.LogWriter log) {
- m_Log = log;
+ FuzzyTester() {
m_BufferExpected = new ArrayList<TreeNode>();
m_BufferActual = new ArrayList<TreeNode>();
m_StackExpected = new Stack<Pair<TreeNode, TreeNodeEnum>>();
@@ -444,12 +448,10 @@ class FuzzyTester
/** idea: traverse both trees, enumerate nodes, stopping at content nodes.
then compare buffers. */
- boolean doTest(TreeNode expected, TreeNode actual)
+ void doTest(TreeNode expected, TreeNode actual)
{
- if (!expected.getType().equals("__ROOT__"))
- throw new RuntimeException("doTest: expected: root");
- if (!actual.getType().equals("__ROOT__"))
- throw new RuntimeException("doTest: actual: root");
+ assertEquals("__ROOT__", expected.getType());
+ assertEquals("__ROOT__", actual.getType());
m_StackExpected.push(new Pair(expected, expected.createEnumeration()));
m_StackActual.push(new Pair(actual, actual.createEnumeration()));
do {
@@ -459,18 +461,19 @@ class FuzzyTester
testBuffer();
} while (!m_StackExpected.empty() || !m_StackActual.empty());
if (m_DiffSequence != 0) {
- m_Log.println("warning: " + m_DiffSequence
+ System.out.println("warning: " + m_DiffSequence
+ " differences in sequence");
}
if (m_DiffSpuriousEmptyText != 0) {
- m_Log.println("warning: " + m_DiffSpuriousEmptyText
+ System.out.println("warning: " + m_DiffSpuriousEmptyText
+ " spurious empty text nodes");
}
if (m_DiffNesting != 0) {
- m_Log.println("WARNING: " + m_DiffNesting
+ System.out.println("WARNING: " + m_DiffNesting
+ " differences in nesting");
}
- return (m_DiffContent == 0) && (m_DiffMissing == 0);
+ assertEquals(0, m_DiffContent);
+ assertEquals(0, m_DiffMissing);
}
private void traverse(Stack<Pair<TreeNode, TreeNodeEnum>> stack,
@@ -563,7 +566,7 @@ class FuzzyTester
}
m_BufferActual.set(j, null);
} else {
-//m_Log.println("testBuffer:");
+//System.out.println("testBuffer:");
printMissing(node);
m_DiffMissing++;
}
@@ -573,7 +576,7 @@ class FuzzyTester
TreeNode node = m_BufferActual.get(j);
if (node != null)
{
-//m_Log.println("testBuffer:");
+//System.out.println("testBuffer:");
printUnexpected(node);
if ((node instanceof TextNode) &&
((TextNode) node).getContent().length() == 0) {
@@ -590,25 +593,25 @@ class FuzzyTester
void printDiff(String prefix, String expected, String actual)
{
- m_Log.println(prefix +
+ System.out.println(prefix +
":\texpected: " + expected + "\tactual: " + actual);
}
void printNesting(TreeNode node, TreeNode nesting)
{
- m_Log.println("node: " + node.toString()
+ System.out.println("node: " + node.toString()
+ " possibly moved across nesting " + nesting.toString());
}
void printMissing(TreeNode node)
{
- m_Log.println(" missing node: " + node.toString());
+ System.out.println(" missing node: " + node.toString());
}
void printUnexpected(TreeNode node)
{
- m_Log.println("unexpected node: " + node.toString());
+ System.out.println("unexpected node: " + node.toString());
}
}
@@ -619,10 +622,9 @@ class FuzzyTester
class EnumConverter
{
private Stack<TreeNode> m_Stack;
- TextPortionEnumerationTest m_T;
- EnumConverter(TextPortionEnumerationTest err) {
- m_Stack = new Stack<TreeNode>(); m_T = err;
+ EnumConverter() {
+ m_Stack = new Stack<TreeNode>();
}
TreeNode convert(XEnumeration xEnum) throws Exception
@@ -630,7 +632,7 @@ class EnumConverter
TreeNode root = new TreeNode();
m_Stack.push(root);
TreeNode ret = convertChildren(xEnum);
- m_T.assure("EnumConverter.convert: stack", m_Stack.empty());
+ assertTrue("EnumConverter.convert: stack", m_Stack.empty());
return ret;
}
@@ -670,7 +672,7 @@ class EnumConverter
xMeta);
XEnumeration xEnumChildren = xEA.createEnumeration();
TreeNode node2 = convertChildren(xEnumChildren);
- m_T.assure("stack error: meta-field", node == node2);
+ assertSame("stack error: meta-field", node2, node);
} else {
XPropertySet xFieldPropSet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xField);
@@ -678,7 +680,7 @@ class EnumConverter
xFieldPropSet.getPropertyValue("Content");
boolean isFixed = (Boolean)
xFieldPropSet.getPropertyValue("IsFixed");
- m_T.assure("field not fixed?", isFixed);
+ assertTrue("field not fixed?", isFixed);
node = new TextFieldNode(content);
}
} else if (type.equals("Footnote")) {
@@ -781,10 +783,8 @@ class EnumConverter
continue;
} else {
node = m_Stack.pop();
- m_T.assure("stack error: Ruby expected; is: " +
- node.toString(), node instanceof RubyNode);
-// m_T.assure("stack error: ruby",
-// ruby.equals(((RubyNode)node).getRubyText()));
+ assertTrue("stack error: Ruby expected; is: " +
+ node.toString(), node instanceof RubyNode);
}
} else if (type.equals("InContentMetadata")) {
Object xMeta = xPropSet.getPropertyValue("InContentMetadata");
@@ -797,9 +797,7 @@ class EnumConverter
UnoRuntime.queryInterface(XEnumerationAccess.class, xMeta);
XEnumeration xEnumChildren = xEA.createEnumeration();
TreeNode node2 = convertChildren(xEnumChildren);
- m_T.assure("stack error: meta", node == node2);
-// } else if (type.equals("MetadataField")) {
-// Object xMeta = xPropSet.getPropertyValue("MetadataField");
+ assertSame("stack error: meta", node2, node);
} else {
throw new RuntimeException("unexpected type: " + type);
}
@@ -1240,7 +1238,7 @@ class RangeInserter extends Inserter
//----------------------------------------------------------------------
-public class TextPortionEnumerationTest extends ComplexTestCase
+public class TextPortionEnumerationTest
{
private XMultiServiceFactory m_xMSF = null;
private XComponentContext m_xContext = null;
@@ -1249,115 +1247,28 @@ public class TextPortionEnumerationTest extends ComplexTestCase
private int m_Count = 1;
-// public String[] getTestMethodNames() { return new String[] { "testLoadStore" }; }
- public String[] getTestMethodNames() {
- return new String[] {
- "testText",
- "testTextField",
-// "testControlChar",
-// "testSoftPageBreak",
- "testFootnote",
- "testFrameAs",
- "testFrameAt",
- "testBookmarkPoint",
- "testBookmark",
- "testBookmarkPointXmlId",
- "testBookmarkXmlId",
- "testRefmarkPoint",
- "testRefmark",
- "testToxmarkPoint",
- "testToxmark",
- "testHyperlink",
- "testHyperlinkEmpty",
- "testRuby",
- "testRubyEmpty",
- "testMeta",
- "testMetaEmpty",
- "testMetaField",
- "testMetaFieldEmpty",
- "testBookmark1",
- "testBookmark2",
- "testRefMark2",
- "testRefMark3",
- "testToxMark2",
- "testToxMark3",
- "testMarks1",
- "testMarks2",
- "testMarks3",
- "testFrameMark1",
- "testFrameMark2",
- "testFrameMark3",
- "testFrameMark4",
- "testFrames1",
- "testFrames2",
- "testFrames3",
- "testFrames4",
- "testFrames5",
- "testRubyHyperlink1",
- "testRubyHyperlink2",
- "testEnd1",
- "testEnd2",
- "testEnd3",
- "testEnd4",
- "testEnd5",
- "testEmpty1",
- "testEmpty2",
- "testEmpty3",
- "test1",
- "testRange1",
- "testRangeHyperlinkHyperlink",
- "testRangeHyperlinkRuby",
- "testRangeRubyHyperlink",
- "testRangeRubyRuby",
- "testRangeHyperlinkMeta",
- "testRangeRubyMeta",
- "testRangeMetaHyperlink",
- "testRangeMetaRuby",
- "testRangeMetaMeta",
- "testRange2",
- "testRange3",
- "testRange4",
- "testRange5",
- "testRange6",
- "testRange7",
- "testMetaXChild",
- "testMetaXText",
- "testMetaXTextCursor",
- "testMetaXTextAttachToxMark",
- "testMetaXTextAttachRefMark",
- "testMetaXTextAttachTextField",
- "testMetaXTextAttachFootnote",
- "testMetaXTextAttachMeta",
- "testMetaFieldXTextField",
- "testMetaFieldXPropertySet",
- "testLoadStore",
- "testLoadStoreXmlid",
- };
- }
-
- public void before() throws Exception
+ @Before public void before() throws Exception
{
- m_xMSF = (XMultiServiceFactory) param.getMSF();
+ m_xMSF = UnoRuntime.queryInterface(
+ XMultiServiceFactory.class,
+ connection.getComponentContext().getServiceManager());
XPropertySet xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, m_xMSF);
Object defaultCtx = xPropertySet.getPropertyValue("DefaultContext");
m_xContext = (XComponentContext)
UnoRuntime.queryInterface(XComponentContext.class, defaultCtx);
- assure("could not get component context.", m_xContext != null);
+ assertNotNull("could not get component context.", m_xContext);
m_xDoc = util.WriterTools.createTextDoc(m_xMSF);
m_TmpDir = util.utils.getOfficeTemp/*Dir*/(m_xMSF);
- log.println("tempdir: " + m_TmpDir);
+ System.out.println("tempdir: " + m_TmpDir);
}
- public void after()
+ @After public void after()
{
- if (m_xDoc != null) {
- util.DesktopTools.closeDoc(m_xDoc);
- m_xDoc = null;
- }
+ util.DesktopTools.closeDoc(m_xDoc);
}
- public void testText() throws Exception
+ @Test public void testText() throws Exception
{
TreeNode root = new TreeNode();
TreeNode text = new TextNode("abc");
@@ -1365,7 +1276,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testTextField() throws Exception
+ @Test public void testTextField() throws Exception
{
String name = mkName("ruby");
TreeNode root = new TreeNode();
@@ -1374,7 +1285,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testControlChar() throws Exception
+ /*@Test*/ public void testControlChar() throws Exception
{
//FIXME this is converted to a text portion: ControlCharacter is obsolete
TreeNode root = new TreeNode();
@@ -1383,7 +1294,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testSoftPageBreak() throws Exception
+ /*@Test*/ public void testSoftPageBreak() throws Exception
{
//FIXME: insert a soft page break: not done
TreeNode root = new TreeNode();
@@ -1394,7 +1305,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFootnote() throws Exception
+ @Test public void testFootnote() throws Exception
{
String name = mkName("ftn");
TreeNode root = new TreeNode();
@@ -1403,7 +1314,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFrameAs() throws Exception
+ @Test public void testFrameAs() throws Exception
{
String name = mkName("frame");
TreeNode root = new TreeNode();
@@ -1412,7 +1323,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFrameAt() throws Exception
+ @Test public void testFrameAt() throws Exception
{
String name = mkName("frame");
TreeNode root = new TreeNode();
@@ -1423,7 +1334,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testBookmarkPoint() throws Exception
+ @Test public void testBookmarkPoint() throws Exception
{
String name = mkName("mark");
TreeNode root = new TreeNode();
@@ -1434,7 +1345,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testBookmark() throws Exception
+ @Test public void testBookmark() throws Exception
{
String name = mkName("mark");
TreeNode root = new TreeNode();
@@ -1447,7 +1358,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testBookmarkPointXmlId() throws Exception
+ @Test public void testBookmarkPointXmlId() throws Exception
{
String name = mkName("mark");
StringPair id = mkId("id");
@@ -1459,7 +1370,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testBookmarkXmlId() throws Exception
+ @Test public void testBookmarkXmlId() throws Exception
{
String name = mkName("mark");
StringPair id = mkId("id");
@@ -1473,7 +1384,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testRefmarkPoint() throws Exception
+ @Test public void testRefmarkPoint() throws Exception
{
String name = mkName("refmark");
TreeNode root = new TreeNode();
@@ -1484,7 +1395,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testRefmark() throws Exception
+ @Test public void testRefmark() throws Exception
{
String name = mkName("refmark");
TreeNode root = new TreeNode();
@@ -1497,7 +1408,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testToxmarkPoint() throws Exception
+ @Test public void testToxmarkPoint() throws Exception
{
String name = mkName("toxmark");
TreeNode root = new TreeNode();
@@ -1508,7 +1419,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testToxmark() throws Exception
+ @Test public void testToxmark() throws Exception
{
String name = mkName("toxmark");
TreeNode root = new TreeNode();
@@ -1521,7 +1432,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testHyperlink() throws Exception
+ @Test public void testHyperlink() throws Exception
{
String name = mkName("url");
TreeNode root = new TreeNode();
@@ -1532,7 +1443,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testHyperlinkEmpty() throws Exception
+ @Test public void testHyperlinkEmpty() throws Exception
{
String name = mkName("url");
TreeNode root = new TreeNode();
@@ -1543,7 +1454,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testRuby() throws Exception
+ @Test public void testRuby() throws Exception
{
String name = mkName("ruby");
TreeNode root = new TreeNode();
@@ -1554,7 +1465,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testRubyEmpty() throws Exception
+ @Test public void testRubyEmpty() throws Exception
{
// BUG: #i91534#
String name = mkName("ruby");
@@ -1564,7 +1475,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testMeta() throws Exception
+ @Test public void testMeta() throws Exception
{
StringPair id = new StringPair("content.xml", mkName("id"));
TreeNode root = new TreeNode();
@@ -1576,7 +1487,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testMetaEmpty() throws Exception
+ @Test public void testMetaEmpty() throws Exception
{
StringPair id = new StringPair("content.xml", mkName("id"));
TreeNode root = new TreeNode();
@@ -1587,7 +1498,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testMetaField() throws Exception
+ @Test public void testMetaField() throws Exception
{
StringPair id = new StringPair("content.xml", mkName("id"));
TreeNode root = new TreeNode();
@@ -1599,7 +1510,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testMetaFieldEmpty() throws Exception
+ @Test public void testMetaFieldEmpty() throws Exception
{
StringPair id = new StringPair("content.xml", mkName("id"));
TreeNode root = new TreeNode();
@@ -1610,7 +1521,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testBookmark1() throws Exception
+ @Test public void testBookmark1() throws Exception
{
String name1 = mkName("mark");
String name2 = mkName("mark");
@@ -1626,7 +1537,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testBookmark2() throws Exception
+ @Test public void testBookmark2() throws Exception
{
String name1 = mkName("mark");
String name2 = mkName("mark");
@@ -1642,7 +1553,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testRefMark2() throws Exception
+ @Test public void testRefMark2() throws Exception
{
String name1 = mkName("refmark");
TreeNode root = new TreeNode();
@@ -1654,7 +1565,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testRefMark3() throws Exception
+ @Test public void testRefMark3() throws Exception
{
// BUG: #i107672# (non-deterministic; depends on pointer ordering)
String name1 = mkName("refmark");
@@ -1684,7 +1595,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testToxMark2() throws Exception
+ @Test public void testToxMark2() throws Exception
{
String name1 = mkName("toxmark");
TreeNode root = new TreeNode();
@@ -1695,7 +1606,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testToxMark3() throws Exception
+ @Test public void testToxMark3() throws Exception
{
// BUG: #i107672# (non-deterministic; depends on pointer ordering)
String name1 = mkName("toxmark");
@@ -1725,7 +1636,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testMarks1() throws Exception
+ @Test public void testMarks1() throws Exception
{
String name1 = mkName("bookmark");
String name2 = mkName("toxmark");
@@ -1744,7 +1655,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testMarks2() throws Exception
+ @Test public void testMarks2() throws Exception
{
String name1 = mkName("bookmark");
String name2 = mkName("refmark");
@@ -1767,7 +1678,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testMarks3() throws Exception
+ @Test public void testMarks3() throws Exception
{
String name1 = mkName("bookmark");
String name2 = mkName("refmark");
@@ -1789,7 +1700,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFrameMark1() throws Exception
+ @Test public void testFrameMark1() throws Exception
{
String name1 = mkName("bookmark");
String name2 = mkName("frame");
@@ -1801,7 +1712,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFrameMark2() throws Exception
+ @Test public void testFrameMark2() throws Exception
{
// BUG: #i98530#
String name1 = mkName("bookmark");
@@ -1814,7 +1725,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFrameMark3() throws Exception
+ @Test public void testFrameMark3() throws Exception
{
String name1 = mkName("frame");
String name2 = mkName("bookmark");
@@ -1826,7 +1737,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFrameMark4() throws Exception
+ @Test public void testFrameMark4() throws Exception
{
String name1 = mkName("frame");
String name2 = mkName("bookmark");
@@ -1838,7 +1749,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFrames1() throws Exception
+ @Test public void testFrames1() throws Exception
{
String name1 = mkName("frame");
String name2 = mkName("frame");
@@ -1850,7 +1761,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFrames2() throws Exception
+ @Test public void testFrames2() throws Exception
{
String name1 = mkName("frame");
String name2 = mkName("frame");
@@ -1862,7 +1773,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFrames3() throws Exception
+ @Test public void testFrames3() throws Exception
{
String name1 = mkName("frame");
String name2 = mkName("frame");
@@ -1874,7 +1785,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFrames4() throws Exception
+ @Test public void testFrames4() throws Exception
{
String name1 = mkName("frame");
String name2 = mkName("frame");
@@ -1886,7 +1797,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testFrames5() throws Exception
+ @Test public void testFrames5() throws Exception
{
String name1 = mkName("frame");
String name2 = mkName("frame");
@@ -1898,7 +1809,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testRubyHyperlink1() throws Exception
+ @Test public void testRubyHyperlink1() throws Exception
{
String name1 = mkName("ruby");
String name2 = mkName("url");
@@ -1911,7 +1822,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testRubyHyperlink2() throws Exception
+ @Test public void testRubyHyperlink2() throws Exception
{
String name1 = mkName("url");
String name2 = mkName("ruby");
@@ -1924,7 +1835,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testEnd1() throws Exception
+ @Test public void testEnd1() throws Exception
{
String name1 = mkName("bookmark");
String name2 = mkName("toxmark");
@@ -1937,7 +1848,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testEnd2() throws Exception
+ @Test public void testEnd2() throws Exception
{
String name1 = mkName("bookmark");
String name2 = mkName("frame");
@@ -1954,7 +1865,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testEnd3() throws Exception
+ @Test public void testEnd3() throws Exception
{
String name1 = mkName("ftn");
String name2 = mkName("toxmark");
@@ -1965,7 +1876,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testEnd4() throws Exception
+ @Test public void testEnd4() throws Exception
{
String name1 = mkName("bookmark");
String name2 = mkName("frame");
@@ -1977,7 +1888,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testEnd5() throws Exception
+ @Test public void testEnd5() throws Exception
{
String name1 = mkName("refmark");
String name2 = mkName("ruby");
@@ -1991,7 +1902,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testEmpty1() throws Exception
+ @Test public void testEmpty1() throws Exception
{
String name1 = mkName("refmark");
String name2 = mkName("toxmark");
@@ -2013,7 +1924,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testEmpty2() throws Exception
+ @Test public void testEmpty2() throws Exception
{
String name3 = mkName("bookmark");
String name4 = mkName("frame");
@@ -2027,7 +1938,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void testEmpty3() throws Exception
+ @Test public void testEmpty3() throws Exception
{
String name1 = mkName("refmark");
String name2 = mkName("toxmark");
@@ -2058,7 +1969,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root);
}
- public void test1() throws Exception
+ @Test public void test1() throws Exception
{
String name1 = mkName("frame");
String name2 = mkName("bookmark");
@@ -2085,7 +1996,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
attributes; if these ever become entities, they should not be split!
*/
- public void testRange1() throws Exception
+ @Test public void testRange1() throws Exception
{
String name1 = mkName("url");
RangeInserter inserter = new RangeInserter(m_xDoc);
@@ -2100,7 +2011,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRangeHyperlinkHyperlink() throws Exception
+ @Test public void testRangeHyperlinkHyperlink() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2159,7 +2070,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRangeHyperlinkRuby() throws Exception
+ @Test public void testRangeHyperlinkRuby() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2225,7 +2136,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRangeRubyHyperlink() throws Exception
+ @Test public void testRangeRubyHyperlink() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2282,7 +2193,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRangeRubyRuby() throws Exception
+ @Test public void testRangeRubyRuby() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2328,7 +2239,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRangeHyperlinkMeta() throws Exception
+ @Test public void testRangeHyperlinkMeta() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2394,7 +2305,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRangeRubyMeta() throws Exception
+ @Test public void testRangeRubyMeta() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2461,7 +2372,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRangeMetaHyperlink() throws Exception
+ @Test public void testRangeMetaHyperlink() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2518,7 +2429,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRangeMetaRuby() throws Exception
+ @Test public void testRangeMetaRuby() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2607,7 +2518,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRangeMetaMeta() throws Exception
+ @Test public void testRangeMetaMeta() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2618,7 +2529,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
TreeNode met2 = new MetaNode( mkId("id") );
try {
inserter.insertRange( new Range(0, 4, met2) );
- assure("testRangeMetaMeta: overlap left allowed", false);
+ fail("testRangeMetaMeta: overlap left allowed");
} catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ }
TreeNode root = new TreeNode()
.appendChild( new TextNode("123") )
@@ -2629,7 +2540,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
TreeNode met3 = new MetaNode( mkId("id") );
try {
inserter.insertRange( new Range(5/*-1*/, 8/*-1*/, met3) );
- assure("testRangeMetaMeta: overlap right allowed", false);
+ fail("testRangeMetaMeta: overlap right allowed");
} catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ }
root = new TreeNode()
.appendChild( new TextNode("123") )
@@ -2659,7 +2570,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRange2() throws Exception
+ @Test public void testRange2() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2729,7 +2640,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRange3() throws Exception
+ @Test public void testRange3() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2763,7 +2674,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRange4() throws Exception
+ @Test public void testRange4() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2817,7 +2728,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRange5() throws Exception
+ @Test public void testRange5() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2866,7 +2777,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRange6() throws Exception
+ @Test public void testRange6() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2906,7 +2817,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
doTest(root, false);
}
- public void testRange7() throws Exception
+ @Test public void testRange7() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123456789");
@@ -2947,7 +2858,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
/* TODO: test partial selection, test UNDO/REDO */
// #i109601# NestedTextContent and XChild
- public void testMetaXChild() throws Exception
+ @Test public void testMetaXChild() throws Exception
{
StringPair id1 = new StringPair("content.xml", mkName("id"));
StringPair id2 = new StringPair("content.xml", mkName("id"));
@@ -3022,12 +2933,12 @@ public class TextPortionEnumerationTest extends ComplexTestCase
XTextContent xNTC = (XTextContent)
UnoRuntime.queryInterface(XTextContent.class, oNTC);
if (null == nestedTextContent[i]) {
- assure("unexpected NestedTextContent at: " + i, null == xNTC);
+ assertNull("unexpected NestedTextContent at: " + i, xNTC);
} else {
XMetadatable xMetadatable = (XMetadatable)
UnoRuntime.queryInterface(XMetadatable.class, xNTC);
StringPair xmlid = xMetadatable.getMetadataReference();
- assure("wrong NestedTextContent at: " + i,
+ assertTrue("wrong NestedTextContent at: " + i,
MetaNode.eq(nestedTextContent[i], xmlid));
}
xDocTextCursor.goRight((short)1, false);
@@ -3047,37 +2958,37 @@ public class TextPortionEnumerationTest extends ComplexTestCase
UnoRuntime.queryInterface(XChild.class, xMeta6);
try {
xChild1.setParent(xChild4);
- assure("setParent(): allowed?", false);
+ fail("setParent(): allowed?");
} catch (NoSupportException e) { /* expected */ }
- assure("getParent(): not null", xChild1.getParent() == null);
- assure("getParent(): not null", xChild2.getParent() == null);
- assure("getParent(): not null", xChild6.getParent() == null);
+ assertNull("getParent(): not null", xChild1.getParent());
+ assertNull("getParent(): not null", xChild2.getParent());
+ assertNull("getParent(): not null", xChild6.getParent());
{
Object xParent3 = xChild3.getParent();
- assure("getParent(): null", null != xParent3);
+ assertNotNull("getParent(): null", xParent3);
XMetadatable xMetadatable = (XMetadatable)
UnoRuntime.queryInterface(XMetadatable.class, xParent3);
StringPair xmlid = xMetadatable.getMetadataReference();
- assure("getParent(): wrong", MetaNode.eq(xmlid, id2));
+ assertTrue("getParent(): wrong", MetaNode.eq(xmlid, id2));
}{
Object xParent4 = xChild4.getParent();
- assure("getParent(): null", null != xParent4);
+ assertNotNull("getParent(): null", xParent4);
XMetadatable xMetadatable = (XMetadatable)
UnoRuntime.queryInterface(XMetadatable.class, xParent4);
StringPair xmlid = xMetadatable.getMetadataReference();
- assure("getParent(): wrong", MetaNode.eq(xmlid, id3));
+ assertTrue("getParent(): wrong", MetaNode.eq(xmlid, id3));
}{
Object xParent5 = xChild5.getParent();
- assure("getParent(): null", null != xParent5);
+ assertNotNull("getParent(): null", xParent5);
XMetadatable xMetadatable = (XMetadatable)
UnoRuntime.queryInterface(XMetadatable.class, xParent5);
StringPair xmlid = xMetadatable.getMetadataReference();
- assure("getParent(): wrong", MetaNode.eq(xmlid, id3));
+ assertTrue("getParent(): wrong", MetaNode.eq(xmlid, id3));
}
}
/** test SwXMeta XText interface */
- public void testMetaXText() throws Exception
+ @Test public void testMetaXText() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("12AB6789");
@@ -3099,113 +3010,106 @@ public class TextPortionEnumerationTest extends ComplexTestCase
XText xText = (XText) UnoRuntime.queryInterface(XText.class, xMeta);
XText xParentText = xText.getText();
- assure("getText(): no parent", xParentText != null);
+ assertNotNull("getText(): no parent", xParentText);
XTextRange xStart = xText.getStart();
- assure("getStart(): no start", xStart != null);
+ assertNotNull("getStart(): no start", xStart);
XTextRange xEnd = xText.getEnd();
- assure("getEnd(): no end", xEnd != null);
-
- /*
- String string = xText.getString();
- assure("getString(): invalid string returned",
- string != null && "AB".equals(string) );
- */
+ assertNotNull("getEnd(): no end", xEnd);
xText.setString("45");
{
String string = xText.getString();
- assure("getString(): invalid string returned: " + string,
- string != null && "45".equals(string) );
+ assertEquals("getString(): invalid string returned",
+ "45", string);
}
XTextCursor xTextCursor = xText.createTextCursor();
- assure("createTextCursor(): failed", xTextCursor != null);
+ assertNotNull("createTextCursor(): failed", xTextCursor);
try {
xText.createTextCursorByRange(null);
- assure("createTextCursorByRange(): null allowed?", false);
+ fail("createTextCursorByRange(): null allowed?");
} catch (RuntimeException e) { /* expected */ }
XTextCursor xTextCursorStart = xText.createTextCursorByRange(xStart);
- assure("createTextCursorByRange(): failed for start",
- xTextCursorStart != null);
+ assertNotNull("createTextCursorByRange(): failed for start",
+ xTextCursorStart);
XTextCursor xTextCursorEnd = xText.createTextCursorByRange(xEnd);
- assure("createTextCursorByRange(): failed for end",
- xTextCursorEnd != null);
+ assertNotNull("createTextCursorByRange(): failed for end",
+ xTextCursorEnd);
// move outside meta
xDocTextCursor.gotoStart(false);
try {
xText.insertString(null, "foo", false);
- assure("insertString(): null allowed?", false);
+ fail("insertString(): null allowed?");
} catch (RuntimeException e) { /* expected */ }
try {
xText.insertString(xDocTextCursor, "foo", false);
- assure("insertString(): cursor outside allowed?", false);
+ fail("insertString(): cursor outside allowed?");
} catch (RuntimeException e) { /* expected */ }
xStart = xText.getStart();
xText.insertString(xStart, "A", false);
{
String string = xText.getString();
- assure("getString(): invalid string returned: " + string,
- string != null && "A45".equals(string) );
+ assertEquals("getString(): invalid string returned",
+ "A45", string);
}
xText.insertString(xEnd, "B", false);
{
String string = xText.getString();
- assure("getString(): invalid string returned: " + string,
- string != null && "A45B".equals(string) );
+ assertEquals("getString(): invalid string returned",
+ "A45B", string);
}
try {
xText.insertControlCharacter(null, HARD_HYPHEN, false);
- assure("insertControlCharacter(): null allowed?", false);
+ fail("insertControlCharacter(): null allowed?");
} catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ }
xStart = xText.getStart();
try {
xText.insertControlCharacter(xDocTextCursor, HARD_HYPHEN, false);
- assure("insertControlCharacter(): cursor outside allowed?", false);
+ fail("insertControlCharacter(): cursor outside allowed?");
} catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ }
xText.insertControlCharacter(xStart, HARD_HYPHEN, false);
{
String string = xText.getString();
- assure("getString(): invalid string returned: " + string,
- string != null && ('\u2011' + "A45B").equals(string) );
+ assertEquals("getString(): invalid string returned",
+ '\u2011' + "A45B", string);
}
xText.insertControlCharacter(xEnd, HARD_HYPHEN, false);
{
String string = xText.getString();
- assure("getString(): invalid string returned: " + string,
- string != null &&
- ('\u2011' + "A45B" + '\u2011').equals(string) );
+ assertEquals("getString(): invalid string returned",
+ '\u2011' + "A45B" + '\u2011', string);
}
xText.setString("45");
try {
xText.insertTextContent(null, xMeta, false);
- assure("insertTextContent(): null range allowed?", false);
+ fail("insertTextContent(): null range allowed?");
} catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ }
try {
xText.insertTextContent(xStart, null, false);
- assure("insertTextContent(): null content allowed?", false);
+ fail("insertTextContent(): null content allowed?");
} catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ }
try {
xText.insertTextContent(xDocTextCursor, xMeta, false);
- assure("insertTextContent(): cursor outside allowed?", false);
+ fail("insertTextContent(): cursor outside allowed?");
} catch (com.sun.star.lang.IllegalArgumentException e) { /* ignore */ }
TextFieldNode field1 = new TextFieldNode( "f1" );
@@ -3237,13 +3141,13 @@ public class TextPortionEnumerationTest extends ComplexTestCase
try {
xText.removeTextContent(null);
- assure("removeTextContent(): null content allowed?", false);
+ fail("removeTextContent(): null content allowed?");
} catch (RuntimeException e) { /* expected */ }
xText.removeTextContent(xField1);
XTextRange xAnchor = xMeta.getAnchor();
- assure("getAnchor(): null", xAnchor != null);
+ assertNotNull("getAnchor(): null", xAnchor);
// evil test case: insert ruby around meta
RubyNode ruby = new RubyNode( mkName("ruby") );
@@ -3263,31 +3167,31 @@ public class TextPortionEnumerationTest extends ComplexTestCase
XEnumerationAccess xEA = (XEnumerationAccess)
UnoRuntime.queryInterface(XEnumerationAccess.class, xMeta);
XEnumeration xEnum = xEA.createEnumeration();
- assure("createEnumeration(): returns null", xEnum != null);
+ assertNotNull("createEnumeration(): returns null", xEnum);
{
- assure("hasNext(): first missing", xEnum.hasMoreElements());
+ assertTrue("hasNext(): first missing", xEnum.hasMoreElements());
Object xElement = xEnum.nextElement();
XTextRange xPortion = (XTextRange)
UnoRuntime.queryInterface(XTextRange.class, xElement);
XPropertySet xPropSet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xPortion);
String type = (String) xPropSet.getPropertyValue("TextPortionType");
- assure("first: not text: " + type, type.equals("Text"));
+ assertEquals("first: not text", "Text", type);
String txt = xPortion.getString();
- assure("first: text differs: " + txt, "45".equals(txt));
+ assertEquals("first: text differs", "45", txt);
}
{
- assure("hasNext(): second missing", xEnum.hasMoreElements());
+ assertTrue("hasNext(): second missing", xEnum.hasMoreElements());
Object xElement = xEnum.nextElement();
XTextRange xPortion = (XTextRange)
UnoRuntime.queryInterface(XTextRange.class, xElement);
XPropertySet xPropSet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xPortion);
String type = (String) xPropSet.getPropertyValue("TextPortionType");
- assure("second: not text", type.equals("TextField"));
+ assertEquals("second: not text", "TextField", type);
}
// no ruby end here!!!
- assure("hasNext(): more elements?", !xEnum.hasMoreElements());
+ assertFalse("hasNext(): more elements?", xEnum.hasMoreElements());
XComponent xComponent = (XComponent)
UnoRuntime.queryInterface(XComponent.class, xMeta);
@@ -3295,14 +3199,14 @@ public class TextPortionEnumerationTest extends ComplexTestCase
try {
XTextCursor xCursor = xText.createTextCursor();
- assure("createTextCursor(): succeeds on disposed object?",
- xCursor == null);
+ assertNull("createTextCursor(): succeeds on disposed object?",
+ xCursor);
} catch (RuntimeException e) { /* expected */ }
}
/** check that cursor move methods move to positions in the meta,
but do not move to positions outside the meta. */
- public void testMetaXTextCursor() throws Exception
+ @Test public void testMetaXTextCursor() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("Text. 12 More text here.");
@@ -3323,30 +3227,30 @@ public class TextPortionEnumerationTest extends ComplexTestCase
XText xText = (XText) UnoRuntime.queryInterface(XText.class, xMeta);
XTextRange xStart = xText.getStart();
- assure("getStart(): no start", xStart != null);
+ assertNotNull("getStart(): no start", xStart);
XTextRange xEnd = xText.getEnd();
- assure("getEnd(): no end", xEnd != null);
+ assertNotNull("getEnd(): no end", xEnd);
XTextCursor xTextCursor = xText.createTextCursor();
- assure("createTextCursor(): no cursor", xTextCursor != null);
+ assertNotNull("createTextCursor(): no cursor", xTextCursor);
// XTextCursor
boolean bSuccess = false;
xTextCursor.gotoStart(false);
xTextCursor.gotoEnd(false);
bSuccess = xTextCursor.goLeft((short)1, false);
- assure("goLeft(): failed", bSuccess);
+ assertTrue("goLeft(): failed", bSuccess);
bSuccess = xTextCursor.goLeft((short)1000, false);
- assure("goLeft(): succeeded", !bSuccess);
+ assertFalse("goLeft(): succeeded", bSuccess);
bSuccess = xTextCursor.goRight((short)1, false);
- assure("goRight(): failed", bSuccess);
+ assertTrue("goRight(): failed", bSuccess);
bSuccess = xTextCursor.goRight((short)1000, false);
- assure("goRight(): succeeded", !bSuccess);
+ assertFalse("goRight(): succeeded", bSuccess);
xTextCursor.gotoRange(xStart, false);
xTextCursor.gotoRange(xEnd, false);
try {
xTextCursor.gotoRange(xDocTextCursor, false);
- assure("gotoRange(): succeeded", false);
+ fail("gotoRange(): succeeded");
} catch (RuntimeException e) { /* expected */ }
// XWordCursor
@@ -3356,44 +3260,44 @@ public class TextPortionEnumerationTest extends ComplexTestCase
UnoRuntime.queryInterface(XWordCursor.class, xTextCursor);
bSuccess = xWordCursor.gotoNextWord(true);
- assure("gotoNextWord(): failed", bSuccess);
+ assertTrue("gotoNextWord(): failed", bSuccess);
{
String string = xTextCursor.getString();
- assure("gotoNextWord(): wrong string: " + string,
- "Two ".equals(string));
+ assertEquals("gotoNextWord(): wrong string",
+ "Two ", string);
}
bSuccess = xWordCursor.gotoNextWord(false);
- assure("gotoNextWord(): succeeded", !bSuccess);
+ assertFalse("gotoNextWord(): succeeded", bSuccess);
xTextCursor.collapseToEnd();
bSuccess = xWordCursor.gotoPreviousWord(true);
- assure("gotoPreviousWord(): failed", bSuccess);
+ assertTrue("gotoPreviousWord(): failed", bSuccess);
{
String string = xTextCursor.getString();
- assure("gotoPreviousWord(): wrong string: " + string,
- "words".equals(string));
+ assertEquals("gotoPreviousWord(): wrong string",
+ "words", string);
}
bSuccess = xWordCursor.gotoPreviousWord(false);
- assure("gotoPreviousWord(): succeeded", !bSuccess);
+ assertFalse("gotoPreviousWord(): succeeded", bSuccess);
bSuccess = xWordCursor.gotoEndOfWord(true);
- assure("gotoEndOfWord(): failed", bSuccess);
+ assertTrue("gotoEndOfWord(): failed", bSuccess);
{
String string = xTextCursor.getString();
- assure("gotoEndOfWord(): wrong string: " + string,
- "Two".equals(string));
+ assertEquals("gotoEndOfWord(): wrong string",
+ "Two", string);
}
xTextCursor.gotoEnd(false);
bSuccess = xWordCursor.gotoStartOfWord(true);
- assure("gotoStartOfWord(): failed", bSuccess);
+ assertTrue("gotoStartOfWord(): failed", bSuccess);
{
String string = xTextCursor.getString();
- assure("gotoStartOfWord(): wrong string: " + string,
- "words".equals(string));
+ assertEquals("gotoStartOfWord(): wrong string",
+ "words", string);
}
xText.setString("");
bSuccess = xWordCursor.gotoEndOfWord(false);
- assure("gotoEndOfWord(): succeeded", !bSuccess);
+ assertFalse("gotoEndOfWord(): succeeded", bSuccess);
bSuccess = xWordCursor.gotoStartOfWord(false);
- assure("gotoStartOfWord(): succeeded", !bSuccess);
+ assertFalse("gotoStartOfWord(): succeeded", bSuccess);
// XSentenceCursor
xText.setString("This is a sentence. Another sentence.");
@@ -3402,60 +3306,60 @@ public class TextPortionEnumerationTest extends ComplexTestCase
UnoRuntime.queryInterface(XSentenceCursor.class, xTextCursor);
bSuccess = xSentenceCursor.gotoNextSentence(true);
- assure("gotoNextSentence(): failed", bSuccess);
+ assertTrue("gotoNextSentence(): failed", bSuccess);
{
String string = xTextCursor.getString();
- assure("gotoNextSentence(): wrong string: " + string,
- "This is a sentence. ".equals(string));
+ assertEquals("gotoNextSentence(): wrong string",
+ "This is a sentence. ", string);
}
bSuccess = xSentenceCursor.gotoNextSentence(false);
- assure("gotoNextSentence(): succeeded", !bSuccess);
+ assertFalse("gotoNextSentence(): succeeded", bSuccess);
// FIXME:
// the sentence cursor seems to work differently than the word cursor
xText.setString("This is a sentence. Another sentence. Sentence 3.");
xTextCursor.gotoEnd(false);
bSuccess = xSentenceCursor.gotoPreviousSentence(true);
- assure("gotoPreviousSentence(): failed", bSuccess);
+ assertTrue("gotoPreviousSentence(): failed", bSuccess);
{
String string = xTextCursor.getString();
- assure("gotoPreviousSentence(): wrong string: " + string,
- "Another sentence. Sentence 3.".equals(string));
+ assertEquals("gotoPreviousSentence(): wrong string",
+ "Another sentence. Sentence 3.", string);
}
bSuccess = xSentenceCursor.gotoPreviousSentence(false);
- assure("gotoPreviousSentence(): succeeded", !bSuccess);
+ assertFalse("gotoPreviousSentence(): succeeded", bSuccess);
bSuccess = xSentenceCursor.gotoEndOfSentence(true);
- assure("gotoEndOfSentence(): failed", bSuccess);
+ assertTrue("gotoEndOfSentence(): failed", bSuccess);
{
String string = xTextCursor.getString();
- assure("gotoEndOfSentence(): wrong string: " + string,
- "This is a sentence.".equals(string));
+ assertEquals("gotoEndOfSentence(): wrong string",
+ "This is a sentence.", string);
}
xTextCursor.gotoEnd(false);
bSuccess = xSentenceCursor.gotoStartOfSentence(true);
- assure("gotoStartOfSentence(): failed", bSuccess);
+ assertTrue("gotoStartOfSentence(): failed", bSuccess);
{
String string = xTextCursor.getString();
- assure("gotoStartOfSentence(): wrong string: " + string,
- "Sentence 3.".equals(string));
+ assertEquals("gotoStartOfSentence(): wrong string",
+ "Sentence 3.", string);
}
xText.setString("");
bSuccess = xSentenceCursor.gotoEndOfSentence(false);
- assure("gotoEndOfSentence(): succeeded", !bSuccess);
+ assertFalse("gotoEndOfSentence(): succeeded", bSuccess);
bSuccess = xSentenceCursor.gotoStartOfSentence(false);
- assure("gotoStartOfSentence(): succeeded", !bSuccess);
+ assertFalse("gotoStartOfSentence(): succeeded", bSuccess);
XParagraphCursor xParagraphCursor = (XParagraphCursor)
UnoRuntime.queryInterface(XParagraphCursor.class, xTextCursor);
// XParagraphCursor (does not make sense)
bSuccess = xParagraphCursor.gotoNextParagraph(false);
- assure("gotoNextParagraph(): succeeded", !bSuccess);
+ assertFalse("gotoNextParagraph(): succeeded", bSuccess);
bSuccess = xParagraphCursor.gotoPreviousParagraph(false);
- assure("gotoPreviousParagraph(): succeeded", !bSuccess);
+ assertFalse("gotoPreviousParagraph(): succeeded", bSuccess);
bSuccess = xParagraphCursor.gotoStartOfParagraph(false);
- assure("gotoStartOfParagraph(): succeeded", !bSuccess);
+ assertFalse("gotoStartOfParagraph(): succeeded", bSuccess);
bSuccess = xParagraphCursor.gotoEndOfParagraph(false);
- assure("gotoEndOfParagraph(): succeeded", !bSuccess);
+ assertFalse("gotoEndOfParagraph(): succeeded", bSuccess);
}
@@ -3469,7 +3373,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
throws Exception { }
}
- public void testMetaXTextAttachToxMark() throws Exception
+ @Test public void testMetaXTextAttachToxMark() throws Exception
{
doMetaXTextAttach( new AttachHelper()
{
@@ -3485,7 +3389,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
});
}
- public void testMetaXTextAttachRefMark() throws Exception
+ @Test public void testMetaXTextAttachRefMark() throws Exception
{
doMetaXTextAttach( new AttachHelper()
{
@@ -3501,7 +3405,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
});
}
- public void testMetaXTextAttachTextField() throws Exception
+ @Test public void testMetaXTextAttachTextField() throws Exception
{
doMetaXTextAttach( new AttachHelper()
{
@@ -3517,7 +3421,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
});
}
- public void testMetaXTextAttachFootnote() throws Exception
+ @Test public void testMetaXTextAttachFootnote() throws Exception
{
doMetaXTextAttach( new AttachHelper()
{
@@ -3533,7 +3437,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
});
}
- public void testMetaXTextAttachMeta() throws Exception
+ @Test public void testMetaXTextAttachMeta() throws Exception
{
doMetaXTextAttach( new AttachHelper()
{
@@ -3783,7 +3687,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
}
}
- public void testMetaFieldXTextField() throws Exception
+ @Test public void testMetaFieldXTextField() throws Exception
{
com.sun.star.rdf.XRepositorySupplier xModel =
(com.sun.star.rdf.XRepositorySupplier) UnoRuntime.queryInterface(
@@ -3821,12 +3725,12 @@ public class TextPortionEnumerationTest extends ComplexTestCase
xGraph.addStatement(xMetadatable, xOdfPrefix, xPrefix);
xGraph.addStatement(xMetadatable, xOdfSuffix, xSuffix);
- assure("getPresentation(): wrong",
- "fooabcbar".equals(xMetaField.getPresentation(false)));
+ assertEquals("getPresentation(): wrong",
+ "fooabcbar", xMetaField.getPresentation(false));
inserter.insertRange( new Range(0, 0, text) );
}
- public void testMetaFieldXPropertySet() throws Exception
+ @Test public void testMetaFieldXPropertySet() throws Exception
{
RangeInserter inserter = new RangeInserter(m_xDoc);
TreeNode text = new TextNode("123");
@@ -3842,32 +3746,32 @@ public class TextPortionEnumerationTest extends ComplexTestCase
XPropertySet xPropertySet = (XPropertySet)
UnoRuntime.queryInterface(XPropertySet.class, xMetaField);
- assure("PropertySet: not supported?", xPropertySet != null);
+ assertNotNull("PropertySet: not supported?", xPropertySet);
XPropertySetInfo xPropertySetInfo = xPropertySet.getPropertySetInfo();
- assure("hasPropertyByName(\"NumberFormat\"):",
- xPropertySetInfo.hasPropertyByName("NumberFormat"));
- assure("hasPropertyByName(\"IsFixedLanguage\"):",
- xPropertySetInfo.hasPropertyByName("IsFixedLanguage"));
+ assertTrue("hasPropertyByName(\"NumberFormat\"):",
+ xPropertySetInfo.hasPropertyByName("NumberFormat"));
+ assertTrue("hasPropertyByName(\"IsFixedLanguage\"):",
+ xPropertySetInfo.hasPropertyByName("IsFixedLanguage"));
int def = (Integer) xPropertySet.getPropertyValue("NumberFormat");
- log.println("NumberFormat: default is " + def);
+ System.out.println("NumberFormat: default is " + def);
short INT = com.sun.star.i18n.NumberFormatIndex.NUMBER_INT;
xPropertySet.setPropertyValue("NumberFormat", INT);
xPropertySet.setPropertyValue("IsFixedLanguage", true);
int format = (Integer) xPropertySet.getPropertyValue("NumberFormat");
- assure("NumberFormat: failed", format == INT);
+ assertEquals("NumberFormat: failed", INT, format);
boolean isFixed = (Boolean)
xPropertySet.getPropertyValue("IsFixedLanguage");
- assure("IsFixedLanguage: failed", isFixed);
+ assertTrue("IsFixedLanguage: failed", isFixed);
}
- public void testLoadStore() throws Exception
+ @Test public void testLoadStore() throws Exception
{
XTextDocument xComp = null;
String filename = "TESTMETA.odt";
String file;
try {
- file = util.utils.getFullTestURL(filename);
+ file = TestDocument.getUrl(filename);
xComp = doLoad(file);
if (xComp != null)
{
@@ -3885,21 +3789,21 @@ public class TextPortionEnumerationTest extends ComplexTestCase
private void doStore(XComponent xComp, String file) throws Exception
{
- log.println("Storing test document...");
+ System.out.println("Storing test document...");
XStorable xStor = (XStorable) UnoRuntime.queryInterface(
XStorable.class, xComp);
xStor.storeToURL(file, new PropertyValue[0]);
- log.println("...done");
+ System.out.println("...done");
}
public XTextDocument doLoad(String file) throws Exception
{
XComponent xComp = null;
- log.println("Loading test document...");
+ System.out.println("Loading test document...");
PropertyValue[] loadProps = new PropertyValue[1];
loadProps[0] = new PropertyValue();
@@ -3912,9 +3816,9 @@ public class TextPortionEnumerationTest extends ComplexTestCase
XTextDocument xTextDoc = (XTextDocument)
UnoRuntime.queryInterface(XTextDocument.class, xComp);
- assure("cannot load: " + file, xTextDoc != null);
+ assertNotNull("cannot load: " + file, xTextDoc);
- log.println("...done");
+ System.out.println("...done");
return xTextDoc;
}
@@ -3923,7 +3827,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
{
XText xText = xTextDoc.getText();
- log.println("Checking meta(-field)s in loaded test document...");
+ System.out.println("Checking meta(-field)s in loaded test document...");
TreeNode root = new TreeNode()
.appendChild( new RubyNode("ruby1")
@@ -3968,16 +3872,16 @@ public class TextPortionEnumerationTest extends ComplexTestCase
.appendChild( new TextNode(" X X ") );
doTest(xTextDoc, root, false);
- log.println("...done");
+ System.out.println("...done");
}
- public void testLoadStoreXmlid() throws Exception
+ @Test public void testLoadStoreXmlid() throws Exception
{
XTextDocument xComp = null;
String filename = "TESTXMLID.odt";
String file;
try {
- file = util.utils.getFullTestURL(filename);
+ file = TestDocument.getUrl(filename);
xComp = doLoad(file);
if (xComp != null)
{
@@ -3997,7 +3901,7 @@ public class TextPortionEnumerationTest extends ComplexTestCase
{
XText xText = xTextDoc.getText();
- log.println("Checking bookmarks in loaded test document...");
+ System.out.println("Checking bookmarks in loaded test document...");
XRepositorySupplier xRS = (XRepositorySupplier)
UnoRuntime.queryInterface(XRepositorySupplier.class, xTextDoc);
@@ -4009,14 +3913,14 @@ public class TextPortionEnumerationTest extends ComplexTestCase
XNameAccess xBookmarks = xBMS.getBookmarks();
XMetadatable xMark1 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xBookmarks.getByName("mk1"));
- assure("mark1",
+ assertTrue("mark1",
eq(xMark1.getMetadataReference(),
new StringPair("content.xml", "id90")));
XMetadatable xMark2 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xBookmarks.getByName("mk2"));
Pair<Statement[], Boolean> result = xRepo.getStatementRDFa(xMark2);
- assure("mark2", (result.First.length == 1)
+ assertTrue("mark2", (result.First.length == 1)
&& result.First[0].Subject.getStringValue().equals("uri:foo")
&& result.First[0].Predicate.getStringValue().equals("uri:bar")
&& result.First[0].Object.getStringValue().contains("a fooish bar")
@@ -4024,13 +3928,13 @@ public class TextPortionEnumerationTest extends ComplexTestCase
XMetadatable xMark3 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xBookmarks.getByName("mk3"));
- assure("mark3",
+ assertTrue("mark3",
eq(xMark3.getMetadataReference(),
new StringPair("content.xml", "id91")));
- log.println("...done");
+ System.out.println("...done");
- log.println("Checking sections in loaded test document...");
+ System.out.println("Checking sections in loaded test document...");
XTextSectionsSupplier xTSS = (XTextSectionsSupplier)
UnoRuntime.queryInterface(XTextSectionsSupplier.class, xTextDoc);
@@ -4039,58 +3943,58 @@ public class TextPortionEnumerationTest extends ComplexTestCase
XMetadatable xSection1 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xSections.getByName("Section 1"));
- assure("idsection1", eq(xSection1.getMetadataReference(),
+ assertTrue("idsection1", eq(xSection1.getMetadataReference(),
new StringPair("content.xml", "idSection1")));
XMetadatable xSection2 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xSections.getByName("Section 2"));
- assure("idSection2", eq(xSection2.getMetadataReference(),
+ assertTrue("idSection2", eq(xSection2.getMetadataReference(),
new StringPair("content.xml", "idSection2")));
XMetadatable xSection3 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class,
xSections.getByName("Table of Contents1_Head"));
- assure("idTOCTitle", eq(xSection3.getMetadataReference(),
+ assertTrue("idTOCTitle", eq(xSection3.getMetadataReference(),
new StringPair("content.xml", "idTOCTitle")));
XMetadatable xSection4 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class,
xSections.getByName("Alphabetical Index1_Head"));
- assure("idAITitle", eq(xSection4.getMetadataReference(),
+ assertTrue("idAITitle", eq(xSection4.getMetadataReference(),
new StringPair("content.xml", "idAITitle")));
XMetadatable xSection5 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class,
xSections.getByName("Illustration Index1_Head"));
- assure("idIITitle", eq(xSection5.getMetadataReference(),
+ assertTrue("idIITitle", eq(xSection5.getMetadataReference(),
new StringPair("content.xml", "idIITitle")));
XMetadatable xSection6 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class,
xSections.getByName("Index of Tables1_Head"));
- assure("idIOTTitle", eq(xSection6.getMetadataReference(),
+ assertTrue("idIOTTitle", eq(xSection6.getMetadataReference(),
new StringPair("content.xml", "idIOTTitle")));
XMetadatable xSection7 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class,
xSections.getByName("User-Defined1_Head"));
- assure("idUDTitle", eq(xSection7.getMetadataReference(),
+ assertTrue("idUDTitle", eq(xSection7.getMetadataReference(),
new StringPair("content.xml", "idUDTitle")));
XMetadatable xSection8 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class,
xSections.getByName("Table of Objects1_Head"));
- assure("idTOOTitle", eq(xSection8.getMetadataReference(),
+ assertTrue("idTOOTitle", eq(xSection8.getMetadataReference(),
new StringPair("content.xml", "idTOOTitle")));
XMetadatable xSection9 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xSections.getByName("Bibliography1_Head"));
- assure("idBibTitle", eq(xSection9.getMetadataReference(),
+ assertTrue("idBibTitle", eq(xSection9.getMetadataReference(),
new StringPair("content.xml", "idBibTitle")));
- log.println("...done");
+ System.out.println("...done");
- log.println("Checking indexes in loaded test document...");
+ System.out.println("Checking indexes in loaded test document...");
XDocumentIndexesSupplier xDIS = (XDocumentIndexesSupplier)
UnoRuntime.queryInterface(XDocumentIndexesSupplier.class, xTextDoc);
@@ -4100,68 +4004,68 @@ public class TextPortionEnumerationTest extends ComplexTestCase
XMetadatable xIndex1 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xIndexes.getByName("Table of Contents1"));
- assure("idTOC", eq(xIndex1.getMetadataReference(),
+ assertTrue("idTOC", eq(xIndex1.getMetadataReference(),
new StringPair("content.xml", "idTOC")));
XMetadatable xIndex1s = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xSections.getByName("Table of Contents1"));
- assure("idTOC", eq(xIndex1s.getMetadataReference(),
+ assertTrue("idTOC", eq(xIndex1s.getMetadataReference(),
new StringPair("content.xml", "idTOC")));
XMetadatable xIndex2 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xIndexes.getByName("Alphabetical Index1"));
- assure("idAI", eq(xIndex2.getMetadataReference(),
+ assertTrue("idAI", eq(xIndex2.getMetadataReference(),
new StringPair("content.xml", "idAI")));
XMetadatable xIndex2s = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xSections.getByName("Alphabetical Index1"));
- assure("idAI", eq(xIndex2s.getMetadataReference(),
+ assertTrue("idAI", eq(xIndex2s.getMetadataReference(),
new StringPair("content.xml", "idAI")));
XMetadatable xIndex3 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xIndexes.getByName("Illustration Index1"));
- assure("idII", eq(xIndex3.getMetadataReference(),
+ assertTrue("idII", eq(xIndex3.getMetadataReference(),
new StringPair("content.xml", "idII")));
XMetadatable xIndex3s = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xSections.getByName("Illustration Index1"));
- assure("idII", eq(xIndex3s.getMetadataReference(),
+ assertTrue("idII", eq(xIndex3s.getMetadataReference(),
new StringPair("content.xml", "idII")));
XMetadatable xIndex4 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xIndexes.getByName("Index of Tables1"));
- assure("idIOT", eq(xIndex4.getMetadataReference(),
+ assertTrue("idIOT", eq(xIndex4.getMetadataReference(),
new StringPair("content.xml", "idIOT")));
XMetadatable xIndex4s = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xSections.getByName("Index of Tables1"));
- assure("idIOT", eq(xIndex4s.getMetadataReference(),
+ assertTrue("idIOT", eq(xIndex4s.getMetadataReference(),
new StringPair("content.xml", "idIOT")));
XMetadatable xIndex5 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xIndexes.getByName("User-Defined1"));
- assure("idUD", eq(xIndex5.getMetadataReference(),
+ assertTrue("idUD", eq(xIndex5.getMetadataReference(),
new StringPair("content.xml", "idUD")));
XMetadatable xIndex5s = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xSections.getByName("User-Defined1"));
- assure("idUD", eq(xIndex5s.getMetadataReference(),
+ assertTrue("idUD", eq(xIndex5s.getMetadataReference(),
new StringPair("content.xml", "idUD")));
XMetadatable xIndex6 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xIndexes.getByName("Table of Objects1"));
- assure("idTOO", eq(xIndex6.getMetadataReference(),
+ assertTrue("idTOO", eq(xIndex6.getMetadataReference(),
new StringPair("content.xml", "idTOO")));
XMetadatable xIndex6s = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xSections.getByName("Table of Objects1"));
- assure("idTOO", eq(xIndex6s.getMetadataReference(),
+ assertTrue("idTOO", eq(xIndex6s.getMetadataReference(),
new StringPair("content.xml", "idTOO")));
XMetadatable xIndex7 = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xIndexes.getByName("Bibliography1"));
- assure("idBib", eq(xIndex7.getMetadataReference(),
+ assertTrue("idBib", eq(xIndex7.getMetadataReference(),
new StringPair("content.xml", "idBib")));
XMetadatable xIndex7s = (XMetadatable) UnoRuntime.queryInterface(
XMetadatable.class, xSections.getByName("Bibliography1"));
- assure("idBib", eq(xIndex7s.getMetadataReference(),
+ assertTrue("idBib", eq(xIndex7s.getMetadataReference(),
new StringPair("content.xml", "idBib")));
- log.println("...done");
+ System.out.println("...done");
}
static void close(XComponent i_comp)
@@ -4205,19 +4109,18 @@ public class TextPortionEnumerationTest extends ComplexTestCase
XEnumerationAccess xEA = (XEnumerationAccess)
UnoRuntime.queryInterface(XEnumerationAccess.class, xElement);
XEnumeration xEnum = xEA.createEnumeration();
- TreeNode outtree = new EnumConverter(this).convert(xEnum);
+ TreeNode outtree = new EnumConverter().convert(xEnum);
dumpTree(outtree, "O: ");
- boolean success = new FuzzyTester(log).doTest(intree, outtree);
- assure("test failed", success);
+ new FuzzyTester().doTest(intree, outtree);
}
private void dumpTree(TreeNode tree) { dumpTree(tree, "> "); }
private void dumpTree(TreeNode tree, String prefix)
{
- log.println(prefix + tree.toString());
+ System.out.println(prefix + tree.toString());
TreeNodeEnum children = tree.createEnumeration();
while (children.hasNext()) {
TreeNode node = children.next();
@@ -4246,6 +4149,16 @@ public class TextPortionEnumerationTest extends ComplexTestCase
((i_Left.Second).equals(i_Right.Second));
}
- public void assure(String str, boolean cond) { super.assure(str, cond); }
+ @BeforeClass public static void setUpConnection() throws Exception {
+ connection.setUp();
+ }
+
+ @AfterClass public static void tearDownConnection()
+ throws InterruptedException, com.sun.star.uno.Exception
+ {
+ connection.tearDown();
+ }
+
+ private static final OfficeConnection connection = new OfficeConnection();
}