From dad9d5418000c260b34bd8479914d4e9dca57794 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Tue, 21 Apr 2009 14:50:46 +0000 Subject: [PATCH] 2009-04-21 Sebastien Pouliot * UriParserTest.cs: Ensure "tcp" is not a registred scheme * UriTest2.cs: Make sure GetComponents and IsBaseOf do not throw NRE is no UriParser was registred for the URI scheme svn path=/trunk/mcs/; revision=132265 --- mcs/class/System/Test/System/ChangeLog | 6 ++++++ mcs/class/System/Test/System/UriParserTest.cs | 3 +++ mcs/class/System/Test/System/UriTest2.cs | 29 +++++++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/mcs/class/System/Test/System/ChangeLog b/mcs/class/System/Test/System/ChangeLog index d838893fd51..fbef80d14c2 100644 --- a/mcs/class/System/Test/System/ChangeLog +++ b/mcs/class/System/Test/System/ChangeLog @@ -1,3 +1,9 @@ +2009-04-21 Sebastien Pouliot + + * UriParserTest.cs: Ensure "tcp" is not a registred scheme + * UriTest2.cs: Make sure GetComponents and IsBaseOf do not throw + NRE is no UriParser was registred for the URI scheme + 2009-04-21 Sebastien Pouliot * UriTest2.cs: More constructor test cases diff --git a/mcs/class/System/Test/System/UriParserTest.cs b/mcs/class/System/Test/System/UriParserTest.cs index 30aaeb6e3ab..f4a87f78025 100644 --- a/mcs/class/System/Test/System/UriParserTest.cs +++ b/mcs/class/System/Test/System/UriParserTest.cs @@ -453,6 +453,9 @@ namespace MonoTests.System { // variations - mixed and upper case Assert.IsTrue (UriParser.IsKnownScheme ("FiLe"), "FiLe"); Assert.IsTrue (UriParser.IsKnownScheme ("FTP"), "ftp"); + + // see 496783 + Assert.IsFalse (UriParser.IsKnownScheme ("tcp"), "tcp"); } [Test] diff --git a/mcs/class/System/Test/System/UriTest2.cs b/mcs/class/System/Test/System/UriTest2.cs index e1d973bc5d6..f1d6ed3068c 100644 --- a/mcs/class/System/Test/System/UriTest2.cs +++ b/mcs/class/System/Test/System/UriTest2.cs @@ -519,6 +519,35 @@ TextWriter sw = Console.Out; Uri uri = new Uri ("/Moonlight", UriKind.Relative); CheckRelativeUri (uri); } + + [Test] + public void Bug496783 () + { + string s = "tcp://csve2.csse.unimelb.edu.au:9090/Aneka"; + Uri uri = new Uri (s); + // this is not parsed by a known UriParser + Assert.IsFalse (UriParser.IsKnownScheme (uri.Scheme), "UriParser"); + + Uri uri2 = new Uri ("tcp://csve2.csse.unimelb.edu.au:9090/"); + Assert.IsTrue (uri2.IsBaseOf (uri), "IsBaseOf"); + + Assert.AreEqual (uri.AbsoluteUri, uri.GetComponents (UriComponents.AbsoluteUri, UriFormat.Unescaped), "AbsoluteUri"); + Assert.AreEqual (uri.Fragment, uri.GetComponents (UriComponents.Fragment, UriFormat.Unescaped), "Fragment"); + Assert.AreEqual (uri.Host, uri.GetComponents (UriComponents.Host, UriFormat.Unescaped), "Host"); + Assert.AreEqual (uri.Authority, uri.GetComponents (UriComponents.HostAndPort, UriFormat.Unescaped), "HostAndPort"); + Assert.AreEqual (uri.AbsoluteUri, uri.GetComponents (UriComponents.HttpRequestUrl, UriFormat.Unescaped), "HttpRequestUrl"); + Assert.AreEqual (String.Empty, uri.GetComponents (UriComponents.KeepDelimiter, UriFormat.Unescaped), "KeepDelimiter"); + Assert.AreEqual ("Aneka", uri.GetComponents (UriComponents.Path, UriFormat.Unescaped), "Path"); + Assert.AreEqual (uri.LocalPath, uri.GetComponents (UriComponents.PathAndQuery, UriFormat.Unescaped), "PathAndQuery"); + Assert.AreEqual (uri.Port.ToString (), uri.GetComponents (UriComponents.Port, UriFormat.Unescaped), "Port"); + Assert.AreEqual (uri.Query, uri.GetComponents (UriComponents.Query, UriFormat.Unescaped), "Query"); + Assert.AreEqual (uri.Scheme, uri.GetComponents (UriComponents.Scheme, UriFormat.Unescaped), "Scheme"); + Assert.AreEqual ("tcp://csve2.csse.unimelb.edu.au:9090", uri.GetComponents (UriComponents.SchemeAndServer, UriFormat.Unescaped), "SchemeAndServer"); + Assert.AreEqual (uri.OriginalString, uri.GetComponents (UriComponents.SerializationInfoString, UriFormat.Unescaped), "SerializationInfoString"); + Assert.AreEqual (uri.Authority, uri.GetComponents (UriComponents.StrongAuthority, UriFormat.Unescaped), "StrongAuthority"); + Assert.AreEqual (uri.Port.ToString (), uri.GetComponents (UriComponents.StrongPort, UriFormat.Unescaped), "StrongPort"); + Assert.AreEqual (uri.UserInfo, uri.GetComponents (UriComponents.UserInfo, UriFormat.Unescaped), "UserInfo"); + } #endif } } -- 2.11.4.GIT