Search in sources :

Example 6 with BLangRuntimeException

use of org.ballerinalang.util.exceptions.BLangRuntimeException in project ballerina by ballerina-lang.

the class EndpointTest method testEndpointInFunction.

@Test(description = "Test endpoint testEndpoint In Function")
public void testEndpointInFunction() {
    CompileResult testEndpointsInFunction = BCompileUtil.compile("test-src/endpoint/testEndpointInFunction.bal");
    BValue[] returns = BRunUtil.invoke(testEndpointsInFunction, "test1");
    Assert.assertTrue(returns.length == 1);
    Assert.assertEquals(returns[0].stringValue(), "init:DummyEndpoint;start:DummyEndpoint;" + "getClient:DummyEndpoint;invoke1:DummyClient;getClient:DummyEndpoint;invoke2:DummyClient;t2");
    returns = BRunUtil.invoke(testEndpointsInFunction, "test2");
    Assert.assertTrue(returns.length == 1);
    Assert.assertEquals(returns[0].stringValue(), "init:DummyEndpoint;start:DummyEndpoint;<test2Caller>" + "getClient:DummyEndpoint;invoke1:DummyClient;getClient:DummyEndpoint;invoke2:DummyClient;t2");
    returns = BRunUtil.invoke(testEndpointsInFunction, "test3");
    Assert.assertTrue(returns.length == 1);
    Assert.assertEquals(returns[0].stringValue(), "<test3>init:DummyEndpoint;start:DummyEndpoint;" + "getClient:DummyEndpoint;invoke1:DummyClient;getClient:DummyEndpoint;invoke2:DummyClient;t2");
    try {
        BRunUtil.invoke(testEndpointsInFunction, "test4");
    } catch (BLangRuntimeException e) {
        Assert.fail("NullReferenceException was thrown at test4 of EndpointTest.");
    }
}
Also used : BLangRuntimeException(org.ballerinalang.util.exceptions.BLangRuntimeException) BValue(org.ballerinalang.model.values.BValue) CompileResult(org.ballerinalang.launcher.util.CompileResult) Test(org.testng.annotations.Test)

Aggregations

BLangRuntimeException (org.ballerinalang.util.exceptions.BLangRuntimeException)6 NativeCallableUnit (org.ballerinalang.model.NativeCallableUnit)2 BValue (org.ballerinalang.model.values.BValue)2 UTF8CPEntry (org.ballerinalang.util.codegen.cpentries.UTF8CPEntry)2 Path (java.nio.file.Path)1 QName (javax.xml.namespace.QName)1 OMAttribute (org.apache.axiom.om.OMAttribute)1 OMElement (org.apache.axiom.om.OMElement)1 OMNamespace (org.apache.axiom.om.OMNamespace)1 OMNamespaceImpl (org.apache.axiom.om.impl.common.OMNamespaceImpl)1 OMAttributeImpl (org.apache.axiom.om.impl.llom.OMAttributeImpl)1 BLangProgramLoader (org.ballerinalang.BLangProgramLoader)1 Context (org.ballerinalang.bre.Context)1 WorkerExecutionContext (org.ballerinalang.bre.bvm.WorkerExecutionContext)1 CompileResult (org.ballerinalang.launcher.util.CompileResult)1 BStructType (org.ballerinalang.model.types.BStructType)1 PackageInfo (org.ballerinalang.util.codegen.PackageInfo)1 ProgramFile (org.ballerinalang.util.codegen.ProgramFile)1 ServiceInfo (org.ballerinalang.util.codegen.ServiceInfo)1 TypeRefCPEntry (org.ballerinalang.util.codegen.cpentries.TypeRefCPEntry)1