/* * Created on Jan 7, 2005 * * @author Mohan Radhakrishnan */ //package com.blueprint.ui.util; import java.lang.ref.ReferenceQueue; import java.lang.ref.SoftReference; import java.util.AbstractMap; import java.util.HashMap; import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; /* * Undo/redo for each shape. This can be used to maintain * a list of changes to rollback. Since the calls to the * model tier are direct and the reverse calls to update the * UI are Commands, this list is for the latter. */ public class ShapeCommandMap extends AbstractMap { private final Map> internalMap = new HashMap>(); private final ReferenceQueue queue = new ReferenceQueue(); public V put( K key, V value ){ //remove stale entries SoftReference ref = new SoftReference( value, queue ); SoftReference s = internalMap.put( key, ref ); return ( s != null ? s.get() : null ); } /*public V get( K key ){ //remove stale entries SoftReference value = internalMap.get( key ); return ( value != null ? value.get() : null ); }*/ public Set> entrySet(){ Set> commands = new LinkedHashSet>(); for( final Entry> entry : internalMap.entrySet() ){ final V value = entry.getValue().get(); commands.add( new Entry(){ public K getKey(){ return entry.getKey(); } public V getValue(){ return value; } public V setValue( V v ){ entry.setValue( new SoftReference( v, queue ) ); return value; } }); } return commands; } } aspect TriggerBug { public void foo() { ShapeCommandMap map = new ShapeCommandMap(); map.put("hi","there"); } before() : execution(* getValue(..)) { System.out.println("a matching call"); } } ption value='add-caldav-repair-middleware'>add-caldav-repair-middleware Nextcloud server, a safe home for all your data: https://github.com/nextcloud/serverwww-data
summaryrefslogtreecommitdiffstats
blob: 426bfc5d6d5a0a11c5d53cb1b0b62329b9a5320d (plain)
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
<?php
/**
 * @copyright Copyright (c) 2016, ownCloud, Inc.
 *
 * @author Morris Jobke <hey@morrisjobke.de>
 * @author Thomas Müller <thomas.mueller@tmit.eu>
 *
 * @license AGPL-3.0
 *
 * This code is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License, version 3,
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License, version 3,
 * along with this program. If not, see <http://www.gnu.org/licenses/>
 *
 */

namespace OCA\Federation\Tests\DAV;

use OCA\Federation\DAV\FedAuth;
use OCA\Federation\DbHandler;
use Test\TestCase;

class FedAuthTest extends TestCase {

	/**
	 * @dataProvider providesUser
	 *
	 * @param array $expected
	 * @param string $user
	 * @param string $password
	 */
	public function testFedAuth($expected, $user, $password) {
		/** @var DbHandler | \PHPUnit\Framework\MockObject\MockObject $db */
		$db = $this->getMockBuilder('OCA\Federation\DbHandler')->disableOriginalConstructor()->getMock();
		$db->method('auth')->willReturn(true);
		$auth = new FedAuth($db);
		$result = $this->invokePrivate($auth, 'validateUserPass', [$user, $password]);
		$this->assertEquals($expected, $result);
	}

	public function providesUser() {
		return [
			[true, 'system', '123456']
		];
	}
}