Uploaded image for project: 'Thorntail'
  1. Thorntail
  2. THORN-675

Swarm.component() does not work inside a test

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Out of Date
    • 2016.9
    • None
    • core
    • None

    Description

      org.wildfly.swarm.container.ProjectStagesArqTest never calls the ProjectStageInjectable.customize() and the following test presents the following error:

      package org.wildfly.swarm.container;
      
      import java.util.Optional;
      
      import javax.inject.Inject;
      import javax.inject.Singleton;
      
      import org.jboss.arquillian.container.test.api.Deployment;
      import org.jboss.arquillian.junit.Arquillian;
      import org.jboss.shrinkwrap.api.Archive;
      import org.jboss.shrinkwrap.api.ShrinkWrap;
      import org.jboss.shrinkwrap.api.asset.ClassLoaderAsset;
      import org.junit.Assert;
      import org.junit.Test;
      import org.junit.runner.RunWith;
      import org.wildfly.swarm.Swarm;
      import org.wildfly.swarm.arquillian.CreateSwarm;
      import org.wildfly.swarm.spi.api.Customizer;
      import org.wildfly.swarm.spi.api.JARArchive;
      import org.wildfly.swarm.spi.runtime.annotations.ConfigurationValue;
      import org.wildfly.swarm.spi.runtime.annotations.Pre;
      
      /**
       * @author George Gastaldi
       */
      @RunWith(Arquillian.class)
      public class ConfigurationValueProducerTest {
      
          @Deployment(testable = false)
          public static Archive createDeployment() throws Exception {
              JARArchive jarArchive = ShrinkWrap.create(JARArchive.class, "arqDeployment.jar");
              jarArchive.add(new ClassLoaderAsset("project-stages.yml", ConfigurationValueProducerTest.class.getClassLoader()), "project-stages.yml");
              return jarArchive;
          }
      
          @Test
          public void testNothing() {
              // nothing
          }
      
          @CreateSwarm
          public static Swarm createSwarm() throws Exception {
              return new Swarm().component(OptionalServerAddressCustomizer.class);
          }
      
      
          @Pre
          @Singleton
          public static class OptionalServerAddressCustomizer implements Customizer {
      
              @Inject
              @ConfigurationValue("server.address")
              private Optional<String> serverAddress;
      
              @Override
              public void customize() {
                  Assert.assertNotNull(serverAddress);
              }
          }
      }
      
      Caused by: org.jboss.weld.exceptions.DeploymentException: WELD-001408: Unsatisfied dependencies for type Optional<String> with qualifiers @ConfigurationValue
        at injection point [BackedAnnotatedField] @Inject @ConfigurationValue private org.wildfly.swarm.container.ConfigurationValueProducerTest$OptionalServerAddressCustomizer.serverAddress
        at org.wildfly.swarm.container.ConfigurationValueProducerTest$OptionalServerAddressCustomizer.serverAddress(OptionalServerAddressCustomizer.java:0)
      WELD-001475: The following beans match by type, but none have matching qualifiers:
        - Producer Method [Optional<T>] with qualifiers [@Any @ConfigurationValue] declared as [[BackedAnnotatedMethod] @ConfigurationValue @Dependent @Produces org.wildfly.swarm.container.runtime.cdi.ConfigurationValueProducer.produceOptionalConfigValue(InjectionPoint)]
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rhn-support-ggastald George Gastaldi
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: