@Test( expected = IOException.class ) public void testInstanceResources_exception_subDir() throws Exception { TestApplicationTemplate app = new TestApplicationTemplate(); Map<String,byte[]> fileNameToFileContent = new HashMap<> (); fileNameToFileContent.put( "dir1/dir2/f3.txt", "I am file 3".getBytes( "UTF-8" )); File dir = InstanceHelpers.findInstanceDirectoryOnAgent( app.getTomcat()); Utils.deleteFilesRecursively( dir ); Assert.assertFalse( dir.exists()); Assert.assertTrue( dir.mkdirs()); Assert.assertTrue( new File( dir, "dir1" ).createNewFile()); try { AgentUtils.copyInstanceResources( app.getTomcat(), fileNameToFileContent ); } finally { Utils.deleteFilesRecursively( dir ); } }
public static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ) throws IOException { File dir = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); Utils.createDirectory( dir ); if( fileNameToFileContent != null ) { for( Map.Entry<String,byte[]> entry : fileNameToFileContent.entrySet()) { File f = new File( dir, entry.getKey()); Utils.createDirectory( f.getParentFile()); ByteArrayInputStream in = new ByteArrayInputStream( entry.getValue()); Utils.copyStream( in, f ); } } }
AgentUtils { public static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ) throws IOException { File dir = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); Utils.createDirectory( dir ); if( fileNameToFileContent != null ) { for( Map.Entry<String,byte[]> entry : fileNameToFileContent.entrySet()) { File f = new File( dir, entry.getKey()); Utils.createDirectory( f.getParentFile()); ByteArrayInputStream in = new ByteArrayInputStream( entry.getValue()); Utils.copyStream( in, f ); } } } }
AgentUtils { public static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ) throws IOException { File dir = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); Utils.createDirectory( dir ); if( fileNameToFileContent != null ) { for( Map.Entry<String,byte[]> entry : fileNameToFileContent.entrySet()) { File f = new File( dir, entry.getKey()); Utils.createDirectory( f.getParentFile()); ByteArrayInputStream in = new ByteArrayInputStream( entry.getValue()); Utils.copyStream( in, f ); } } } private  AgentUtils(); }
AgentUtils { public static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ) throws IOException { File dir = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); Utils.createDirectory( dir ); if( fileNameToFileContent != null ) { for( Map.Entry<String,byte[]> entry : fileNameToFileContent.entrySet()) { File f = new File( dir, entry.getKey()); Utils.createDirectory( f.getParentFile()); ByteArrayInputStream in = new ByteArrayInputStream( entry.getValue()); Utils.copyStream( in, f ); } } } private  AgentUtils(); static boolean isValidIP( String ip ); static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ); static void executeScriptResources( File scriptsDir ); static void deleteInstanceResources( Instance instance ); static void changeRoboconfLogLevel( String logLevel, String etcDir ); static Map<String,byte[]> collectLogs( String karafData ); static String findIpAddress( String networkInterface ); static void injectConfigurations(
			String karafEtc,
			String applicationName,
			String scopedInstancePath,
			String domain,
			String ipAddress ); }
AgentUtils { public static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ) throws IOException { File dir = InstanceHelpers.findInstanceDirectoryOnAgent( instance ); Utils.createDirectory( dir ); if( fileNameToFileContent != null ) { for( Map.Entry<String,byte[]> entry : fileNameToFileContent.entrySet()) { File f = new File( dir, entry.getKey()); Utils.createDirectory( f.getParentFile()); ByteArrayInputStream in = new ByteArrayInputStream( entry.getValue()); Utils.copyStream( in, f ); } } } private  AgentUtils(); static boolean isValidIP( String ip ); static void copyInstanceResources( Instance instance, Map<String,byte[]> fileNameToFileContent ); static void executeScriptResources( File scriptsDir ); static void deleteInstanceResources( Instance instance ); static void changeRoboconfLogLevel( String logLevel, String etcDir ); static Map<String,byte[]> collectLogs( String karafData ); static String findIpAddress( String networkInterface ); static void injectConfigurations(
			String karafEtc,
			String applicationName,
			String scopedInstancePath,
			String domain,
			String ipAddress ); static final String INJECTED_CONFIGS_DIR; }