[squeak-dev] The Trunk: NetworkTests-pre.62.mcz

commits at source.squeak.org commits at source.squeak.org
Fri Apr 22 19:06:39 UTC 2022


Patrick Rein uploaded a new version of NetworkTests to project The Trunk:
http://source.squeak.org/trunk/NetworkTests-pre.62.mcz

==================== Summary ====================

Name: NetworkTests-pre.62
Author: pre
Time: 22 April 2022, 9:06:34.386677 pm
UUID: 218eaf21-1e2d-5c45-8df6-102ab6ee8892
Ancestors: NetworkTests-ct.61

Adds tests for equality of Urls and URIs. Unites the test classes for Url subclasses in one hierarchy.

=============== Diff against NetworkTests-ct.61 ===============

Item was changed:
+ UrlSubclassesTest subclass: #FileUrlTest
- ClassTestCase subclass: #FileUrlTest
  	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'NetworkTests-Url'!

Item was added:
+ ----- Method: FileUrlTest>>classToBeTested (in category 'coverage') -----
+ classToBeTested
+ 
+ 	^ FileUrl!

Item was added:
+ ----- Method: FileUrlTest>>createUrlFrom: (in category 'private') -----
+ createUrlFrom: aString
+ 
+ 	^ FileUrl absoluteFromText: aString!

Item was added:
+ ----- Method: FileUrlTest>>testEqual (in category 'tests') -----
+ testEqual
+ 
+ 	self 
+ 		assertUrl: 'file:///C:/Users/Uniform%20Resource%20Identifier.html'
+ 		equals: 'file:///C:/Users/Uniform%20Resource%20Identifier.html'.
+ 	
+ 	self 
+ 		denyUrl: 'file:///C:/Users/Uniform%20Resource%20Identifier.html'
+ 		equals: 'file:///C:/Users/Uniform%20Resource%20Identifier2.html'.!

Item was added:
+ ----- Method: FileUrlTest>>testEqualWithHostAndFragment (in category 'tests') -----
+ testEqualWithHostAndFragment
+ 
+ 	self 
+ 		assertUrl: 'file://localhost/C:/Users/Uniform%20Resource%20Identifier.html#heading1' 
+ 		equals: 'file://localhost/C:/Users/Uniform%20Resource%20Identifier.html#heading1'.
+ 	
+ 	self 	
+ 		denyUrl: 'file://localhost/C:/Users/Uniform%20Resource%20Identifier.html#heading1' 
+ 		equals: 'file://localhost/C:/Users/Uniform%20Resource%20Identifier.html#heading2'.
+ 		
+ 	self 	
+ 		denyUrl: 'file://localhost/C:/Users/Uniform%20Resource%20Identifier.html#heading1' 
+ 		equals: 'file://localhost2/C:/Users/Uniform%20Resource%20Identifier.html#heading1'.!

Item was changed:
+ UrlSubclassesTest subclass: #GenericUrlTest
- ClassTestCase subclass: #GenericUrlTest
  	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'NetworkTests-Url'!

Item was added:
+ ----- Method: GenericUrlTest>>classToBeTested (in category 'coverage') -----
+ classToBeTested
+ 
+ 	^ GenericUrl!

Item was added:
+ ----- Method: GenericUrlTest>>createUrlFrom: (in category 'private') -----
+ createUrlFrom: aString 
+ 	
+ 	^ GenericUrl absoluteFromText: aString!

Item was added:
+ ----- Method: GenericUrlTest>>testEqual (in category 'tests') -----
+ testEqual
+ 
+ 	self 
+ 		assertUrl: 'http://nobody:password@example.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2'
+ 		equals: 'http://nobody:password@example.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2'.
+ 	
+ 	"Different port"
+ 	self 
+ 		denyUrl: 'http://nobody:password@example.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2'
+ 		equals: 'http://nobody:password@example.org:8081/cgi-bin/script.php?action=submit&pageid=86392001#section_2'.
+ 		
+ 	"Different host"
+ 	self 
+ 		denyUrl: 'http://nobody:password@example.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2'
+ 		equals: 'http://nobody:password@example2.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2'.
+ 		
+ 	"Different query"
+ 	self 
+ 		denyUrl: 'http://nobody:password@example.org:8080/cgi-bin/script.php?action=submit&pageid=86#section_2'
+ 		equals: 'http://nobody:password@example2.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2'.
+ 		
+ 	"Different fragment"
+ 	self 
+ 		denyUrl: 'http://nobody:password@example.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2'
+ 		equals: 'http://nobody:password@example2.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section'.
+ 		
+ 	"Different authentication"
+ 	self 
+ 		denyUrl: 'http://nobody:password@example.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2'
+ 		equals: 'http://someone:password@example2.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2'.
+ 		
+ 	"Different schema"
+ 	self 
+ 		denyUrl: 'http://nobody:password@example.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2'
+ 		equals: 'sometp://someone:password@example2.org:8080/cgi-bin/script.php?action=submit&pageid=86392001#section_2'.
+ 	
+ 		!

