diff options
author | Vladimir Glazunov <vg@openoffice.org> | 2010-10-14 14:25:42 +0200 |
---|---|---|
committer | Vladimir Glazunov <vg@openoffice.org> | 2010-10-14 14:25:42 +0200 |
commit | ee4b5132f9d210dd435f242b228c3d1ad6d3b904 (patch) | |
tree | 93edf42a3543cdf1a0a2fae069acce9b5b82290b | |
parent | 8db1c25acfaaa5bb66faa66c5c6668e62129b415 (diff) | |
parent | ef94db4da3f11ad59062fdcfc1dd35a9ff6b571d (diff) |
CWS-TOOLING: integrate CWS sb123
-rw-r--r-- | starmath/qa/unoapi/knownissues.xcl | 3 | ||||
-rw-r--r--[-rwxr-xr-x] | sw/prj/build.lst | 8 | ||||
-rw-r--r-- | sw/qa/complex/accessibility/AccessibleRelationSet.java | 173 | ||||
-rw-r--r-- | sw/qa/complex/accessibility/makefile.mk | 43 | ||||
-rwxr-xr-x | sw/qa/complex/checkColor/CheckChangeColor.java | 121 | ||||
-rwxr-xr-x | sw/qa/complex/checkColor/makefile.mk | 61 | ||||
-rwxr-xr-x | sw/qa/complex/indeterminateState/CheckIndeterminateState.java | 133 | ||||
-rwxr-xr-x | sw/qa/complex/indeterminateState/makefile.mk | 66 | ||||
-rw-r--r-- | sw/qa/complex/writer/CheckBookmarks.java | 127 | ||||
-rw-r--r-- | sw/qa/complex/writer/CheckCrossReferences.java | 334 | ||||
-rw-r--r-- | sw/qa/complex/writer/CheckFlies.java | 219 | ||||
-rwxr-xr-x | sw/qa/complex/writer/CheckIndexedPropertyValues.java | 184 | ||||
-rwxr-xr-x | sw/qa/complex/writer/CheckNamedPropertyValues.java | 200 | ||||
-rw-r--r-- | sw/qa/complex/writer/TestDocument.java | 39 | ||||
-rwxr-xr-x | sw/qa/complex/writer/TextPortionEnumerationTest.java | 645 | ||||
-rwxr-xr-x | sw/qa/complex/writer/makefile.mk | 100 | ||||
-rw-r--r-- | sw/qa/unoapi/knownissues.xcl | 14 | ||||
-rw-r--r-- | sw/qa/unoapi/sw.sce | 6 |
18 files changed, 1022 insertions, 1454 deletions
diff --git a/starmath/qa/unoapi/knownissues.xcl b/starmath/qa/unoapi/knownissues.xcl index e11895ef3f..f82014a51a 100644 --- a/starmath/qa/unoapi/knownissues.xcl +++ b/starmath/qa/unoapi/knownissues.xcl @@ -16,3 +16,6 @@ sm.SmGraphicAccessible::com::sun::star::accessibility::XAccessibleText ### i111220 ### sm.XMLMetaExporter::com::sun::star::document::XFilter + +### i112743 ### +sm.XMLSettingsExporter::com::sun::star::document::XFilter diff --git a/sw/prj/build.lst b/sw/prj/build.lst index 87d163d726..8b6cecba92 100755..100644 --- a/sw/prj/build.lst +++ b/sw/prj/build.lst @@ -74,4 +74,10 @@ sw sw\source\ui nmake - all sw_ui sw_app sw sw\source\core nmake - all sw_core sw_attr sw_bast sw_crsr sw_dcnd sw_doc sw_draw sw_edit sw_excpt sw_fld sw_frmed sw_grph sw_layo sw_ole sw_para sw_sw3io sw_swg sw_text sw_tox sw_txtnd sw_uco sw_undo sw_view sw_acc sw_objpos sw_NumberTree sw_tablecore NULL sw sw\source\filter nmake - all sw_flt sw_ascii sw_bsflt sw_html sw_rtf sw_wrtr sw_ww1 sw_ww8 sw_xml NULL sw sw\util nmake - all sw_util sw_core sw_flt sw_sdi sw_ui NULL -sw sw\qa\unoapi nmake - all sw_qa_unoapi NULL + +sw sw\qa\complex\accessibility nmake - all sw_qa_complex_accessibility sw_util NULL +sw sw\qa\complex\checkColor nmake - all sw_qa_complex_checkColor sw_util NULL +# fails +# sw sw\qa\complex\indeterminateState nmake - all sw_qa_complex_indeterminateState sw_util NULL +# sw sw\qa\complex\writer nmake - all sw_qa_complex_writer sw_util NULL +sw sw\qa\unoapi nmake - all sw_qa_unoapi sw_util NULL diff --git a/sw/qa/complex/accessibility/AccessibleRelationSet.java b/sw/qa/complex/accessibility/AccessibleRelationSet.java index eb9b4fe31b..4c9b99af6d 100644 --- a/sw/qa/complex/accessibility/AccessibleRelationSet.java +++ b/sw/qa/complex/accessibility/AccessibleRelationSet.java @@ -27,7 +27,6 @@ package complex.accessibility; -import com.sun.star.accessibility.AccessibleRelation; import com.sun.star.accessibility.AccessibleRole; import com.sun.star.accessibility.XAccessible; import com.sun.star.accessibility.XAccessibleText; @@ -42,68 +41,61 @@ import com.sun.star.text.XText; import com.sun.star.text.XTextCursor; import com.sun.star.text.XTextDocument; import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XInterface; -import complexlib.ComplexTestCase; -import java.io.PrintWriter; -import lib.StatusException; +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 util.AccessibilityTools; import util.WriterTools; -import util.utils; +import static org.junit.Assert.*; -public class AccessibleRelationSet extends ComplexTestCase { - - private static XAccessible para1 = null; - private static XAccessible para2 = null; - private static XAccessible para3 = null; - private static XTextDocument xTextDoc = null; +public class AccessibleRelationSet { + private XAccessible para1 = null; + private XAccessible para2 = null; + private XAccessible para3 = null; + private XTextDocument xTextDoc = null; private final static String[] types = {"INVALID","CONTENT_FLOWS_FROM","CONTENT_FLOWS_TO","CONTROLLED_BY","CONTROLLER_FOR","LABEL_FOR","LABELED_BY","MEMBER_OF","SUB_WINDOW_OF"}; - public String[] getTestMethodNames() { - return new String[]{"contents_flows_to","contents_flows_from"}; - } - - public void contents_flows_to() { + @Test public void contents_flows_to() { XAccessibleRelationSet set = getAccessibleRelation(para1); - boolean res = true; short firstrelation=-1; XAccessibleText atarget=null; if (set != null) { - log.println("Count of relations "+set.getRelationCount()); - assure("didn't gain correct count of relations", - set.getRelationCount() == 1); + assertEquals( + "didn't gain correct count of relations", 1, + set.getRelationCount()); try { firstrelation = set.getRelation(0).RelationType; Object oTmp = set.getRelation(0).TargetSet[0]; atarget = (XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, oTmp); } catch (IndexOutOfBoundsException e) { - log.println("Exception when getting relations "+e); - res = false; + fail("Exception when getting relations "+e); } } - log.println("Expected for paragraph 0 "+types[2]); - log.println("gained for paragraph 0 "+types[firstrelation]); - res = types[2].equals(types[firstrelation]); - assure("didn't gain correct relation type",res); + assertEquals( + "didn't gain correct relation type for paragraph 0", types[2], + types[firstrelation]); - log.println("Text of target paragraph "+atarget.getText()); XAccessibleText paraTxt2 = (XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, para2); - assure("didn't gain correct target paragraph", - atarget.getText().equals(paraTxt2.getText()) ); + assertEquals( + "didn't gain correct target paragraph", atarget.getText(), + paraTxt2.getText()); } - public void contents_flows_from() { + @Test public void contents_flows_from() { XAccessibleRelationSet set = getAccessibleRelation(para2); - boolean res = true; short[] relationtypes = new short[2]; XAccessibleText[] atargets = new XAccessibleText[2]; if (set != null) { - log.println("Count of relations "+set.getRelationCount()); - assure("didn't gain correct count of relations", - set.getRelationCount() == 2); + assertEquals( + "didn't gain correct count of relations", 2, + set.getRelationCount()); try { short tmprelation = set.getRelation(0).RelationType; if ( tmprelation == 1 ) @@ -120,7 +112,7 @@ public class AccessibleRelationSet extends ComplexTestCase { } else { - assure("didn't gain correct relation type", false); + fail("didn't gain correct relation type"); } tmprelation = set.getRelation(1).RelationType; if ( tmprelation == 1 ) @@ -137,79 +129,51 @@ public class AccessibleRelationSet extends ComplexTestCase { } else { - assure("didn't gain correct relation type", false); + fail("didn't gain correct relation type"); } } catch (IndexOutOfBoundsException e) { - log.println("Exception when getting relations "+e); - res = false; + fail("Exception when getting relations "+e); } } - log.println("### Checking "+types[1]+" for paragraph 1"); - log.println("Expected for paragraph 1 "+types[1]); - log.println("gained for paragraph 1 "+types[relationtypes[0]]); - res = types[1].equals(types[relationtypes[0]]); - assure("didn't gain correct relation type",res); + assertEquals( + "didn't gain correct relation type for paragraph 1", types[1], + types[relationtypes[0]]); - log.println("Text of target paragraph "+atargets[0].getText()); XAccessibleText paraTxt1 = (XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, para1); - assure("didn't gain correct target paragraph", - atargets[0].getText().equals(paraTxt1.getText()) ); + assertEquals( + "didn't gain correct target paragraph", atargets[0].getText(), + paraTxt1.getText()); - log.println("### Checking "+types[2]+" for paragraph 1"); - log.println("Expected for paragraph 1 "+types[2]); - log.println("gained for paragraph 1 "+types[relationtypes[1]]); - res = types[2].equals(types[relationtypes[1]]); - assure("didn't gain correct relation type",res); + assertEquals( + "didn't gain correct relation type for paragraph 3", types[2], + types[relationtypes[1]]); - log.println("Text of target paragraph "+atargets[1].getText()); XAccessibleText paraTxt3 = (XAccessibleText) UnoRuntime.queryInterface(XAccessibleText.class, para3); - assure("didn't gain correct target paragraph", - atargets[1].getText().equals(paraTxt3.getText()) ); + assertEquals( + "didn't gain correct target paragraph", atargets[1].getText(), + paraTxt3.getText()); } - private boolean getResult(XAccessible aPara, short index, int nr) { - XAccessibleRelationSet set = getAccessibleRelation(aPara); - - boolean res = true; - short firstrelation=-1; - if (set != null) { - log.println("Count of relations "+set.getRelationCount()); - try { - firstrelation = set.getRelation(0).RelationType; - } catch (IndexOutOfBoundsException e) { - log.println("Exception when getting relations "+e); - res = false; - } - } + @Before public void before() + throws com.sun.star.lang.IllegalArgumentException, + IndexOutOfBoundsException + { + XMultiServiceFactory factory = UnoRuntime.queryInterface( + XMultiServiceFactory.class, + connection.getComponentContext().getServiceManager()); - - log.println("Expected for paragraph "+nr+" "+types[index]); - log.println("gained for paragraph "+nr+" "+types[firstrelation]); - res = types[index].equals(types[firstrelation]); - return res; - } - - - public void before() { - log.println( "creating a text document" ); - xTextDoc = WriterTools.createTextDoc( (XMultiServiceFactory) param.getMSF()); + xTextDoc = WriterTools.createTextDoc(factory); XText oText = xTextDoc.getText(); XTextCursor oCursor = oText.createTextCursor(); - log.println( "inserting some lines" ); - try { - for (int i=0; i<5; i++){ - oText.insertString( oCursor,"Paragraph Number: " + i, false); - oText.insertControlCharacter( - oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); - } - } catch ( com.sun.star.lang.IllegalArgumentException e ){ - e.printStackTrace((PrintWriter)log); - throw new StatusException( "Couldn't insert lines", e ); + for (int i=0; i<5; i++){ + oText.insertString( oCursor,"Paragraph Number: " + i, false); + oText.insertControlCharacter( + oCursor, ControlCharacter.PARAGRAPH_BREAK, false ); } XModel aModel = (XModel) @@ -217,26 +181,17 @@ public class AccessibleRelationSet extends ComplexTestCase { AccessibilityTools at = new AccessibilityTools(); - XWindow xWindow = at.getCurrentWindow( (XMultiServiceFactory) param.getMSF(), aModel); + XWindow xWindow = at.getCurrentWindow(factory, aModel); XAccessible xRoot = at.getAccessibleObject(xWindow); at.getAccessibleObjectForRole(xRoot, AccessibleRole.DOCUMENT); - try { - para1 = at.SearchedContext.getAccessibleChild(0); - para2 = at.SearchedContext.getAccessibleChild(1); - para3 = at.SearchedContext.getAccessibleChild(2); - } catch(IndexOutOfBoundsException e) { - e.printStackTrace((PrintWriter)log); - throw new StatusException( "Couldn't insert lines", e ); - } - - log.println("ImplementationName (para1)" + utils.getImplName(para1)); - log.println("ImplementationName (para2)" + utils.getImplName(para2)); + para1 = at.SearchedContext.getAccessibleChild(0); + para2 = at.SearchedContext.getAccessibleChild(1); + para3 = at.SearchedContext.getAccessibleChild(2); } - public void after() { - log.println("close text document"); + @After public void after() { util.DesktopTools.closeDoc(xTextDoc); } @@ -248,5 +203,15 @@ public class AccessibleRelationSet extends ComplexTestCase { return set; } + @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(); } diff --git a/sw/qa/complex/accessibility/makefile.mk b/sw/qa/complex/accessibility/makefile.mk index e4096829bb..06e7c6a704 100644 --- a/sw/qa/complex/accessibility/makefile.mk +++ b/sw/qa/complex/accessibility/makefile.mk @@ -25,33 +25,26 @@ # #************************************************************************* -PRJ = ..$/..$/.. -TARGET = AccessibleRelationSet -PRJNAME = sw -PACKAGE = complex$/accessibility - -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - - -#----- compile .java files ----------------------------------------- +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE -JARFILES = ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar -JAVAFILES = AccessibleRelationSet.java -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -#----- make a jar from compiled files ------------------------------ - -MAXLINELENGTH = 100000 - -JARCLASSDIRS = $(PACKAGE) -JARTARGET = $(TARGET).jar -JARCOMPRESS = TRUE +PRJ = ../../.. +PRJNAME = sw +TARGET = qa_complex_accessibility -# --- Targets ------------------------------------------------------ +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/accessibility +JAVATESTFILES = AccessibleRelationSet.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END -.INCLUDE : target.mk +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk +ALLTAR : javatest -run: - +java -cp $(CLASSPATH) org.openoffice.Runner -TimeOut 0 -tb java_complex -o $(PACKAGE:s#$/#.#).$(JAVAFILES:b) +.END diff --git a/sw/qa/complex/checkColor/CheckChangeColor.java b/sw/qa/complex/checkColor/CheckChangeColor.java index 5fac27a99d..a072072e18 100755 --- a/sw/qa/complex/checkColor/CheckChangeColor.java +++ b/sw/qa/complex/checkColor/CheckChangeColor.java @@ -1,90 +1,89 @@ package complex.checkColor; -import com.sun.star.awt.Rectangle; import com.sun.star.awt.Size; -import com.sun.star.awt.WindowDescriptor; -import com.sun.star.awt.XControlModel; -import com.sun.star.awt.XToolkit; -import com.sun.star.awt.XWindow; -import com.sun.star.awt.XWindowPeer; -import com.sun.star.beans.PropertyValue; import com.sun.star.beans.XPropertySet; import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; -import com.sun.star.drawing.XControlShape; -import com.sun.star.drawing.XShape; -import com.sun.star.frame.XComponentLoader; -import com.sun.star.frame.XController; -import com.sun.star.lang.XComponent; import com.sun.star.lang.XMultiServiceFactory; import com.sun.star.style.XStyleFamiliesSupplier; import com.sun.star.text.XTextDocument; +import com.sun.star.uno.Any; +import com.sun.star.uno.Type; import com.sun.star.uno.UnoRuntime; -import com.sun.star.uno.XInterface; -import com.sun.star.view.XControlAccess; -import complexlib.ComplexTestCase; -import java.io.PrintWriter; -import util.FormTools; +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 util.DesktopTools; import util.SOfficeFactory; -import util.WriterTools; +import static org.junit.Assert.*; /** * Created because of complaint on dev@openoffice.org: check the changing of * BackColor and IsLandscape properties on the PageStyle service. */ -public class CheckChangeColor extends ComplexTestCase { - - private XToolkit xToolkit = null; - private XWindowPeer xWinPeer = null; - - /** - * Get all test method names. - * @return The test methods. - */ - public String[] getTestMethodNames() { - return new String[] {"checkChangeColor"}; - } - - +public class CheckChangeColor { /** * Check BackColor and IsLandscape properties, wait for an exception: test * is ok if no exception happened. */ - public void checkChangeColor() { - try { - XMultiServiceFactory m_xMSF_ = (XMultiServiceFactory)param.getMSF(); - XComponentLoader aLoader = (XComponentLoader)UnoRuntime.queryInterface(XComponentLoader.class,m_xMSF_.createInstance( "com.sun.star.frame.Desktop" )); - XComponent xDocument = (XComponent)UnoRuntime.queryInterface(XComponent.class, aLoader.loadComponentFromURL( "private:factory/swriter", "_blank", 0, new PropertyValue[ 0 ] ) ); - // xDocument.addEventListener( this ); + @Test public void checkChangeColor() throws Exception { + // create a supplier to get the Style family collection + XStyleFamiliesSupplier xSupplier = ( XStyleFamiliesSupplier ) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, document); - XTextDocument oDoc = (XTextDocument) UnoRuntime.queryInterface(XTextDocument.class, xDocument); - XMultiServiceFactory oDocMSF = (XMultiServiceFactory) UnoRuntime.queryInterface(XMultiServiceFactory.class, oDoc ); + // get the NameAccess interface from the Style family collection + XNameAccess xNameAccess = xSupplier.getStyleFamilies(); - // XInterface xInterface = (XInterface) oDocMSF.createInstance( "com.sun.star.style.PageStyle" ); + XNameContainer xPageStyleCollection = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xNameAccess.getByName( "PageStyles" )); - // create a supplier to get the Style family collection - XStyleFamiliesSupplier xSupplier = ( XStyleFamiliesSupplier ) UnoRuntime.queryInterface(XStyleFamiliesSupplier.class, oDoc ); + // create a PropertySet to set the properties for the new Pagestyle + XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xPageStyleCollection.getByName("Standard") ); - // get the NameAccess interface from the Style family collection - XNameAccess xNameAccess = xSupplier.getStyleFamilies(); + assertEquals( + "BackColor", new Any(Type.LONG, 0xFFFFFFFF), + Any.complete(xPropertySet.getPropertyValue("BackColor"))); + assertEquals( + "IsLandscape", new Any(Type.BOOLEAN, false), + Any.complete(xPropertySet.getPropertyValue("IsLandscape"))); + assertEquals( + "Size", new Type(Size.class), + Any.complete(xPropertySet.getPropertyValue("Size")).getType()); - XNameContainer xPageStyleCollection = (XNameContainer) UnoRuntime.queryInterface(XNameContainer.class, xNameAccess.getByName( "PageStyles" )); + xPropertySet.setPropertyValue("BackColor", 0xFF000000); + xPropertySet.setPropertyValue("IsLandscape", true); + assertEquals( + "BackColor", new Any(Type.LONG, 0xFF000000), + Any.complete(xPropertySet.getPropertyValue("BackColor"))); + assertEquals( + "IsLandscape", new Any(Type.BOOLEAN, true), + Any.complete(xPropertySet.getPropertyValue("IsLandscape"))); + } - // create a PropertySet to set the properties for the new Pagestyle - XPropertySet xPropertySet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, xPageStyleCollection.getByName("Standard") ); + @Before public void setUpDocument() throws com.sun.star.uno.Exception { + document = SOfficeFactory.getFactory( + UnoRuntime.queryInterface( + XMultiServiceFactory.class, + connection.getComponentContext().getServiceManager())). + createTextDoc(null); + } + + @After public void tearDownDocument() { + DesktopTools.closeDoc(document); + } + + private XTextDocument document = null; - log.println("BackColor @ "+xPropertySet.getPropertyValue("BackColor").toString()); - log.println("IsLandscape @ "+xPropertySet.getPropertyValue("IsLandscape").toString()); - log.println("Size @ H:"+((Size)xPropertySet.getPropertyValue("Size")).Height+" W:"+((Size)xPropertySet.getPropertyValue("Size")).Width); - - log.println("Set Landscape"); - xPropertySet.setPropertyValue("IsLandscape",new Boolean(true) ); - log.println("Set BackColor"); - xPropertySet.setPropertyValue("BackColor",new Integer((int)255000000) ); - } - catch(Exception e) { - e.printStackTrace(); - failed("Exception."); - } + @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(); } diff --git a/sw/qa/complex/checkColor/makefile.mk b/sw/qa/complex/checkColor/makefile.mk index 3048fb8fff..e5b368083a 100755 --- a/sw/qa/complex/checkColor/makefile.mk +++ b/sw/qa/complex/checkColor/makefile.mk @@ -25,51 +25,26 @@ # #************************************************************************* -PRJ = ..$/..$/.. -TARGET = CheckChangeColor -PRJNAME = $(TARGET) -PACKAGE = complex$/checkColor - -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - - -#----- compile .java files ----------------------------------------- - -JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar mysql.jar -JAVAFILES = CheckChangeColor.java -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -#----- make a jar from compiled files ------------------------------ - -MAXLINELENGTH = 100000 - -JARCLASSDIRS = $(PACKAGE) -JARTARGET = $(TARGET).jar -JARCOMPRESS = TRUE - -# --- Parameters for the test -------------------------------------- - -# test base is java complex -CT_TESTBASE = -TestBase java_complex - -# test looks something like the.full.package.TestName -CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b) - -# start the runner application -CT_APP = org.openoffice.Runner +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: +.ELSE -# --- Targets ------------------------------------------------------ +PRJ = ../../.. +PRJNAME = sw +TARGET = qa_complex_checkColor -.IF "$(depend)" == "" -ALL : ALLTAR -.ELSE -ALL: ALLDEP -.ENDIF +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/checkColor +JAVATESTFILES = CheckChangeColor.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END -.INCLUDE : target.mk +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk -RUN: run +ALLTAR : javatest -run: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_TESTBASE) $(CT_NOOFFICE) $(CT_TEST) +.END diff --git a/sw/qa/complex/indeterminateState/CheckIndeterminateState.java b/sw/qa/complex/indeterminateState/CheckIndeterminateState.java index c7c35e30bd..e987d64aa6 100755 --- a/sw/qa/complex/indeterminateState/CheckIndeterminateState.java +++ b/sw/qa/complex/indeterminateState/CheckIndeterminateState.java @@ -27,110 +27,99 @@ package complex.indeterminateState; -import complexlib.ComplexTestCase; -import helper.OfficeProvider; -import util.SOfficeFactory; -import util.AccessibilityTools; +import com.sun.star.accessibility.AccessibleRole; +import com.sun.star.accessibility.AccessibleStateType; +import com.sun.star.accessibility.XAccessible; +import com.sun.star.accessibility.XAccessibleContext; +import com.sun.star.accessibility.XAccessibleStateSet; +import com.sun.star.awt.FontWeight; import com.sun.star.awt.XWindow; -import com.sun.star.awt.XExtendedToolkit; -import com.sun.star.frame.XDispatch; +import com.sun.star.beans.XPropertySet; import com.sun.star.frame.XController; -import com.sun.star.frame.XDesktop; import com.sun.star.frame.XModel; -import com.sun.star.text.XTextDocument; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XText; +import com.sun.star.text.XTextDocument; +import com.sun.star.text.XTextRange; +import com.sun.star.text.XTextViewCursorSupplier; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XInterface; -import com.sun.star.accessibility.AccessibleRole; -import com.sun.star.accessibility.XAccessible; -import com.sun.star.accessibility.XAccessibleValue; -import com.sun.star.accessibility.XAccessibleContext; -import com.sun.star.accessibility.XAccessibleStateSet; -import com.sun.star.accessibility.AccessibleStateType; -import com.sun.star.accessibility.XAccessibleAction; -import com.sun.star.awt.XTopWindow; -import com.sun.star.uno.UnoRuntime; -import com.sun.star.frame.XDispatchProvider; -import com.sun.star.util.URL; -import com.sun.star.util.XURLTransformer; - -import java.io.PrintWriter; +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 util.AccessibilityTools; +import util.DesktopTools; +import util.SOfficeFactory; +import static org.junit.Assert.*; /** */ -public class CheckIndeterminateState extends ComplexTestCase { - - /** - * Return all test methods. - * @return The test methods. - */ - public String[] getTestMethodNames() { - return new String[]{"checkToolBoxItem"}; - } - +public class CheckIndeterminateState { /* * Test the indeterminate state of AccessibleToolBarItem * The used tools are in project qadevOOo/runner */ - public void checkToolBoxItem() { - log.println( "creating a test environment" ); - XTextDocument xTextDoc = null; - // get a soffice factory object - SOfficeFactory SOF = SOfficeFactory.getFactory((XMultiServiceFactory) param.getMSF()); - - try { - log.println( "creating a text document" ); - xTextDoc = SOF.createTextDoc(null); - } catch ( com.sun.star.uno.Exception e ) { - // Some exception occures.FAILED - e.printStackTrace( (java.io.PrintWriter)log ); - failed (e.getMessage()); - } - + @Test public void checkToolBoxItem() throws Exception { XModel aModel = (XModel) - UnoRuntime.queryInterface(XModel.class, xTextDoc); + UnoRuntime.queryInterface(XModel.class, document); XController xController = aModel.getCurrentController(); - XInterface oObj = null; + XText text = document.getText(); + text.setString("normal"); + XTextRange end = text.getEnd(); + end.setString("bold"); + UnoRuntime.queryInterface(XPropertySet.class, end).setPropertyValue( + "CharWeight", FontWeight.BOLD); + UnoRuntime.queryInterface(XTextViewCursorSupplier.class, xController). + getViewCursor().gotoRange(text, false); - System.out.println("Press any key after making 'Bold' indeterminate."); - try{ - byte[]b = new byte[16]; - System.in.read(b); - } catch (Exception e) { - e.printStackTrace(); - } + XInterface oObj = null; AccessibilityTools at = new AccessibilityTools(); - XWindow xWindow = at.getCurrentContainerWindow((XMultiServiceFactory)param.getMSF(), aModel); + XWindow xWindow = at.getCurrentContainerWindow(getFactory(), aModel); XAccessible xRoot = at.getAccessibleObject(xWindow); - // uncomment to print the whole accessible tree. -// at.printAccessibleTree((java.io.PrintWriter)log,xRoot); - - oObj = at.getAccessibleObjectForRole(xRoot, - AccessibleRole.PUSH_BUTTON, "Bold"); - System.out.println("Found a PUSH_BUTTON: " + (oObj != null)); - oObj = at.getAccessibleObjectForRole(xRoot, AccessibleRole.TOGGLE_BUTTON, "Bold"); - System.out.println("Found a TOGGLE_BUTTON: " + (oObj != null)); - - log.println("ImplementationName: "+ util.utils.getImplName(oObj)); + assertNotNull("Found a TOGGLE_BUTTON", oObj); XAccessibleContext oContext = (XAccessibleContext) UnoRuntime.queryInterface(XAccessibleContext.class, oObj); XAccessibleStateSet oSet = oContext.getAccessibleStateSet(); - short[]states = oSet.getStates(); - for(int i=0; i<states.length; i++) - System.out.println("State "+i+": "+states[i]); + assertTrue("The 'INDETERMINATE' state is not set.",oSet.contains(AccessibleStateType.INDETERMINATE)); + } - assure("The 'INDETERMINATE' state is not set.",oSet.contains(AccessibleStateType.INDETERMINATE)); + @Before public void setUpDocument() throws com.sun.star.uno.Exception { + document = SOfficeFactory.getFactory(getFactory()).createTextDoc(null); } -} + @After public void tearDownDocument() { + DesktopTools.closeDoc(document); + } + private XTextDocument document = null; + @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(); + + private static final XMultiServiceFactory getFactory() { + return UnoRuntime.queryInterface( + XMultiServiceFactory.class, + connection.getComponentContext().getServiceManager()); + } +} diff --git a/sw/qa/complex/indeterminateState/makefile.mk b/sw/qa/complex/indeterminateState/makefile.mk index 8850da116f..d19915b1e2 100755 --- a/sw/qa/complex/indeterminateState/makefile.mk +++ b/sw/qa/complex/indeterminateState/makefile.mk @@ -25,58 +25,26 @@ # #************************************************************************* -PRJ = ..$/..$/.. -TARGET = CheckIndexedPropertyValue -PRJNAME = $(TARGET) -PACKAGE = complex$/indeterminateState - -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - - -#----- compile .java files ----------------------------------------- - -JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar -JAVAFILES = CheckIndeterminateState.java -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -#----- make a jar from compiled files ------------------------------ - -MAXLINELENGTH = 100000 - -JARCLASSDIRS = $(PACKAGE) -JARTARGET = $(TARGET).jar -JARCOMPRESS = TRUE - -# --- Parameters for the test -------------------------------------- - -# start an office if the parameter is set for the makefile -.IF "$(OFFICE)" == "" -CT_APPEXECCOMMAND = +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: .ELSE -CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;" -.ENDIF - -# test base is java complex -CT_TESTBASE = -TestBase java_complex - -# test looks something like the.full.package.TestName -CT_TEST = -o $(PACKAGE:s\$/\.\).$(JAVAFILES:b) -# start the runner application -CT_APP = org.openoffice.Runner +PRJ = ../../.. +PRJNAME = sw +TARGET = qa_complex_indeterminateState -# --- Targets ------------------------------------------------------ +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/indeterminateState +JAVATESTFILES = CheckIndeterminateState.java +JAVAFILES = $(JAVATESTFILES) +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END -.IF "$(depend)" == "" -ALL: ALLTAR -.ELSE -ALL: ALLDEP -.ENDIF - -.INCLUDE : target.mk +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk -RUN: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_TEST) +ALLTAR : javatest -run: RUN +.END diff --git a/sw/qa/complex/writer/CheckBookmarks.java b/sw/qa/complex/writer/CheckBookmarks.java index d50916f51a..cb20467646 100644 --- a/sw/qa/complex/writer/CheckBookmarks.java +++ b/sw/qa/complex/writer/CheckBookmarks.java @@ -43,9 +43,15 @@ import com.sun.star.text.XTextRange; import com.sun.star.uno.UnoRuntime; import complexlib.ComplexTestCase; import java.math.BigInteger; +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.*; class BookmarkHashes { - public String m_sName; public BigInteger m_nSetupHash; public BigInteger m_nInsertRandomHash; public BigInteger m_nDeleteRandomHash; @@ -53,40 +59,13 @@ class BookmarkHashes { public BigInteger m_nOdfReloadHash; public BigInteger m_nMsWordReloadHash; - public BookmarkHashes(String sName) { - m_sName = sName; - } - - public String checkExpectationString(BookmarkHashes aExpectation) { - StringBuffer buffer = new StringBuffer(); - buffer.append("Comparing " + m_sName + " to expectations from " + aExpectation.m_sName + "\n"); - buffer.append(compareHashString("after setup", m_nSetupHash, aExpectation.m_nSetupHash)); - buffer.append(compareHashString("after insert random", m_nInsertRandomHash, aExpectation.m_nInsertRandomHash)); - buffer.append(compareHashString("after delete random", m_nDeleteRandomHash, aExpectation.m_nDeleteRandomHash)); - buffer.append(compareHashString("after line breaks", m_nLinebreakHash, aExpectation.m_nLinebreakHash)); - buffer.append(compareHashString("after ODF roundtrip", m_nOdfReloadHash, aExpectation.m_nOdfReloadHash)); - buffer.append(compareHashString("after MsWord roundtrip", m_nMsWordReloadHash, aExpectation.m_nMsWordReloadHash)); - return buffer.toString(); - }; - - public boolean meetsExpectation(BookmarkHashes aExpectation) { - return m_nSetupHash.equals(aExpectation.m_nSetupHash) - && m_nInsertRandomHash.equals(aExpectation.m_nInsertRandomHash) - && m_nDeleteRandomHash.equals(aExpectation.m_nDeleteRandomHash) - && m_nLinebreakHash.equals(aExpectation.m_nLinebreakHash) - && m_nOdfReloadHash.equals(aExpectation.m_nOdfReloadHash) - && m_nMsWordReloadHash.equals(aExpectation.m_nMsWordReloadHash); - } - - private String compareHashString(String sCheckName, BigInteger nActual, BigInteger nExpectation) { - StringBuffer buffer = new StringBuffer(sCheckName); - buffer.append(": "); - if(nActual.equals(nExpectation)) - buffer.append("good (" + nActual.toString(16) + ")"); - else - buffer.append("bad (actual:" + nActual.toString(16) + ", expected: " + nExpectation.toString(16) + ")"); - buffer.append("\n"); - return buffer.toString(); + public void assertExpectation(BookmarkHashes aExpectation) { + assertEquals(aExpectation.m_nSetupHash, m_nSetupHash); + assertEquals(aExpectation.m_nInsertRandomHash, m_nInsertRandomHash); + assertEquals(aExpectation.m_nDeleteRandomHash, m_nDeleteRandomHash); + assertEquals(aExpectation.m_nLinebreakHash, m_nLinebreakHash); + assertEquals(aExpectation.m_nOdfReloadHash, m_nOdfReloadHash); + assertEquals(aExpectation.m_nMsWordReloadHash, m_nMsWordReloadHash); } static public java.math.BigInteger getBookmarksHash(XTextDocument xDoc) @@ -114,18 +93,15 @@ class BookmarkHashes { } } -public class CheckBookmarks extends ComplexTestCase { +public class CheckBookmarks { private XMultiServiceFactory m_xMsf = null; private XTextDocument m_xDoc = null; private XTextDocument m_xOdfReloadedDoc = null; private XTextDocument m_xMsWordReloadedDoc = null; - - public String[] getTestMethodNames() { - return new String[]{"checkBookmarks"}; - } + private final BookmarkHashes actualHashes = new BookmarkHashes(); private BookmarkHashes getDEV300m41Expectations() { - BookmarkHashes result = new BookmarkHashes("DEV300m41"); + BookmarkHashes result = new BookmarkHashes(); result.m_nSetupHash = new BigInteger("-4b0706744e8452fe1ae9d5e1c28cf70fb6194795",16); result.m_nInsertRandomHash = new BigInteger("25aa0fad3f4881832dcdfe658ec2efa8a1a02bc5",16); result.m_nDeleteRandomHash = new BigInteger("-3ec87e810b46d734677c351ad893bbbf9ea10f55",16); @@ -135,42 +111,51 @@ public class CheckBookmarks extends ComplexTestCase { return result; } - public void checkBookmarks() + @Test public void checkBookmarks() throws com.sun.star.uno.Exception, com.sun.star.io.IOException, java.security.NoSuchAlgorithmException { - try { - m_xMsf = (XMultiServiceFactory)param.getMSF(); - m_xDoc = util.WriterTools.createTextDoc(m_xMsf); - BookmarkHashes actualHashes = new BookmarkHashes("actual"); - BookmarkHashes expectedHashes = getDEV300m41Expectations(); - setupBookmarks(); - actualHashes.m_nSetupHash = BookmarkHashes.getBookmarksHash(m_xDoc); - insertRandomParts(200177); - actualHashes.m_nInsertRandomHash = BookmarkHashes.getBookmarksHash(m_xDoc); - deleteRandomParts(4711); - actualHashes.m_nDeleteRandomHash = BookmarkHashes.getBookmarksHash(m_xDoc); - insertLinebreaks(007); - actualHashes.m_nLinebreakHash = BookmarkHashes.getBookmarksHash(m_xDoc); - m_xOdfReloadedDoc = reloadFrom("StarOffice XML (Writer)", "odf"); - actualHashes.m_nOdfReloadHash = BookmarkHashes.getBookmarksHash(m_xOdfReloadedDoc); - m_xMsWordReloadedDoc = reloadFrom("MS Word 97", "doc"); - actualHashes.m_nMsWordReloadHash = BookmarkHashes.getBookmarksHash(m_xMsWordReloadedDoc); - log.println(actualHashes.checkExpectationString(expectedHashes)); - if(!actualHashes.meetsExpectation(expectedHashes)) - failed("CheckBookmark did not meet expectations (" + expectedHashes.m_sName + ")."); - } finally { - // closing test document - if(m_xDoc != null) - util.DesktopTools.closeDoc(m_xDoc); - if(m_xOdfReloadedDoc!= null) - util.DesktopTools.closeDoc(m_xOdfReloadedDoc); - if(m_xMsWordReloadedDoc!= null) - util.DesktopTools.closeDoc(m_xMsWordReloadedDoc); - } + actualHashes.assertExpectation(getDEV300m41Expectations()); } + @Before public void setUpDocuments() throws Exception { + m_xMsf = UnoRuntime.queryInterface( + XMultiServiceFactory.class, + connection.getComponentContext().getServiceManager()); + m_xDoc = util.WriterTools.createTextDoc(m_xMsf); + setupBookmarks(); + actualHashes.m_nSetupHash = BookmarkHashes.getBookmarksHash(m_xDoc); + insertRandomParts(200177); + actualHashes.m_nInsertRandomHash = BookmarkHashes.getBookmarksHash(m_xDoc); + deleteRandomParts(4711); + actualHashes.m_nDeleteRandomHash = BookmarkHashes.getBookmarksHash(m_xDoc); + insertLinebreaks(007); + actualHashes.m_nLinebreakHash = BookmarkHashes.getBookmarksHash(m_xDoc); + m_xOdfReloadedDoc = reloadFrom("StarOffice XML (Writer)", "odf"); + actualHashes.m_nOdfReloadHash = BookmarkHashes.getBookmarksHash(m_xOdfReloadedDoc); + m_xMsWordReloadedDoc = reloadFrom("MS Word 97", "doc"); + actualHashes.m_nMsWordReloadHash = BookmarkHashes.getBookmarksHash(m_xMsWordReloadedDoc); + } + + @After public void tearDownDocuments() { + util.DesktopTools.closeDoc(m_xDoc); + util.DesktopTools.closeDoc(m_xOdfReloadedDoc); + util.DesktopTools.closeDoc(m_xMsWordReloadedDoc); + } + + @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(); + private void setupBookmarks() throws com.sun.star.uno.Exception { diff --git a/sw/qa/complex/writer/CheckCrossReferences.java b/sw/qa/complex/writer/CheckCrossReferences.java index 7b469c0a4a..cc7fcb1c7e 100644 --- a/sw/qa/complex/writer/CheckCrossReferences.java +++ b/sw/qa/complex/writer/CheckCrossReferences.java @@ -1,123 +1,96 @@ -/* - * CheckCrossReferences.java - * - * Created on November 1, 2007, 1:49 PM - * - * To change this template, choose Tools | Template Manager - * and open the template in the editor. - */ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ package complex.writer; -import complexlib.ComplexTestCase; import com.sun.star.lang.XMultiServiceFactory; +import com.sun.star.text.XTextDocument; import com.sun.star.uno.UnoRuntime; +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.*; /** * * @author od138299 */ -public class CheckCrossReferences extends ComplexTestCase { +public class CheckCrossReferences { - private com.sun.star.text.XTextDocument xDoc; private com.sun.star.container.XEnumeration xParaEnum; private com.sun.star.container.XEnumeration xPortionEnum; private com.sun.star.util.XRefreshable xFldsRefresh; - public String[] getTestMethodNames() { - return new String[]{"checkCrossReferences"}; - } - - public com.sun.star.text.XTextField getNextField() { - - com.sun.star.text.XTextField xField = null; + public com.sun.star.text.XTextField getNextField() + throws com.sun.star.uno.Exception + { if ( xPortionEnum != null ) { - try { - while ( xPortionEnum.hasMoreElements() ) { - com.sun.star.beans.XPropertySet xPortionProps = - (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( - com.sun.star.beans.XPropertySet.class , xPortionEnum.nextElement()); - final String sPortionType = - xPortionProps.getPropertyValue( "TextPortionType" ).toString(); - if ( sPortionType.equals( "TextField") ) { - xField = (com.sun.star.text.XTextField)UnoRuntime.queryInterface( - com.sun.star.text.XTextField.class, - xPortionProps.getPropertyValue( "TextField" ) ); - if ( xField == null ) { - System.out.println("Cannot retrieve next field."); - failed("Cannot retrieve next field."); - return null; - } - return xField; - } + while ( xPortionEnum.hasMoreElements() ) { + com.sun.star.beans.XPropertySet xPortionProps = + (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( + com.sun.star.beans.XPropertySet.class , xPortionEnum.nextElement()); + final String sPortionType = + xPortionProps.getPropertyValue( "TextPortionType" ).toString(); + if ( sPortionType.equals( "TextField") ) { + com.sun.star.text.XTextField xField = (com.sun.star.text.XTextField)UnoRuntime.queryInterface( + com.sun.star.text.XTextField.class, + xPortionProps.getPropertyValue( "TextField" ) ); + assertNotNull("Cannot retrieve next field.", xField); + return xField; } - } catch (com.sun.star.container.NoSuchElementException e) { - System.out.println("Cannot retrieve next field."); - e.printStackTrace(); - failed(e.getMessage()); - return null; - } catch (com.sun.star.beans.UnknownPropertyException e) { - System.out.println("Cannot retrieve next field."); - e.printStackTrace(); - failed(e.getMessage()); - return null; - } catch (com.sun.star.lang.WrappedTargetException e) { - System.out.println("Cannot retrieve next field."); - e.printStackTrace(); - failed(e.getMessage()); - return null; } } while ( xParaEnum.hasMoreElements() ) { - try { - com.sun.star.container.XEnumerationAccess aPara = - (com.sun.star.container.XEnumerationAccess)UnoRuntime.queryInterface( - com.sun.star.container.XEnumerationAccess.class, xParaEnum.nextElement()); - xPortionEnum = aPara.createEnumeration(); - while ( xPortionEnum.hasMoreElements() ) { - com.sun.star.beans.XPropertySet xPortionProps = - (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( - com.sun.star.beans.XPropertySet.class , xPortionEnum.nextElement()); - final String sPortionType = - xPortionProps.getPropertyValue( "TextPortionType" ).toString(); - if ( sPortionType.equals( "TextField") ) { - xField = (com.sun.star.text.XTextField)UnoRuntime.queryInterface( - com.sun.star.text.XTextField.class, - xPortionProps.getPropertyValue( "TextField" ) ); - if ( xField == null ) { - System.out.println("Cannot retrieve next field."); - failed("Cannot retrieve next field."); - return null; - } - return xField; - } + com.sun.star.container.XEnumerationAccess aPara = + (com.sun.star.container.XEnumerationAccess)UnoRuntime.queryInterface( + com.sun.star.container.XEnumerationAccess.class, xParaEnum.nextElement()); + xPortionEnum = aPara.createEnumeration(); + while ( xPortionEnum.hasMoreElements() ) { + com.sun.star.beans.XPropertySet xPortionProps = + (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( + com.sun.star.beans.XPropertySet.class , xPortionEnum.nextElement()); + final String sPortionType = + xPortionProps.getPropertyValue( "TextPortionType" ).toString(); + if ( sPortionType.equals( "TextField") ) { + com.sun.star.text.XTextField xField = (com.sun.star.text.XTextField)UnoRuntime.queryInterface( + com.sun.star.text.XTextField.class, + xPortionProps.getPropertyValue( "TextField" ) ); + assertNotNull("Cannot retrieve next field.", xField); + return xField; } - } catch (com.sun.star.container.NoSuchElementException e) { - System.out.println("Cannot retrieve next field."); - e.printStackTrace(); - failed(e.getMessage()); - return null; - } catch (com.sun.star.beans.UnknownPropertyException e) { - System.out.println("Cannot retrieve next field."); - e.printStackTrace(); - failed(e.getMessage()); - return null; - } catch (com.sun.star.lang.WrappedTargetException e) { - System.out.println("Cannot retrieve next field."); - e.printStackTrace(); - failed(e.getMessage()); - return null; } } - if ( xField == null ) { - System.out.println("Cannot retrieve next field."); - failed("Cannot retrieve next field."); - return null; - } - - return xField; + fail("Cannot retrieve next field."); + return null; // unreachable } public com.sun.star.beans.XPropertySet getFieldProps( @@ -126,11 +99,7 @@ public class CheckCrossReferences extends ComplexTestCase { (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( com.sun.star.beans.XPropertySet.class, xField ); - if ( xProps == null ) { - System.out.println("Cannot retrieve field properties."); - failed("Cannot retrieve field properties."); - return null; - } + assertNotNull("Cannot retrieve field properties.", xProps); return xProps; } @@ -138,56 +107,26 @@ public class CheckCrossReferences extends ComplexTestCase { public void checkField( com.sun.star.text.XTextField xField, com.sun.star.beans.XPropertySet xProps, short nFormat, - String aExpectedFldResult ) { + String aExpectedFldResult ) + throws com.sun.star.uno.Exception + { // set requested format - try { - xProps.setPropertyValue("ReferenceFieldPart", new Short(nFormat)); - } catch (com.sun.star.lang.IllegalArgumentException e) { - System.out.println("Cannot set ReferenceFieldPart property at field."); - e.printStackTrace(); - failed(e.getMessage()); - return; - } catch (com.sun.star.beans.PropertyVetoException e) { - System.out.println("Cannot set ReferenceFieldPart property at field."); - e.printStackTrace(); - failed(e.getMessage()); - return; - } catch (com.sun.star.lang.WrappedTargetException e) { - System.out.println("Cannot set ReferenceFieldPart property at field."); - e.printStackTrace(); - failed(e.getMessage()); - return; - } catch (com.sun.star.beans.UnknownPropertyException e) { - System.out.println("Cannot set ReferenceFieldPart property at field."); - e.printStackTrace(); - failed(e.getMessage()); - return; - } + xProps.setPropertyValue("ReferenceFieldPart", new Short(nFormat)); + // refresh fields in order to get new format applied xFldsRefresh.refresh(); String aFldResult = xField.getPresentation( false ); - assure( "set reference field format doesn't result in correct field result", - aFldResult.equals(aExpectedFldResult), true ); + assertEquals( "set reference field format doesn't result in correct field result", + aExpectedFldResult, aFldResult); } - public void checkCrossReferences() throws com.sun.star.uno.Exception { - // load test document - try { - XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF(); - xDoc = util.WriterTools.loadTextDoc( xMSF, util.utils.getFullTestURL("CheckCrossReferences.odt")); - } catch(com.sun.star.uno.RuntimeException e) { - System.out.println("Cannot load test document."); - e.printStackTrace(); - failed(e.getMessage()); - return; - } - + @Test public void checkCrossReferences() throws com.sun.star.uno.Exception { // setup paragraph enumeration { com.sun.star.container.XEnumerationAccess xParaEnumAccess = (com.sun.star.container.XEnumerationAccess)UnoRuntime.queryInterface( - com.sun.star.container.XEnumerationAccess.class, xDoc.getText()); + com.sun.star.container.XEnumerationAccess.class, document.getText()); xParaEnum = xParaEnumAccess.createEnumeration(); } @@ -195,7 +134,7 @@ public class CheckCrossReferences extends ComplexTestCase { { com.sun.star.text.XTextFieldsSupplier xFieldSupp = (com.sun.star.text.XTextFieldsSupplier)UnoRuntime.queryInterface( - com.sun.star.text.XTextFieldsSupplier.class, xDoc); + com.sun.star.text.XTextFieldsSupplier.class, document); xFldsRefresh = (com.sun.star.util.XRefreshable)UnoRuntime.queryInterface( com.sun.star.util.XRefreshable.class, xFieldSupp.getTextFields()); } @@ -214,7 +153,6 @@ public class CheckCrossReferences extends ComplexTestCase { com.sun.star.text.XTextField xField = null; com.sun.star.beans.XPropertySet xProps = null; - log.println( "Checking field reference formats NUMBER, NUMBER_NO_CONTEXT and NUMBER_FULL_CONTEXT for existing fields" ); xField = getNextField(); xProps = getFieldProps( xField ); checkField( xField, xProps, com.sun.star.text.ReferenceFieldPart.NUMBER, FldResult2 ); @@ -254,63 +192,36 @@ public class CheckCrossReferences extends ComplexTestCase { // insert a certain cross-reference bookmark and a reference field to this bookmark { - log.println("Checking insert of cross-reference bookmark and corresponding reference field"); // restart paragraph enumeration com.sun.star.container.XEnumerationAccess xParaEnumAccess = (com.sun.star.container.XEnumerationAccess)UnoRuntime.queryInterface( - com.sun.star.container.XEnumerationAccess.class, xDoc.getText()); + com.sun.star.container.XEnumerationAccess.class, document.getText()); xParaEnum = xParaEnumAccess.createEnumeration(); // iterate on the paragraphs to find certain paragraph to insert the bookmark com.sun.star.text.XTextRange xParaTextRange = null; while ( xParaEnum.hasMoreElements() ) { - try { - xParaTextRange = (com.sun.star.text.XTextRange)UnoRuntime.queryInterface( - com.sun.star.text.XTextRange.class, xParaEnum.nextElement()); - if ( xParaTextRange.getString().equals( "J" ) ) { - break; - } - else { - xParaTextRange = null; - } - } catch (com.sun.star.container.NoSuchElementException e) { - System.out.println("Cannot find paragraph to insert cross-reference bookmark."); - e.printStackTrace(); - failed(e.getMessage()); - return; - } catch (com.sun.star.lang.WrappedTargetException e) { - System.out.println("Cannot find paragraph to insert cross-reference bookmark."); - e.printStackTrace(); - failed(e.getMessage()); - return; + xParaTextRange = (com.sun.star.text.XTextRange)UnoRuntime.queryInterface( + com.sun.star.text.XTextRange.class, xParaEnum.nextElement()); + if ( xParaTextRange.getString().equals( "J" ) ) { + break; + } + else { + xParaTextRange = null; } } - if ( xParaTextRange == null ) { - System.out.println("Cannot find paragraph to insert cross-reference bookmark."); - failed("Cannot find paragraph to insert cross-reference bookmark."); - return; - } + assertNotNull( + "Cannot find paragraph to insert cross-reference bookmark.", + xParaTextRange); // insert bookmark XMultiServiceFactory xFac = (XMultiServiceFactory)UnoRuntime.queryInterface( - XMultiServiceFactory.class, xDoc); + XMultiServiceFactory.class, document); final String cBookmarkName = "__RefNumPara__47114711"; - com.sun.star.text.XTextContent xBookmark = null; - try { - xBookmark = (com.sun.star.text.XTextContent)UnoRuntime.queryInterface( - com.sun.star.text.XTextContent.class, - xFac.createInstance( "com.sun.star.text.Bookmark" ) ); - } catch (com.sun.star.lang.IllegalArgumentException e) { - System.out.println("Cannot create bookmark."); - e.printStackTrace(); - failed(e.getMessage()); - return; - } catch (com.sun.star.uno.Exception e) { - System.out.println("Cannot create bookmark."); - e.printStackTrace(); - failed(e.getMessage()); - return; - } + com.sun.star.text.XTextContent xBookmark = + (com.sun.star.text.XTextContent)UnoRuntime.queryInterface( + com.sun.star.text.XTextContent.class, + xFac.createInstance( "com.sun.star.text.Bookmark" ) ); if ( xBookmark != null ) { com.sun.star.container.XNamed xName = (com.sun.star.container.XNamed)UnoRuntime.queryInterface( @@ -320,22 +231,10 @@ public class CheckCrossReferences extends ComplexTestCase { } // insert reference field, which references the inserted bookmark - com.sun.star.text.XTextContent xNewField = null; - try { - xNewField = (com.sun.star.text.XTextContent)UnoRuntime.queryInterface( - com.sun.star.text.XTextContent.class, - xFac.createInstance( "com.sun.star.text.TextField.GetReference" ) ); - } catch (com.sun.star.lang.IllegalArgumentException e) { - System.out.println("Cannot create new field."); - e.printStackTrace(); - failed(e.getMessage()); - return; - } catch (com.sun.star.uno.Exception e) { - System.out.println("Cannot create new field."); - e.printStackTrace(); - failed(e.getMessage()); - return; - } + com.sun.star.text.XTextContent xNewField = + (com.sun.star.text.XTextContent)UnoRuntime.queryInterface( + com.sun.star.text.XTextContent.class, + xFac.createInstance( "com.sun.star.text.TextField.GetReference" ) ); if ( xNewField != null ) { com.sun.star.beans.XPropertySet xFieldProps = (com.sun.star.beans.XPropertySet)UnoRuntime.queryInterface( @@ -354,16 +253,39 @@ public class CheckCrossReferences extends ComplexTestCase { com.sun.star.text.XTextField xField = (com.sun.star.text.XTextField)UnoRuntime.queryInterface( com.sun.star.text.XTextField.class, xNewField ); - assure( "inserted reference field doesn't has correct field result", - xField.getPresentation( false ).equals("J"), true ); + assertEquals( "inserted reference field doesn't has correct field result", + "J", xField.getPresentation( false ) ); xParaTextRange.getStart().setString( "Hallo new bookmark: " ); xFldsRefresh.refresh(); - assure( "inserted reference field doesn't has correct field result. Instead it's: "+xField.getPresentation( false ), - xField.getPresentation( false ).equals("Hallo new bookmark: J"), true ); + assertEquals( "inserted reference field doesn't has correct field result", + "Hallo new bookmark: J", xField.getPresentation( false ) ); } + } + + @Before public void setUpDocument() throws com.sun.star.uno.Exception { + document = util.WriterTools.loadTextDoc( + UnoRuntime.queryInterface( + XMultiServiceFactory.class, + connection.getComponentContext().getServiceManager()), + TestDocument.getUrl("CheckCrossReferences.odt")); + } - // closing test document - util.DesktopTools.closeDoc( xDoc ); + @After public void tearDownDocument() { + util.DesktopTools.closeDoc(document); } + + private XTextDocument document = null; + + @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(); } diff --git a/sw/qa/complex/writer/CheckFlies.java b/sw/qa/complex/writer/CheckFlies.java index 89a85b8e1c..59d2fe847d 100644 --- a/sw/qa/complex/writer/CheckFlies.java +++ b/sw/qa/complex/writer/CheckFlies.java @@ -38,43 +38,34 @@ import complexlib.ComplexTestCase; import java.math.BigInteger; import java.util.Collection; import java.util.ArrayList; +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.*; -public class CheckFlies extends ComplexTestCase { - private XMultiServiceFactory m_xMsf = null; - private XTextDocument m_xDoc = null; - - public String[] getTestMethodNames() { - return new String[]{"checkFlies"}; - } - - public void checkFlies() - throws com.sun.star.uno.Exception, - com.sun.star.io.IOException +public class CheckFlies { + @Test public void checkFlies() + throws com.sun.star.uno.Exception { - try { - m_xMsf = (XMultiServiceFactory)param.getMSF(); - m_xDoc = util.WriterTools.loadTextDoc(m_xMsf, util.utils.getFullTestURL("CheckFlies.odt")); - com.sun.star.text.XTextFramesSupplier xTFS = (com.sun.star.text.XTextFramesSupplier)UnoRuntime.queryInterface( - com.sun.star.text.XTextFramesSupplier.class, - m_xDoc); - checkTextFrames(xTFS); - com.sun.star.text.XTextGraphicObjectsSupplier xTGOS = (com.sun.star.text.XTextGraphicObjectsSupplier)UnoRuntime.queryInterface( - com.sun.star.text.XTextGraphicObjectsSupplier.class, - m_xDoc); - checkGraphicFrames(xTGOS); - com.sun.star.text.XTextEmbeddedObjectsSupplier xTEOS = (com.sun.star.text.XTextEmbeddedObjectsSupplier)UnoRuntime.queryInterface( - com.sun.star.text.XTextEmbeddedObjectsSupplier.class, - m_xDoc); - checkEmbeddedFrames(xTEOS); - } finally { - // closing test document - if(m_xDoc != null) - util.DesktopTools.closeDoc(m_xDoc); - } + com.sun.star.text.XTextFramesSupplier xTFS = (com.sun.star.text.XTextFramesSupplier)UnoRuntime.queryInterface( + com.sun.star.text.XTextFramesSupplier.class, + document); + checkTextFrames(xTFS); + com.sun.star.text.XTextGraphicObjectsSupplier xTGOS = (com.sun.star.text.XTextGraphicObjectsSupplier)UnoRuntime.queryInterface( + com.sun.star.text.XTextGraphicObjectsSupplier.class, + document); + checkGraphicFrames(xTGOS); + com.sun.star.text.XTextEmbeddedObjectsSupplier xTEOS = (com.sun.star.text.XTextEmbeddedObjectsSupplier)UnoRuntime.queryInterface( + com.sun.star.text.XTextEmbeddedObjectsSupplier.class, + document); + checkEmbeddedFrames(xTEOS); } private void checkEmbeddedFrames(com.sun.star.text.XTextEmbeddedObjectsSupplier xTGOS) - throws com.sun.star.lang.WrappedTargetException + throws com.sun.star.uno.Exception { Collection<String> vExpectedEmbeddedFrames = new ArrayList<String>(); vExpectedEmbeddedFrames.add("Object1"); @@ -82,51 +73,42 @@ public class CheckFlies extends ComplexTestCase { com.sun.star.container.XNameAccess xEmbeddedFrames = xTGOS.getEmbeddedObjects(); for(String sFrameName : xEmbeddedFrames.getElementNames()) { - if(!vExpectedEmbeddedFrames.remove(sFrameName)) - failed("Unexpected frame name"); - try - { - xEmbeddedFrames.getByName(sFrameName); - } - catch(com.sun.star.container.NoSuchElementException e) - { - failed("Could not get embedded frame by name."); - } - if(!xEmbeddedFrames.hasByName(sFrameName)) - failed("Could not find embedded frame by name."); + assertTrue( + "Unexpected frame name", + vExpectedEmbeddedFrames.remove(sFrameName)); + xEmbeddedFrames.getByName(sFrameName); + assertTrue( + "Could not find embedded frame by name.", + xEmbeddedFrames.hasByName(sFrameName)); } - if(!vExpectedEmbeddedFrames.isEmpty()) - failed("Missing expected embedded frames."); + assertTrue( + "Missing expected embedded frames.", + vExpectedEmbeddedFrames.isEmpty()); try { xEmbeddedFrames.getByName("Nonexisting embedded frame"); - failed("Got nonexisting embedded frame"); + fail("Got nonexisting embedded frame"); } catch(com.sun.star.container.NoSuchElementException e) {} - if(xEmbeddedFrames.hasByName("Nonexisting embedded frame")) - failed("Has nonexisting embedded frame"); + assertFalse( + "Has nonexisting embedded frame", + xEmbeddedFrames.hasByName("Nonexisting embedded frame")); com.sun.star.container.XIndexAccess xEmbeddedFramesIdx = (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface( com.sun.star.container.XIndexAccess.class, xEmbeddedFrames); - if(xEmbeddedFramesIdx.getCount() != nEmbeddedFrames) - failed("Unexpected number of embedded frames reported."); + assertEquals( + "Unexpected number of embedded frames reported.", nEmbeddedFrames, + xEmbeddedFramesIdx.getCount()); for(int nCurrentFrameIdx = 0; nCurrentFrameIdx < xEmbeddedFramesIdx.getCount(); nCurrentFrameIdx++) { - try - { - xEmbeddedFramesIdx.getByIndex(nCurrentFrameIdx); - } - catch(com.sun.star.lang.IndexOutOfBoundsException e) - { - failed("Could not get embedded frame by index."); - } + xEmbeddedFramesIdx.getByIndex(nCurrentFrameIdx); } } private void checkGraphicFrames(com.sun.star.text.XTextGraphicObjectsSupplier xTGOS) - throws com.sun.star.lang.WrappedTargetException + throws com.sun.star.uno.Exception { Collection<String> vExpectedGraphicFrames = new ArrayList<String>(); vExpectedGraphicFrames.add("graphics1"); @@ -134,51 +116,42 @@ public class CheckFlies extends ComplexTestCase { com.sun.star.container.XNameAccess xGraphicFrames = xTGOS.getGraphicObjects(); for(String sFrameName : xGraphicFrames.getElementNames()) { - if(!vExpectedGraphicFrames.remove(sFrameName)) - failed("Unexpected frame name"); - try - { - xGraphicFrames.getByName(sFrameName); - } - catch(com.sun.star.container.NoSuchElementException e) - { - failed("Could not get graphics frame by name."); - } - if(!xGraphicFrames.hasByName(sFrameName)) - failed("Could not find graphics frame by name."); + assertTrue( + "Unexpected frame name", + vExpectedGraphicFrames.remove(sFrameName)); + xGraphicFrames.getByName(sFrameName); + assertTrue( + "Could not find graphics frame by name.", + xGraphicFrames.hasByName(sFrameName)); } - if(!vExpectedGraphicFrames.isEmpty()) - failed("Missing expected graphics frames."); + assertTrue( + "Missing expected graphics frames.", + vExpectedGraphicFrames.isEmpty()); try { xGraphicFrames.getByName("Nonexisting graphics frame"); - failed("Got nonexisting graphics frame"); + fail("Got nonexisting graphics frame"); } catch(com.sun.star.container.NoSuchElementException e) {} - if(xGraphicFrames.hasByName("Nonexisting graphics frame")) - failed("Has nonexisting graphics frame"); + assertFalse( + "Has nonexisting graphics frame", + xGraphicFrames.hasByName("Nonexisting graphics frame")); com.sun.star.container.XIndexAccess xGraphicFramesIdx = (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface( com.sun.star.container.XIndexAccess.class, xGraphicFrames); - if(xGraphicFramesIdx.getCount() != nGraphicFrames) - failed("Unexpected number of graphics frames reported."); + assertEquals( + "Unexpected number of graphics frames reported.", nGraphicFrames, + xGraphicFramesIdx.getCount()); for(int nCurrentFrameIdx = 0; nCurrentFrameIdx < xGraphicFramesIdx.getCount(); nCurrentFrameIdx++) { - try - { - xGraphicFramesIdx.getByIndex(nCurrentFrameIdx); - } - catch(com.sun.star.lang.IndexOutOfBoundsException e) - { - failed("Could not get graphics frame by index."); - } + xGraphicFramesIdx.getByIndex(nCurrentFrameIdx); } } private void checkTextFrames(com.sun.star.text.XTextFramesSupplier xTFS) - throws com.sun.star.lang.WrappedTargetException + throws com.sun.star.uno.Exception { Collection<String> vExpectedTextFrames = new ArrayList<String>(); vExpectedTextFrames.add("Frame1"); @@ -188,46 +161,62 @@ public class CheckFlies extends ComplexTestCase { com.sun.star.container.XNameAccess xTextFrames = xTFS.getTextFrames(); for(String sFrameName : xTextFrames.getElementNames()) { - if(!vExpectedTextFrames.remove(sFrameName)) - failed("Unexpected frame name"); - try - { - xTextFrames.getByName(sFrameName); - } - catch(com.sun.star.container.NoSuchElementException e) - { - failed("Could not get text frame by name."); - } - if(!xTextFrames.hasByName(sFrameName)) - failed("Could not find text frame by name."); + assertTrue( + "Unexpected frame name", + vExpectedTextFrames.remove(sFrameName)); + xTextFrames.getByName(sFrameName); + assertTrue( + "Could not find text frame by name.", + xTextFrames.hasByName(sFrameName)); } - if(!vExpectedTextFrames.isEmpty()) - failed("Missing expected text frames."); + assertTrue( + "Missing expected text frames.", vExpectedTextFrames.isEmpty()); try { xTextFrames.getByName("Nonexisting Textframe"); - failed("Got nonexisting text frame."); + fail("Got nonexisting text frame."); } catch(com.sun.star.container.NoSuchElementException e) {} - if(xTextFrames.hasByName("Nonexisting text frame")) - failed("Has nonexisting text frame."); + assertFalse( + "Has nonexisting text frame.", + xTextFrames.hasByName("Nonexisting text frame")); com.sun.star.container.XIndexAccess xTextFramesIdx = (com.sun.star.container.XIndexAccess)UnoRuntime.queryInterface( com.sun.star.container.XIndexAccess.class, xTextFrames); - if(xTextFramesIdx.getCount() != nTextFrames) - failed("Unexpected number of text frames reported."); + assertEquals( + "Unexpected number of text frames reported.", nTextFrames, + xTextFramesIdx.getCount()); for(int nCurrentFrameIdx = 0; nCurrentFrameIdx < xTextFramesIdx.getCount(); nCurrentFrameIdx++) { - try - { - xTextFramesIdx.getByIndex(nCurrentFrameIdx); - } - catch(com.sun.star.lang.IndexOutOfBoundsException e) - { - failed("Could not get text frame by index."); - } + xTextFramesIdx.getByIndex(nCurrentFrameIdx); } } + + @Before public void setUpDocument() throws com.sun.star.uno.Exception { + document = util.WriterTools.loadTextDoc( + UnoRuntime.queryInterface( + XMultiServiceFactory.class, + connection.getComponentContext().getServiceManager()), + TestDocument.getUrl("CheckFlies.odt")); + } + + @After public void tearDownDocument() { + util.DesktopTools.closeDoc(document); + } + + private XTextDocument document = null; + + @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(); } diff --git a/sw/qa/complex/writer/CheckIndexedPropertyValues.java b/sw/qa/complex/writer/CheckIndexedPropertyValues.java index 0f6f6a25f7..1d68a46186 100755 --- a/sw/qa/complex/writer/CheckIndexedPropertyValues.java +++ b/sw/qa/complex/writer/CheckIndexedPropertyValues.java @@ -27,53 +27,31 @@ package complex.writer; -import complexlib.ComplexTestCase; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.uno.XInterface; import com.sun.star.beans.PropertyValue; import com.sun.star.container.XIndexContainer; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.Type; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; /** * Test the com.sun.star.document.IndexedPropertyValues service */ -public class CheckIndexedPropertyValues extends ComplexTestCase { +public class CheckIndexedPropertyValues { + @Test public void checkIndexedPropertyValues() + throws com.sun.star.uno.Exception + { + XIndexContainer xCont = UnoRuntime.queryInterface( + XIndexContainer.class, + (connection.getComponentContext().getServiceManager(). + createInstanceWithContext( + "com.sun.star.document.IndexedPropertyValues", + connection.getComponentContext()))); - private final String testedServiceName = - "com.sun.star.document.IndexedPropertyValues"; - public String[] getTestMethodNames() { - return new String[]{"checkIndexedPropertyValues"}; - } - -/* public String getTestObjectName() { - return testedServiceName; - } -*/ - public void checkIndexedPropertyValues() { - Object oObj = null; - try { - // print information about the service - XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF(); - oObj = xMSF.createInstance(testedServiceName); - System.out.println("****************"); - System.out.println("Service Name:"); - util.dbg.getSuppServices(oObj); - System.out.println("****************"); - System.out.println("Interfaces:"); - util.dbg.printInterfaces((XInterface)oObj, true); - } - catch(com.sun.star.uno.Exception e) { - System.out.println("Cannot create object."); - e.printStackTrace(); - failed(e.getMessage()); - return; - } - XIndexContainer xCont = (XIndexContainer)UnoRuntime.queryInterface( - XIndexContainer.class, oObj); - - assure("XIndexContainer was queried but returned null.", - (xCont != null)); + assertNotNull("XIndexContainer was queried but returned null.", xCont); PropertyValue[] prop1 = new PropertyValue[1]; prop1[0] = new PropertyValue(); prop1[0].Name = "Jupp"; @@ -84,99 +62,55 @@ public class CheckIndexedPropertyValues extends ComplexTestCase { prop2[0].Name = "Horst"; prop2[0].Value = "BadGuy"; - try { - Type t = xCont.getElementType(); - log.println("Insertable Type: " + t.getTypeName()); - assure("Initial container is not empty: " + xCont.getCount(), xCont.getCount()==0); - log.println("Inserting a PropertyValue."); - xCont.insertByIndex(0, prop1); - PropertyValue[]ret = (PropertyValue[])xCont.getByIndex(0); - assure("Got the wrong PropertyValue: " + - ret[0].Name + " " +(String)ret[0].Value, - ret[0].Name.equals(prop1[0].Name) && - ret[0].Value.equals(prop1[0].Value)); - log.println("Replace the PropertyValue."); - xCont.replaceByIndex(0, prop2); - ret = (PropertyValue[])xCont.getByIndex(0); - assure("Got the wrong PropertyValue: " + - ret[0].Name + " " +(String)ret[0].Value, - ret[0].Name.equals(prop2[0].Name) && - ret[0].Value.equals(prop2[0].Value)); - log.println("Remove the PropertyValue."); - xCont.removeByIndex(0); - assure("Could not remove PropertyValue.", - !xCont.hasElements() && xCont.getCount()==0); - log.println("Insert again."); - xCont.insertByIndex(0, prop1); - xCont.insertByIndex(1, prop2); - assure("Did not insert PropertyValue.", - xCont.hasElements() && xCont.getCount()==2); - - try { - log.println("Insert with wrong index."); - xCont.insertByIndex(25, prop2); - failed("IllegalArgumentException was not thrown."); - } - catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Wrong exception thrown."); - failed(e.getMessage()); - e.printStackTrace(); - } - catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception thrown: "+e); - } - catch(com.sun.star.lang.WrappedTargetException e) { - log.println("Wrong exception thrown."); - failed(e.getMessage()); - e.printStackTrace(); - } - - try { - log.println("Remove non-existing index."); - xCont.removeByIndex(25); - failed("IndexOutOfBoundsException was not thrown."); - } - catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Expected exception thrown: "+e); - } - catch(com.sun.star.lang.WrappedTargetException e) { - log.println("Wrong exception thrown."); - failed(e.getMessage()); - e.printStackTrace(); - } - - try { - log.println("Insert wrong argument."); - xCont.insertByIndex(2, "Example String"); - failed("IllegalArgumentException was not thrown."); - } - catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Expected exception thrown: " + e); - } - catch(com.sun.star.lang.IndexOutOfBoundsException e) { - log.println("Wrong exception thrown."); - failed(e.getMessage()); - e.printStackTrace(); - } - catch(com.sun.star.lang.WrappedTargetException e) { - log.println("Wrong exception thrown."); - failed(e.getMessage()); - e.printStackTrace(); - } + Type t = xCont.getElementType(); + assertEquals("Initial container is not empty", 0, xCont.getCount()); + xCont.insertByIndex(0, prop1); + PropertyValue[]ret = (PropertyValue[])xCont.getByIndex(0); + assertEquals(prop1[0].Name, ret[0].Name); + assertEquals(prop1[0].Value, ret[0].Value); + xCont.replaceByIndex(0, prop2); + ret = (PropertyValue[])xCont.getByIndex(0); + assertEquals(prop2[0].Name, ret[0].Name); + assertEquals(prop2[0].Value, ret[0].Value); + xCont.removeByIndex(0); + assertTrue("Could not remove PropertyValue.", + !xCont.hasElements() && xCont.getCount()==0); + xCont.insertByIndex(0, prop1); + xCont.insertByIndex(1, prop2); + assertTrue("Did not insert PropertyValue.", + xCont.hasElements() && xCont.getCount()==2); + try { + xCont.insertByIndex(25, prop2); + fail("IllegalArgumentException was not thrown."); } - catch(com.sun.star.lang.IllegalArgumentException e) { - failed(e.getMessage()); - e.printStackTrace(); + catch(com.sun.star.lang.IndexOutOfBoundsException e) { + } + + try { + xCont.removeByIndex(25); + fail("IndexOutOfBoundsException was not thrown."); } catch(com.sun.star.lang.IndexOutOfBoundsException e) { - failed(e.getMessage()); - e.printStackTrace(); } - catch(com.sun.star.lang.WrappedTargetException e) { - failed(e.getMessage()); - e.printStackTrace(); + + try { + xCont.insertByIndex(2, "Example String"); + fail("IllegalArgumentException was not thrown."); + } + catch(com.sun.star.lang.IllegalArgumentException e) { } } + @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(); } diff --git a/sw/qa/complex/writer/CheckNamedPropertyValues.java b/sw/qa/complex/writer/CheckNamedPropertyValues.java index 7eefc334bb..7fb010d84f 100755 --- a/sw/qa/complex/writer/CheckNamedPropertyValues.java +++ b/sw/qa/complex/writer/CheckNamedPropertyValues.java @@ -27,53 +27,31 @@ package complex.writer; - -import complexlib.ComplexTestCase; import com.sun.star.beans.PropertyValue; -import com.sun.star.lang.XMultiServiceFactory; -import com.sun.star.uno.XInterface; import com.sun.star.container.XNameContainer; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.Type; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; +import org.openoffice.test.OfficeConnection; +import static org.junit.Assert.*; /** * */ -public class CheckNamedPropertyValues extends ComplexTestCase { - - private final String testedServiceName = - "com.sun.star.document.NamedPropertyValues"; - - public String[] getTestMethodNames() { - return new String[]{"checkNamedPropertyValues"}; - } - -/* public String getTestObjectName() { - return "complex.writer.CheckNamedPropertyValues"; - } */ - - public void checkNamedPropertyValues() { - Object oObj = null; - try { - XMultiServiceFactory xMSF = (XMultiServiceFactory)param.getMSF(); - oObj = xMSF.createInstance(testedServiceName); - System.out.println("****************"); - System.out.println("Service Name:"); - util.dbg.getSuppServices(oObj); - System.out.println("****************"); - System.out.println("Interfaces:"); - util.dbg.printInterfaces((XInterface)oObj, true); - } - catch(com.sun.star.uno.Exception e) { - e.printStackTrace(); - failed(e.getMessage()); - return; - } - XNameContainer xCont = (XNameContainer)UnoRuntime.queryInterface( - XNameContainer.class, oObj); - - assure("XNameContainer was queried but returned null.", - (xCont != null)); +public class CheckNamedPropertyValues { + @Test public void checkNamedPropertyValues() + throws com.sun.star.uno.Exception + { + XNameContainer xCont = UnoRuntime.queryInterface( + XNameContainer.class, + (connection.getComponentContext().getServiceManager(). + createInstanceWithContext( + "com.sun.star.document.NamedPropertyValues", + connection.getComponentContext()))); + + assertNotNull("XNameContainer was queried but returned null.", xCont); PropertyValue[] prop1 = new PropertyValue[1]; prop1[0] = new PropertyValue(); prop1[0].Name = "Jupp"; @@ -84,113 +62,61 @@ public class CheckNamedPropertyValues extends ComplexTestCase { prop2[0].Name = "Horst"; prop2[0].Value = "BadGuy"; - try { - Type t = xCont.getElementType(); - log.println("Insertable Type: " + t.getTypeName()); - assure("Initial container is not empty.", !xCont.hasElements()); - - log.println("Insert a PropertyValue."); - xCont.insertByName("prop1", prop1); - PropertyValue[]ret = (PropertyValue[])xCont.getByName("prop1"); - assure("Got the wrong PropertyValue: " + - ret[0].Name + " " +(String)ret[0].Value, - ret[0].Name.equals(prop1[0].Name) && - ret[0].Value.equals(prop1[0].Value)); - log.println("Replace the PropertyValue."); - xCont.replaceByName("prop1", prop2); - ret = (PropertyValue[])xCont.getByName("prop1"); - assure("Got the wrong PropertyValue: " + - ret[0].Name + " " +(String)ret[0].Value, - ret[0].Name.equals(prop2[0].Name) && - ret[0].Value.equals(prop2[0].Value)); - log.println("Remove the PropertyValue."); - xCont.removeByName("prop1"); - assure("Could not remove PropertyValue.", !xCont.hasElements()); - log.println("Insert again."); - xCont.insertByName("prop1", prop1); - xCont.insertByName("prop2", prop2); - assure("Did not insert PropertyValue.", xCont.hasElements()); - String[] names = xCont.getElementNames(); - int count = 0; - for (int i=0; i<names.length; i++) { - if (names[i].equals("prop1") || names[i].equals("prop2")) - count++; - else - failed("Got a wrong element name: "+names[i]); - } - if (count != 2) - failed("Not all element names were returned."); - - try { - log.println("Insert PropertyValue with an existing name."); - xCont.insertByName("prop2", prop1); - failed("ElementExistException was not thrown."); - } - catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Wrong exception thrown."); - failed(e.getMessage()); - e.printStackTrace(); - } - catch(com.sun.star.container.ElementExistException e) { - log.println("Expected exception thrown: "+e); - } - catch(com.sun.star.lang.WrappedTargetException e) { - log.println("Wrong exception thrown."); - failed(e.getMessage()); - e.printStackTrace(); - } - - try { - log.println("Inserting a wrong argument."); - xCont.insertByName("prop3", "Example String"); - failed("IllegalArgumentException was not thrown."); - } - catch(com.sun.star.lang.IllegalArgumentException e) { - log.println("Expected exception thrown: "+e); - } - catch(com.sun.star.container.ElementExistException e) { - log.println("Wrong exception thrown."); - failed(e.getMessage()); - e.printStackTrace(); - } - catch(com.sun.star.lang.WrappedTargetException e) { - log.println("Wrong exception thrown."); - failed(e.getMessage()); - e.printStackTrace(); - } + Type t = xCont.getElementType(); + assertFalse("Initial container is not empty.", xCont.hasElements()); + + xCont.insertByName("prop1", prop1); + PropertyValue[]ret = (PropertyValue[])xCont.getByName("prop1"); + assertEquals(prop1[0].Name, ret[0].Name); + assertEquals(prop1[0].Value, ret[0].Value); + xCont.replaceByName("prop1", prop2); + ret = (PropertyValue[])xCont.getByName("prop1"); + assertEquals(prop2[0].Name, ret[0].Name); + assertEquals(prop2[0].Value, ret[0].Value); + xCont.removeByName("prop1"); + assertFalse("Could not remove PropertyValue.", xCont.hasElements()); + xCont.insertByName("prop1", prop1); + xCont.insertByName("prop2", prop2); + assertTrue("Did not insert PropertyValue.", xCont.hasElements()); + String[] names = xCont.getElementNames(); + assertEquals("Not all element names were returned.", 2, names.length); + for (int i=0; i<names.length; i++) { + assertTrue( + "Got a wrong element name", + names[i].equals("prop1") || names[i].equals("prop2")); + } - try { - log.println("Remove a non-existing element."); - xCont.removeByName("prop3"); - failed("NoSuchElementException was not thrown."); - } - catch(com.sun.star.container.NoSuchElementException e) { - log.println("Expected exception thrown: "+e); - } - catch(com.sun.star.lang.WrappedTargetException e) { - log.println("Wrong exception thrown."); - failed(e.getMessage()); - e.printStackTrace(); - } + try { + xCont.insertByName("prop2", prop1); + fail("ElementExistException was not thrown."); + } + catch(com.sun.star.container.ElementExistException e) { + } + try { + xCont.insertByName("prop3", "Example String"); + fail("IllegalArgumentException was not thrown."); } catch(com.sun.star.lang.IllegalArgumentException e) { - failed(e.getMessage()); - e.printStackTrace(); } - catch(com.sun.star.container.ElementExistException e) { - failed(e.getMessage()); - e.printStackTrace(); + + try { + xCont.removeByName("prop3"); + fail("NoSuchElementException was not thrown."); } catch(com.sun.star.container.NoSuchElementException e) { - failed(e.getMessage()); - e.printStackTrace(); - } - catch(com.sun.star.lang.WrappedTargetException e) { - failed(e.getMessage()); - e.printStackTrace(); } } + @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(); } diff --git a/sw/qa/complex/writer/TestDocument.java b/sw/qa/complex/writer/TestDocument.java new file mode 100644 index 0000000000..25a11338ae --- /dev/null +++ b/sw/qa/complex/writer/TestDocument.java @@ -0,0 +1,39 @@ +/************************************************************************* +* +* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +* +* Copyright 2000, 2010 Oracle and/or its affiliates. +* +* OpenOffice.org - a multi-platform office productivity suite +* +* This file is part of OpenOffice.org. +* +* OpenOffice.org is free software: you can redistribute it and/or modify +* it under the terms of the GNU Lesser General Public License version 3 +* only, as published by the Free Software Foundation. +* +* OpenOffice.org is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU Lesser General Public License version 3 for more details +* (a copy is included in the LICENSE file that accompanied this code). +* +* You should have received a copy of the GNU Lesser General Public License +* version 3 along with OpenOffice.org. If not, see +* <http://www.openoffice.org/license.html> +* for a copy of the LGPLv3 License. +* +************************************************************************/ + +package complex.writer; + +import java.io.File; +import org.openoffice.test.OfficeFileUrl; + +final class TestDocument { + public static String getUrl(String name) { + return OfficeFileUrl.getAbsolute(new File("testdocuments", name)); + } + + private TestDocument() {} +} diff --git a/sw/qa/complex/writer/TextPortionEnumerationTest.java b/sw/qa/complex/writer/TextPortionEnumerationTest.java index b526b30e4e..5c1f7dcfcb 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(); } diff --git a/sw/qa/complex/writer/makefile.mk b/sw/qa/complex/writer/makefile.mk index ae2a15f821..550e9d64fd 100755 --- a/sw/qa/complex/writer/makefile.mk +++ b/sw/qa/complex/writer/makefile.mk @@ -25,84 +25,32 @@ # #************************************************************************* -PRJ = ..$/..$/.. -TARGET = PropertyValues -PRJNAME = $(TARGET) -PACKAGE = complex$/writer - -# --- Settings ----------------------------------------------------- -.INCLUDE: settings.mk - - -#----- compile .java files ----------------------------------------- - -JARFILES = mysql.jar ridl.jar unoil.jar jurt.jar juh.jar java_uno.jar OOoRunner.jar -JAVAFILES = CheckIndexedPropertyValues.java CheckNamedPropertyValues.java CheckCrossReferences.java CheckBookmarks.java CheckFlies.java TextPortionEnumerationTest.java -JAVACLASSFILES = $(foreach,i,$(JAVAFILES) $(CLASSDIR)$/$(PACKAGE)$/$(i:b).class) - -#----- make a jar from compiled files ------------------------------ - -MAXLINELENGTH = 100000 - -JARCLASSDIRS = $(PACKAGE) -JARTARGET = $(TARGET).jar -JARCOMPRESS = TRUE - -# --- Parameters for the test -------------------------------------- - -# start an office if the parameter is set for the makefile -.IF "$(OFFICE)" == "" -CT_APPEXECCOMMAND = +.IF "$(OOO_SUBSEQUENT_TESTS)" == "" +nothing .PHONY: .ELSE -CT_APPEXECCOMMAND = -AppExecutionCommand "$(OFFICE)$/soffice -accept=socket,host=localhost,port=8100;urp;" -.ENDIF - -# test base is java complex -CT_TESTBASE = -TestBase java_complex - -# build package name with "." instead of $/ -CT_PACKAGE = -o $(PACKAGE:s\$/\.\) - -# start the runner application -CT_APP = org.openoffice.Runner -# --- Targets ------------------------------------------------------ +PRJ = ../../.. +PRJNAME = sw +TARGET = qa_complex_writer + +.IF "$(OOO_JUNIT_JAR)" != "" +PACKAGE = complex/writer +JAVATESTFILES = \ + CheckBookmarks.java \ + CheckCrossReferences.java \ + CheckFlies.java \ + CheckIndexedPropertyValues.java \ + CheckNamedPropertyValues.java \ + TextPortionEnumerationTest.java +JAVAFILES = $(JAVATESTFILES) TestDocument.java +JARFILES = OOoRunner.jar ridl.jar test.jar unoil.jar +EXTRAJARFILES = $(OOO_JUNIT_JAR) +.END -.IF "$(depend)" == "" -ALL: ALLTAR -.ELSE -ALL: ALLDEP -.ENDIF - -.INCLUDE : target.mk - -run: \ - CheckBookmarks \ - CheckCrossReferences \ - CheckIndexedPropertyValues \ - CheckNamedPropertyValues \ - CheckFlies \ - TextPortionEnumerationTest \ - - -RUN: run - -CheckIndexedPropertyValues: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_PACKAGE).CheckIndexedPropertyValues - - -CheckNamedPropertyValues: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) $(CT_PACKAGE).CheckNamedPropertyValues - -CheckCrossReferences: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) -tdoc $(PWD)$/testdocuments $(CT_PACKAGE).CheckCrossReferences - -CheckBookmarks: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) -tdoc $(PWD)$/testdocuments $(CT_PACKAGE).CheckBookmarks - -CheckFlies: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) -tdoc $(PWD)$/testdocuments $(CT_PACKAGE).CheckFlies +.INCLUDE: settings.mk +.INCLUDE: target.mk +.INCLUDE: installationtest.mk -TextPortionEnumerationTest: - +java -cp $(CLASSPATH) $(CT_APP) $(CT_APPEXECCOMMAND) $(CT_TESTBASE) -tdoc $(PWD)$/testdocuments $(CT_PACKAGE).TextPortionEnumerationTest +ALLTAR : javatest +.END diff --git a/sw/qa/unoapi/knownissues.xcl b/sw/qa/unoapi/knownissues.xcl index 08e441211c..ea5bf843f3 100644 --- a/sw/qa/unoapi/knownissues.xcl +++ b/sw/qa/unoapi/knownissues.xcl @@ -173,3 +173,17 @@ sw.SwXTextEmbeddedObject::com::sun::star::document::XEmbeddedObjectSupplier ### i111332 ### sw.XMLStylesExporter::com::sun::star::document::XFilter + +### i113020 ### +sw.SwXTextEmbeddedObject::com::sun::star::beans::XPropertySet +sw.SwXTextGraphicObject::com::sun::star::beans::XPropertySet +sw.SwXTextFrame::com::sun::star::beans::XPropertySet + +### i113136 ### +sw.SwAccessibleParagraphView::com::sun::star::accessibility::XAccessibleEditableText + +### i114205 ### +sw.SwAccessibleParagraphView::com::sun::star::accessibility::XAccessibleText + +### i114889 ### +sw.SwXTextViewCursor::com::sun::star::view::XScreenCursor diff --git a/sw/qa/unoapi/sw.sce b/sw/qa/unoapi/sw.sce index 0f1092af8a..f6ae766af2 100644 --- a/sw/qa/unoapi/sw.sce +++ b/sw/qa/unoapi/sw.sce @@ -5,9 +5,9 @@ #i111197 -o sw.SwAccessibleDocumentPageView #i86751 -o sw.SwAccessibleDocumentView -o sw.SwAccessibleEndnoteView --o sw.SwAccessibleFooterView --o sw.SwAccessibleFootnoteView --o sw.SwAccessibleHeaderView +#i113142 -o sw.SwAccessibleFooterView +#i114637 -o sw.SwAccessibleFootnoteView +#i113142 -o sw.SwAccessibleHeaderView #i89022 -o sw.SwAccessiblePageView -o sw.SwAccessibleParagraphView -o sw.SwAccessibleTableCellView |