Package hudson.plugins.scm_sync_configuration

Examples of hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin


  }

  public void marshal(Object source, HierarchicalStreamWriter writer,
      MarshallingContext context) {
   
    ScmSyncConfigurationPlugin plugin = (ScmSyncConfigurationPlugin)source;
   
    // Since "v1", providing version number in scm sync configuration heading tag
    writer.addAttribute(VERSION_ATTRIBUTE, String.valueOf(getCurrentScmSyncConfigurationVersionNumber()));
 
    if(plugin.getSCM() != null){
      writer.startNode(AbstractMigrator.SCM_TAG);
      writer.addAttribute(AbstractMigrator.SCM_CLASS_ATTRIBUTE, plugin.getSCM().getId());
      writer.endNode();
    }
   
    if(plugin.getScmRepositoryUrl() != null){
      writer.startNode(AbstractMigrator.SCM_REPOSITORY_URL_TAG);
      writer.setValue(plugin.getScmRepositoryUrl());
      writer.endNode();
    }

    writer.startNode(AbstractMigrator.SCM_NO_USER_COMMIT_MESSAGE);
    writer.setValue(Boolean.toString(plugin.isNoUserCommitMessage()));
    writer.endNode();

    writer.startNode(AbstractMigrator.SCM_DISPLAY_STATUS);
    writer.setValue(Boolean.toString(plugin.isDisplayStatus()));
    writer.endNode();

        if(plugin.getCommitMessagePattern() != null){
            writer.startNode(AbstractMigrator.SCM_COMMIT_MESSAGE_PATTERN);
            writer.setValue(plugin.getCommitMessagePattern());
            writer.endNode();
        }

        if(plugin.getManualSynchronizationIncludes() != null){
            writer.startNode(AbstractMigrator.SCM_MANUAL_INCLUDES);
            for(String include : plugin.getManualSynchronizationIncludes()){
                writer.startNode("include");
                writer.setValue(include);
                writer.endNode();
            }
            writer.endNode();
View Full Code Here


   * current ScmSyncConfigurationPlugin instance
   */
  public Object unmarshal(HierarchicalStreamReader reader,
      UnmarshallingContext context) {
   
    ScmSyncConfigurationPlugin plugin;
    if(context.currentObject() == null || !(context.currentObject() instanceof ScmSyncConfigurationPlugin)){
      // This should never happen to get here
      plugin = new ScmSyncConfigurationPlugin();
    } else {
      // Retrieving already instantiated ScmSyncConfiguration plugin into current context ..
      plugin = (ScmSyncConfigurationPlugin)context.currentObject();
    }

    // Retrieving data representation version number
    String version = reader.getAttribute(VERSION_ATTRIBUTE);
    // Before version 1 (version 0), there wasn't any version in the scm sync configuration
    // configuration file
    int versionNumber = 0;
    if(version != null){
      versionNumber = Integer.parseInt(version);
    }
   
    if(versionNumber != getCurrentScmSyncConfigurationVersionNumber()){
      // There will be a data migration ..
      LOGGER.info("Your version of persisted ScmSyncConfigurationPlugin data is not up-to-date (v"+versionNumber+" < v"+getCurrentScmSyncConfigurationVersionNumber()+") : data will be migrated !");
    }
   
    // Calling version's reader to read data representation
    ScmSyncConfigurationPOJO pojo = MIGRATORS[versionNumber].readScmSyncConfigurationPOJO(reader, context);
   
    // Migrating old data into up-to-date data
    // Added "+1" because we take into consideration InitialMigrator
    for(int i=versionNumber+1; i<getCurrentScmSyncConfigurationVersionNumber()+1; i++){
      pojo = MIGRATORS[i].migrate(pojo);
    }
   
    // Populating latest POJO information into ScmSyncConfigurationPlugin
    plugin.loadData(pojo);
   
    return plugin;
  }
View Full Code Here

  @Before
  public void setup() throws Throwable {
    // Instantiating ScmSyncConfigurationPlugin instance for unit tests by using
        // synchronous transactions (instead of an asynchronous ones)
        // => this way, every commit will be processed synchronously !
    ScmSyncConfigurationPlugin scmSyncConfigPluginInstance = new ScmSyncConfigurationPlugin(true);
   
    // Mocking PluginWrapper attached to current ScmSyncConfigurationPlugin instance
    PluginWrapper pluginWrapper = PowerMockito.mock(PluginWrapper.class);
    when(pluginWrapper.getShortName()).thenReturn("scm-sync-configuration");
    // Setting field on current plugin instance
View Full Code Here

    return super.getHudsonRootBaseTemplate();
  }
 
  @Test
  public void shouldCurrentVersionPluginConfigurationFileLoadCorrectly() throws Throwable {
    ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
    assertThat(plugin.getSCM(), is(notNullValue()));
    assertThat(plugin.getSCM().getId(), is(equalTo(ScmSyncSubversionSCM.class.getName())));
  }
View Full Code Here

    assertThat(plugin.getSCM().getId(), is(equalTo(ScmSyncSubversionSCM.class.getName())));
  }
 
  @Test
  public void shouldCurrentVersionPluginConfigurationMigrationBeIdemPotent() throws Throwable {
    ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
   
    // Plugin has been loaded : let's record scm & repository url
    String expectedRepositoryUrl = plugin.getScmRepositoryUrl();
    SCM expectedScm = plugin.getSCM();
   
    // Persisting data
    mockStatic(SaveableListener.class);
    doNothing().when(SaveableListener.class); SaveableListener.fireOnChange((Saveable)notNull(), (XmlFile)notNull());
    plugin.save();
   
    // Then reloading it...
    PluginUtil.loadPlugin(plugin);
   
    // Verifying repositoryUrl & SCM
    assertThat(plugin.getSCM().getId(), is(equalTo(expectedScm.getId())));
    assertThat(plugin.getScmRepositoryUrl(), is(equalTo(expectedRepositoryUrl)));
  }
View Full Code Here

  public void initObjectsUnderTests() throws Throwable{
    this.sscItemListener = new ScmSyncConfigurationItemListener();
    this.sscConfigurationSaveableListener = new ScmSyncConfigurationSaveableListener();

    // Mocking ScmSyncConfigurationPlugin.getStrategyForSaveable()
    ScmSyncConfigurationPlugin sscPlugin = spy(ScmSyncConfigurationPlugin.getInstance());
    sscPlugin.setBusiness(this.sscBusiness);
    PowerMockito.doReturn(ScmSyncConfigurationPlugin.AVAILABLE_STRATEGIES[0]).when(sscPlugin).getStrategyForSaveable(Mockito.any(Saveable.class), Mockito.any(File.class));
  }
View Full Code Here

    return "hudsonRoot0.0.4WithEmptyConfTemplate/";
  }
 
  @Test
  public void should0_0_4_pluginEmptyConfigurationFileShouldLoadCorrectly() throws Throwable {
    ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
    assertThat(plugin.getSCM(), is(notNullValue()));
    assertThat(plugin.getSCM().getId(), is(equalTo(ScmSyncNoSCM.class.getName())));
  }