Item was changed:
+ UrlSubclassesTest subclass: #HierarchicalUrlTest
- ClassTestCase subclass: #HierarchicalUrlTest
  	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'NetworkTests-Url'!

Item was added:
+ ----- Method: HierarchicalUrlTest>>classToBeTested (in category 'coverage') -----
+ classToBeTested
+ 
+ 	^ HierarchicalUrl!

Item was added:
+ ----- Method: HierarchicalUrlTest>>createUrlFrom: (in category 'private') -----
+ createUrlFrom: aString 
+ 	
+ 	^ HierarchicalUrl absoluteFromText: aString!

Item was added:
+ ----- Method: HierarchicalUrlTest>>testEqual (in category 'tests') -----
+ testEqual
+ 	
+ 	self
+ 		assertUrl: 'ftp://localhost/path/to/file?aQuery'
+ 		equals: 'ftp://localhost/path/to/file?aQuery'.
+ 		
+ 	"Different Schema name"
+ 	self
+ 		denyUrl: 'ftp://localhost/path/to/file?aQuery'
+ 		equals: 'http://localhost/path/to/file?aQuery'.
+ 	
+ 	"Different Authority"
+ 	self
+ 		denyUrl: 'ftp://localhost/path/to/file?aQuery'
+ 		equals: 'ftp://remotehost/path/to/file?aQuery'.
+ 	
+ 	"Different Path"
+ 	self
+ 		denyUrl: 'ftp://localhost/path/to/file?aQuery'
+ 		equals: 'ftp://localhost/anotherpath/to/file?aQuery'.
+ 	
+ 	"Different Query"
+ 	self
+ 		denyUrl: 'ftp://localhost/path/to/file?aQuery'
+ 		equals: 'ftp://localhost/path/to/file?aQuery=aValue'.
+ !

Item was changed:
+ UrlSubclassesTest subclass: #HttpUrlTest
- ClassTestCase subclass: #HttpUrlTest
  	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'NetworkTests-Url'!

Item was added:
+ ----- Method: HttpUrlTest>>classToBeTested (in category 'coverage') -----
+ classToBeTested
+ 
+ 	^ HttpUrl!

Item was added:
+ ----- Method: HttpUrlTest>>createUrlFrom: (in category 'private') -----
+ createUrlFrom: aString 
+ 	
+ 	^ HttpUrl absoluteFromText: aString!

Item was added:
+ ----- Method: HttpUrlTest>>testEqual (in category 'tests') -----
+ testEqual
+ 	
+ 	self
+ 		assertUrl: 'http://localhost/path/to/file?aQuery'
+ 		equals: 'http://localhost/path/to/file?aQuery'.
+ 		
+ 	"Different Schema name"
+ 	self
+ 		denyUrl: 'http://localhost/path/to/file?aQuery'
+ 		equals: 'https://localhost/path/to/file?aQuery'.
+ 	
+ 	"Different Authority"
+ 	self
+ 		denyUrl: 'http://localhost/path/to/file?aQuery'
+ 		equals: 'http://remotehost/path/to/file?aQuery'.
+ 	
+ 	"Different Path"
+ 	self
+ 		denyUrl: 'http://localhost/path/to/file?aQuery'
+ 		equals: 'http://localhost/anotherpath/to/file?aQuery'.
+ 	
+ 	"Different Query"
+ 	self
+ 		denyUrl: 'http://localhost/path/to/file?aQuery'
+ 		equals: 'http://localhost/path/to/file?aQuery=aValue'.
+ !

