From df8c6d6e7b2ac29c5f4fa7c7d2da41ee52fd0c9e Mon Sep 17 00:00:00 2001 From: Sean Flanigan Date: Wed, 20 Aug 2014 15:43:46 +1000 Subject: [PATCH] Add fallback to http-remoting for wildfly JNDI --- .../zanata/util/CleanDocumentStorageRule.java | 29 +++++++++++++------ .../resources/conf/standalone_wildfly.xml | 4 +-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/functional-test/src/test/java/org/zanata/util/CleanDocumentStorageRule.java b/functional-test/src/test/java/org/zanata/util/CleanDocumentStorageRule.java index 8fdeb26841..65be8215f0 100644 --- a/functional-test/src/test/java/org/zanata/util/CleanDocumentStorageRule.java +++ b/functional-test/src/test/java/org/zanata/util/CleanDocumentStorageRule.java @@ -1,5 +1,6 @@ package org.zanata.util; +import com.google.common.base.Throwables; import lombok.extern.slf4j.Slf4j; import org.apache.commons.io.FileUtils; import org.junit.rules.ExternalResource; @@ -55,15 +56,25 @@ public static String getDocumentStoragePath() { .lookup("zanata/files/document-storage-directory"); } catch (NamingException e) { - // TODO wildfly jndi remoting is not working - URL testClassRoot = - Thread.currentThread().getContextClassLoader() - .getResource("setup.properties"); - File targetDir = - new File(testClassRoot.getPath()).getParentFile(); - storagePath = - new File(targetDir, "zanata-documents") - .getAbsolutePath(); + try { + // wildfly uses 'http-remoting:' not 'remote:' + rmiPort = 8080+portOffset; + env.put(Context.PROVIDER_URL, "http-remoting://localhost:" + rmiPort); + remoteContext = new InitialContext(env); + storagePath = + (String) remoteContext + .lookup("zanata/files/document-storage-directory"); + } catch (NamingException e1) { + // fall back option: + URL testClassRoot = + Thread.currentThread().getContextClassLoader() + .getResource("setup.properties"); + File targetDir = + new File(testClassRoot.getPath()).getParentFile(); + storagePath = + new File(targetDir, "zanata-documents") + .getAbsolutePath(); + } } } return storagePath; diff --git a/functional-test/src/test/resources/conf/standalone_wildfly.xml b/functional-test/src/test/resources/conf/standalone_wildfly.xml index 1bc3c0cd63..6b4d654027 100644 --- a/functional-test/src/test/resources/conf/standalone_wildfly.xml +++ b/functional-test/src/test/resources/conf/standalone_wildfly.xml @@ -298,7 +298,7 @@ - + @@ -451,4 +451,4 @@ - \ No newline at end of file +