Skip to content

Commit

Permalink
[WFLY-5403] Update EJBUtil to specify legacy EJB properties when crea…
Browse files Browse the repository at this point in the history
…ting the InitialContext instead of creating a PropertiesBasedEJBClientConfiguration
  • Loading branch information
fjuma committed Jan 31, 2017
1 parent fd58866 commit 639a38a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
Expand Up @@ -22,7 +22,6 @@
package org.jboss.as.test.integration.ejb.remote.security;

import java.net.UnknownHostException;
import java.util.Hashtable;
import java.util.Properties;

import javax.naming.Context;
Expand All @@ -48,12 +47,14 @@ class EJBUtil {
*
* @param beanImplClass
* @param remoteInterface
* @param ejbProperties
* @return
* @throws NamingException
*/
@SuppressWarnings("unchecked")
public static <T> T lookupEJB(Class<? extends T> beanImplClass, Class<T> remoteInterface) throws NamingException {
final Hashtable<String, String> jndiProperties = new Hashtable<String, String>();
public static <T> T lookupEJB(Class<? extends T> beanImplClass, Class<T> remoteInterface, Properties ejbProperties) throws Exception {
final Properties jndiProperties = new Properties();
jndiProperties.putAll(ejbProperties);
jndiProperties.put(Context.URL_PKG_PREFIXES, "org.jboss.ejb.client.naming");
// jndiProperties.put("jboss.naming.client.ejb.context", "true");
final Context context = new InitialContext(jndiProperties);
Expand Down
Expand Up @@ -66,43 +66,31 @@ public static JavaArchive createDeployment() throws IOException {
@Test
public void testDirect() throws Exception {
final Properties ejbClientConfiguration = EJBUtil.createEjbClientConfiguration(Utils.getHost(mgmtClient));
// 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 ejbClientConfiguration

final SecurityInformation targetBean = EJBUtil.lookupEJB(SecuredBean.class, SecurityInformation.class);
final SecurityInformation targetBean = EJBUtil.lookupEJB(SecuredBean.class, SecurityInformation.class, ejbClientConfiguration);

assertEquals("guest", targetBean.getPrincipalName());
}

@Test
public void testUnsecured() throws Exception {
final Properties ejbClientConfiguration = EJBUtil.createEjbClientConfiguration(Utils.getHost(mgmtClient));
// 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 ejbClientConfiguration

final IntermediateAccess targetBean = EJBUtil.lookupEJB(EntryBean.class, IntermediateAccess.class);
final IntermediateAccess targetBean = EJBUtil.lookupEJB(EntryBean.class, IntermediateAccess.class, ejbClientConfiguration);

assertEquals("anonymous", targetBean.getPrincipalName());
}

@Test
public void testSwitched() throws Exception {
final Properties ejbClientConfiguration = EJBUtil.createEjbClientConfiguration(Utils.getHost(mgmtClient));
// 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 ejbClientConfiguration

final IntermediateAccess targetBean = EJBUtil.lookupEJB(EntryBean.class, IntermediateAccess.class);
final IntermediateAccess targetBean = EJBUtil.lookupEJB(EntryBean.class, IntermediateAccess.class, ejbClientConfiguration);

assertEquals("user1", targetBean.getPrincipalName("user1", "password1"));
}

@Test
public void testNotSwitched() throws Exception {
final Properties ejbClientConfiguration = EJBUtil.createEjbClientConfiguration(Utils.getHost(mgmtClient));
// 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 ejbClientConfiguration

final IntermediateAccess targetBean = EJBUtil.lookupEJB(EntryBean.class, IntermediateAccess.class);
final IntermediateAccess targetBean = EJBUtil.lookupEJB(EntryBean.class, IntermediateAccess.class, ejbClientConfiguration);

assertEquals("guest", targetBean.getPrincipalName(null, null));
}
Expand Down

0 comments on commit 639a38a

Please sign in to comment.