@Test public void testProvisionSingleFile() throws Exception { File configFile = createConfigFile(); String pid = getConfigPid( configFile ); Configuration config = mock( Configuration.class ); when( config.getPid() ).thenReturn( pid ); when( this.configAdmin.getConfiguration( eq( pid ), ( String )isNull() ) ).thenReturn( config ); assertTrue( this.configurator.provision( configFile ) ); verify( config ).getPid(); verify( config ).update( any( Dictionary.class ) ); verifyNoMoreInteractions( config ); assertFalse( this.configurator.provision( configFile ) ); verify( config, times( 2 ) ).getPid(); verifyNoMoreInteractions( config ); configFile.setLastModified( System.currentTimeMillis() + 1000 ); assertTrue( this.configurator.provision( configFile ) ); verify( config, times( 3 ) ).getPid(); verify( config, times( 2 ) ).update( any( Dictionary.class ) ); verifyNoMoreInteractions( config ); }
@Override public boolean provision( final File file ) throws IOException { this.log.log( LOG_INFO, "Installing configuration from \"" + file.getName() + "\"..." ); ConfigFileResource resource = new ConfigFileResource( file ); this.log.log( LOG_INFO, "Provisioning configuration \"" + resource.getId() + "\"..." ); return provision( resource ); }
ConfiguratorImpl implements Configurator { @Override public boolean provision( final File file ) throws IOException { this.log.log( LOG_INFO, "Installing configuration from \"" + file.getName() + "\"..." ); ConfigFileResource resource = new ConfigFileResource( file ); this.log.log( LOG_INFO, "Provisioning configuration \"" + resource.getId() + "\"..." ); return provision( resource ); } }
ConfiguratorImpl implements Configurator { @Override public boolean provision( final File file ) throws IOException { this.log.log( LOG_INFO, "Installing configuration from \"" + file.getName() + "\"..." ); ConfigFileResource resource = new ConfigFileResource( file ); this.log.log( LOG_INFO, "Provisioning configuration \"" + resource.getId() + "\"..." ); return provision( resource ); } ConfiguratorImpl(); }
ConfiguratorImpl implements Configurator { @Override public boolean provision( final File file ) throws IOException { this.log.log( LOG_INFO, "Installing configuration from \"" + file.getName() + "\"..." ); ConfigFileResource resource = new ConfigFileResource( file ); this.log.log( LOG_INFO, "Provisioning configuration \"" + resource.getId() + "\"..." ); return provision( resource ); } ConfiguratorImpl(); @Override boolean provision( final File file ); @Override void provisionAll( final File dir ); }
ConfiguratorImpl implements Configurator { @Override public boolean provision( final File file ) throws IOException { this.log.log( LOG_INFO, "Installing configuration from \"" + file.getName() + "\"..." ); ConfigFileResource resource = new ConfigFileResource( file ); this.log.log( LOG_INFO, "Provisioning configuration \"" + resource.getId() + "\"..." ); return provision( resource ); } ConfiguratorImpl(); @Override boolean provision( final File file ); @Override void provisionAll( final File dir ); static final String KEY_CONFIG_DIR; }