Search in sources :

Example 6 with ActiveMqMessagingProvider

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

the class AmqMessagingPluginWithFailoverIntegrationTest method setUp.

@Before
public void setUp() throws Exception {
    amq = docker.create();
    GlobalCIConfiguration gcc = GlobalCIConfiguration.get();
    gcc.setConfigs(Collections.singletonList(new ActiveMqMessagingProvider(SharedMessagingPluginIntegrationTest.DEFAULT_PROVIDER_NAME, createFailoverUrl(amq.getBroker()), true, "CI", null, new UsernameAuthenticationMethod("admin", Secret.fromString("redhat")))));
// TODO test connection. WebClient? Rest?
}
Also used : ActiveMqMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.ActiveMqMessagingProvider) UsernameAuthenticationMethod(com.redhat.jenkins.plugins.ci.authentication.activemq.UsernameAuthenticationMethod) GlobalCIConfiguration(com.redhat.jenkins.plugins.ci.GlobalCIConfiguration) Before(org.junit.Before)

Example 7 with ActiveMqMessagingProvider

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

the class JcascTest method load.

@Test
@ConfiguredWithCode("JcascTest/casc.yaml")
public void load() {
    GlobalCIConfiguration gc = GlobalCIConfiguration.get();
    FedMsgMessagingProvider fedMsg = (FedMsgMessagingProvider) gc.getProvider("Fedora messages");
    assertEquals("org.fedora.bar", fedMsg.getTopic());
    assertEquals("tcp://example.com:5678", fedMsg.getHubAddr());
    assertEquals("tcp://example.com:6789", fedMsg.getPubAddr());
    ActiveMqMessagingProvider amq = (ActiveMqMessagingProvider) gc.getProvider("Active MQ");
    assertEquals("foo.com:4242", amq.getBroker());
    assertEquals("active.mq.com", amq.getTopic());
    assertThat(amq.getTopicProvider(), Matchers.instanceOf(DefaultTopicProvider.class));
    assertEquals(false, amq.getUseQueues());
    UsernameAuthenticationMethod amqam = (UsernameAuthenticationMethod) amq.getAuthenticationMethod();
    assertEquals("foo", amqam.getUsername());
    assertEquals("bar", amqam.getPassword().getPlainText());
    RabbitMQMessagingProvider rmq = (RabbitMQMessagingProvider) gc.getProvider("Rabbit MQ");
    assertEquals("ex", rmq.getExchange());
    assertEquals("rabbitmq.example.com", rmq.getHostname());
    assertEquals(4545, rmq.getPortNumber().intValue());
    assertEquals("foo.bar", rmq.getQueue());
    assertEquals("baz", rmq.getTopic());
    assertEquals("rabbitvh.example.com", rmq.getVirtualHost());
    SSLCertificateAuthenticationMethod rmqam = (SSLCertificateAuthenticationMethod) rmq.getAuthenticationMethod();
    assertEquals("/tmp/key", rmqam.getKeystore());
    assertEquals("/tmp/trust", rmqam.getTruststore());
    assertEquals("keypwd", rmqam.getKeypwd().getPlainText());
    assertEquals("trustpwd", rmqam.getTrustpwd().getPlainText());
}
Also used : ActiveMqMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.ActiveMqMessagingProvider) RabbitMQMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.RabbitMQMessagingProvider) DefaultTopicProvider(com.redhat.jenkins.plugins.ci.messaging.topics.DefaultTopicProvider) UsernameAuthenticationMethod(com.redhat.jenkins.plugins.ci.authentication.activemq.UsernameAuthenticationMethod) SSLCertificateAuthenticationMethod(com.redhat.jenkins.plugins.ci.authentication.rabbitmq.SSLCertificateAuthenticationMethod) FedMsgMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.FedMsgMessagingProvider) Test(org.junit.Test) ConfiguredWithCode(io.jenkins.plugins.casc.misc.ConfiguredWithCode)

Example 8 with ActiveMqMessagingProvider

use of com.redhat.jenkins.plugins.ci.messaging.ActiveMqMessagingProvider 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)

