use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class GetHeader method execute.
@Override
public void execute(Context context) {
BStruct pushPromiseStruct = (BStruct) context.getRefArgument(0);
Http2PushPromise http2PushPromise = HttpUtil.getPushPromise(pushPromiseStruct, HttpUtil.createHttpPushPromise(pushPromiseStruct));
String headerName = context.getStringArgument(0);
context.setReturnValues(new BString(http2PushPromise.getHeader(headerName)));
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class JSONTest method testParseObject.
@Test(description = "Get JSON object from a string")
public void testParseObject() {
BValue[] args = { new BString("{\"name\":\"supun\"}") };
BValue[] returns = BRunUtil.invoke(compileResult, "testParse", args);
Assert.assertTrue(returns[0] instanceof BJSON);
Assert.assertEquals(((BJSON) returns[0]).value().getType(), Type.OBJECT);
Assert.assertEquals(returns[0].stringValue(), "{\"name\":\"supun\"}");
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class JSONTest method testParseArray.
@Test(description = "Get JSON array from a string")
public void testParseArray() {
BValue[] args = { new BString("[\"supun\", 45, true, null]") };
BValue[] returns = BRunUtil.invoke(compileResult, "testParse", args);
Assert.assertTrue(returns[0] instanceof BJSON);
Assert.assertEquals(((BJSON) returns[0]).value().getType(), Type.ARRAY);
Assert.assertEquals(returns[0].stringValue(), "[\"supun\",45,true,null]");
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class JSONTest method testToXMLJsonObject.
@Test(description = "Convert a json object")
public void testToXMLJsonObject() {
BValue[] args = { new BJSON(jsonToXML16) };
BValue[] returns = BRunUtil.invoke(compileResult, "testToXMLWithXMLSequence", args);
Assert.assertTrue(returns[0] instanceof BString);
String textValue = returns[0].stringValue();
Assert.assertEquals(textValue, "<key1>value1</key1><key2>value2</key2>");
}
use of org.ballerinalang.model.values.BString in project ballerina by ballerina-lang.
the class JSONTest method testToXMLMultirootedObjects.
@Test(description = "Convert a json object with multi rooted object")
public void testToXMLMultirootedObjects() {
BValue[] args = { new BJSON(jsonToXML7) };
BValue[] returns = BRunUtil.invoke(compileResult, "testToXMLWithXMLSequence", args);
Assert.assertTrue(returns[0] instanceof BString);
String textValue = returns[0].stringValue();
Assert.assertEquals(textValue, "<bookStore><storeName>foo</storeName><postalCode>94</postalCode>" + "<isOpen>true</isOpen><address><street>PalmGrove</street><city>Colombo</city>" + "<country>SriLanka</country></address><codes><item>4</item><item>8</item><item>9</item></codes>" + "</bookStore><metaInfo>someinfo</metaInfo>");
}
Aggregations