Item was changed:
+ ClassTestCase subclass: #TestURI
- TestCase subclass: #TestURI
  	instanceVariableNames: ''
  	classVariableNames: ''
  	poolDictionaries: ''
  	category: 'NetworkTests-URI'!
  
+ !TestURI commentStamp: 'pre 4/22/2022 21:05' prior: 0!
+ Some parsers allow the scheme name to be present in a relative URI if
- !TestURI commentStamp: 'mir 2/27/2002 14:42' prior: 0!
- Main comment stating the purpose of this class and relevant relationship to other classes.
- 
- 
-    Some parsers allow the scheme name to be present in a relative URI if
     it is the same as the base URI scheme.  This is considered to be a
     loophole in prior specifications of partial URI [RFC1630]. Its use
     should be avoided.
  
        http:g        =  http:g           ; for validating parsers
                      |  http://a/b/c/g   ; for backwards compatibility
  !

Item was added:
+ ----- Method: TestURI>>classToBeTested (in category 'coverage') -----
+ classToBeTested
+ 
+ 	^ URI!

Item was added:
+ ----- Method: TestURI>>testEquals (in category 'tests - comparing') -----
+ testEquals
+ 
+ 	| uri uriString |
+ 	uri := [:string | URI fromString: string].
+ 
+ 	uriString := 'http://squeak.org/'.
+ 	self assert: (uri value: uriString) = (uri value: uriString).
+ 	uriString := 'http://squeak.org/index.html'.
+ 	self assert: (uri value: uriString) = (uri value: uriString).
+ 	uriString := 'mailto:somebody at somewhere.nowhere#fragment'.
+ 	self assert: (uri value: uriString) = (uri value: uriString).
+ 	
+ 	self deny: (uri value: 'http://squeak.org') = (uri value: 'http://website.com').!

Item was added:
+ ClassTestCase subclass: #UrlSubclassesTest
+ 	instanceVariableNames: ''
+ 	classVariableNames: ''
+ 	poolDictionaries: ''
+ 	category: 'NetworkTests-Url'!

Item was added:
+ ----- Method: UrlSubclassesTest class>>isAbstract (in category 'Testing') -----
+ isAbstract
+ 
+ 	^ self = UrlSubclassesTest!

Item was added:
+ ----- Method: UrlSubclassesTest>>assertUrl:equals: (in category 'assertions') -----
+ assertUrl: aString equals: anotherString
+ 
+ 	self 
+ 		assert: (self createUrlFrom: aString) = (self createUrlFrom: anotherString)
+ 		description: ('Url {1} is not equal to {2}' format: {aString . anotherString}).!

Item was added:
+ ----- Method: UrlSubclassesTest>>createUrlFrom: (in category 'private') -----
+ createUrlFrom: aString
+ 
+ 	self subclassResponsibility.!

Item was added:
+ ----- Method: UrlSubclassesTest>>denyUrl:equals: (in category 'assertions') -----
+ denyUrl: aString equals: anotherString
+ 
+ 	self 
+ 		deny: (self createUrlFrom: aString) = (self createUrlFrom: anotherString)
+ 		description: ('Url {1} is equal to {2} but should not be.' format: {aString . anotherString}).!

Item was changed:
+ ----- Method: UrlTest>>testAbsoluteBrowser (in category 'tests - absolute urls') -----
- ----- Method: UrlTest>>testAbsoluteBrowser (in category 'tests') -----
  testAbsoluteBrowser
  
  	url := Url absoluteFromText: 'browser:bookmarks#mainPart'.
  
  	self assert: url schemeName = 'browser'.
  	self assert: url locator = 'bookmarks'.
  	self assert:url fragment = 'mainPart'.
  	self assert: url class = BrowserUrl.
  	!

Item was changed:
+ ----- Method: UrlTest>>testAbsoluteFILE (in category 'tests - absolute urls') -----
- ----- Method: UrlTest>>testAbsoluteFILE (in category 'tests') -----
  testAbsoluteFILE
  	
  	url := Url absoluteFromText: 'file:/etc/passwd#foo'.
  
  	self assert: url schemeName = 'file'.
  	self assert: url path first = 'etc'.
  	self assert: url path size = 2.	
  	self assert: url fragment = 'foo'.!

