Search in sources :

Example 21 with BValue

use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.

the class ConfigTest method testSetConfig.

@Test(description = "Test setting configs from Ballerina source code")
public void testSetConfig() throws IOException {
    BString key = new BString("ballerina.http.host");
    BString value = new BString("ballerinalang.org");
    BValue[] inputArgs = { key, value };
    registry.initRegistry(getRuntimeProperties(), customConfigFilePath, ballerinaConfPath);
    BRunUtil.invoke(compileResult, "testSetConfig", inputArgs);
    // The config we set in Ballerina code should overwrite the configs set from other sources
    Assert.assertEquals(registry.getConfiguration(key.stringValue()), value.stringValue());
}
Also used : BString(org.ballerinalang.model.values.BString) BValue(org.ballerinalang.model.values.BValue) Test(org.testng.annotations.Test)

Example 22 with BValue

use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.

the class ConfigTest method testGetInstanceValuesWithAllProperties.

@Test(description = "test instance method with runtime, custom and default config file properties")
public void testGetInstanceValuesWithAllProperties() throws IOException {
    BString key = new BString("http1.ballerina.http.port");
    BValue[] inputArg = { key };
    registry.initRegistry(getRuntimeProperties(), customConfigFilePath, ballerinaConfPath);
    BValue[] returnVals = BRunUtil.invoke(compileResult, "testGetAsString", inputArg);
    Assert.assertFalse(returnVals == null || returnVals.length == 0 || returnVals[0] == null, "Invalid Return Values.");
    Assert.assertTrue(returnVals[0] instanceof BString);
    Assert.assertEquals(returnVals[0].stringValue(), "8082");
}
Also used : BString(org.ballerinalang.model.values.BString) BValue(org.ballerinalang.model.values.BValue) Test(org.testng.annotations.Test)

Example 23 with BValue

use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.

the class ConfigTest method testGetAsStringWithRuntime.

@Test(description = "test global method with runtime and custom config file properties")
public void testGetAsStringWithRuntime() throws IOException {
    BString key = new BString("ballerina.http.host");
    BValue[] inputArg = { key };
    registry.initRegistry(getRuntimeProperties(), customConfigFilePath, ballerinaConfPath);
    BValue[] returnVals = BRunUtil.invoke(compileResult, "testGetAsString", inputArg);
    Assert.assertFalse(returnVals == null || returnVals.length == 0 || returnVals[0] == null, "Invalid Return Values.");
    Assert.assertTrue(returnVals[0] instanceof BString);
    Assert.assertEquals(returnVals[0].stringValue(), "10.100.1.201");
}
Also used : BString(org.ballerinalang.model.values.BString) BValue(org.ballerinalang.model.values.BValue) Test(org.testng.annotations.Test)

Example 24 with BValue

use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.

the class SQLActionsTest method testGeneratedKeyOnInsert.

@Test(groups = "ConnectorTest")
public void testGeneratedKeyOnInsert() {
    BValue[] returns = BRunUtil.invoke(result, "testGeneratedKeyOnInsert");
    BString retValue = (BString) returns[0];
    Assert.assertTrue(Integer.parseInt(retValue.stringValue()) > 0);
}
Also used : BValue(org.ballerinalang.model.values.BValue) BString(org.ballerinalang.model.values.BString) Test(org.testng.annotations.Test)

Example 25 with BValue

use of org.ballerinalang.model.values.BValue in project ballerina by ballerina-lang.

the class SQLActionsTest method testNullINParameters.

@Test(groups = "ConnectorTest", enabled = false)
public void testNullINParameters() {
    BValue[] returns = BRunUtil.invoke(result, "testNullINParameters");
    BInteger retValue = (BInteger) returns[0];
    Assert.assertEquals(retValue.intValue(), 1);
}
Also used : BValue(org.ballerinalang.model.values.BValue) BInteger(org.ballerinalang.model.values.BInteger) Test(org.testng.annotations.Test)

Aggregations

BValue (org.ballerinalang.model.values.BValue)1043 Test (org.testng.annotations.Test)923 BString (org.ballerinalang.model.values.BString)437 BInteger (org.ballerinalang.model.values.BInteger)323 BStruct (org.ballerinalang.model.values.BStruct)188 BFloat (org.ballerinalang.model.values.BFloat)118 BJSON (org.ballerinalang.model.values.BJSON)112 BBoolean (org.ballerinalang.model.values.BBoolean)79 CompileResult (org.ballerinalang.launcher.util.CompileResult)60 BRefValueArray (org.ballerinalang.model.values.BRefValueArray)45 BMap (org.ballerinalang.model.values.BMap)43 BXMLItem (org.ballerinalang.model.values.BXMLItem)42 BXML (org.ballerinalang.model.values.BXML)40 BStringArray (org.ballerinalang.model.values.BStringArray)30 BIntArray (org.ballerinalang.model.values.BIntArray)25 BBlob (org.ballerinalang.model.values.BBlob)23 HttpHeaders (io.netty.handler.codec.http.HttpHeaders)19 BeforeTest (org.testng.annotations.BeforeTest)19 HTTPCarbonMessage (org.wso2.transport.http.netty.message.HTTPCarbonMessage)19 BallerinaException (org.ballerinalang.util.exceptions.BallerinaException)16