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: _XDatabaseRanges.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 lib
.MultiMethodTest
;
35 import com
.sun
.star
.sheet
.XDatabaseRanges
;
36 import com
.sun
.star
.table
.CellRangeAddress
;
39 * Testing <code>com.sun.star.sheet.XDatabaseRanges</code>
42 * <li><code> addNewByName()</code></li>
43 * <li><code> removeByName()</code></li>
45 * @see com.sun.star.sheet.XDatabaseRanges
47 public class _XDatabaseRanges
extends MultiMethodTest
{
49 public XDatabaseRanges oObj
= null;
50 CellRangeAddress CRA
= null;
54 * Test adds a new database range to the collection, checks that range with
55 * this name exist in collection and then tries to add range with the same
57 * Has <b> OK </b> status if the added range exists in collection and
58 * exception was thrown when trying to add range with name that is same as name
59 * of existent range. <p>
61 public void _addNewByName() {
62 boolean bResult
= true;
63 log
.println("Trying to add range with proper name.");
65 CRA
= new CellRangeAddress((short)0, 1, 2, 3, 4);
66 name
= "_XDatabaseRanges_addNewByRange";
68 oObj
.addNewByName(name
, CRA
);
70 bResult
&= oObj
.hasByName(name
);
72 if (bResult
) log
.println("Ok");
73 log
.println("Trying to add existing element.");
76 oObj
.addNewByName(name
, CRA
);
77 log
.println("Exception expected... Test failed.");
79 } catch(com
.sun
.star
.uno
.RuntimeException e
) {
80 log
.println("Exception occured while testing addNewByName() : " + e
);
84 tRes
.tested("addNewByName()", bResult
);
88 * Test removes the database range with name that exist exactly and then
89 * tries to remove the range with name that doesn't exist exactly. <p>
90 * Has <b> OK </b> status if first range was succesfully removed and
91 * exception was thrown when trying to remove non-existent database range.<p>
92 * The following method tests are to be completed successfully before :
94 * <li> <code> addNewByName() </code> : to have definitely existed database
98 public void _removeByName(){
99 boolean bResult
= true;
100 requiredMethod("addNewByName()");
102 log
.println("Remove inserted element.");
105 oObj
.removeByName(name
);
106 bResult
&= !oObj
.hasByName(name
);
107 } catch (com
.sun
.star
.uno
.RuntimeException e
) {
108 log
.println("Exception occured while testing removeByName() : " + e
);
112 log
.println("OK.\nTrying to remove unexistant element.");
115 oObj
.removeByName(name
);
116 log
.println("Exception expected... - FAILED");
118 } catch (com
.sun
.star
.uno
.RuntimeException e
) {
119 log
.println("Expected exception. - OK : " + e
);
121 tRes
.tested("removeByName()", bResult
);