Item was changed:
+ ----- Method: UrlTest>>testAbsoluteFILE2 (in category 'tests - absolute urls') -----
- ----- Method: UrlTest>>testAbsoluteFILE2 (in category 'tests') -----
  testAbsoluteFILE2
  	
  	url := 'fILE:/foo/bar//zookie/?fakequery/#fragger' asUrl.
  
  	self assert: url schemeName = 'file'.
  	self assert: url class = FileUrl.
  	self assert: url path first ='foo'.
  	self assert: url path size = 5.
  	self assert: url fragment = 'fragger'.!

Item was changed:
+ ----- Method: UrlTest>>testAbsoluteFILE3 (in category 'tests - absolute urls') -----
- ----- Method: UrlTest>>testAbsoluteFILE3 (in category 'tests') -----
  testAbsoluteFILE3
  	"Just a few selected tests for FileUrl, not complete by any means."
  
  
  	{'file:'. 'file:/'. 'file://'} do: [:s |
  	 	url := FileUrl absoluteFromText: s.
  		self assert: (url asString = 'file:///').
  		self assert: (url host = '').
  		self assert: url isAbsolute].
  	
  	url := FileUrl absoluteFromText: 'file://localhost/dir/file.txt'.
  	self assert: (url asString = 'file://localhost/dir/file.txt').
  	self assert: (url host = 'localhost').
  	
  	url := FileUrl absoluteFromText: 'file://localhost/dir/file.txt'.
  	self assert: (url asString = 'file://localhost/dir/file.txt').
  	self assert: (url host = 'localhost').
  	self assert: url isAbsolute.
  	
  	url := FileUrl absoluteFromText: 'file:///dir/file.txt'.
  	self assert: (url asString = 'file:///dir/file.txt').
  	self assert: (url host = '').
  	self assert: url isAbsolute.
  	
  	url := FileUrl absoluteFromText: '/dir/file.txt'.
  	self assert: (url asString = 'file:///dir/file.txt').
  	self assert: url isAbsolute.
  	
  	url := FileUrl absoluteFromText: 'dir/file.txt'.
  	self assert: (url asString = 'file:///dir/file.txt').
  	self deny: url isAbsolute.
  	
  	url := FileUrl absoluteFromText: 'c:/dir/file.txt'.
  	self assert: (url asString = 'file:///c%3A/dir/file.txt').
  	self assert: url isAbsolute.
  	
  	"Only a drive letter doesn't refer to a directory."
  	url := FileUrl absoluteFromText: 'c:'.
  	self assert: (url asString = 'file:///c%3A/').
  	self assert: url isAbsolute.
  	
  	url := FileUrl absoluteFromText: 'c:/'.
  	self assert: (url asString = 'file:///c%3A/').
  	self assert: url isAbsolute!

Item was changed:
+ ----- Method: UrlTest>>testAbsoluteFTP (in category 'tests - absolute urls') -----
- ----- Method: UrlTest>>testAbsoluteFTP (in category 'tests') -----
  testAbsoluteFTP
  	
  	url := 'ftP://some.server/some/directory/' asUrl.
  
  	self assert: url schemeName = 'ftp'.
  	self assert: url class = FtpUrl.
  	self assert: url authority = 'some.server'.	
  	self assert: url path first = 'some'.
  	self assert: url path size  = 3.
  	!

Item was changed:
+ ----- Method: UrlTest>>testAbsoluteHTTP (in category 'tests - absolute urls') -----
- ----- Method: UrlTest>>testAbsoluteHTTP (in category 'tests') -----
  testAbsoluteHTTP
  	
  	url := 'hTTp://chaos.resnet.gatech.edu:8000/docs/java/index.html?A%20query%20#part' asUrl.
  
  	self assert: url schemeName = 'http'.
  	self assert: url authority = 'chaos.resnet.gatech.edu'.
  	self assert: url path first = 'docs'.
  	self assert: url path size = 3.
  	self assert: url query = 'A%20query%20'.
  	self assert: url fragment = 'part'.!

