के साथ इंजेक्शन नहीं दिया गया है, मैं एक स्टेटलेस सत्र बीन का परीक्षण करने के लिए आर्किलीयन का उपयोग करता हूं जिसमें स्पष्ट स्थानीय और दूरस्थ इंटरफ़ेस है। लेकिन परीक्षण में आर्किलियन उस क्षेत्र में कुछ भी "इंजेक्ट" नहीं करता है जिसमें स्थानीय इंटरफ़ेस का प्रकार होता है, लेकिन यह दूरस्थ इंटरफ़ेस के लिए काम करता है।स्पष्टीकरण स्थानीय ईजेबी आर्किलीयन
@Stateless
public class TestServiceImpl implements TestServiceLocal, TestServiceRemote {
public String greet() {
return "hallo";
}
}
दूरस्थ इंटरफ़ेस:
@Remote
public interface TestServiceRemote {
public String greet();
}
स्थान इंटरफ़ेस:
@Local
public interface TestServiceLocal {
public String greet();
}
और यह परीक्षण है:
@RunWith(Arquillian.class)
public class GenericEntityDaoEjbIntegrationTest {
@Deployment
public static JavaArchive createTestArchive()
throws UnsupportedEncodingException {
return ShrinkWrap.create(JavaArchive.class, "test.jar")
.addClasses(
TestServiceLocal.class,
TestServiceRemote.class,
TestServiceImpl.class);
}
@EJB
private TestServiceLocal testServiceLocal;
@EJB
private TestServiceRemote testServiceRemote;
//Will Fail
@Test
public void testTestServiceLocal() {
assertNotNull(this.testServiceLocal);
}
//Success
@Test
public void testTestServiceRemote() {
assertNotNull(this.testServiceRemote);
}
}
मैं उपयोग कर रहा हूँ Arquillian-glassfish एम्बेडेड 1.0.0.CR2, ग्लासफ़िश-एम्बेडडे डी-सब 3.1 और Arquillian-JUnit-कंटेनर 1.0.0.CR5 मेरी पोम के प्रासंगिक हिस्सा है:
<!-- arquillian test -->
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<version>1.0.0.CR5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-container-spi</artifactId>
<version>1.0.0.CR5</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-glassfish-embedded-3.1</artifactId>
<version>1.0.0.CR2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.extras</groupId>
<artifactId>glassfish-embedded-all</artifactId>
<version>3.1</version>
<scope>test</scope>
</dependency>
की इस फ़ाइल (यह किसी अपवाद शामिल नहीं है) के प्रासंगिक हिस्सा है:
10.04.2012 15:38:16 com.sun.ejb.containers.BaseContainer initializeHome
INFO: Portable JNDI names for EJB TestServiceImpl : [java:global/test/TestServiceImpl!de.test.service.TestServiceRemote, java:global/test/TestServiceImpl!de.test.service.TestServiceLocal]
10.04.2012 15:38:16 com.sun.ejb.containers.BaseContainer initializeHome
INFO: Glassfish-specific (Non-portable) JNDI names for EJB TestServiceImpl : [de.test.service.TestServiceRemote, de.test.service.TestServiceRemote#de.test.service.TestServiceRemote]
10.04.2012 15:38:16 com.sun.enterprise.web.WebApplication start
INFO: WEB0671: Loading application [test] at [/test]
10.04.2012 15:38:16 org.glassfish.deployment.admin.DeployCommand execute
INFO: test was successfully deployed in 11.844 milliseconds.
मेरी गलती क्या है? लोकेल इंटरफ़ेस के लिए इंजेक्शन प्राप्त करने के लिए मुझे क्या आवश्यकता है?