Branch libreoffice-5-0-4
[LibreOffice.git] / qadevOOo / tests / java / mod / _i18n / BreakIterator.java
blob2b182b89c8d1a33154d5a694fa9994b11d3c503d
1 /*
2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 package mod._i18n;
21 import java.io.PrintWriter;
23 import lib.StatusException;
24 import lib.TestCase;
25 import lib.TestEnvironment;
26 import lib.TestParameters;
27 import util.SOfficeFactory;
28 import util.utils;
30 import com.sun.star.lang.Locale;
31 import com.sun.star.lang.XComponent;
32 import com.sun.star.lang.XMultiServiceFactory;
33 import com.sun.star.text.XTextDocument;
34 import com.sun.star.text.XTextRange;
35 import com.sun.star.uno.UnoRuntime;
36 import com.sun.star.uno.XInterface;
38 /**
39 * Test for object which is represented by service
40 * <code>com.sun.star.i18n.BreakIterator</code>. <p>
41 * Object implements the following interfaces :
42 * <ul>
43 * <li> <code>com::sun::star::i18n::XBreakIterator</code></li>
44 * </ul>
45 * This object test <b> is NOT </b> designed to be run in several
46 * threads concurently.
47 * @see ifc.i18n._XBreakIterator
49 public class BreakIterator extends TestCase {
51 XComponent xTextDoc;
53 /**
54 * Loads a Text document with name 'Iterator.sxw' from test
55 * documents directory
57 @Override
58 protected void initialize( TestParameters tParam, PrintWriter log ) {
60 SOfficeFactory SOF = SOfficeFactory.getFactory( tParam.getMSF() );
62 try {
63 log.println( "creating a drawdoc" );
64 xTextDoc = SOF.loadDocument(utils.getFullTestURL("Iterator.sxw"));
65 } catch ( com.sun.star.uno.Exception e ) {
66 // Some exception occurs.FAILED
67 e.printStackTrace( log );
68 throw new StatusException( "Couldn't load document", e );
72 /**
73 * Creating a Testenvironment for the interfaces to be tested.
74 * Creates an instance of the service
75 * <code>com.sun.star.i18n.BreakIterator</code>.
77 @Override
78 public TestEnvironment createTestEnvironment( TestParameters Param,
79 PrintWriter log )
80 throws StatusException {
81 XInterface oObj = null;
82 Object oInterface = null;
84 try {
85 XMultiServiceFactory xMSF = Param.getMSF();
86 oInterface = xMSF.createInstance( "com.sun.star.i18n.BreakIterator" );
88 catch( com.sun.star.uno.Exception e ) {
89 log.println("Can't create an object." );
90 throw new StatusException( "Can't create an object", e );
93 oObj = (XInterface) oInterface;
95 TestEnvironment tEnv = new TestEnvironment( oObj );
97 tEnv.addObjRelation("Locale", new Locale("en", "US", ""));
99 XTextDocument xDoc = UnoRuntime.queryInterface
100 (XTextDocument.class, xTextDoc);
101 XTextRange xTextRange = xDoc.getText();
102 tEnv.addObjRelation("UnicodeString", xTextRange.getString());
104 return tEnv;
105 } // finish method getTestEnvironment
108 * Disposes the Text document loaded before.
110 @Override
111 protected void cleanup( TestParameters tParam, PrintWriter log ) {
112 log.println( " disposing xTextDoc " );
113 xTextDoc.dispose();
116 } // finish class BreakIterator