/** * Note that the remote naming tests were not really using the properties submitted to them * by the Properties instance. Instead, the file jboss-ejb-client.properties was read, same as * with the EJB Client API... * @throws Exception */ @Ignore("PR-285 Not working with WildFly 10, didn't investigate further. We probably don't need this...") @Test public void canLookup_testFacadeBean_usingRemoteNaming() throws Exception { // https://docs.jboss.org/author/display/AS72/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project Properties jndiProps = new Properties(); jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); jndiProps.put(Context.PROVIDER_URL, "remote://localhost:14447"); // jndiProps.put("remote.connection.default.port", "8080"); // create a context passing these properties Context ctx = new InitialContext(jndiProps); // Important: We can either use 'java:' as prefix or none TestRemote testRemote = (TestRemote) ctx.lookup("test/TestRemoteInterfaceBean!" + TestRemote.class.getName()); Assert.assertEquals("TestRemoteBean says hello to RemoteNamingWithoutPrefix", testRemote.getGreeting("RemoteNamingWithoutPrefix")); testRemote = (TestRemote) ctx.lookup("java:ee-ear-ear/ee-ear-ejb/TestRemoteBean!" + TestRemote.class.getName()); Assert.assertEquals("TestRemoteBean says hello to RemoteNaming", testRemote.getGreeting("RemoteNaming")); }
/** * Note that the remote naming tests were not really using the properties submitted to them * by the Properties instance. Instead, the file jboss-ejb-client.properties was read, same as * with the EJB Client API... * @throws Exception */ @Ignore("PR-285 Not working with WildFly 10, didn't investigate further. We probably don't need this...") @Test public void canLookup_testFacadeBean_usingRemoteNaming() throws Exception { // https://docs.jboss.org/author/display/AS72/Remote+EJB+invocations+via+JNDI+-+EJB+client+API+or+remote-naming+project Properties jndiProps = new Properties(); jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory"); jndiProps.put(Context.PROVIDER_URL, "remote://localhost:14447"); // jndiProps.put("remote.connection.default.port", "8080"); // create a context passing these properties Context ctx = new InitialContext(jndiProps); // Important: We can either use 'java:' as prefix or none TestRemote testRemote = (TestRemote) ctx.lookup("test/TestRemoteInterfaceBean!" + TestRemote.class.getName()); Assert.assertEquals("TestRemoteBean says hello to RemoteNamingWithoutPrefix", testRemote.getGreeting("RemoteNamingWithoutPrefix")); testRemote = (TestRemote) ctx.lookup("java:ee-ear-ear/ee-ear-ejb/TestRemoteBean!" + TestRemote.class.getName()); Assert.assertEquals("TestRemoteBean says hello to RemoteNaming", testRemote.getGreeting("RemoteNaming")); }
Assert.assertEquals("TestRemoteBean says hello to EjbClientApi", testRemote.getGreeting("EjbClientApi"));
@Test public void canLookup_testFacadeBean_usingEjbClientApi_withoutFile() throws Exception { // Set EJB Client API properties programmatically instead of using // jboss-ejb-client.properties file Properties clientProp = new Properties(); clientProp.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false"); clientProp.put("remote.connections", "default"); clientProp.put("remote.connection.default.port", "18080"); clientProp.put("remote.connection.default.host", "localhost"); // clientProp.put("remote.connection.default.username", "ejbUser"); // clientProp.put("remote.connection.default.password", "ejbPassword"); clientProp.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false"); // Set selector (avoiding usage of jboss-ejb-client.properties file) EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(clientProp); ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc); EJBClientContext.setSelector(selector); final Hashtable<String, String> jndiProperties = new Hashtable<>(); // jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:14447"); jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); final Context context = new InitialContext(jndiProperties); // Important: We need to use the 'ejb:' prefix... TestRemote testRemote = (TestRemote) context.lookup("ejb:/test//TestRemoteInterfaceBean!" + TestRemote.class.getName()); Assert.assertEquals("TestRemoteBean says hello to EjbClientApi", testRemote.getGreeting("EjbClientApi")); }
Assert.assertEquals("TestRemoteBean says hello to EjbClientApi", testRemote.getGreeting("EjbClientApi"));
@Test public void canLookup_testFacadeBean_usingEjbClientApi_withoutFile() throws Exception { // Set EJB Client API properties programmatically instead of using // jboss-ejb-client.properties file Properties clientProp = new Properties(); clientProp.put("remote.connectionprovider.create.options.org.xnio.Options.SSL_ENABLED", "false"); clientProp.put("remote.connections", "default"); clientProp.put("remote.connection.default.port", "18080"); clientProp.put("remote.connection.default.host", "localhost"); // clientProp.put("remote.connection.default.username", "ejbUser"); // clientProp.put("remote.connection.default.password", "ejbPassword"); clientProp.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false"); // Set selector (avoiding usage of jboss-ejb-client.properties file) EJBClientConfiguration cc = new PropertiesBasedEJBClientConfiguration(clientProp); ContextSelector<EJBClientContext> selector = new ConfigBasedEJBClientContextSelector(cc); EJBClientContext.setSelector(selector); final Hashtable<String, String> jndiProperties = new Hashtable<>(); // jndiProperties.put(Context.PROVIDER_URL, "remote://localhost:14447"); jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming"); final Context context = new InitialContext(jndiProperties); // Important: We need to use the 'ejb:' prefix... TestRemote testRemote = (TestRemote) context.lookup("ejb:/test//TestRemoteInterfaceBean!" + TestRemote.class.getName()); Assert.assertEquals("TestRemoteBean says hello to EjbClientApi", testRemote.getGreeting("EjbClientApi")); }
@Test public void canLookup_testFacadeBean_usingServiceLocatorBuilder() throws Exception { JndiServiceLocator loc = ServiceLocatorBuilder.buildRemote() .remoteServer("localhost", 18080) .appName("") .moduleName("test") .createServiceLocator(); // TestRemote testRemote = loc.lookup(TestRemote.class); TestRemote testRemote = loc.lookup("TestRemoteInterfaceBean!" + TestRemote.class.getName()); Assert.assertEquals("TestRemoteBean says hello to ServiceLocatorBuilder", testRemote.getGreeting("ServiceLocatorBuilder")); } }
@Test public void canLookup_testFacadeBean_usingServiceLocatorBuilder() throws Exception { JndiServiceLocator loc = ServiceLocatorBuilder.buildRemote() .remoteServer("localhost", 18080) .appName("") .moduleName("test") .createServiceLocator(); // TestRemote testRemote = loc.lookup(TestRemote.class); TestRemote testRemote = loc.lookup("TestRemoteInterfaceBean!" + TestRemote.class.getName()); Assert.assertEquals("TestRemoteBean says hello to ServiceLocatorBuilder", testRemote.getGreeting("ServiceLocatorBuilder")); } }