Package helper

Examples of helper.OfficeProvider$OfficeWatcherPing


        log.println(utils.getDateTime() + ": start testing module '" + module + "'");

        log.println(utils.getDateTime() + "start new Office instance...");

        // TODO: is Office started with this program?
        final OfficeProvider officeProvider = new OfficeProvider();

        log.println(utils.getDateTime() + "Receiving the ServiceManager of the Office ");
        final XMultiServiceFactory msf = (XMultiServiceFactory) officeProvider.getManager(param);
        assure("couldnot get ServiceFarcotry", msf != null, mContinue);
        param.put("ServiceFactory", msf);

        final String sep = System.getProperty("file.separator");
        final String sUnoapi = getModulePath(module);
        final File fUnoapi = new File(sUnoapi);
        final String sMakeFile = sUnoapi + sep + "makefile.mk";
        final File fMakeFile = new File(sMakeFile);
        assure("ERROR: could not find makefile: '" + sMakeFile + "'", fMakeFile.exists(), mContinue);

        final String[] commands = getDmakeCommands(sUnoapi);

        final ProcessHandler procHdl = bet.runCommandsInEnvironmentShell(commands, fUnoapi, 0);
        log.println("exit code of dmake: " + procHdl.getExitCode());
        String test = procHdl.getOutputText();
        test += procHdl.getErrorText();
