-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FORGE-1876: WeldServiceRegistry.hasService should call BeanManager.ge…
…tBeans().isEmpty()
- Loading branch information
Showing
6 changed files
with
125 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,5 +13,5 @@ | |
*/ | ||
public interface PlainInterface | ||
{ | ||
|
||
String getValue(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
.../main/java/test/org/jboss/forge/furnace/mocks/services/ProducesPlainInterfaceService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package test.org.jboss.forge.furnace.mocks.services; | ||
|
||
import javax.enterprise.inject.Produces; | ||
|
||
import test.org.jboss.forge.furnace.mocks.PlainInterface; | ||
|
||
/** | ||
* | ||
* @author <a href="ggastald@redhat.com">George Gastaldi</a> | ||
*/ | ||
public class ProducesPlainInterfaceService | ||
{ | ||
@Produces | ||
public PlainInterface produceRawType() | ||
{ | ||
return new PlainInterface() | ||
{ | ||
@Override | ||
public String getValue() | ||
{ | ||
return "Produced"; | ||
} | ||
}; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
tests/src/test/java/test/org/jboss/forge/furnace/services/ProducerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
/** | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package test.org.jboss.forge.furnace.services; | ||
|
||
import javax.inject.Inject; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.forge.arquillian.AddonDependency; | ||
import org.jboss.forge.arquillian.Dependencies; | ||
import org.jboss.forge.arquillian.archive.ForgeArchive; | ||
import org.jboss.forge.furnace.addons.AddonRegistry; | ||
import org.jboss.forge.furnace.repositories.AddonDependencyEntry; | ||
import org.jboss.forge.furnace.services.Imported; | ||
import org.jboss.forge.furnace.spi.ServiceRegistry; | ||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.junit.Assert; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import test.org.jboss.forge.furnace.mocks.PlainInterface; | ||
import test.org.jboss.forge.furnace.mocks.services.ProducesPlainInterfaceService; | ||
|
||
/** | ||
* | ||
* @author <a href="ggastald@redhat.com">George Gastaldi</a> | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class ProducerTest | ||
{ | ||
@Deployment | ||
@Dependencies({ | ||
@AddonDependency(name = "org.jboss.forge.furnace.container:cdi") | ||
}) | ||
public static ForgeArchive getDeployment() | ||
{ | ||
ForgeArchive archive = ShrinkWrap | ||
.create(ForgeArchive.class) | ||
.addBeansXML() | ||
.addClasses(PlainInterface.class, ProducesPlainInterfaceService.class) | ||
.addAsAddonDependencies( | ||
AddonDependencyEntry.create("org.jboss.forge.furnace.container:cdi") | ||
); | ||
return archive; | ||
} | ||
|
||
@Inject | ||
AddonRegistry addonRegistry; | ||
|
||
@Inject | ||
ServiceRegistry serviceRegistry; | ||
|
||
@Test | ||
public void testProducer() | ||
{ | ||
Assert.assertTrue(serviceRegistry.hasService(PlainInterface.class)); | ||
Imported<PlainInterface> services = addonRegistry.getServices(PlainInterface.class); | ||
Assert.assertFalse(services.isUnsatisfied()); | ||
Assert.assertFalse(services.isAmbiguous()); | ||
PlainInterface pi = services.get(); | ||
Assert.assertEquals("Produced", pi.getValue()); | ||
} | ||
} |