Bonjour,
je continue mes tests mais je ne comprends pas tous à fait ce que je fait alors, je vous sollicite pour m’aiguiller sur le bon chemin...
voici mon test:
Et mon EJB est le suivant:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package com.sample; import org.jboss.seam.mock.SeamTest; import org.testng.annotations.Test; import com.zanox.adspace.AdspaceOverviewBean; import com.zanox.api.namespace._2009_07_01.AdspaceItem; public class SeamSampleTest extends SeamTest { protected static final AdspaceOverviewBean ADSPACE_OVERVIEW_BEAN = new AdspaceOverviewBean(); protected static AdspaceItem ITEM = null; // @Test(expectedExceptions = Exception.class) @Test public void injectionFieldIsNull() throws Exception { new ComponentTest() { protected void testComponents() throws Exception { setValue("#{user.name}", "toto"); } }.run(); } }
et quand je lance le test, j'obtiens:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66 /** * */ package com.sample; import org.jboss.seam.ScopeType; import org.jboss.seam.annotations.Name; import org.jboss.seam.annotations.Scope; /** * @author j.vacheron * */ @Scope(ScopeType.SESSION) @Name("user") public class User { private String name; private String password; private String username; /** * @return the name */ public String getName() { return name; } /** * @param name * the name to set */ public void setName(String name) { this.name = name; } /** * @return the password */ public String getPassword() { return password; } /** * @param password * the password to set */ public void setPassword(String password) { this.password = password; } /** * @return the username */ public String getUsername() { return username; } /** * @param username * the username to set */ public void setUsername(String username) { this.username = username; } }
mais que se passe-t'il?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31 javax.el.PropertyNotFoundException: Target Unreachable, identifier 'user' resolved to null at org.jboss.el.parser.AstValue.getTarget(AstValue.java:38) at org.jboss.el.parser.AstValue.setValue(AstValue.java:83) at org.jboss.el.ValueExpressionImpl.setValue(ValueExpressionImpl.java:249) at org.jboss.seam.core.Expressions$1.setValue(Expressions.java:117) at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.setValue(AbstractSeamTest.java:152) at com.sample.SeamSampleTest$1.testComponents(SeamSampleTest.java:19) at org.jboss.seam.mock.AbstractSeamTest$ComponentTest.run(AbstractSeamTest.java:162) at com.sample.SeamSampleTest.injectionFieldIsNull(SeamSampleTest.java:27) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:592) at org.testng.internal.MethodHelper.invokeMethod(MethodHelper.java:604) at org.testng.internal.Invoker.invokeMethod(Invoker.java:470) at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:564) at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:830) at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125) at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109) at org.testng.TestRunner.runWorkers(TestRunner.java:678) at org.testng.TestRunner.privateRun(TestRunner.java:624) at org.testng.TestRunner.run(TestRunner.java:495) at org.testng.SuiteRunner.runTest(SuiteRunner.java:300) at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:295) at org.testng.SuiteRunner.privateRun(SuiteRunner.java:275) at org.testng.SuiteRunner.run(SuiteRunner.java:190) at org.testng.TestNG.createAndRunSuiteRunners(TestNG.java:792) at org.testng.TestNG.runSuitesLocally(TestNG.java:765) at org.testng.TestNG.run(TestNG.java:699) at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:73) at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:122)
Partager