Update ooo320-m1
[ooovba.git] / qadevOOo / tests / java / mod / _dbaccess / OSQLMessageDialog.java
blob2cc4812653e1a629a068a556c94bcd35d1919575
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: OSQLMessageDialog.java,v $
10 * $Revision: 1.6 $
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 ************************************************************************/
31 package mod._dbaccess;
33 import java.io.PrintWriter;
35 import lib.Status;
36 import lib.StatusException;
37 import lib.TestCase;
38 import lib.TestEnvironment;
39 import lib.TestParameters;
41 import com.sun.star.lang.XMultiServiceFactory;
42 import com.sun.star.uno.UnoRuntime;
43 import com.sun.star.uno.XInterface;
45 /**
46 * Test for object which is represented by service
47 * <code>com.sun.star.sdb.ErrorMessageDialog</code>. <p>
48 * Object implements the following interfaces :
49 * <ul>
50 * <li> <code>com::sun::star::lang::XInitialization</code></li>
51 * <li> <code>com::sun::star::sdb::ErrorMessageDialog</code></li>
52 * <li> <code>com::sun::star::ui::dialogs::XExecutableDialog</code></li>
53 * <li> <code>com::sun::star::beans::XPropertySet</code></li>
54 * </ul> <p>
55 * This object test <b> is NOT </b> designed to be run in several
56 * threads concurently.
58 * @see com.sun.star.lang.XInitialization
59 * @see com.sun.star.sdb.ErrorMessageDialog
60 * @see com.sun.star.ui.dialogs.XExecutableDialog
61 * @see com.sun.star.beans.XPropertySet
62 * @see ifc.lang._XInitialization
63 * @see ifc.sdb._ErrorMessageDialog
64 * @see ifc.ui.dialogs._XExecutableDialog
65 * @see ifc.beans._XPropertySet
67 public class OSQLMessageDialog extends TestCase {
69 /**
70 * Creating a Testenvironment for the interfaces to be tested.
72 * Creates an instance of the service
73 * <code>com.sun.star.sdb.ErrorMessageDialog</code>.
74 * Object relations created :
75 * <ul>
76 * <li> <code>'ERR1', 'ERR2'</code> for
77 * {@link ifc.sdb._ErrorMessageDialog} </li>
78 * </ul>
80 public TestEnvironment createTestEnvironment( TestParameters Param,
81 PrintWriter log ) throws StatusException {
82 XInterface oObj = null;
83 Object oInterface = null;
85 Object err1 = null;
86 Object err2 = null;
88 try {
89 oInterface = ((XMultiServiceFactory)Param.getMSF()).createInstance(
90 "com.sun.star.sdb.ErrorMessageDialog" );
92 err1 = new com.sun.star.sdbc.SQLException("err1");
93 err2 = new com.sun.star.sdbc.SQLException("err2");
95 catch( com.sun.star.uno.Exception e ) {
96 log.println("Service not available" );
97 throw new StatusException("Service not available", e) ;
100 if (oInterface == null) {
101 log.println("Service wasn't created") ;
102 throw new StatusException(Status.failed("Service wasn't created")) ;
105 oObj = (XInterface) oInterface;
107 // create XWindow for Object relations...
108 com.sun.star.awt.XToolkit xToolkit = null;
110 try{
111 xToolkit = (com.sun.star.awt.XToolkit)UnoRuntime.queryInterface(
112 com.sun.star.awt.XToolkit.class,
113 ((XMultiServiceFactory)Param.getMSF()).createInstance("com.sun.star.awt.Toolkit") );
114 } catch (com.sun.star.uno.Exception e){
115 log.println("could not create instacne of 'com.sun.star.awt.Toolkit'" );
116 throw new StatusException("could not create instacne of 'com.sun.star.awt.Toolkit'", e) ;
119 // Describe the properties of the container window.
120 com.sun.star.awt.WindowDescriptor aDescriptor =
121 new com.sun.star.awt.WindowDescriptor();
123 aDescriptor.Type = com.sun.star.awt.WindowClass.TOP ;
124 aDescriptor.WindowServiceName = "window" ;
125 aDescriptor.ParentIndex = -1;
126 aDescriptor.Parent = null;
127 aDescriptor.Bounds = new com.sun.star.awt.Rectangle(0,0,0,0);
129 aDescriptor.WindowAttributes =
130 com.sun.star.awt.WindowAttribute.BORDER |
131 com.sun.star.awt.WindowAttribute.MOVEABLE |
132 com.sun.star.awt.WindowAttribute.SIZEABLE |
133 com.sun.star.awt.WindowAttribute.CLOSEABLE ;
135 com.sun.star.awt.XWindowPeer xPeer = null;
136 try{
138 xPeer = xToolkit.createWindow(aDescriptor) ;
140 } catch (com.sun.star.lang.IllegalArgumentException e){
141 log.println("could not create window" );
142 throw new StatusException("could not create window", e) ;
145 com.sun.star.awt.XWindow xWindow = (com.sun.star.awt.XWindow)UnoRuntime.queryInterface (
146 com.sun.star.awt.XWindow .class, xPeer);
148 log.println( " creating a new environment for object" );
149 TestEnvironment tEnv = new TestEnvironment( oObj );
151 log.println("add ObjectRelations err1 and err2 for 'ErrorMessageDialog'");
152 tEnv.addObjRelation("ERR1",err1);
153 tEnv.addObjRelation("ERR2",err2);
154 tEnv.addObjRelation("ERR_XWindow", xWindow);
156 return tEnv;
157 } // finish method getTestEnvironment
159 } // finish class OSQLMessageDialog