* This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ namespace Test; use OCP\Http\Client\IClientService; class HTTPHelperTest extends \Test\TestCase { /** @var \OCP\IConfig*/ private $config; /** @var \OC\HTTPHelper */ private $httpHelperMock; /** @var \OCP\Http\Client\IClientService */ private $clientService; protected function setUp() { parent::setUp(); $this->config = $this->getMockBuilder('\OCP\IConfig') ->disableOriginalConstructor()->getMock(); $this->clientService = $this->createMock(IClientService::class); $this->httpHelperMock = $this->getMockBuilder('\OC\HTTPHelper') ->setConstructorArgs(array($this->config, $this->clientService)) ->setMethods(array('getHeaders')) ->getMock(); } public function isHttpTestData() { return array( array('http://wwww.owncloud.org/enterprise/', true), array('https://wwww.owncloud.org/enterprise/', true), array('HTTPS://WWW.OWNCLOUD.ORG', true), array('HTTP://WWW.OWNCLOUD.ORG', true), array('FILE://WWW.OWNCLOUD.ORG', false), array('file://www.owncloud.org', false), array('FTP://WWW.OWNCLOUD.ORG', false), array('ftp://www.owncloud.org', false), ); } /** * @dataProvider isHttpTestData */ public function testIsHTTP($url, $expected) { $this->assertSame($expected, $this->httpHelperMock->isHTTPURL($url)); } public function testPostSuccess() { $client = $this->getMockBuilder('\OCP\Http\Client\IClient') ->disableOriginalConstructor()->getMock(); $this->clientService ->expects($this->once()) ->method('newClient') ->will($this->returnValue($client)); $response = $this->getMockBuilder('\OCP\Http\Client\IResponse') ->disableOriginalConstructor()->getMock(); $client ->expects($this->once()) ->method('post') ->with( 'https://owncloud.org', [ 'body' => [ 'Foo' => 'Bar', ], 'connect_timeout' => 10, ] ) ->will($this->returnValue($response)); $response ->expects($this->once()) ->method('getBody') ->will($this->returnValue('Body of the requested page')); $response = $this->httpHelperMock->post('https://owncloud.org', ['Foo' => 'Bar']); $expected = [ 'success' => true, 'result' => 'Body of the requested page' ]; $this->assertSame($expected, $response); } public function testPostException() { $client = $this->getMockBuilder('\OCP\Http\Client\IClient') ->disableOriginalConstructor()->getMock(); $this->clientService ->expects($this->once()) ->method('newClient') ->will($this->returnValue($client)); $client ->expects($this->once()) ->method('post') ->with( 'https://owncloud.org', [ 'body' => [ 'Foo' => 'Bar', ], 'connect_timeout' => 10, ] ) ->will($this->throwException(new \Exception('Something failed'))); $response = $this->httpHelperMock->post('https://owncloud.org', ['Foo' => 'Bar']); $expected = [ 'success' => false, 'result' => 'Something failed' ]; $this->assertSame($expected, $response); } } 01412180710-r'>dependabot/maven/org.eclipse.jgit-org.eclipse.jgit-3.5.3.201412180710-r Vaadin 6, 7, 8 is a Java framework for modern Java web applications: https://github.com/vaadin/frameworkwww-data
aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin/server/NoOutputStreamException.java
blob: 4a9e0b0ceb933ffc11e3657cfcb8a1380bdf6fed (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * Copyright 2000-2016 Vaadin Ltd.
 *
 * 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.vaadin.server;

@SuppressWarnings("serial")
public class NoOutputStreamException extends Exception {

}