org.wso2.carbon.utils.FileUtil Java Examples
The following examples show how to use
org.wso2.carbon.utils.FileUtil.
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 File: IstioExecutor.java From istio-apim with Apache License 2.0 | 6 votes |
/** * 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
Source File: APIManagerComponentAddRxtConfigsTest.java From carbon-apimgt with Apache License 2.0 | 5 votes |
@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 File: APIManagerComponent.java From carbon-apimgt with Apache License 2.0 | 4 votes |
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); }