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: DicList.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
;
40 import com
.sun
.star
.lang
.Locale
;
41 import com
.sun
.star
.lang
.XMultiServiceFactory
;
42 import com
.sun
.star
.linguistic2
.XDictionary
;
43 import com
.sun
.star
.linguistic2
.XDictionaryList
;
44 import com
.sun
.star
.uno
.UnoRuntime
;
45 import com
.sun
.star
.uno
.XInterface
;
48 * Test for object which is represented by service
49 * <code>com.sun.star.lingu2.DicList</code>. <p>
50 * Object implements the following interfaces :
52 * <li> <code>com::sun::star::linguistic2::XSearchableDictionaryList</code></li>
53 * <li> <code>com::sun::star::lang::XComponent</code></li>
54 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
55 * <li> <code>com::sun::star::linguistic2::XDictionaryList</code></li>
58 * This object test <b> is NOT </b> designed to be run in several
59 * threads concurently.
61 * @see com.sun.star.linguistic2.XSearchableDictionaryList
62 * @see com.sun.star.lang.XComponent
63 * @see com.sun.star.lang.XServiceInfo
64 * @see com.sun.star.linguistic2.XDictionaryList
65 * @see ifc.linguistic2._XSearchableDictionaryList
66 * @see ifc.lang._XComponent
67 * @see ifc.lang._XServiceInfo
68 * @see ifc.linguistic2._XDictionaryList
70 public class DicList
extends TestCase
{
73 * Creating a Testenvironment for the interfaces to be tested.
74 * Creates an instance of the service
75 * <code>com.sun.star.lingu2.DicList</code>. Then two dictionaries
76 * are created (positive and negative) and added to the list, one
77 * entry is added to each of dictionaries and they both are activated.
78 * The distionary list is retruned as a component for testing.
80 public synchronized TestEnvironment
createTestEnvironment( TestParameters Param
, PrintWriter log
)
81 throws StatusException
{
83 XMultiServiceFactory xMSF
= (XMultiServiceFactory
)Param
.getMSF();
84 XInterface oObj
= null;
87 oObj
= (XInterface
)xMSF
.createInstance("com.sun.star.lingu2.DicList");
88 } catch (com
.sun
.star
.uno
.Exception e
) {
89 e
.printStackTrace(log
);
90 throw new StatusException("Unexpected exception", e
);
93 String Iname
= util
.utils
.getImplName(oObj
);
94 log
.println("Implementation Name: "+Iname
);
95 TestEnvironment tEnv
= new TestEnvironment(oObj
);
97 //creating a user defined dictionary for XSearchableDictionaryList
98 XDictionaryList xDicList
= (XDictionaryList
) UnoRuntime
.queryInterface(
99 XDictionaryList
.class, oObj
);
100 xDicList
.removeDictionary(xDicList
.getDictionaryByName("MyDictionary"));
101 XDictionary xDic
= xDicList
.createDictionary("NegativDic",new Locale(
102 "en","US","WIN"),com
.sun
.star
.linguistic2
.DictionaryType
.NEGATIVE
,"");
103 XDictionary xDic2
= xDicList
.createDictionary("PositivDic",new Locale(
104 "en","US","WIN"),com
.sun
.star
.linguistic2
.DictionaryType
.POSITIVE
,"");
105 xDic2
.add("Positiv",false,"");
106 xDic
.add("Negativ",true,"");
107 xDicList
.addDictionary(xDic
);
108 xDicList
.addDictionary(xDic2
);
109 xDic
.setActive(true);
110 xDic2
.setActive(true);
115 } // finish class DicList