Skip to content

Commit 525a254

Browse files
committed
ISSUE8 - AlternativesFoodProcessorTest no longer works - back to Weld SE
1 parent a2c4d60 commit 525a254

5 files changed

Lines changed: 83 additions & 6 deletions

File tree

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ allprojects {
7676
slf4jVersion = "1.7.14"
7777
weldEEEmbeddedVersion = "1.0.0.CR3"
7878
weldSEVersion = "2.3.2.Final"
79-
// weldSEVersion = "3.0.0.Alpha14"
79+
// weldSEVersion = "3.0.0.Alpha14"
8080

8181
}
8282

ch02/standalone/build.gradle

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,15 @@ dependencies {
2929

3030
compile "javax:javaee-api:${javaeeVersion}"
3131

32-
// compile "org.jboss.weld.se:weld-se-core:${weldSEVersion}"
33-
compile "org.apache.openwebbeans:openwebbeans-impl:1.6.2"
32+
compile "org.jboss.weld.se:weld-se-core:${weldSEVersion}"
33+
// compile "org.apache.openwebbeans:openwebbeans-impl:1.6.2"
34+
3435
compile "org.slf4j:slf4j-simple:${slf4jVersion}"
3536
compile "org.apache.deltaspike.cdictrl:deltaspike-cdictrl-api:${deltaspikeVersion}"
36-
// compile "org.apache.deltaspike.cdictrl:deltaspike-cdictrl-weld:${deltaspikeVersion}"
37-
compile "org.apache.deltaspike.cdictrl:deltaspike-cdictrl-owb:${deltaspikeVersion}"
37+
compile "org.apache.deltaspike.cdictrl:deltaspike-cdictrl-weld:${deltaspikeVersion}"
38+
39+
// compile "org.apache.deltaspike.cdictrl:deltaspike-cdictrl-owb:${deltaspikeVersion}"
40+
3841
compile "org.apache.deltaspike.modules:deltaspike-test-control-module-api:${deltaspikeVersion}"
3942
testCompile "org.apache.deltaspike.modules:deltaspike-test-control-module-impl:${deltaspikeVersion}"
4043
}

ch02/standalone/src/test/java/je7hb/standalone/AlternativesFoodProcessorTest.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public class AlternativesFoodProcessorTest {
4242

4343
private @Inject FoodProcessor foodProcessor;
4444

45+
@Ignore
4546
@Test
4647
public void shouldInjectAlternative() {
4748
System.out.printf("java.class.path=%s\n", System.getProperty("java.class.path"));
@@ -50,4 +51,10 @@ public void shouldInjectAlternative() {
5051
assertNotNull(foodProcessor);
5152
assertEquals("Xenonique", foodProcessor.sayBrand());
5253
}
54+
55+
56+
@Test
57+
public void shouldInjectAnyFoodProcesor() {
58+
assertNotNull(foodProcessor);
59+
}
5360
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*******************************************************************************
2+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3+
*
4+
* Copyright (c) 2013,2014 by Peter Pilgrim, Addiscombe, Surrey, XeNoNiQUe UK
5+
*
6+
* All rights reserved. This program and the accompanying materials
7+
* are made available under the terms of the GNU GPL v3.0
8+
* which accompanies this distribution, and is available at:
9+
* http://www.gnu.org/licenses/gpl-3.0.txt
10+
*
11+
* Developers:
12+
* Peter Pilgrim -- design, development and implementation
13+
* -- Blog: http://www.xenonique.co.uk/blog/
14+
* -- Twitter: @peter_pilgrim
15+
*
16+
* Contributors:
17+
*
18+
*******************************************************************************/
19+
20+
package je7hb.standalone;
21+
22+
import je7hb.standalone.alternatives.FoodProcessor;
23+
import org.jboss.weld.environment.se.Weld;
24+
import org.jboss.weld.environment.se.WeldContainer;
25+
import org.junit.Test;
26+
27+
import javax.inject.Inject;
28+
29+
import static org.junit.Assert.assertEquals;
30+
import static org.junit.Assert.assertNotNull;
31+
32+
/**
33+
* A unit test AlternativesFoodProcessorTest to verify the operation of AlternativesFoodProcessorTest
34+
*
35+
* @author Peter Pilgrim
36+
*/
37+
38+
// https://deltaspike.apache.org/documentation/test-control.html
39+
40+
public class AlternativesFoodProcessorWeldSETest {
41+
42+
private @Inject FoodProcessor foodProcessor;
43+
44+
@Test
45+
public void shouldInjectAlternative() {
46+
47+
System.out.printf("java.class.path=%s\n", System.getProperty("java.class.path"));
48+
System.out.printf("java.home=%s\n", System.getProperty("java.home"));
49+
System.out.printf("user.dir=%s\n", System.getProperty("user.dir"));
50+
51+
Weld weld = new Weld();
52+
53+
WeldContainer container = weld.initialize();
54+
55+
foodProcessor = container.select(FoodProcessor.class).get();
56+
57+
assertNotNull(foodProcessor);
58+
assertEquals("Xenonique", foodProcessor.sayBrand());
59+
60+
container.shutdown();
61+
}
62+
63+
64+
}

ch02/standalone/src/test/java/je7hb/travelfunk/TravelServiceTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@
2121

2222
import je7hb.standalone.Economy;
2323
import je7hb.standalone.Premium;
24+
import org.apache.deltaspike.testcontrol.api.junit.CdiTestRunner;
2425
import org.junit.Test;
26+
import org.junit.runner.RunWith;
2527

2628
import javax.inject.Inject;
2729

@@ -32,7 +34,8 @@
3234
*
3335
* @author Peter Pilgrim
3436
*/
35-
public class TravelServiceTest extends AbstractCdiContainerTest {
37+
@RunWith(CdiTestRunner.class)
38+
public class TravelServiceTest {
3639

3740
@Inject @Premium TravelService premiumTravelService;
3841
@Inject @Economy TravelService economyTravelService;

0 commit comments

Comments
 (0)