View Full Code Here

  }
 
  @Test
  // JENKINS-8453 related
  public void should0_0_3_pluginConfigurationFileShouldLoadCorrectly() throws Throwable {
    ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
    assertThat(plugin.getSCM(), is(notNullValue()));
    assertThat(plugin.getSCM().getId(), is(equalTo(ScmSyncSubversionSCM.class.getName())));
  }
View Full Code Here

    assertThat(plugin.getSCM().getId(), is(equalTo(ScmSyncSubversionSCM.class.getName())));
  }
 
  @Test
  public void should0_0_3_pluginConfigurationMigrationBeIdemPotent() throws Throwable {
    ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
   
    // Plugin has been loaded : let's record scm & repository url
    String expectedRepositoryUrl = plugin.getScmRepositoryUrl();
    SCM expectedScm = plugin.getSCM();
   
    // Persisting data
    mockStatic(SaveableListener.class);
    doNothing().when(SaveableListener.class); SaveableListener.fireOnChange((Saveable)notNull(), (XmlFile)notNull());
    plugin.save();
   
    // Then reloading it...
    PluginUtil.loadPlugin(plugin);
   
    // Verifying repositoryUrl & SCM
    assertThat(plugin.getSCM().getId(), is(equalTo(expectedScm.getId())));
    assertThat(plugin.getScmRepositoryUrl(), is(equalTo(expectedRepositoryUrl)));
  }
View Full Code Here

  }
 
  @Test
  // JENKINS-8453 related
  public void should0_0_2_pluginConfigurationFileShouldLoadCorrectly() throws Throwable {
    ScmSyncConfigurationPlugin plugin = ScmSyncConfigurationPlugin.getInstance();
    assertThat(plugin.getSCM(), is(notNullValue()));
    assertThat(plugin.getSCM().getId(), is(equalTo(ScmSyncSubversionSCM.class.getName())));
    assertThat(plugin.getScmRepositoryUrl(), is(equalTo("scm:svn:https://myrepo/synchronizedDirectory/")));
  }
View Full Code Here

TOP

Related Classes of hudson.plugins.scm_sync_configuration.ScmSyncConfigurationPlugin

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.