Item was changed:
+ ----- Method: UrlTest>>testAbsolutePortErrorFix (in category 'tests - absolute urls') -----
- ----- Method: UrlTest>>testAbsolutePortErrorFix (in category 'tests') -----
  testAbsolutePortErrorFix
  	"This should not throw an exception."
  	Url absoluteFromText: 'http://swikis.ddo.jp:8823/'.
  
  	self should: [Url absoluteFromText: 'http://swikis.ddo.jp:-1/'] raise: Error.
  	self should: [Url absoluteFromText: 'http://swikis.ddo.jp:65536/'] raise: Error.
  	self should: [Url absoluteFromText: 'http://swikis.ddo.jp:auau/'] raise: Error.!

Item was changed:
+ ----- Method: UrlTest>>testAbsoluteTELNET (in category 'tests - absolute urls') -----
- ----- Method: UrlTest>>testAbsoluteTELNET (in category 'tests') -----
  testAbsoluteTELNET
  	
  	url := 'telNet:chaos.resnet.gatech.edu#goo' asUrl.
  
  	self assert: url schemeName = 'telnet'.
  	self assert: url locator = 'chaos.resnet.gatech.edu'.
  	self assert: url fragment = 'goo'.	
  !

Item was changed:
+ ----- Method: UrlTest>>testRelativeFILE (in category 'tests - relative') -----
- ----- Method: UrlTest>>testRelativeFILE (in category 'tests') -----
  testRelativeFILE
  	
  	| url2 |
  	baseUrl := 'file:/some/dir#fragment1' asUrl.
  	url := baseUrl newFromRelativeText: 'file:../another/dir/#fragment2'.
  	self assert: url asText =  'file:///another/dir/#fragment2'.
  	
  	url := FileUrl absoluteFromText: 'file://localhost/dir/dir2/file.txt'.
  	url2 := FileUrl absoluteFromText: 'file://hostname/flip/file.txt'.
  	url2 privateInitializeFromText: '../file2.txt' relativeTo: url.
  	self assert: (url2 asString = 'file://localhost/dir/file2.txt').
  	self assert: (url2 host = 'localhost').
  	self assert: url2 isAbsolute.
  	
  	url := FileUrl absoluteFromText: 'file://localhost/dir/dir2/file.txt'.
  	url2 := FileUrl absoluteFromText: 'flip/file.txt'.
  	self deny: url2 isAbsolute.
  	url2 privateInitializeFromText: '.././flip/file.txt' relativeTo: url.
  	self assert: (url2 asString = 'file://localhost/dir/flip/file.txt').
  	self assert: (url2 host = 'localhost').
  	self assert: url2 isAbsolute.
  	
  !

Item was changed:
+ ----- Method: UrlTest>>testRelativeFTP (in category 'tests - relative') -----
- ----- Method: UrlTest>>testRelativeFTP (in category 'tests') -----
  testRelativeFTP
  	
  	baseUrl := 'ftp://somewhere/some/dir/?query#fragment' asUrl.
  	url := baseUrl newFromRelativeText: 'ftp://a.b'.
  
  	self assert: url asString =  'ftp://a.b/'.!

Item was changed:
+ ----- Method: UrlTest>>testRelativeFTP2 (in category 'tests - relative') -----
- ----- Method: UrlTest>>testRelativeFTP2 (in category 'tests') -----
  testRelativeFTP2
  	
  	baseUrl := 'ftp://somewhere/some/dir/?query#fragment' asUrl.
  	url := baseUrl newFromRelativeText: 'ftp:xyz'.
  
  
  	self assert: url asString =  'ftp://somewhere/some/dir/xyz'.!

Item was changed:
+ ----- Method: UrlTest>>testRelativeFTP3 (in category 'tests - relative') -----
- ----- Method: UrlTest>>testRelativeFTP3 (in category 'tests') -----
  testRelativeFTP3
  	
  	baseUrl := 'ftp://somewhere/some/dir/?query#fragment' asUrl.
  	url := baseUrl newFromRelativeText: 'http:xyz'.
  
  	self assert: url asString = 'http://xyz/'.!

Item was changed:
+ ----- Method: UrlTest>>testRelativeHTTP (in category 'tests - relative') -----
- ----- Method: UrlTest>>testRelativeHTTP (in category 'tests') -----
  testRelativeHTTP
  	
  	baseUrl := 'http://some.where/some/dir?query1#fragment1' asUrl.
  	url := baseUrl newFromRelativeText: '../another/dir/?query2#fragment2'.
  
  	self assert: url asString =  'http://some.where/another/dir/?query2#fragment2'.!



More information about the Squeak-dev mailing list