Skip to content

Commit 0c5ce6d

Browse files
committed
WICKET-7176 test @ActivatedAlternatives annotation
1 parent 81be31b commit 0c5ce6d

2 files changed

Lines changed: 53 additions & 4 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
package org.apache.wicket.cdi;
18+
19+
import io.github.cdiunit.ActivatedAlternatives;
20+
import jakarta.enterprise.inject.spi.BeanManager;
21+
import jakarta.inject.Inject;
22+
import org.apache.wicket.cdi.testapp.AlternativeTestAppScope;
23+
import org.apache.wicket.cdi.testapp.TestPage;
24+
import org.junit.jupiter.api.Test;
25+
26+
27+
/**
28+
* @author pedrosans
29+
*/
30+
@ActivatedAlternatives(AlternativeTestAppScope.class)
31+
class AlternativeCdiConfigurationTest extends WicketCdiTestCase
32+
{
33+
@Inject
34+
BeanManager beanManager;
35+
36+
@Test
37+
void testApplicationScope()
38+
{
39+
configure(new CdiConfiguration());
40+
tester.startPage(TestPage.class);
41+
tester.assertLabel("appscope", "Alternative ok");
42+
}
43+
44+
@Test
45+
void testUsesCdiJUnitConfiguration()
46+
{
47+
configure(new CdiConfiguration().setBeanManager(beanManager));
48+
tester.startPage(TestPage.class);
49+
tester.assertLabel("appscope", "Alternative ok");
50+
}
51+
52+
}

wicket-cdi-tests/src/test/java/org/apache/wicket/cdi/CdiConfigurationTest.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@
1616
*/
1717
package org.apache.wicket.cdi;
1818

19-
import io.github.cdiunit.ActivatedAlternatives;
2019
import jakarta.enterprise.inject.spi.BeanManager;
2120
import jakarta.inject.Inject;
2221
import org.apache.wicket.Application;
23-
import org.apache.wicket.cdi.testapp.AlternativeTestAppScope;
2422
import org.apache.wicket.cdi.testapp.ModelWithInjectedDependency;
2523
import org.apache.wicket.cdi.testapp.TestConversationPage;
2624
import org.apache.wicket.cdi.testapp.TestPage;
@@ -32,7 +30,6 @@
3230
/**
3331
* @author jsarman
3432
*/
35-
@ActivatedAlternatives(AlternativeTestAppScope.class)
3633
class CdiConfigurationTest extends WicketCdiTestCase
3734
{
3835
@Inject
@@ -51,7 +48,7 @@ void testUsesCdiJUnitConfiguration()
5148
{
5249
configure(new CdiConfiguration().setBeanManager(beanManager));
5350
tester.startPage(TestPage.class);
54-
tester.assertLabel("appscope", "Alternative ok");
51+
tester.assertLabel("appscope", "Test ok");
5552
}
5653

5754
@Test

0 commit comments

Comments
 (0)