Commit bf09e978 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ added standard and http libraries as templates (to be moved to separate bundle or core bundle)

parent ba1f07d7
Loading
Loading
Loading
Loading
+125 −0
Original line number Diff line number Diff line
Package HTTP { 
	Package MessageBasedConfiguration {
        Import all from MessageBased
        Message Gate HTTPGate accepts Request,Response
        Component API {
            //Add variables and timers here or define new component types and configurations 
            gate HTTPGate http
        }
        Configuration BasicClientServer {
            API client as Tester,
            API server as SUT,
            connect client::http to server::http
        }
    
	} Note : "Message based types and instances"
	
	Package MessageBased {
        Import all from Standard
        
        //Generic Method type
        Type Method
        Method mGET
        Method mPOST
        Method mPUT
        Method mPATCH
        Method mDELETE

        //Generic Request type    
        Structure Request (
            String uri,
            optional Method method,
            optional Headers headers,
            optional Parameters parameters,
            optional Body body
        )
        
        //Generic Request instances
        Request GET ( )
        Request POST ( )
        Request PUT ( )
        Request PATCH ( )
        Request DELETE ( )
        
        //Generic Response type    
        Structure Response (
            optional Integer status,
            optional String statusMessage,
            optional Headers headers,
            optional Body body
        )
        
        //Generic Response instances, name = status code
        
        Response r200 (statusMessage = "OK")
        Response r201 (statusMessage = "Created")
        Response r204 (statusMessage = "No Content")
        Response r400 (statusMessage = "Bad Request")
        Response r401 (statusMessage = "Not Found")
        Response r403 (statusMessage = "Not Authorized")
        Response r404 (statusMessage = "Forbidden")

        //Generic Response instances, name = status message        
        Response OK (status = "200")
        Response Created (status = "201")
        Response NoContent (status = "204")
        Response BadRequest (status = "400")
        Response NotFound (status = "404")
        Response NotAuthorized (status = "401")
        Response Forbidden (status = "403")
        
        //supporting types
        Collection Parameters of Parameter
        Structure Parameter (
            Location location,
            String ^name,
            String ^value
        )
        Type Location
        Location path
        Location query

        //may need a structure, not necessarily relevant in standardized testing
        Location cookie
        
        //separate headers -> not necessary
        //Location header;
        Collection Headers of Header
        Structure Header (
            String ^name,
            String ^value
            //not relevant in TDL? 
            //optional contentLength of type Integer,
            //optional contentType of type String 
        )
        
        //Base body for extension
        Structure Body ( )
        
        //Basic string body
        Structure StringBody extends Body (
            String text
        )
        
        //Basic wrapper for collection responses
        Structure CollectionBody extends Body (
            Bodies items
        )
        
        //Any body can be included
        //If consistent type is needed, a custom subtype shall be defined and used 
        Collection Bodies of Body
        
        //Custom collection data instances can be defined
        //  - inline in the responses 
        //  - predefined as a separate data element
        //Custom collection data instances can be defined 
        //to enforce type consistency specific for API 
    
        //Basic form body    
        Structure FormBody extends Body (
            String field,
            String content
        )
    } 
}
 No newline at end of file
+56 −0
Original line number Diff line number Diff line
Package Standard {
	//TODO: extract to standard library
	Constraint length
	Constraint minLength
	Constraint maxLength
	Constraint range
	Constraint format
	Constraint union
	Constraint uniontype
	
	Type Boolean
	Type Integer
	Type String
	Type Verdict
	
	//TODO: these do not work at present -> literal values take precedence?
//	Boolean true
//	Boolean false
	Boolean True
	Boolean False
	
	Verdict pass
	Verdict fail
	Verdict inconclusive
	
	Time second
	
	Annotation Master
	Annotation MappingName

    //standard annotations for STO
    Annotation Initial conditions
    Annotation Expected behaviour
    Annotation Final conditions
    Annotation Test Purpose Description
    Annotation when
    Annotation then
	
	Predefined == returns Boolean
	Predefined != returns Boolean
	Predefined and returns Boolean
	Predefined or returns Boolean
	Predefined xor returns Boolean
	Predefined not returns Boolean
	Predefined < returns Boolean
	Predefined > returns Boolean
	Predefined <= returns Boolean
	Predefined >= returns Boolean
	Predefined +
	Predefined -
	Predefined *
	Predefined /
	Predefined mod
	Predefined size returns Integer
	
}
 No newline at end of file