Search in sources :

Example 1 with DefaultTopicProvider

use of com.redhat.jenkins.plugins.ci.messaging.topics.DefaultTopicProvider in project jms-messaging-plugin by jenkinsci.

the class MigrationTest method testAlreadyMigratedConfig.

@LocalData
@Test
public void testAlreadyMigratedConfig() {
    assertEquals("config is not 1", 1, GlobalCIConfiguration.get().getConfigs().size());
    JMSMessagingProvider config = GlobalCIConfiguration.get().getConfigs().get(0);
    ActiveMqMessagingProvider aconfig = (ActiveMqMessagingProvider) config;
    String topic = aconfig.getTopic();
    assertEquals("topic is not CI", "CI", topic);
    assertTrue(aconfig.getTopicProvider() instanceof DefaultTopicProvider);
    AbstractProject<?, ?> triggerJob = (AbstractProject<?, ?>) j.getInstance().getItem("ci-trigger");
    CIBuildTrigger trigger = triggerJob.getTrigger(CIBuildTrigger.class);
    assertNotNull(trigger);
    assertNotNull(triggerJob.getTrigger(CIBuildTrigger.class).getProviderName());
    FreeStyleProject notifierJob = (FreeStyleProject) j.getInstance().getItem("ci-notifier");
    CIMessageBuilder builder = notifierJob.getBuildersList().get(CIMessageBuilder.class);
    assertNotNull(builder);
    assertNotNull(builder.getProviderName());
    assertNotNull(notifierJob.getPublishersList());
    CIMessageNotifier notifierPublisher = notifierJob.getPublishersList().get(CIMessageNotifier.class);
    assertNotNull(notifierPublisher.getProviderName());
    FreeStyleProject subscriberJob = (FreeStyleProject) j.getInstance().getItem("ci-message-subscriber");
    CIMessageSubscriberBuilder subscriberBuilder = subscriberJob.getBuildersList().get(CIMessageSubscriberBuilder.class);
    assertNotNull(subscriberBuilder);
    assertNotNull(subscriberBuilder.getProviderName());
}
Also used : ActiveMqMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.ActiveMqMessagingProvider) JMSMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.JMSMessagingProvider) DefaultTopicProvider(com.redhat.jenkins.plugins.ci.messaging.topics.DefaultTopicProvider) AbstractProject(hudson.model.AbstractProject) FreeStyleProject(hudson.model.FreeStyleProject) LocalData(org.jvnet.hudson.test.recipes.LocalData) Test(org.junit.Test)

Example 2 with DefaultTopicProvider

use of com.redhat.jenkins.plugins.ci.messaging.topics.DefaultTopicProvider in project jms-messaging-plugin by jenkinsci.

the class MigrationTest method testUpgradeFromOnlyUserBaseAuth.

@LocalData
@Test
public void testUpgradeFromOnlyUserBaseAuth() {
    assertEquals("config is not 1", 1, GlobalCIConfiguration.get().getConfigs().size());
    JMSMessagingProvider config = GlobalCIConfiguration.get().getConfigs().get(0);
    ActiveMqMessagingProvider aconfig = (ActiveMqMessagingProvider) config;
    assertNotNull(aconfig.getAuthenticationMethod());
    assertTrue(aconfig.getAuthenticationMethod() instanceof UsernameAuthenticationMethod);
    UsernameAuthenticationMethod authMethod = (UsernameAuthenticationMethod) aconfig.getAuthenticationMethod();
    assertEquals("username should be scott", "scott", authMethod.getUsername());
    assertTrue(aconfig.getTopicProvider() instanceof DefaultTopicProvider);
    GlobalCIConfiguration newGlobalConfig = new GlobalCIConfiguration();
    JMSMessagingProvider config2 = newGlobalConfig.getConfigs().get(0);
    ActiveMqMessagingProvider aconfig2 = (ActiveMqMessagingProvider) config2;
    assertNotNull(aconfig2.getAuthenticationMethod());
}
Also used : ActiveMqMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.ActiveMqMessagingProvider) JMSMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.JMSMessagingProvider) DefaultTopicProvider(com.redhat.jenkins.plugins.ci.messaging.topics.DefaultTopicProvider) UsernameAuthenticationMethod(com.redhat.jenkins.plugins.ci.authentication.activemq.UsernameAuthenticationMethod) LocalData(org.jvnet.hudson.test.recipes.LocalData) Test(org.junit.Test)

