- Install Ballerina using windows installer.
- Open cmd or powershell.
- Clone this scripts.
git clone https://gist.github.com/e606661be03d7045be973868b9e9ed67.git wintests
. cd
towintests
.- run
test
command.
Last active
December 19, 2019 07:56
-
-
Save hasithaa/e606661be03d7045be973868b9e9ed67 to your computer and use it in GitHub Desktop.
A script to test Ballerina installers on windows.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ballerina/http; | |
import ballerina/io; | |
http:Client clientEndpoint = new ("http://postman-echo.com"); | |
public function main() { | |
io:println("GET request:"); | |
var response = clientEndpoint->get("/get?test=123"); | |
handleResponse(response); | |
io:println("\nPOST request:"); | |
response = clientEndpoint->post("/post", "POST: Hello World"); | |
handleResponse(response); | |
io:println("\nUse custom HTTP verbs:"); | |
response = clientEndpoint->execute("COPY", "/get", "CUSTOM: Hello World"); | |
http:Request req = new; | |
req.addHeader("Sample-Name", "http-client-connector"); | |
response = clientEndpoint->get("/get", req); | |
if (response is http:Response) { | |
string contentType = response.getHeader("Content-Type"); | |
io:println("Content-Type: " + contentType); | |
int statusCode = response.statusCode; | |
io:println("Status code: " + statusCode.toString()); | |
} else { | |
io:println("Error when calling the backend: ", response.reason()); | |
} | |
} | |
function handleResponse(http:Response | error response) { | |
if (response is http:Response) { | |
var msg = response.getJsonPayload(); | |
if (msg is json) { | |
io:println(msg.toJsonString()); | |
} else { | |
io:println("Invalid payload received:", msg.reason()); | |
} | |
} else { | |
io:println("Error when calling the backend: ", response.reason()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
@echo "=====================================" | |
@echo "======Testing Project Bal file=======" | |
@echo "=====================================" | |
rmdir hello-proj /S /Q | |
call ballerina new hello-proj | |
@echo on | |
cd hello-proj | |
call ballerina add hello_service -t service | |
@echo on | |
call ballerina add hello_main -t main | |
@echo on | |
call ballerina run hello_main | |
@echo on | |
call ballerina clean | |
@echo on | |
rmdir target /S /Q | |
call ballerina build -a | |
@echo on | |
call ballerina run target\bin\hello_main.jar | |
@echo on | |
rmdir target /S /Q | |
call ballerina build -a --skip-tests | |
@echo on | |
call ballerina run target\bin\hello_main.jar | |
@echo on | |
@cd .. | |
rmdir hello-proj /S /Q |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
@echo "=====================================" | |
@echo "======Testing Single Bal file========" | |
@echo "=====================================" | |
CALL ballerina version | |
@echo on | |
@del hello.jar /f /Q > nul 2> nul | |
CALL ballerina run hello.bal | |
@echo on | |
@del hello.jar /f /Q > nul 2> nul | |
call ballerina build hello.bal | |
@echo on | |
call ballerina run hello.jar | |
@echo on | |
del hello.jar /f /Q |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment