Java Code Examples for org.wso2.carbon.utils.FileUtil

The following examples show how to use org.wso2.carbon.utils.FileUtil. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: istio-apim   Source File: IstioExecutor.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Build the config for the client
 */
private Config buildConfig() throws APIManagementException {

    System.setProperty(TRY_KUBE_CONFIG, "false");
    System.setProperty(TRY_SERVICE_ACCOUNT, "true");
    ConfigBuilder configBuilder;

    configBuilder = new ConfigBuilder().withMasterUrl(kubernetesAPIServerUrl);

    if (!StringUtils.isEmpty(saTokenFileName)) {
        String token;
        String tokenFile = saTokenFilePath + "/" + saTokenFileName;
        try {
            token = FileUtil.readFileToString(tokenFile);
        } catch (IOException e) {
            throw new APIManagementException("Error while reading the SA Token FIle " + tokenFile);
        }
        configBuilder.withOauthToken(token);
    }

    return configBuilder.build();
}
 
Example 2
@Before
public void setup() throws IOException {
    PowerMockito.mockStatic(ServiceReferenceHolder.class);
    PowerMockito.mockStatic(FileUtil.class);
    serviceReferenceHolder = Mockito.mock(ServiceReferenceHolder.class);
    componentContext = Mockito.mock(ComponentContext.class);
    registryService = Mockito.mock(RegistryService.class);
    userRegistry = Mockito.mock(UserRegistry.class);
    resource = Mockito.mock(Resource.class);

    Mockito.when(serviceReferenceHolder.getRegistryService()).thenReturn(registryService);
    PowerMockito.when(ServiceReferenceHolder.getInstance()).thenReturn(serviceReferenceHolder);
}
 
Example 3
Source Project: carbon-apimgt   Source File: APIManagerComponent.java    License: Apache License 2.0 4 votes vote down vote up
private void updateRegistryResourceContent(Resource resource, UserRegistry systemRegistry, String rxtDir, String rxtPath, String resourcePath) throws RegistryException, IOException {
    String rxt = FileUtil.readFileToString(rxtDir + File.separator + rxtPath);
    resource.setContent(rxt.getBytes(Charset.defaultCharset()));
    resource.setMediaType(APIConstants.RXT_MEDIA_TYPE);
    systemRegistry.put(resourcePath, resource);
}