merge the formfield patch from ooo-build
[ooovba.git] / qadevOOo / tests / java / mod / _smplmail / SimpleSystemMail.java
blob188a8a98827676e6ec8169db34e61d4a4e05f237
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: SimpleSystemMail.java,v $
10 * $Revision: 1.5 $
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._smplmail;
33 import java.io.PrintWriter;
35 import lib.StatusException;
36 import lib.TestCase;
37 import lib.TestEnvironment;
38 import lib.TestParameters;
40 import com.sun.star.lang.XMultiServiceFactory;
41 import com.sun.star.uno.XInterface;
43 /**
44 * Test for object which is represented by service
45 * <code>com.sun.star.system.SimpleSystemMail</code>. <p>
47 * Object implements the following interfaces :
48 * <ul>
49 * <li> <code>com::sun::star::system::XSimpleMailClientSupplier</code></li>
50 * <li> <code>com::sun::star::lang::XServiceInfo</code></li>
51 * <li> <code>com::sun::star::lang::XTypeProvider</code></li>
52 * </ul> <p>
54 * This object test <b> is NOT </b> designed to be run in several
55 * threads concurently.
57 * @see com.sun.star.system.XSimpleMailClientSupplier
58 * @see com.sun.star.lang.XServiceInfo
59 * @see com.sun.star.lang.XTypeProvider
60 * @see ifc.system._XSimpleMailClientSupplier
61 * @see ifc.lang._XServiceInfo
62 * @see ifc.lang._XTypeProvider
64 public class SimpleSystemMail extends TestCase {
66 /**
67 * Creating a Testenvironment for the interfaces to be tested.
68 * In case if OS is Win or not specified tries to create an instance
69 * of the service <code>com.sun.star.system.SimpleSystemMail</code>. <p>
71 * Object relations created :
72 * <ul>
73 * <li> <code>'SystemMailExist'</code> for
74 * {@link ifc.system._XSimpleMailClientSupplier} :
75 * the value depends on tested platform and
76 * <code>test.system.mail.isExist</code> INI
77 * parameter.</li>
78 * </ul>
80 public TestEnvironment createTestEnvironment( TestParameters Param,
81 PrintWriter log )
82 throws StatusException {
83 XInterface oObj = null;
84 Object oInterface = null;
85 boolean isWinOS = false ;
86 boolean isSystemMailExist = false ;
88 // if 'OS' parameter is not defined then by default
89 // Win platform is used. If really not the error will occurs.
90 isWinOS = Param.get("OS") == null ||
91 "wntmsci".equals(Param.get("OS")) ;
92 isSystemMailExist = "true".equalsIgnoreCase
93 ((String) Param.get("test.system.mail.isExist")) ;
95 XMultiServiceFactory xMSF = (XMultiServiceFactory)Param.getMSF();
96 try {
97 if (isWinOS) {
98 log.println("The OS is Win : trying to create service");
99 oInterface = xMSF.createInstance
100 ( "com.sun.star.system.SimpleSystemMail" );
101 } else {
102 log.println("The OS is NOT Win, SKIPPING this component");
103 log.println("Creating Dummy object ...");
104 oInterface = xMSF.createInstance( "com.sun.star.io.Pipe" );
106 } catch( com.sun.star.uno.Exception e ) {
107 log.println("Can't create an object." );
108 throw new StatusException( "Can't create an object", e );
111 oObj = (XInterface) oInterface;
113 log.println("ImplementationName: "+util.utils.getImplName(oObj));
115 TestEnvironment tEnv = new TestEnvironment( oObj );
117 tEnv.addObjRelation("SystemMailExist", new Boolean(isSystemMailExist));
119 return tEnv;
121 } // finish method getTestEnvironment
123 } // finish class SimpleSystemMail