From 1f9abbd13e98b50a03813b643477d7aed96b5a3e Mon Sep 17 00:00:00 2001 From: sb Date: Fri, 7 May 2010 11:03:36 +0200 Subject: sb123: #i111449# adapted sw/qa/complex to new framework --- sw/qa/complex/writer/CheckNamedPropertyValues.java | 198 +++++++-------------- 1 file changed, 61 insertions(+), 137 deletions(-) (limited to 'sw/qa/complex/writer/CheckNamedPropertyValues.java') diff --git a/sw/qa/complex/writer/CheckNamedPropertyValues.java b/sw/qa/complex/writer/CheckNamedPropertyValues.java index 851381cf3c24..bad8bbda3303 100755 --- a/sw/qa/complex/writer/CheckNamedPropertyValues.java +++ b/sw/qa/complex/writer/CheckNamedPropertyValues.java @@ -27,53 +27,29 @@ 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.getFactory().createInstance( + "com.sun.star.document.NamedPropertyValues")); + + assertNotNull("XNameContainer was queried but returned null.", xCont); PropertyValue[] prop1 = new PropertyValue[1]; prop1[0] = new PropertyValue(); prop1[0].Name = "Jupp"; @@ -84,113 +60,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 Date: Fri, 14 May 2010 13:50:22 +0200 Subject: sb123: #i111598# OfficeConnection getFactory -> getComponentContext --- sw/qa/complex/writer/CheckNamedPropertyValues.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'sw/qa/complex/writer/CheckNamedPropertyValues.java') diff --git a/sw/qa/complex/writer/CheckNamedPropertyValues.java b/sw/qa/complex/writer/CheckNamedPropertyValues.java index bad8bbda3303..b2541954ce9f 100755 --- a/sw/qa/complex/writer/CheckNamedPropertyValues.java +++ b/sw/qa/complex/writer/CheckNamedPropertyValues.java @@ -46,8 +46,10 @@ public class CheckNamedPropertyValues { { XNameContainer xCont = UnoRuntime.queryInterface( XNameContainer.class, - connection.getFactory().createInstance( - "com.sun.star.document.NamedPropertyValues")); + (connection.getComponentContext().getServiceManager(). + createInstanceWithContext( + "com.sun.star.document.NamedPropertyValues", + connection.getComponentContext()))); assertNotNull("XNameContainer was queried but returned null.", xCont); PropertyValue[] prop1 = new PropertyValue[1]; -- cgit