HadoopClusterManager implements RuntimeTestProgressCallback { public JSONObject installDriver( FileItemStream driver ) { boolean success = false; if ( driver != null ) { String destination = Const.getShimDriverDeploymentLocation(); try ( final InputStream driverStream = driver.openStream() ) { FileUtils.copyInputStreamToFile( driverStream, new File( destination + fileSeparator + driver.getFieldName() ) ); success = true; } catch ( IOException e ) { log.logError( e.getMessage() ); } } JSONObject response = new JSONObject(); response.put( INSTALLED, success ); return response; } HadoopClusterManager( Spoon spoon, NamedClusterService namedClusterService, IMetaStore metaStore,
                               String internalShim ); JSONObject importNamedCluster( ThinNameClusterModel model,
                                        Map<String, CachedFileItemStream> siteFilesSource ); JSONObject createNamedCluster( ThinNameClusterModel model,
                                        Map<String, CachedFileItemStream> siteFilesSource ); JSONObject editNamedCluster( ThinNameClusterModel model, boolean isEditMode,
                                      Map<String, CachedFileItemStream> siteFilesSource ); ThinNameClusterModel getNamedCluster( String namedCluster ); JSONObject installDriver( FileItemStream driver ); boolean isValidConfigurationFile( String fileName ); void deleteNamedCluster( IMetaStore metaStore, String namedCluster, boolean refreshTree ); Object runTests( RuntimeTester runtimeTester, String namedCluster ); void onProgress( final RuntimeTestStatus clusterTestStatus ); static final String STRING_NAMED_CLUSTERS; static final String PLACEHOLDER_VALUE; }
@Test public void testInstallDriver() throws IOException { System.getProperties() .setProperty( "SHIM_DRIVER_DEPLOYMENT_LOCATION", "src/test/resources/driver-destination" ); File driverFile = new File( "src/test/resources/driver-source/driver.kar" ); FileItemStream fileItemStream = mock( FileItemStream.class ); when( fileItemStream.getFieldName() ).thenReturn( driverFile.getName() ); when( fileItemStream.getName() ).thenReturn( driverFile.getName() ); when( fileItemStream.openStream() ).thenReturn( new FileInputStream( driverFile ) ); JSONObject response = hadoopClusterManager.installDriver( fileItemStream ); boolean isSuccess = (boolean) response.get( "installed" ); if ( isSuccess ) { File driver = new File( "src/test/resources/driver-destination/driver.kar" ); assertTrue( driver.exists() ); } }