Skip to content

Commit

Permalink
[WFLY-5403] Update multinode and manualmode tests to pass EJB propert…
Browse files Browse the repository at this point in the history
…ies to the InitialContext instead of using the legacy properties-based config and custom context selector approach
  • Loading branch information
fjuma committed Feb 3, 2017
1 parent 49fd104 commit 4bae0fe
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 51 deletions.
Expand Up @@ -73,6 +73,21 @@ public static Context createNamingContext() throws NamingException {

}

/**
* Helper to create the InitialContext with the given properties.
*
* @param properties the environment properties
* @return the constructed InitialContext
* @throws NamingException if an error occurs while creating the InitialContext
*/
public static Context createNamingContext(final Properties properties) throws NamingException {
final Properties jndiProps = new Properties();
jndiProps.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
jndiProps.putAll(properties);
return new InitialContext(jndiProps);

}

public static <T> T lookup(final String name, final Class<T> cls) throws NamingException {
InitialContext ctx = new InitialContext();
try {
Expand Down
Expand Up @@ -37,7 +37,6 @@
import org.jboss.as.test.manualmode.ejb.Util;
import org.jboss.as.test.shared.TestSuiteEnvironment;
import org.jboss.dmr.ModelNode;
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
Expand Down Expand Up @@ -98,9 +97,8 @@ public class EJBClientClusterConfigurationTestCase {

@Before
public void before() throws Exception {
this.context = Util.createNamingContext();
// setup the client context selector
setupEJBClientContextSelector();
final Properties ejbClientProperties = setupEJBClientProperties();
this.context = Util.createNamingContext(ejbClientProperties);

}

Expand Down Expand Up @@ -206,24 +204,21 @@ public void testServerToServerClusterFormation() throws Exception {
}

/**
* Sets up the EJB client context to use a selector which processes and sets up EJB receivers
* based on this testcase specific jboss-ejb-client.properties file
* Sets up the EJB client properties based on this testcase specific jboss-ejb-client.properties file
*
* @return
* @throws java.io.IOException
*/
private static EJBClientContext setupEJBClientContextSelector() throws IOException {
// setup the selector
private static Properties setupEJBClientProperties() throws IOException {
// setup the properties
final String clientPropertiesFile = "jboss-ejb-client.properties";
final InputStream inputStream = EJBClientClusterConfigurationTestCase.class.getResourceAsStream(clientPropertiesFile);
if (inputStream == null) {
throw new IllegalStateException("Could not find " + clientPropertiesFile + " in classpath");
}
final Properties properties = new Properties();
properties.load(inputStream);
// TODO Elytron: Once support for legacy EJB properties has been added back, actually set the EJB properties
// that should be used for this test using properties
return null;
return properties;
}

private static ModelControllerClient createModelControllerClient(final String container) throws UnknownHostException {
Expand Down
Expand Up @@ -31,7 +31,6 @@
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.test.manualmode.ejb.Util;
import org.jboss.as.test.shared.util.DisableInvocationTestUtil;
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
Expand Down Expand Up @@ -87,9 +86,8 @@ public static void beforeClass() {

@Before
public void before() throws Exception {
this.context = Util.createNamingContext();
// setup the client context selector
setupEJBClientContextSelector();
final Properties ejbClientProperties = setupEJBClientProperties();
this.context = Util.createNamingContext(ejbClientProperties);
}

@After
Expand Down Expand Up @@ -254,23 +252,20 @@ public void testRemoteServerRestarts() throws Exception {
}

/**
* Sets up the EJB client context to use a selector which processes and sets up EJB receivers
* based on this testcase specific jboss-ejb-client.properties file
* Sets up the EJB client properties based on this testcase specific jboss-ejb-client.properties file
*
* @return
* @throws java.io.IOException
*/
private static EJBClientContext setupEJBClientContextSelector() throws IOException {
// setup the selector
private static Properties setupEJBClientProperties() throws IOException {
// setup the properties
final String clientPropertiesFile = "org/jboss/as/test/manualmode/ejb/client/outbound/connection/jboss-ejb-client.properties";
final InputStream inputStream = RemoteOutboundConnectionReconnectTestCase.class.getClassLoader().getResourceAsStream(clientPropertiesFile);
if (inputStream == null) {
throw new IllegalStateException("Could not find " + clientPropertiesFile + " in classpath");
}
final Properties properties = new Properties();
properties.load(inputStream);
// TODO Elytron: Once support for legacy EJB properties has been added back, actually set the EJB properties
// that should be used for this test using properties
return null;
return properties;
}
}
Expand Up @@ -30,7 +30,6 @@
import org.jboss.arquillian.test.api.ArquillianResource;
import org.jboss.as.test.manualmode.ejb.Util;
import org.jboss.ejb.client.EJBClient;
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.ejb.client.StatelessEJBLocator;

import org.jboss.logging.Logger;
Expand Down Expand Up @@ -85,9 +84,8 @@ public static Archive<?> deploy() {

@Before
public void before() throws Exception {
this.context = Util.createNamingContext();
// setup the client context selector
setupEJBClientContextSelector();
final Properties ejbClientProperties = setupEJBClientProperties();
this.context = Util.createNamingContext(ejbClientProperties);

controller.start(CONTAINER);
log.trace("===appserver started===");
Expand Down Expand Up @@ -169,24 +167,21 @@ private <T> T lookup(final Class<T> remoteClass, final Class<?> beanClass, final
}

/**
* Sets up the EJB client context to use a selector which processes and sets up EJB receivers
* based on this testcase specific jboss-ejb-client.properties file
* Sets up the EJB client properties based on this testcase specific jboss-ejb-client.properties file
*
* @return
* @throws java.io.IOException
*/
private static EJBClientContext setupEJBClientContextSelector() throws IOException {
// setup the selector
private static Properties setupEJBClientProperties() throws IOException {
// setup the properties
final String clientPropertiesFile = "jboss-ejb-client.properties";
final InputStream inputStream = EJBClientReconnectionTestCase.class.getResourceAsStream(clientPropertiesFile);
if (inputStream == null) {
throw new IllegalStateException("Could not find " + clientPropertiesFile + " in classpath");
}
final Properties properties = new Properties();
properties.load(inputStream);
// TODO Elytron: Once support for legacy EJB properties has been added back, actually set the EJB properties
// that should be used for this test using properties
return null;
return properties;
}


Expand Down
Expand Up @@ -36,7 +36,6 @@
import org.jboss.as.test.manualmode.ejb.ssl.beans.StatelessBean;
import org.jboss.as.test.manualmode.ejb.ssl.beans.StatelessBeanRemote;
import org.jboss.as.test.shared.TestSuiteEnvironment;
import org.jboss.ejb.client.EJBClientContext;
import org.jboss.logging.Logger;
import org.jboss.shrinkwrap.api.Archive;
import org.jboss.shrinkwrap.api.ShrinkWrap;
Expand Down Expand Up @@ -112,19 +111,17 @@ public static void prepare() throws Exception {
System.setProperty("jboss.ejb.client.properties.skip.classloader.scan", "true");
}

private static EJBClientContext setupEJBClientContextSelector() throws IOException {
private static Properties setupEJBClientProperties() throws IOException {
log.trace("*** reading EJBClientContextSelector properties");
// setup the selector
// setup the properties
final String clientPropertiesFile = "org/jboss/as/test/manualmode/ejb/ssl/jboss-ejb-client.properties";
final InputStream inputStream = SSLEJBRemoteClientTestCase.class.getClassLoader().getResourceAsStream(clientPropertiesFile);
if (inputStream == null) {
throw new IllegalStateException("Could not find " + clientPropertiesFile + " in classpath");
}
final Properties properties = new Properties();
properties.load(inputStream);
// TODO Elytron: Once support for legacy EJB properties has been added back, actually set the EJB properties
// that should be used for this test using properties
return null;
return properties;
}


Expand All @@ -146,7 +143,6 @@ public void prepareServerOnce() throws Exception {
managementClient = new ManagementClient(client, TestSuiteEnvironment.getServerAddress(), TestSuiteEnvironment.getServerPort(), "http-remoting");
// write SSL realm config to output - debugging purposes
SSLRealmSetupTool.readSSLRealmConfig(managementClient);
setupEJBClientContextSelector();
serverConfigDone = true;
} else {
log.trace("*** Server already prepared, skipping config procedure");
Expand All @@ -160,10 +156,11 @@ public static void tearDown() throws Exception {
SSLRealmSetupTool.tearDown(mClient, container);
}

private Properties getEjbClientContextProperties() {
private Properties getEjbClientContextProperties() throws IOException {
Properties env = new Properties();
env.setProperty(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
env.put("jboss.naming.client.ejb.context", true);
env.putAll(setupEJBClientProperties());
return env;
}

Expand Down
Expand Up @@ -209,7 +209,7 @@ public Context getRemoteContext(ManagementClient managementClient) throws Except
// WildFly naming client doesn't currently handle this property, we need to manually set the EJBClientConfiguration
// in this test for now. We need to revisit this modification when the new WildFly naming client and EJB client are
// being integrated.
createEJBClientConfiguration(managementClient);
final Properties ejbClientProperties = createEJBClientConfiguration(managementClient);

final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
Expand All @@ -219,18 +219,17 @@ public Context getRemoteContext(ManagementClient managementClient) throws Except
env.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
env.put("jboss.naming.client.security.callback.handler.class", CallbackHandler.class.getName());
env.put("jboss.naming.client.ejb.context", true);
env.putAll(ejbClientProperties);
return new InitialContext(env);
}

private void createEJBClientConfiguration(ManagementClient managementClient) {
private Properties createEJBClientConfiguration(ManagementClient managementClient) {
final Properties config = new Properties();
config.put("remote.connections", "default");
config.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
config.put("remote.connection.default.host", managementClient.getWebUri().getHost());
config.put("remote.connection.default.port", String.valueOf(managementClient.getWebUri().getPort()));

// TODO Elytron: Once support for legacy EJB properties has been added back, actually set the EJB properties
// that should be used for this test using config
return config;
}

}
Expand Up @@ -245,7 +245,7 @@ public Context getRemoteContext(ManagementClient managementClient) throws Except
// WildFly naming client doesn't currently handle this property, we need to manually set the EJBClientConfiguration
// in this test for now. We need to revisit this modification when the new WildFly naming client and EJB client are
// being integrated.
createEJBClientConfiguration(managementClient);
final Properties ejbClientProperties = createEJBClientConfiguration(managementClient);

final Properties env = new Properties();
env.put(Context.INITIAL_CONTEXT_FACTORY, org.jboss.naming.remote.client.InitialContextFactory.class.getName());
Expand All @@ -255,17 +255,16 @@ public Context getRemoteContext(ManagementClient managementClient) throws Except
env.put("jboss.naming.client.connect.options.org.xnio.Options.SASL_POLICY_NOPLAINTEXT", "false");
env.put("jboss.naming.client.security.callback.handler.class", CallbackHandler.class.getName());
env.put("jboss.naming.client.ejb.context", true);
env.putAll(ejbClientProperties);
return new InitialContext(env);
}

private void createEJBClientConfiguration(ManagementClient managementClient) {
private Properties createEJBClientConfiguration(ManagementClient managementClient) {
final Properties config = new Properties();
config.put("remote.connections", "default");
config.put("remote.connection.default.connect.options.org.xnio.Options.SASL_POLICY_NOANONYMOUS", "false");
config.put("remote.connection.default.host", managementClient.getWebUri().getHost());
config.put("remote.connection.default.port", String.valueOf(managementClient.getWebUri().getPort()));

// TODO Elytron: Once support for legacy EJB properties has been added back, actually set the EJB properties
// that should be used for this test using config
return config;
}
}

0 comments on commit 4bae0fe

Please sign in to comment.