RegressionTests__URLTest.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 2247 78f2b8da16ec
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding

"{ Encoding: utf8 }"

"{ Package: 'stx:goodies/regression' }"

"{ NameSpace: RegressionTests }"

TestCase subclass:#URLTest
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'tests-Regression-Files and Encodings'
!


!URLTest methodsFor:'testing'!

test01_fromString
    |u|

    u := URL fromString:'foo'.
    self assert:u host isNil.
    self assert:u path = 'foo'.
    self assert:u method isNil.
    self assert:u port isNil.

    u := URL fromString:'fff/'.
    self assert:u host isNil.
    self assert:u path = 'fff/'.
    self assert:u method isNil.
    self assert:u port isNil.

    u := URL fromString:'localhost:8080/'.
    self assert:u host = 'localhost'.
    self assert:u path isEmptyOrNil.
    self assert:u method isNil.
    self assert:u port = 8080.

    u := URL fromString:'http://localhost/'.
    self assert:u host = 'localhost'.
    self assert:u path isEmptyOrNil.
    self assert:u method = 'http'.

    u := URL fromString:'http://www.exept.de/'.
    self assert:u host = 'www.exept.de'.
    self assert:u path isEmptyOrNil.
    self assert:u method = 'http'.

    "
     self new test01_fromString
    "

    "Modified: / 28-02-2017 / 16:04:43 / cg"
!

test02_construct
    |u1 u2|

    u1 := URL fromString:'http://localhost/'.

    u2 := u1 construct:'subdir1'.
    self assert:u2 host = 'localhost'.
    self assert:u2 path = '/subdir1'.
    self assert:u2 method = 'http'.
    self assert:u2 port isNil.

    u2 := u1 construct:'/subdir1'.
    self assert:u2 host = 'localhost'.
    self assert:u2 path = '/subdir1'.
    self assert:u2 method = 'http'.
    self assert:u2 port isNil.

    u2 := u1 construct:'http://www.google.de:/top.html'.
    self assert:u2 host = 'www.google.de'.
    self assert:u2 path = '/top.html'.
    self assert:u2 method = 'http'.
    self assert:u2 port isNil.

    "
     self new test02_construct
    "
!

test03_missingParts
    |u|

    u := URL fromString:'http://:8080/foo'.
    self assert:u host isNil.
    self assert:u path = '/foo'.
    self assert:u method = 'http'.
    self assert:u port = 8080.

    "
     self new test03_missingParts
    "

    "Created: / 28-02-2017 / 16:05:44 / cg"
!

test04_differentSchemes
    |u|

    u := URL fromString:'ftp://ftp.is.co.za/rfc/rfc1808.txt'.
    self assert:u method = 'ftp'.
    self assert:u host = 'ftp.is.co.za'.
    self assert:u path = '/rfc/rfc1808.txt'.
    self assert:u port isNil.

    u := URL fromString:'http://www.ietf.org/rfc/rfc2396.txt'.
    self assert:u method = 'http'.
    self assert:u host = 'www.ietf.org'.
    self assert:u path = '/rfc/rfc2396.txt'.
    self assert:u port isNil.

    u := URL fromString:'https://www.ietf.org/rfc/rfc2396.txt'.
    self assert:u method = 'https'.
    self assert:u host = 'www.ietf.org'.
    self assert:u path = '/rfc/rfc2396.txt'.
    self assert:u port isNil.

    u := URL fromString:'ldap://[2001:db8::7]/c=GB?objectClass?one'. 
    self assert:u method = 'ldap'.
    self assert:u host = '2001:db8::7'.
    self assert:u hostIsIPv6.
"/    self assert:u path = '/c=GB?objectClass?one'.

"/    u := URL fromString:'mailto:John.Doe@example.com'. 
"/    self assert:u method = 'mailto'.
"/    self assert:u host = 'www.ietf.org'.
"/    self assert:u path = '/rfc/rfc2396.txt'.
"/    self assert:u port isNil.

"/    u := URL fromString:'news:comp.infosystems.www.servers.unix'. 
"/
"/    u := URL fromString:'tel:+1-816-555-1212'. 
"/
"/    u := URL fromString:'telnet://192.0.2.16:80/'. 

    "
     self new test03_missingParts
    "

    "Created: / 27-05-2019 / 16:54:41 / Claus Gittinger"
! !

!URLTest class methodsFor:'documentation'!

version
    ^ '$Header$'
! !