PluginPuppet implements PluginInterface { @Override public void initialize( Instance instance ) throws PluginException { this.logger.fine( this.agentId + " is initializing the plug-in for " + instance.getName()); try { installPuppetModules( instance ); } catch( Exception e ) { throw new PluginException( e ); } }  @Override String getPluginName(); @Override void setNames( String applicationName, String scopedInstancePath ); @Override void initialize( Instance instance ); @Override void deploy( Instance instance ); @Override void start( Instance instance ); @Override void update(Instance instance, Import importChanged, InstanceStatus statusChanged); @Override void stop( Instance instance ); @Override void undeploy( Instance instance ); static final String PLUGIN_NAME; }
@Test public void testInitialize_withVersion() throws Exception { Assume.assumeTrue( this.running ); copyResources( "/with-version" ); File[] subFiles = this.instanceDirectory.listFiles(); Assert.assertNotNull( subFiles ); Assert.assertEquals( 1, subFiles.length ); File moduleDirectory = new File( this.instanceDirectory, "sysctl" ); Assert.assertFalse( moduleDirectory.exists()); this.plugin.initialize( this.inst ); subFiles = this.instanceDirectory.listFiles(); Assert.assertNotNull( subFiles ); Assert.assertEquals( 2, subFiles.length ); Assert.assertTrue( moduleDirectory.exists()); Assert.assertTrue( moduleDirectory.isDirectory()); }
@Test public void testInitialize_withoutVersion() throws Exception { Assume.assumeTrue( this.running ); copyResources( "/without-version" ); File[] moduleDirectories = new File[ 2 ]; moduleDirectories[ 0 ] = new File( this.instanceDirectory, "sysctl" ); moduleDirectories[ 1 ] = new File( this.instanceDirectory, "redis" ); for( File f : moduleDirectories ) Assert.assertFalse( f.getAbsolutePath(), f.exists()); this.plugin.initialize( this.inst ); for( File f : moduleDirectories ) { Assert.assertTrue( f.getAbsolutePath(), f.exists()); Assert.assertTrue( f.getAbsolutePath(), f.isDirectory()); } }
@Test public void testInitialize_inexistingDirectory() throws Exception { Assume.assumeTrue( this.running ); Utils.deleteFilesRecursively( this.instanceDirectory ); this.plugin.initialize( this.inst ); Assert.assertFalse( this.instanceDirectory.exists()); }
@Test( expected = PluginException.class ) public void testInitialize_withInvalidModule() throws Exception { Assume.assumeTrue( this.running ); copyResources( "/with-invalid-module" ); this.plugin.initialize( this.inst ); }