1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: BreakIterator.java,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
33 import java
.io
.PrintWriter
;
35 import lib
.StatusException
;
37 import lib
.TestEnvironment
;
38 import lib
.TestParameters
;
39 import util
.SOfficeFactory
;
42 import com
.sun
.star
.lang
.Locale
;
43 import com
.sun
.star
.lang
.XComponent
;
44 import com
.sun
.star
.lang
.XMultiServiceFactory
;
45 import com
.sun
.star
.text
.XTextDocument
;
46 import com
.sun
.star
.text
.XTextRange
;
47 import com
.sun
.star
.uno
.UnoRuntime
;
48 import com
.sun
.star
.uno
.XInterface
;
51 * Test for object which is represented by service
52 * <code>com.sun.star.i18n.BreakIterator</code>. <p>
53 * Object implements the following interfaces :
55 * <li> <code>com::sun::star::i18n::XBreakIterator</code></li>
57 * This object test <b> is NOT </b> designed to be run in several
58 * threads concurently.
59 * @see ifc.i18n._XBreakIterator
61 public class BreakIterator
extends TestCase
{
66 * Loads a Text document with name 'Iterator.sxw' from test
69 protected void initialize( TestParameters tParam
, PrintWriter log
) {
71 SOfficeFactory SOF
= SOfficeFactory
.getFactory( (XMultiServiceFactory
)tParam
.getMSF() );
74 log
.println( "creating a drawdoc" );
75 xTextDoc
= SOF
.loadDocument(utils
.getFullTestURL("Iterator.sxw"));
76 } catch ( com
.sun
.star
.uno
.Exception e
) {
77 // Some exception occures.FAILED
78 e
.printStackTrace( log
);
79 throw new StatusException( "Couldn't load document", e
);
84 * Creating a Testenvironment for the interfaces to be tested.
85 * Creates an instance of the service
86 * <code>com.sun.star.i18n.BreakIterator</code>.
88 public TestEnvironment
createTestEnvironment( TestParameters Param
,
90 throws StatusException
{
91 XInterface oObj
= null;
92 Object oInterface
= null;
95 XMultiServiceFactory xMSF
= (XMultiServiceFactory
)Param
.getMSF();
96 oInterface
= xMSF
.createInstance( "com.sun.star.i18n.BreakIterator" );
98 catch( com
.sun
.star
.uno
.Exception e
) {
99 log
.println("Can't create an object." );
100 throw new StatusException( "Can't create an object", e
);
103 oObj
= (XInterface
) oInterface
;
105 TestEnvironment tEnv
= new TestEnvironment( oObj
);
107 tEnv
.addObjRelation("Locale", new Locale("en", "US", ""));
109 XTextDocument xDoc
= (XTextDocument
)UnoRuntime
.queryInterface
110 (XTextDocument
.class, xTextDoc
);
111 XTextRange xTextRange
= (XTextRange
)xDoc
.getText();
112 tEnv
.addObjRelation("UnicodeString", xTextRange
.getString());
115 } // finish method getTestEnvironment
118 * Disposes the Text document loaded before.
120 protected void cleanup( TestParameters tParam
, PrintWriter log
) {
121 log
.println( " disposing xTextDoc " );
125 } // finish class BreakIterator