1*cdf0e10cSrcweir /************************************************************************* 2*cdf0e10cSrcweir * 3*cdf0e10cSrcweir * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4*cdf0e10cSrcweir * 5*cdf0e10cSrcweir * Copyright 2000, 2010 Oracle and/or its affiliates. 6*cdf0e10cSrcweir * 7*cdf0e10cSrcweir * OpenOffice.org - a multi-platform office productivity suite 8*cdf0e10cSrcweir * 9*cdf0e10cSrcweir * This file is part of OpenOffice.org. 10*cdf0e10cSrcweir * 11*cdf0e10cSrcweir * OpenOffice.org is free software: you can redistribute it and/or modify 12*cdf0e10cSrcweir * it under the terms of the GNU Lesser General Public License version 3 13*cdf0e10cSrcweir * only, as published by the Free Software Foundation. 14*cdf0e10cSrcweir * 15*cdf0e10cSrcweir * OpenOffice.org is distributed in the hope that it will be useful, 16*cdf0e10cSrcweir * but WITHOUT ANY WARRANTY; without even the implied warranty of 17*cdf0e10cSrcweir * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18*cdf0e10cSrcweir * GNU Lesser General Public License version 3 for more details 19*cdf0e10cSrcweir * (a copy is included in the LICENSE file that accompanied this code). 20*cdf0e10cSrcweir * 21*cdf0e10cSrcweir * You should have received a copy of the GNU Lesser General Public License 22*cdf0e10cSrcweir * version 3 along with OpenOffice.org. If not, see 23*cdf0e10cSrcweir * <http://www.openoffice.org/license.html> 24*cdf0e10cSrcweir * for a copy of the LGPLv3 License. 25*cdf0e10cSrcweir * 26*cdf0e10cSrcweir ************************************************************************/ 27*cdf0e10cSrcweir package complex.persistent_window_states; 28*cdf0e10cSrcweir 29*cdf0e10cSrcweir import com.sun.star.uno.Any; 30*cdf0e10cSrcweir import com.sun.star.lang.XMultiServiceFactory; 31*cdf0e10cSrcweir import com.sun.star.frame.XFramesSupplier; 32*cdf0e10cSrcweir import com.sun.star.frame.XFrames; 33*cdf0e10cSrcweir import com.sun.star.container.XIndexAccess; 34*cdf0e10cSrcweir import com.sun.star.uno.UnoRuntime; 35*cdf0e10cSrcweir import com.sun.star.uno.AnyConverter; 36*cdf0e10cSrcweir import com.sun.star.frame.XComponentLoader; 37*cdf0e10cSrcweir import com.sun.star.awt.Rectangle; 38*cdf0e10cSrcweir import com.sun.star.util.XCloseable; 39*cdf0e10cSrcweir import helper.ConfigurationRead; 40*cdf0e10cSrcweir 41*cdf0e10cSrcweir 42*cdf0e10cSrcweir 43*cdf0e10cSrcweir // import org.junit.After; 44*cdf0e10cSrcweir import org.junit.AfterClass; 45*cdf0e10cSrcweir // import org.junit.Before; 46*cdf0e10cSrcweir import org.junit.BeforeClass; 47*cdf0e10cSrcweir import org.junit.Test; 48*cdf0e10cSrcweir import org.openoffice.test.OfficeConnection; 49*cdf0e10cSrcweir import static org.junit.Assert.*; 50*cdf0e10cSrcweir 51*cdf0e10cSrcweir /** 52*cdf0e10cSrcweir * Parameters: 53*cdf0e10cSrcweir * <ul> 54*cdf0e10cSrcweir * <li>NoOffice=yes - StarOffice is not started initially.</li> 55*cdf0e10cSrcweir * </ul> 56*cdf0e10cSrcweir */ 57*cdf0e10cSrcweir public class PersistentWindowTest 58*cdf0e10cSrcweir { 59*cdf0e10cSrcweir 60*cdf0e10cSrcweir // private XMultiServiceFactory xMSF; 61*cdf0e10cSrcweir // private OfficeProvider oProvider; 62*cdf0e10cSrcweir private int iOfficeCloseTime = 0; 63*cdf0e10cSrcweir 64*cdf0e10cSrcweir /** 65*cdf0e10cSrcweir * A frunction to tell the framework, which test functions are available. 66*cdf0e10cSrcweir * Right now, it's only 'checkPersistentWindowState'. 67*cdf0e10cSrcweir * @return All test methods. 68*cdf0e10cSrcweir */ 69*cdf0e10cSrcweir // public String[] getTestMethodNames() 70*cdf0e10cSrcweir // { 71*cdf0e10cSrcweir // return new String[] 72*cdf0e10cSrcweir // { 73*cdf0e10cSrcweir // "checkPersistentWindowState" 74*cdf0e10cSrcweir // }; 75*cdf0e10cSrcweir // } 76*cdf0e10cSrcweir 77*cdf0e10cSrcweir /** 78*cdf0e10cSrcweir * The test parameters 79*cdf0e10cSrcweir */ 80*cdf0e10cSrcweir // private static TestParameters param = null; 81*cdf0e10cSrcweir 82*cdf0e10cSrcweir /** 83*cdf0e10cSrcweir * Test if all available document types change the 84*cdf0e10cSrcweir * persistent Window Attributes 85*cdf0e10cSrcweir * 86*cdf0e10cSrcweir * The test follows basically these steps: 87*cdf0e10cSrcweir * - Create a configuration reader and a componentloader 88*cdf0e10cSrcweir * - Look for all document types in the configuration 89*cdf0e10cSrcweir * - Do for every doc type 90*cdf0e10cSrcweir * - start office 91*cdf0e10cSrcweir * - read configuration attibute settings 92*cdf0e10cSrcweir * - create a new document 93*cdf0e10cSrcweir * - resize the document and close it 94*cdf0e10cSrcweir * - close office 95*cdf0e10cSrcweir * - start office 96*cdf0e10cSrcweir * - read configuration attribute settings 97*cdf0e10cSrcweir * - create another new document 98*cdf0e10cSrcweir * - compare old settings with new ones: should be different 99*cdf0e10cSrcweir * - compare the document size with the resized document: should be equal 100*cdf0e10cSrcweir * - close office 101*cdf0e10cSrcweir * - Test finished 102*cdf0e10cSrcweir */ 103*cdf0e10cSrcweir @Test public void checkPersistentWindowState() 104*cdf0e10cSrcweir { 105*cdf0e10cSrcweir // final XMultiServiceFactory xMsf = getMSF(); 106*cdf0e10cSrcweir 107*cdf0e10cSrcweir // some Tests need the qadevOOo TestParameters, it is like a Hashmap for Properties. 108*cdf0e10cSrcweir // param = new TestParameters(); 109*cdf0e10cSrcweir // param.put("ServiceFactory", xMsf); // some qadevOOo functions need the ServiceFactory 110*cdf0e10cSrcweir 111*cdf0e10cSrcweir try 112*cdf0e10cSrcweir { 113*cdf0e10cSrcweir 114*cdf0e10cSrcweir // At first we are already connected 115*cdf0e10cSrcweir // if (!connect()) 116*cdf0e10cSrcweir // { 117*cdf0e10cSrcweir // return; 118*cdf0e10cSrcweir // } 119*cdf0e10cSrcweir 120*cdf0e10cSrcweir // fetch the multi service factory for setup 121*cdf0e10cSrcweir // XMultiServiceFactory xCP = getMSF(); 122*cdf0e10cSrcweir 123*cdf0e10cSrcweir // create the configuration reader 124*cdf0e10cSrcweir // ConfigurationRead cfgRead = new ConfigurationRead(xCP); 125*cdf0e10cSrcweir 126*cdf0e10cSrcweir // just test the wrong ones, not all. 127*cdf0e10cSrcweir String[] els = new String[] 128*cdf0e10cSrcweir { 129*cdf0e10cSrcweir "Office/Factories/com.sun.star.drawing.DrawingDocument", 130*cdf0e10cSrcweir "Office/Factories/com.sun.star.formula.FormulaProperties", 131*cdf0e10cSrcweir //"Office/Factories/com.sun.star.presentation.PresentationDocument", 132*cdf0e10cSrcweir "Office/Factories/com.sun.star.sheet.SpreadsheetDocument", 133*cdf0e10cSrcweir "Office/Factories/com.sun.star.text.GlobalDocument", 134*cdf0e10cSrcweir "Office/Factories/com.sun.star.text.TextDocument", 135*cdf0e10cSrcweir "Office/Factories/com.sun.star.text.WebDocument", 136*cdf0e10cSrcweir }; 137*cdf0e10cSrcweir // uncomment the following line for all doc types 138*cdf0e10cSrcweir // String [] els = cfgRead.getSubNodeNames("Office/Factories"); 139*cdf0e10cSrcweir 140*cdf0e10cSrcweir System.out.println("Found " + els.length + " document types to test.\n"); 141*cdf0e10cSrcweir disconnect(); 142*cdf0e10cSrcweir 143*cdf0e10cSrcweir // for all types 144*cdf0e10cSrcweir for (int i = 0; i < els.length; i++) 145*cdf0e10cSrcweir { 146*cdf0e10cSrcweir System.out.println("\tStart test for document type " + i + ": " + els[i]); 147*cdf0e10cSrcweir // exclude chart documents: cannot be created this way. 148*cdf0e10cSrcweir if (els[i].indexOf("ChartDocument") != -1) 149*cdf0e10cSrcweir { 150*cdf0e10cSrcweir System.out.println("Skipping chart document: cannot be create like this."); 151*cdf0e10cSrcweir continue; 152*cdf0e10cSrcweir } 153*cdf0e10cSrcweir 154*cdf0e10cSrcweir // start an office 155*cdf0e10cSrcweir connect(); 156*cdf0e10cSrcweir 157*cdf0e10cSrcweir // get configuration 158*cdf0e10cSrcweir String[] settings = getConfigurationAndLoader(getMSF(), els[i]); 159*cdf0e10cSrcweir if (settings == null) 160*cdf0e10cSrcweir { 161*cdf0e10cSrcweir System.out.println("Skipping document type " + els[i]); 162*cdf0e10cSrcweir disconnect(); 163*cdf0e10cSrcweir continue; 164*cdf0e10cSrcweir } 165*cdf0e10cSrcweir String cfg = settings[1]; 166*cdf0e10cSrcweir 167*cdf0e10cSrcweir // load a document 168*cdf0e10cSrcweir DocumentHandle handle = loadDocument(getMSF(), settings[0]); 169*cdf0e10cSrcweir 170*cdf0e10cSrcweir // first size 171*cdf0e10cSrcweir Rectangle rect1 = handle.getDocumentPosSize(); 172*cdf0e10cSrcweir 173*cdf0e10cSrcweir // resize 174*cdf0e10cSrcweir handle.resizeDocument(); 175*cdf0e10cSrcweir // after resize 176*cdf0e10cSrcweir Rectangle rect2 = handle.getDocumentPosSize(); 177*cdf0e10cSrcweir 178*cdf0e10cSrcweir // disposeManager and start a new office 179*cdf0e10cSrcweir disconnect(); 180*cdf0e10cSrcweir 181*cdf0e10cSrcweir connect(); 182*cdf0e10cSrcweir 183*cdf0e10cSrcweir // get configuration 184*cdf0e10cSrcweir settings = getConfigurationAndLoader(getMSF(), els[i]); 185*cdf0e10cSrcweir 186*cdf0e10cSrcweir String newCfg = settings[1]; 187*cdf0e10cSrcweir 188*cdf0e10cSrcweir // load a document 189*cdf0e10cSrcweir handle = loadDocument(getMSF(), settings[0]); 190*cdf0e10cSrcweir 191*cdf0e10cSrcweir Rectangle newRect = handle.getDocumentPosSize(); 192*cdf0e10cSrcweir 193*cdf0e10cSrcweir // print the settings and window sizes 194*cdf0e10cSrcweir System.out.println("----------------------------"); 195*cdf0e10cSrcweir System.out.println("Initial Config String : " + cfg); 196*cdf0e10cSrcweir System.out.println("Config String after restart: " + newCfg); 197*cdf0e10cSrcweir 198*cdf0e10cSrcweir System.out.println("----------------------------"); 199*cdf0e10cSrcweir System.out.println("Initial window (X,Y,Width,Height): " 200*cdf0e10cSrcweir + rect1.X + ";" + rect1.Y + ";" + rect1.Width + ";" + rect1.Height); 201*cdf0e10cSrcweir System.out.println("Window after resize (X,Y,Width,Height): " 202*cdf0e10cSrcweir + rect2.X + ";" + rect2.Y + ";" + rect2.Width + ";" + rect2.Height); 203*cdf0e10cSrcweir System.out.println("Window after restart (X,Y,Width,Height): " 204*cdf0e10cSrcweir + newRect.X + ";" + newRect.Y + ";" + newRect.Width + ";" 205*cdf0e10cSrcweir + newRect.Height); 206*cdf0e10cSrcweir 207*cdf0e10cSrcweir // compare to see if resize worked 208*cdf0e10cSrcweir System.out.println("----------------------------"); 209*cdf0e10cSrcweir if (els[i].indexOf("SpreadsheetDocument") == -1 && 210*cdf0e10cSrcweir els[i].indexOf("DrawingDocument") == -1) 211*cdf0e10cSrcweir { 212*cdf0e10cSrcweir // leave out Spreadsheet- and DrawingDocumnt 213*cdf0e10cSrcweir assertTrue("Resize values for " + els[i] + " are equal.", !compareRectangles(rect1, rect2)); 214*cdf0e10cSrcweir } 215*cdf0e10cSrcweir // compare settings and sizes 216*cdf0e10cSrcweir assertTrue("Config settings for " + els[i] + " were not changed.", !cfg.equals(newCfg)); 217*cdf0e10cSrcweir assertTrue("Resized and restarted window for " + els[i] + " are not equal.", compareRectangles(rect2, newRect)); 218*cdf0e10cSrcweir System.out.println("----------------------------"); 219*cdf0e10cSrcweir 220*cdf0e10cSrcweir // disposeManager 221*cdf0e10cSrcweir disconnect(); 222*cdf0e10cSrcweir 223*cdf0e10cSrcweir System.out.println("\tFinish test for document type " + i + ": " + els[i]); 224*cdf0e10cSrcweir 225*cdf0e10cSrcweir } 226*cdf0e10cSrcweir } 227*cdf0e10cSrcweir catch (Exception e) 228*cdf0e10cSrcweir { 229*cdf0e10cSrcweir e.printStackTrace(); 230*cdf0e10cSrcweir } 231*cdf0e10cSrcweir } 232*cdf0e10cSrcweir 233*cdf0e10cSrcweir /** 234*cdf0e10cSrcweir * Get the configuration settings and the document loader 235*cdf0e10cSrcweir * @param xMSF A MultiServiceFactory from an office 236*cdf0e10cSrcweir * @param cfgString A configuration string 237*cdf0e10cSrcweir * @return Settings and Loader 238*cdf0e10cSrcweir */ 239*cdf0e10cSrcweir private static String[] getConfigurationAndLoader(XMultiServiceFactory xMSF, 240*cdf0e10cSrcweir String cfgString) 241*cdf0e10cSrcweir { 242*cdf0e10cSrcweir String[] conf = new String[2]; 243*cdf0e10cSrcweir 244*cdf0e10cSrcweir try 245*cdf0e10cSrcweir { 246*cdf0e10cSrcweir Object o = xMSF.createInstance( 247*cdf0e10cSrcweir "com.sun.star.configuration.ConfigurationProvider"); 248*cdf0e10cSrcweir 249*cdf0e10cSrcweir // fetch the multi service factory for setup 250*cdf0e10cSrcweir XMultiServiceFactory xCP = UnoRuntime.queryInterface(XMultiServiceFactory.class, o); 251*cdf0e10cSrcweir 252*cdf0e10cSrcweir // create the configuration reader 253*cdf0e10cSrcweir ConfigurationRead cfgRead = new ConfigurationRead(xCP); 254*cdf0e10cSrcweir 255*cdf0e10cSrcweir // get the document loader 256*cdf0e10cSrcweir String loader = getStringFromObject( 257*cdf0e10cSrcweir cfgRead.getByHierarchicalName(cfgString + "/ooSetupFactoryEmptyDocumentURL")); 258*cdf0e10cSrcweir 259*cdf0e10cSrcweir if (loader == null) 260*cdf0e10cSrcweir { 261*cdf0e10cSrcweir return null; 262*cdf0e10cSrcweir } 263*cdf0e10cSrcweir System.out.println("\tLoader: " + loader); 264*cdf0e10cSrcweir 265*cdf0e10cSrcweir // read attributes 266*cdf0e10cSrcweir String hierchName = cfgString + "/ooSetupFactoryWindowAttributes"; 267*cdf0e10cSrcweir String setupSettings = getStringFromObject(cfgRead.getByHierarchicalName(hierchName)); 268*cdf0e10cSrcweir // remove slots: just plain document types have to start 269*cdf0e10cSrcweir if (loader.indexOf("?slot") != -1) 270*cdf0e10cSrcweir { 271*cdf0e10cSrcweir loader = loader.substring(0, loader.indexOf("?slot")); 272*cdf0e10cSrcweir System.out.println("Loader: " + loader); 273*cdf0e10cSrcweir } 274*cdf0e10cSrcweir 275*cdf0e10cSrcweir conf[0] = loader; 276*cdf0e10cSrcweir conf[1] = setupSettings; 277*cdf0e10cSrcweir } 278*cdf0e10cSrcweir catch (com.sun.star.uno.Exception e) 279*cdf0e10cSrcweir { 280*cdf0e10cSrcweir } 281*cdf0e10cSrcweir return conf; 282*cdf0e10cSrcweir } 283*cdf0e10cSrcweir 284*cdf0e10cSrcweir /** 285*cdf0e10cSrcweir * Load a document 286*cdf0e10cSrcweir * @param xMSF A MultiServiceFactory from an office 287*cdf0e10cSrcweir * @param docLoader A documet loader 288*cdf0e10cSrcweir * @return A handle to the document 289*cdf0e10cSrcweir */ 290*cdf0e10cSrcweir private DocumentHandle loadDocument(XMultiServiceFactory xMSF, 291*cdf0e10cSrcweir String docLoader) 292*cdf0e10cSrcweir { 293*cdf0e10cSrcweir DocumentHandle docHandle = null; 294*cdf0e10cSrcweir try 295*cdf0e10cSrcweir { 296*cdf0e10cSrcweir // create component loaader 297*cdf0e10cSrcweir XComponentLoader xCompLoader = UnoRuntime.queryInterface(XComponentLoader.class, xMSF.createInstance("com.sun.star.frame.Desktop")); 298*cdf0e10cSrcweir XFramesSupplier xFrameSupp = UnoRuntime.queryInterface(XFramesSupplier.class, xCompLoader); 299*cdf0e10cSrcweir // close all existing frames 300*cdf0e10cSrcweir XFrames xFrames = xFrameSupp.getFrames(); 301*cdf0e10cSrcweir XIndexAccess xAcc = UnoRuntime.queryInterface(XIndexAccess.class, xFrames); 302*cdf0e10cSrcweir for (int i = 0; i < xAcc.getCount(); i++) 303*cdf0e10cSrcweir { 304*cdf0e10cSrcweir XCloseable xClose = UnoRuntime.queryInterface(XCloseable.class, xAcc.getByIndex(i)); 305*cdf0e10cSrcweir try 306*cdf0e10cSrcweir { 307*cdf0e10cSrcweir if (xClose != null) 308*cdf0e10cSrcweir { 309*cdf0e10cSrcweir xClose.close(false); 310*cdf0e10cSrcweir } 311*cdf0e10cSrcweir else 312*cdf0e10cSrcweir { 313*cdf0e10cSrcweir fail("Could not query frame for XCloseable!"); 314*cdf0e10cSrcweir } 315*cdf0e10cSrcweir } 316*cdf0e10cSrcweir catch (com.sun.star.uno.Exception e) 317*cdf0e10cSrcweir { 318*cdf0e10cSrcweir e.printStackTrace(); 319*cdf0e10cSrcweir fail("Could not query frame for XCloseable!"); 320*cdf0e10cSrcweir } 321*cdf0e10cSrcweir } 322*cdf0e10cSrcweir docHandle = new DocumentHandle(xCompLoader); 323*cdf0e10cSrcweir docHandle.loadDocument(docLoader, false); 324*cdf0e10cSrcweir } 325*cdf0e10cSrcweir catch (com.sun.star.uno.Exception e) 326*cdf0e10cSrcweir { 327*cdf0e10cSrcweir e.printStackTrace(); 328*cdf0e10cSrcweir } 329*cdf0e10cSrcweir catch (java.lang.Exception e) 330*cdf0e10cSrcweir { 331*cdf0e10cSrcweir e.printStackTrace(); 332*cdf0e10cSrcweir } 333*cdf0e10cSrcweir return docHandle; 334*cdf0e10cSrcweir } 335*cdf0e10cSrcweir 336*cdf0e10cSrcweir private boolean connect() 337*cdf0e10cSrcweir { 338*cdf0e10cSrcweir try 339*cdf0e10cSrcweir { 340*cdf0e10cSrcweir connection.setUp(); 341*cdf0e10cSrcweir } 342*cdf0e10cSrcweir catch (java.lang.InterruptedException e) 343*cdf0e10cSrcweir { 344*cdf0e10cSrcweir fail("can't connect."); 345*cdf0e10cSrcweir } 346*cdf0e10cSrcweir catch (Exception e) 347*cdf0e10cSrcweir { 348*cdf0e10cSrcweir fail("can't connect."); 349*cdf0e10cSrcweir } 350*cdf0e10cSrcweir return true; 351*cdf0e10cSrcweir } 352*cdf0e10cSrcweir 353*cdf0e10cSrcweir private boolean disconnect() 354*cdf0e10cSrcweir { 355*cdf0e10cSrcweir try 356*cdf0e10cSrcweir { 357*cdf0e10cSrcweir connection.tearDown(); 358*cdf0e10cSrcweir } 359*cdf0e10cSrcweir catch (java.lang.InterruptedException e) 360*cdf0e10cSrcweir { 361*cdf0e10cSrcweir fail("can't disconnect."); 362*cdf0e10cSrcweir } 363*cdf0e10cSrcweir catch (Exception e) 364*cdf0e10cSrcweir { 365*cdf0e10cSrcweir fail("can't disconnect."); 366*cdf0e10cSrcweir } 367*cdf0e10cSrcweir return true; 368*cdf0e10cSrcweir } 369*cdf0e10cSrcweir 370*cdf0e10cSrcweir private static String getStringFromObject(Object oName) 371*cdf0e10cSrcweir { 372*cdf0e10cSrcweir if (oName instanceof String) 373*cdf0e10cSrcweir { 374*cdf0e10cSrcweir return (String) oName; 375*cdf0e10cSrcweir } 376*cdf0e10cSrcweir String value = null; 377*cdf0e10cSrcweir if (oName instanceof Any) 378*cdf0e10cSrcweir { 379*cdf0e10cSrcweir try 380*cdf0e10cSrcweir { 381*cdf0e10cSrcweir value = AnyConverter.toString(oName); 382*cdf0e10cSrcweir if (value == null) 383*cdf0e10cSrcweir { 384*cdf0e10cSrcweir System.out.println("Got a void css.uno.Any as loading string."); 385*cdf0e10cSrcweir } 386*cdf0e10cSrcweir } 387*cdf0e10cSrcweir catch (Exception e) 388*cdf0e10cSrcweir { 389*cdf0e10cSrcweir System.out.println("This document type cannot be opened directly."); 390*cdf0e10cSrcweir } 391*cdf0e10cSrcweir } 392*cdf0e10cSrcweir return value; 393*cdf0e10cSrcweir } 394*cdf0e10cSrcweir 395*cdf0e10cSrcweir /** 396*cdf0e10cSrcweir * Compare two rectangles. Return true, if both are equal, false 397*cdf0e10cSrcweir * otherwise. 398*cdf0e10cSrcweir * @param rect1 First Rectangle. 399*cdf0e10cSrcweir * @param rect2 Second Rectangle. 400*cdf0e10cSrcweir * @return True, if the rectangles are equal. 401*cdf0e10cSrcweir */ 402*cdf0e10cSrcweir private boolean compareRectangles(Rectangle rect1, Rectangle rect2) 403*cdf0e10cSrcweir { 404*cdf0e10cSrcweir boolean result = true; 405*cdf0e10cSrcweir result &= (rect1.X == rect2.X); 406*cdf0e10cSrcweir result &= (rect1.Y == rect2.Y); 407*cdf0e10cSrcweir result &= (rect1.Width == rect2.Width); 408*cdf0e10cSrcweir result &= (rect1.Height == rect2.Height); 409*cdf0e10cSrcweir return result; 410*cdf0e10cSrcweir } 411*cdf0e10cSrcweir 412*cdf0e10cSrcweir 413*cdf0e10cSrcweir 414*cdf0e10cSrcweir private XMultiServiceFactory getMSF() 415*cdf0e10cSrcweir { 416*cdf0e10cSrcweir final XMultiServiceFactory xMSF1 = UnoRuntime.queryInterface(XMultiServiceFactory.class, connection.getComponentContext().getServiceManager()); 417*cdf0e10cSrcweir return xMSF1; 418*cdf0e10cSrcweir } 419*cdf0e10cSrcweir 420*cdf0e10cSrcweir // setup and close connections 421*cdf0e10cSrcweir @BeforeClass public static void setUpConnection() throws Exception { 422*cdf0e10cSrcweir System.out.println("setUpConnection()"); 423*cdf0e10cSrcweir connection.setUp(); 424*cdf0e10cSrcweir } 425*cdf0e10cSrcweir 426*cdf0e10cSrcweir @AfterClass public static void tearDownConnection() 427*cdf0e10cSrcweir throws InterruptedException, com.sun.star.uno.Exception 428*cdf0e10cSrcweir { 429*cdf0e10cSrcweir System.out.println("tearDownConnection()"); 430*cdf0e10cSrcweir connection.tearDown(); 431*cdf0e10cSrcweir } 432*cdf0e10cSrcweir 433*cdf0e10cSrcweir private static final OfficeConnection connection = new OfficeConnection(); 434*cdf0e10cSrcweir 435*cdf0e10cSrcweir } 436