2 * This file is part of the LibreOffice project.
4 * This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 * This file incorporates work covered by the following license notice:
10 * Licensed to the Apache Software Foundation (ASF) under one or more
11 * contributor license agreements. See the NOTICE file distributed
12 * with this work for additional information regarding copyright
13 * ownership. The ASF licenses this file to you under the Apache
14 * License, Version 2.0 (the "License"); you may not use this file
15 * except in compliance with the License. You may obtain a copy of
16 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 import lib
.MultiMethodTest
;
23 import com
.sun
.star
.sheet
.XDatabaseRanges
;
24 import com
.sun
.star
.table
.CellRangeAddress
;
27 * Testing <code>com.sun.star.sheet.XDatabaseRanges</code>
30 * <li><code> addNewByName()</code></li>
31 * <li><code> removeByName()</code></li>
33 * @see com.sun.star.sheet.XDatabaseRanges
35 public class _XDatabaseRanges
extends MultiMethodTest
{
37 public XDatabaseRanges oObj
= null;
38 CellRangeAddress CRA
= null;
42 * Test adds a new database range to the collection, checks that range with
43 * this name exist in collection and then tries to add range with the same
45 * Has <b> OK </b> status if the added range exists in collection and
46 * exception was thrown when trying to add range with name that is same as name
47 * of existent range. <p>
49 public void _addNewByName() {
50 boolean bResult
= true;
51 log
.println("Trying to add range with proper name.");
53 CRA
= new CellRangeAddress((short)0, 1, 2, 3, 4);
54 name
= "_XDatabaseRanges_addNewByRange";
56 oObj
.addNewByName(name
, CRA
);
58 bResult
&= oObj
.hasByName(name
);
60 if (bResult
) log
.println("Ok");
61 log
.println("Trying to add existing element.");
64 oObj
.addNewByName(name
, CRA
);
65 log
.println("Exception expected... Test failed.");
67 } catch(com
.sun
.star
.uno
.RuntimeException e
) {
68 log
.println("Exception occurred while testing addNewByName() : " + e
);
72 tRes
.tested("addNewByName()", bResult
);
76 * Test removes the database range with name that exist exactly and then
77 * tries to remove the range with name that doesn't exist exactly. <p>
78 * Has <b> OK </b> status if first range was successfully removed and
79 * exception was thrown when trying to remove non-existent database range.<p>
80 * The following method tests are to be completed successfully before :
82 * <li> <code> addNewByName() </code> : to have definitely existed database
86 public void _removeByName(){
87 boolean bResult
= true;
88 requiredMethod("addNewByName()");
90 log
.println("Remove inserted element.");
93 oObj
.removeByName(name
);
94 bResult
&= !oObj
.hasByName(name
);
95 } catch (com
.sun
.star
.uno
.RuntimeException e
) {
96 log
.println("Exception occurred while testing removeByName() : " + e
);
100 log
.println("OK.\nTrying to remove unexistant element.");
103 oObj
.removeByName(name
);
104 log
.println("Exception expected... - FAILED");
106 } catch (com
.sun
.star
.uno
.RuntimeException e
) {
107 log
.println("Expected exception. - OK : " + e
);
109 tRes
.tested("removeByName()", bResult
);