/*
* This software and supporting documentation were developed by
*
* Siemens Corporate Technology
* Competence Center Knowledge Management and Business Transformation
* D-81730 Munich, Germany
*
* Authors (representing a really great team ;-) )
* Stefan B. Augustin, Thorbj�rn Hansen, Manfred Langen
*
* This software is Open Source under GNU General Public License (GPL).
* Read the text of this license in LICENSE.TXT
* or look at www.opensource.org/licenses/
*
* Once more we emphasize, that:
* THIS SOFTWARE IS MADE AVAILABLE, AS IS, WITHOUT ANY WARRANTY
* REGARDING THE SOFTWARE, ITS PERFORMANCE OR
* FITNESS FOR ANY PARTICULAR USE, FREEDOM FROM ANY COMPUTER DISEASES OR
* ITS CONFORMITY TO ANY SPECIFICATION. THE ENTIRE RISK AS TO QUALITY AND
* PERFORMANCE OF THE SOFTWARE IS WITH THE USER.
*
*/
package KFM.test;
import junit.framework.*;
import KFM.URLSyntaxChecker;
public class URLSyntaxCheckerTest extends TestCase
{
protected URLSyntaxChecker mURLSyntaxChecker;
public URLSyntaxCheckerTest(String s)
{
super(s);
}
protected void setUp()
{
mURLSyntaxChecker = new URLSyntaxChecker();
}
protected void tearDown()
{
}
public void testHttpAllowSlashesInQuery()
{
String tURL = "http://www.google.de/index.html?href=/pfad/datei.html";
assertTrue("Expected " + tURL + " to be a valid http url altough it contains slashed in querystring. " +
"Slashes in the querystring should be escaped according to RFC.",
mURLSyntaxChecker.isValidHttpURL(tURL));
}
public void testHttpNormalURL()
{
String tURL = "http://www.google.de/";
assertTrue("Expected " + tURL + " to be a valid http url, but is not.",
mURLSyntaxChecker.isValidHttpURL(tURL));
}
public void testHttpNoPath()
{
String tURL = "http://www.google.de";
assertTrue("Expected " + tURL + " to be a valid http url although it does not contain a path element.",
mURLSyntaxChecker.isValidHttpURL(tURL));
}
public void testHttpNoPathButQueryString()
{
String tURL = "http://www.google.de?querystring";
assertTrue("Expected " + tURL + " to be a valid http url although it only contains a querystring but no path",
mURLSyntaxChecker.isValidHttpURL(tURL));
}
public void testHttpVeryLongURL()
{
StringBuffer tSB = new StringBuffer("http://google.de/index.html?");
while(tSB.length() < 2000) { tSB.append("test=test&"); }
tSB.append("test=test&test");
String tVeryLongURL = tSB.toString();
assertTrue("Expected " + tVeryLongURL + " to be a valid http url, but is not.",
mURLSyntaxChecker.isValidHttpURL(tVeryLongURL));
}
}