/* * Copyright 2014-2015 the original author or authors. * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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 General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ package de.schildbach.pte.util; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import org.junit.Before; import org.junit.Test; import okhttp3.HttpUrl; /** * @author Andreas Schildbach */ public class HttpClientTest { private HttpUrl base; @Before public void setUp() throws Exception { base = HttpUrl.parse("http://example.com"); } @Test public void vodafoneRedirect() throws Exception { final HttpUrl url = HttpClient.testRedirect(base, "Vodafone Center

Sie werden weitergeleitet ...

Sollten Sie nicht weitergeleitet werden, klicken Sie bitte window.location = \"http://www.hotspot.kabeldeutschland.de/portal/?RequestedURI=http%3A%2F%2Fwww.fahrinfo-berlin.de%2FFahrinfo%2Fbin%2Fajax-getstop.bin%2Fdny%3Fgetstop%3D1%26REQ0JourneyStopsS0A%3D255%26REQ0JourneyStopsS0G%3Dgneisenustra%25DFe%3F%26js%3Dtrue&RedirectReason=Policy&RedirectAqpId=100&DiscardAqpId=100&SubscriberId=4fa432d4a653e5f8b2acb27aa862f98d&SubscriberType=ESM&ClientIP=10.136.25.241&SystemId=10.143.181.2-1%2F2&GroupId=1&PartitionId=2&Application=Unknown&ApplicationGroup=Unknown\" "); assertNotNull(url); assertEquals("www.hotspot.kabeldeutschland.de", url.host()); } @Test public void tplinkRedirect() throws Exception { final HttpUrl url = HttpClient.testRedirect(base, ""); assertNotNull(url); assertEquals("tplinkextender.net", url.host()); } @Test public void mshtmlRedirect() throws Exception { final HttpUrl url = HttpClient.testRedirect(base, "HTML Redirection "); assertNotNull(url); assertEquals("example.com", url.host()); } @Test public void efaExpired() throws Exception { assertTrue(HttpClient.testExpired( "Efa9 Internal Error

Internal Error
Your session has expired.
")); } @Test public void tflExpired() throws Exception { assertTrue(HttpClient.testExpired( "Session Expired
 \"\"
 Session Expire")); } @Test public void nvbwExpired() throws Exception { assertTrue(HttpClient.testExpired("

Ihre Verbindungskennung ist nicht mehr gültig.

")); } @Test public void internalError() throws Exception { assertTrue(HttpClient.testInternalError( " Internal error in gateway

Internal error in gateway

")); } @Test public void vgnInternalError() throws Exception { assertTrue(HttpClient.testInternalError( "Efa9 Internal Error
Internal Error
.\\EfaHttpServer.cpp
Line: 2507
")); } @Test public void vrnInternalError() throws Exception { assertTrue(HttpClient.testInternalError( "VRN - Keine Verbindung zum Server möglich
 
")); } }