//        if (mDebug) {
//            log.println("---> Output of dmake:");
//            log.println(procHdl.getOutputText());
//            log.println("<--- Output of dmake:");
//            log.println("---> Error output of dmake:");
//            log.println(procHdl.getErrorText());
//            log.println("<--- Error output of dmake:");
//        }
        assure("module '" + module + "' failed", verifyOutput(test), mContinue);
        log.println(utils.getDateTime() + " module '" + module + "': kill existing office...");

        // TODO: how to check if the office is not started with this process.
        boolean bNoOffice = param.getBool("NoOffice");
        if (!bNoOffice)
        {
            try
            {
                officeProvider.closeExistingOffice(param, true);
            }
            catch (java.lang.UnsatisfiedLinkError exception)
            {
                log.println("Office seems not to be running");
            }
View Full Code Here


        try {

        log.println("Connect the first time.");
  log.println("AppExecCommand: " + (String)param.get("AppExecutionCommand"));
  log.println("ConnString: " + (String)param.get("ConnectionString"));
        oProvider = new OfficeProvider();
        iOfficeCloseTime = param.getInt("OfficeCloseTime");
        if ( iOfficeCloseTime == 0 ) {
            iOfficeCloseTime = 1000;
        }
View Full Code Here

        try {

      log.println("Connect the first time.");
      log.println("AppExecCommand: " + (String)param.get("AppExecutionCommand"));
      log.println("ConnString: " + (String)param.get("ConnectionString"));
      oProvider = new OfficeProvider();
      iOfficeCloseTime = param.getInt("OfficeCloseTime");
      if ( iOfficeCloseTime == 0 ) {
        iOfficeCloseTime = 1000;
      }
 
View Full Code Here

            param.put("TimeOut", new Integer(300000));
            System.out.println("TimeOut: " + param.getInt("TimeOut"));
            System.out.println("ThreadTimeOut: " + param.getInt("ThreadTimeOut"));

            // OfficeProvider aProvider = null;
            m_aProvider = new OfficeProvider();
            m_xXMultiServiceFactory = (XMultiServiceFactory) m_aProvider.getManager(param);
            param.put("ServiceFactory", m_xXMultiServiceFactory);
        }
View Full Code Here

            // we don't need to start a new office.
            GraphicalTestArguments aGTA_local = getGraphicalTestArguments();
            // if (GraphicalDifferenceCheck.isReferenceExists(_sInputFile, _sReferencePath, aGTA_local) == false)
            // {
            // start a fresh Office
            OfficeProvider aProvider = null;
            if (aGTA_local.restartOffice())
            {
                aProvider = new OfficeProvider();
                XMultiServiceFactory xMSF = (XMultiServiceFactory) aProvider.getManager(param);
                param.put("ServiceFactory", xMSF);
            }
            GraphicalTestArguments aGTA = getGraphicalTestArguments();
           
            if (aGTA.getOfficeProgram().toLowerCase().equals("msoffice"))
            {
                // ReferenceType is MSOffice
                GlobalLogWriter.get().println("USE MSOFFICE AS EXPORT FORMAT.");
                MSOfficePrint a = new MSOfficePrint();
                try
                {
                    String sInputFileBasename = FileHelper.getBasename(_sInputFile);
                    String fs = System.getProperty("file.separator");
                    FileHelper.makeDirectories("", _sReferencePath);
                    String sOutputFile = _sReferencePath;
                    if (sOutputFile.endsWith(fs))
                    {
                        sOutputFile += sInputFileBasename;
                    }
                    else
                    {
                        sOutputFile += fs + sInputFileBasename;
                    }
                   
                    a.storeToFileWithMSOffice(aGTA, _sInputFile, sOutputFile);
                }
                catch(ConvWatchCancelException e)
                {
                    GlobalLogWriter.get().println(e.getMessage());
                }
                catch(java.io.IOException e)
                {
                    GlobalLogWriter.get().println(e.getMessage());
                }
            }
            else
            {
                try
                {
                    OfficePrint.convertDocument(_sInputFile, _sReferencePath, aGTA);
                }
                catch(ConvWatchCancelException e)
                {
                    assure(e.getMessage(), false);
                }
                catch(ConvWatchException e)
                {
                    assure(e.getMessage(), false);
                }
            }
           
            if (aGTA.restartOffice())
            {
                // Office shutdown
                aProvider.closeExistingOffice(param, true);
            }
            // }
        }
View Full Code Here

            // we don't need to start a new office.
            GraphicalTestArguments aGTA = getGraphicalTestArguments();
            if (GraphicalDifferenceCheck.isReferenceExists(_sInputPath, _sReferencePath, aGTA) == false)
            {
            // start a fresh Office
                OfficeProvider aProvider = null;
                // SimpleFileSemaphore aSemaphore = new SimpleFileSemaphore();
                if (aGTA.shouldOfficeStart())
                {
                    // if (OSHelper.isWindows())
                    // {
                    //     aSemaphore.P(aSemaphore.getSemaphoreFile());
                    // }
                    aGTA.getPerformance().startTime(PerformanceContainer.OfficeStart);
                    aProvider = new OfficeProvider();
                    XMultiServiceFactory xMSF = (XMultiServiceFactory) aProvider.getManager(param);
                    param.put("ServiceFactory", xMSF);
                    aGTA.getPerformance().stopTime(PerformanceContainer.OfficeStart);

                    long nStartTime = aGTA.getPerformance().getTime(PerformanceContainer.OfficeStart);
                    aGTA = getGraphicalTestArguments();
                    aGTA.getPerformance().setTime(PerformanceContainer.OfficeStart, nStartTime);
                }
               
                // Watcher Object is need in log object to give a simple way to say if a running office is alive.
                // As long as a log comes, it pings the Watcher and says the office is alive, if not an
                // internal counter increase and at a given point (300 seconds) the office is killed.
                GlobalLogWriter.get().println("Set office watcher");
                Object aWatcher = param.get("Watcher");
                GlobalLogWriter.get().setWatcher(aWatcher);
                // initializeWatcher(param);

                try
                {
                    log.println("Reference type is " + aGTA.getReferenceType());
                    DB.source_start();
                    GraphicalDifferenceCheck.createOneReferenceFile(_sInputPath, _sReferencePath, aGTA);
                    DB.source_finished();
                }
                catch(ConvWatchCancelException e)
                {
                    assure(e.getMessage(), false);
                    DB.source_failed(e.getMessage());
                }
                catch(ConvWatchException e)
                {
                    assure(e.getMessage(), false);
                    DB.source_failed(e.getMessage());
                }
                catch(com.sun.star.lang.DisposedException e)
                {
                    assure(e.getMessage(), false, true);
                    DB.source_failed(e.getMessage());
                }
               
                // Office shutdown
                if (aProvider != null)
                {
                    boolean bClosed = aProvider.closeExistingOffice(param, true);
                    // Hope I can check that the close of the office fails
                    assure("Office closed", bClosed, true);
                    // if (OSHelper.isWindows())
                    // {
                    //     aSemaphore.V(aSemaphore.getSemaphoreFile());
View Full Code Here

     */
    public boolean executeTest(TestParameters param)
    {
        DescGetter dg = new APIDescGetter();
        String job = (String) param.get("TestJob");
        OfficeProvider office = null;
        debug = param.getBool("DebugIsActive");


        //get Job-Descriptions
        System.out.print("Getting Descriptions for Job: " + job + " from ");

        DescEntry[] entries = dg.getDescriptionFor(job,
                (String) param.get(
                "DescriptionPath"),
                debug);

        if (entries == null)
        {
            System.out.println("Couldn't get Description for Job");

            return false;
        }

        String ExclusionFile = (String) param.get("ExclusionList");
        Vector exclusions = null;

        if (ExclusionFile != null)
        {
            exclusions = getExclusionList(ExclusionFile, debug);
        }

        String conStr = (String) param.get("ConnectionString");
        System.out.println("");
        System.out.print("> Connecting the Office ");
        System.out.println("With " + conStr);

        for (int l = 0; l < entries.length; l++)
        {
            if (entries[l].hasErrorMsg)
            {
                System.out.println(entries[l].ErrorMsg);

                continue;
            }

            office = new OfficeProvider();

            XMultiServiceFactory msf = (XMultiServiceFactory) office.getManager(
                    param);

            if (msf == null)
            {
                return false;
            }

            param.put("ServiceFactory", msf);

            DescEntry entry = entries[l];

            //get some helper classes
            Summarizer sumIt = new Summarizer();
            DynamicClassLoader dcl = new DynamicClassLoader();

            TestCase tCase = null;

            tCase = (TestCase) new BasicTestCase(entry);

            if (tCase == null)
            {
                sumIt.summarizeDown(entry, entry.ErrorMsg);

                LogWriter sumObj = OutProducerFactory.createOutProducer(param);
                sumObj.initialize(entry, true);
                sumObj.summary(entry);

                continue;
            }

            System.out.println("Creating: " + tCase.getObjectName());

            LogWriter log = (LogWriter) dcl.getInstance(
                    (String) param.get("LogWriter"));
            log.initialize(entry, true);
            entry.UserDefinedParams = param;
            tCase.setLogWriter((PrintWriter) log);

            try
            {
                tCase.initializeTestCase(param);
            }
            catch (RuntimeException e)
            {
                helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
                        "AppProvider");

                if (ph != null)
                {
                    OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");

                    if ((ow != null) && ow.isAlive())
                    {
                        ow.finish = true;
                    }

                    ph.kill();
                    shortWait(5000);
                }

                continue;
            }

            TestEnvironment tEnv = tCase.getTestEnvironment(param);

            if (tEnv == null)
            {
                sumIt.summarizeDown(entry, "Unable to create testcase");

                LogWriter sumObj = OutProducerFactory.createOutProducer(param);
                sumObj.initialize(entry, true);
                sumObj.summary(entry);

                helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
                        "AppProvider");

                if (ph != null)
                {
                    OfficeWatcher ow = (OfficeWatcher) param.get("Watcher");

                    if ((ow != null) && ow.isAlive())
                    {
                        ow.finish = true;
                    }

                    ph.kill();
                    shortWait(5000);
                }

                continue;
            }

            System.out.println("created " + tCase.getObjectName());

            for (int j = 0; j < entry.SubEntryCount; j++)
            {
                if (!entry.SubEntries[j].isToTest)
                {
                    Summarizer.summarizeDown(entry.SubEntries[j],
                            "not part of the job");

                    continue;
                }

                if ((exclusions != null) &&
                        (exclusions.contains(entry.SubEntries[j].longName)))
                {
                    Summarizer.summarizeDown(entry.SubEntries[j],
                            "known issue");

                    continue;
                }

                System.out.println("running: " +
                        entry.SubEntries[j].entryName);

                LogWriter ifclog = (LogWriter) dcl.getInstance(
                        (String) param.get("LogWriter"));
                ifclog.initialize(entry.SubEntries[j], true);
                entry.SubEntries[j].UserDefinedParams = param;
                entry.SubEntries[j].Logger = ifclog;

                if ((tEnv == null) || tEnv.isDisposed())
                {
                    helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
                            "AppProvider");

                    if (ph != null)
                    {
                        office.closeExistingOffice(param, true);
                        shortWait(5000);
                    }

                    tEnv = getEnv(entry, param);
                }

                BasicIfcTest ifc = null;
                lib.TestResult res = null;
                ifc = new BasicIfcTest(entry.SubEntries[j].longName);
                res = ifc.run(entry.SubEntries[j], tEnv, param);

                sumIt.summarizeUp(entry.SubEntries[j]);

                LogWriter sumIfc = OutProducerFactory.createOutProducer(param);

                sumIfc.initialize(entry.SubEntries[j], true);
                sumIfc.summary(entry.SubEntries[j]);
            }

            try
            {
                tCase.cleanupTestCase(param);
            }
            catch (Exception e)
            {
                log.println("TestCase already gone");

                helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
                        "AppProvider");

                if (ph != null)
                {
                    office.closeExistingOffice(param, true);
                    shortWait(5000);
                }
            }

            sumIt.summarizeUp(entry);

            LogWriter sumObj = OutProducerFactory.createOutProducer(param);
            sumObj.initialize(entry, true);
            sumObj.summary(entry);
        }

        if (entries.length > 1)
        {
            System.out.println();

            int counter = 0;
            System.out.println(
                    "Failures that appeared during scenario execution:");

            for (int i = 0; i < entries.length; i++)
            {
                if (!entries[i].State.endsWith("OK"))
                {
                    System.out.println("\t " + entries[i].longName);
                    counter++;
                }
            }

            System.out.println(counter + " of " + entries.length +
                    " tests failed");
        }

        helper.ProcessHandler ph = (helper.ProcessHandler) param.get(
                "AppProvider");

        if (ph != null)
        {
            office.closeExistingOffice(param, true);
        }

        return true;
    }
View Full Code Here

TOP

Related Classes of helper.OfficeProvider$OfficeWatcherPing

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.