1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
/* Copyright (c) 2013 James Ahlborn Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package com.healthmarketscience.jackcess; import java.io.IOException; import java.util.Iterator; import java.util.List; import java.util.Map; import com.healthmarketscience.jackcess.util.ErrorHandler; /** * A single database table. A Table instance is retrieved from a {@link * Database} instance. The Table instance provides access to the table * metadata as well as the table data. There are basic data operations on the * Table interface (i.e. {@link #iterator} {@link #addRow}, {@link #updateRow} * and {@link #deleteRow}), but for advanced search and data manipulation a * {@link Cursor} instance should be used. New Tables can be created using a * {@link TableBuilder}. The {@link com.healthmarketscience.jackcess.util.Joiner} utility can be used to traverse * table relationships (e.g. find rows in another table based on a foreign-key * relationship). *
* A Table instance is not thread-safe (see {@link Database} for more * thread-safety details). * * @author James Ahlborn * @usage _general_class_ */ public interface Table extends Iterable* Note, if this table has an auto-number column, the value generated will be * put back into the given row array (assuming the given row array is at * least as long as the number of Columns in this Table). * * @param row row values for a single row. the given row array will be * modified if this table contains an auto-number column, * otherwise it will not be modified. * @return the given row values if long enough, otherwise a new array. the * returned array will contain any autonumbers generated * @usage _general_method_ */ public Object[] addRow(Object... row) throws IOException; /** * Calls {@link #asRow} on the given row map and passes the result to {@link * #addRow}. *
* Note, if this table has an auto-number column, the value generated will be * put back into the given row map. * @return the given row map, which will contain any autonumbers generated * @usage _general_method_ */ public* Note, if this table has an auto-number column, the values written will be * put back into the given row arrays (assuming the given row array is at * least as long as the number of Columns in this Table). *
* Most exceptions thrown from this method will be wrapped with a {@link * BatchUpdateException} which gives useful information in the case of a * partially successful write. * * @see #addRow(Object...) for more details on row arrays * * @param rows List of Object[] row values. the rows will be modified if * this table contains an auto-number column, otherwise they * will not be modified. * @return the given row values list (unless row values were to small), with * appropriately sized row values (the ones passed in if long * enough). the returned arrays will contain any autonumbers * generated * @usage _general_method_ */ public List extends Object[]> addRows(List extends Object[]> rows) throws IOException; /** * Calls {@link #asRow} on the given row maps and passes the results to * {@link #addRows}. *
* Note, if this table has an auto-number column, the values generated will * be put back into the appropriate row maps. *
* Most exceptions thrown from this method will be wrapped with a {@link
* BatchUpdateException} which gives useful information in the case of a
* partially successful write.
*
* @return the given row map list, where the row maps will contain any
* autonumbers generated
* @usage _general_method_
*/
public Nextcloud server, a safe home for all your data: https://github.com/nextcloud/server www-data
aboutsummaryrefslogtreecommitdiffstats
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\OCS;
use OC\OCS\DiscoveryService;
use OCP\Http\Client\IClientService;
use OCP\ICacheFactory;
use OCP\OCS\IDiscoveryService;
use Test\TestCase;
class DiscoveryServiceTest extends TestCase {
/** @var \PHPUnit\Framework\MockObject\MockObject | ICacheFactory */
private $cacheFactory;
/** @var \PHPUnit\Framework\MockObject\MockObject | IClientService */
private $clientService;
/** @var IDiscoveryService */
private $discoveryService;
protected function setUp(): void {
parent::setUp();
$this->cacheFactory = $this->getMockBuilder(ICacheFactory::class)->getMock();
$this->clientService = $this->getMockBuilder(IClientService::class)->getMock();
$this->discoveryService = new DiscoveryService(
$this->cacheFactory,
$this->clientService
);
}
/**
*
* @param string $url
* @param bool $expected
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataTestIsSafeUrl')]
public function testIsSafeUrl($url, $expected): void {
$result = $this->invokePrivate($this->discoveryService, 'isSafeUrl', [$url]);
$this->assertSame($expected, $result);
}
public static function dataTestIsSafeUrl(): array {
return [
['api/ocs/v1.php/foo', true],
['/api/ocs/v1.php/foo', true],
['api/ocs/v1.php/foo/', true],
['api/ocs/v1.php/foo-bar/', true],
['api/ocs/v1:php/foo', false],
['api/ocs/<v1.php/foo', false],
['api/ocs/v1.php>/foo', false],
];
}
/**
*
* @param array $decodedServices
* @param string $service
* @param array $expected
*/
#[\PHPUnit\Framework\Attributes\DataProvider('dataTestGetEndpoints')]
public function testGetEndpoints($decodedServices, $service, $expected): void {
$result = $this->invokePrivate($this->discoveryService, 'getEndpoints', [$decodedServices, $service]);
$this->assertSame($expected, $result);
}
public static function dataTestGetEndpoints(): array {
return [
[['services' => ['myService' => ['endpoints' => []]]], 'myService', []],
[['services' => ['myService' => ['endpoints' => ['foo' => '/bar']]]], 'myService', ['foo' => '/bar']],
[['services' => ['myService' => ['endpoints' => ['foo' => '/bar']]]], 'anotherService', []],
[['services' => ['myService' => ['endpoints' => ['foo' => '/bar</foo']]]], 'myService', []],
];
}
}