Example 9 with ActiveMqMessagingProvider

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

the class CIBuildTrigger method readResolve.

@Override
protected Object readResolve() {
    if (providers == null) {
        log.info("Migrating CIBuildTrigger for job '" + getJobName() + "'.");
        providers = new ArrayList<>();
        if (providerData == null) {
            if (providerName == null) {
                log.info("Provider is null for trigger for job '" + getJobName() + "'.");
                JMSMessagingProvider provider = GlobalCIConfiguration.get().getConfigs().get(0);
                if (provider != null) {
                    providerName = provider.getName();
                    providerUpdated = true;
                    saveJob();
                }
            }
            JMSMessagingProvider provider = GlobalCIConfiguration.get().getProvider(providerName);
            if (provider != null) {
                if (provider instanceof ActiveMqMessagingProvider) {
                    log.info("Creating '" + providerName + "' trigger provider data for job '" + getJobName() + "'.");
                    ActiveMQSubscriberProviderData a = new ActiveMQSubscriberProviderData(providerName);
                    a.setSelector(selector);
                    a.setOverrides(overrides);
                    a.setChecks(checks);
                    providers.add(a);
                    providerUpdated = true;
                    saveJob();
                } else if (provider instanceof FedMsgMessagingProvider) {
                    log.info("Creating '" + providerName + "' trigger provider data for job '" + getJobName() + "'.");
                    FedMsgSubscriberProviderData f = new FedMsgSubscriberProviderData(providerName);
                    f.setOverrides(overrides);
                    f.setChecks(checks);
                    providers.add(f);
                    providerUpdated = true;
                    saveJob();
                }
            } else {
                log.warning("Unable to find provider '" + providerName + "', so unable to upgrade job.");
            }
        } else {
            providers.add(providerData);
            providerUpdated = true;
            saveJob();
        }
    }
    return this;
}
Also used : FedMsgSubscriberProviderData(com.redhat.jenkins.plugins.ci.provider.data.FedMsgSubscriberProviderData) ActiveMqMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.ActiveMqMessagingProvider) ActiveMQSubscriberProviderData(com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData) JMSMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.JMSMessagingProvider) FedMsgMessagingProvider(com.redhat.jenkins.plugins.ci.messaging.FedMsgMessagingProvider)

Aggregations

ActiveMqMessagingProvider (com.redhat.jenkins.plugins.ci.messaging.ActiveMqMessagingProvider)9 UsernameAuthenticationMethod (com.redhat.jenkins.plugins.ci.authentication.activemq.UsernameAuthenticationMethod)6 JMSMessagingProvider (com.redhat.jenkins.plugins.ci.messaging.JMSMessagingProvider)5 DefaultTopicProvider (com.redhat.jenkins.plugins.ci.messaging.topics.DefaultTopicProvider)4 Test (org.junit.Test)4 GlobalCIConfiguration (com.redhat.jenkins.plugins.ci.GlobalCIConfiguration)3 Before (org.junit.Before)3 LocalData (org.jvnet.hudson.test.recipes.LocalData)3 FedMsgMessagingProvider (com.redhat.jenkins.plugins.ci.messaging.FedMsgMessagingProvider)2 ActiveMQSubscriberProviderData (com.redhat.jenkins.plugins.ci.provider.data.ActiveMQSubscriberProviderData)2 AbstractProject (hudson.model.AbstractProject)2 FreeStyleProject (hudson.model.FreeStyleProject)2 SSLCertificateAuthenticationMethod (com.redhat.jenkins.plugins.ci.authentication.rabbitmq.SSLCertificateAuthenticationMethod)1 ActiveMQContainer (com.redhat.jenkins.plugins.ci.integration.fixtures.ActiveMQContainer)1 RabbitMQMessagingProvider (com.redhat.jenkins.plugins.ci.messaging.RabbitMQMessagingProvider)1 FedMsgSubscriberProviderData (com.redhat.jenkins.plugins.ci.provider.data.FedMsgSubscriberProviderData)1 ConfiguredWithCode (io.jenkins.plugins.casc.misc.ConfiguredWithCode)1