Example 3 with DefaultTopicProvider

use of com.redhat.jenkins.plugins.ci.messaging.topics.DefaultTopicProvider in project jms-messaging-plugin by jenkinsci.

the class ActiveMqMessagingProvider method readResolve.

protected Object readResolve() {
    if (user != null) {
        log.info("Legacy Message Provider username value is not null.");
        authenticationMethod = new UsernameAuthenticationMethod(user, password);
        log.info("Added default username/password authentication method using deprecated configuration.");
        setMigrationInProgress(true);
    }
    if (topicProvider == null) {
        topicProvider = new DefaultTopicProvider();
        setMigrationInProgress(true);
    }
    return this;
}
Also used : DefaultTopicProvider(com.redhat.jenkins.plugins.ci.messaging.topics.DefaultTopicProvider) UsernameAuthenticationMethod(com.redhat.jenkins.plugins.ci.authentication.activemq.UsernameAuthenticationMethod)

Example 4 with DefaultTopicProvider

use of com.redhat.jenkins.plugins.ci.messaging.topics.DefaultTopicProvider in project jms-messaging-plugin by jenkinsci.

the class GlobalCIConfiguration method readResolve.

protected Object readResolve() {
    if (broker != null) {
        log.info("Legacy Message Provider Broker value is not null.");
        if (configs.size() == 0) {
            log.info("Current Message Provider size is 0.");
            if (getProvider(DEFAULT_PROVIDER) == null) {
                log.info("There is no default Message Provider.");
                configs.add(new ActiveMqMessagingProvider(DEFAULT_PROVIDER, broker, false, topic, new DefaultTopicProvider(), new UsernameAuthenticationMethod(user, password)));
                log.info("Added default Message Provider using deprecated configuration.");
                setMigrationInProgress(true);
            } else {
                log.info("Default (" + DEFAULT_PROVIDER + ") Message Provider already exists.");
            }
        }
    }
    // Examine providers
    if (configs != null) {
        for (JMSMessagingProvider config : configs) {
            if (config instanceof ActiveMqMessagingProvider) {
                ActiveMqMessagingProvider aconfig = (ActiveMqMessagingProvider) config;
                if (aconfig.IsMigrationInProgress()) {
                    log.info("Migration in progress for ActiveMqMessagingProvider " + aconfig.getName());
                    setMigrationInProgress(true);
                }
            }
        }
    }
    return this;
}
Also used : ActiveMqMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.ActiveMqMessagingProvider) JMSMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.JMSMessagingProvider) DefaultTopicProvider(com.redhat.jenkins.plugins.ci.messaging.topics.DefaultTopicProvider) UsernameAuthenticationMethod(com.redhat.jenkins.plugins.ci.authentication.activemq.UsernameAuthenticationMethod)

Aggregations

DefaultTopicProvider (com.redhat.jenkins.plugins.ci.messaging.topics.DefaultTopicProvider)4 UsernameAuthenticationMethod (com.redhat.jenkins.plugins.ci.authentication.activemq.UsernameAuthenticationMethod)3 ActiveMqMessagingProvider (com.redhat.jenkins.plugins.ci.messaging.ActiveMqMessagingProvider)3 JMSMessagingProvider (com.redhat.jenkins.plugins.ci.messaging.JMSMessagingProvider)3 Test (org.junit.Test)2 LocalData (org.jvnet.hudson.test.recipes.LocalData)2 AbstractProject (hudson.model.AbstractProject)1 FreeStyleProject (hudson.model.FreeStyleProject)1