use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class SecureClientSocketTest method testOpenSecureClientSocket.
@Test(description = "Test connection open with properties")
public void testOpenSecureClientSocket() throws URISyntaxException {
PackageInfo ioPackageInfo = socketClient.getProgFile().getPackageInfo("ballerina.io");
StructInfo socketProperties = ioPackageInfo.getStructInfo("SocketProperties");
BStruct propertyStruct = BLangVMStructs.createBStruct(socketProperties);
URL resource = getClass().getClassLoader().getResource("datafiles/security/keyStore/ballerinaTruststore.p12");
Assert.assertNotNull(resource, "Unable to find TrustStore.");
propertyStruct.setStringField(2, Paths.get(resource.toURI()).toFile().getAbsolutePath());
propertyStruct.setStringField(3, "ballerina");
BValue[] args = { new BString("localhost"), new BInteger(port), propertyStruct };
BRunUtil.invoke(socketClient, "openSocketConnection", args);
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class IOUtils method createError.
/**
* Returns the error struct for the corresponding message.
*
* @param context context of the native function.
* @param message error message.
* @return error message struct.
*/
public static BStruct createError(Context context, String message) {
PackageInfo ioPkg = context.getProgramFile().getPackageInfo(IO_PACKAGE);
StructInfo error = ioPkg.getStructInfo(IO_ERROR_STRUCT);
return BLangVMStructs.createBStruct(error, message);
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class HttpUtil method getGenericError.
/**
* Extract generic error message.
*
* @param context Represent ballerina context.
* @param errMsg Error message.
* @return Generic error message.
*/
public static BStruct getGenericError(Context context, String errMsg) {
PackageInfo errorPackageInfo = context.getProgramFile().getPackageInfo(PACKAGE_BUILTIN);
StructInfo errorStructInfo = errorPackageInfo.getStructInfo(STRUCT_GENERIC_ERROR);
BStruct genericError = new BStruct(errorStructInfo.getType());
genericError.setStringField(0, errMsg);
return genericError;
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class FileUtils method createIOError.
public static BStruct createIOError(Context context, String msg) {
PackageInfo filePkg = context.getProgramFile().getPackageInfo(FILE_PACKAGE);
StructInfo ioErrInfo = filePkg.getStructInfo(IO_ERROR);
return BLangVMStructs.createBStruct(ioErrInfo, msg);
}
use of org.ballerinalang.util.codegen.PackageInfo in project ballerina by ballerina-lang.
the class FileUtils method createFileStruct.
public static BStruct createFileStruct(Context context, String path) {
PackageInfo filePkg = context.getProgramFile().getPackageInfo(FILE_PACKAGE);
StructInfo fileInfo = filePkg.getStructInfo(FILE_STRUCT);
return BLangVMStructs.createBStruct(fileInfo, path);
}
Aggregations