Author: ozizka(a)redhat.com
Date: 2009-10-27 23:07:16 -0400 (Tue, 27 Oct 2009)
New Revision: 823
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryCreationTest.java
Log:
* EmbJoprTestCase::isDeployed() updated - now first tries to match ProfileService
deployments by regex + handling of stupid exception thrown ni case of no match.
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-10-28
02:10:23 UTC (rev 822)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EmbjoprTestCase.java 2009-10-28
03:07:16 UTC (rev 823)
@@ -1086,9 +1086,9 @@
* @param deployment - the deployment we are interested in
* @param secured If true, JAAS secured ManagementView is used.
*/
- protected boolean isDeployed(String deployment, boolean secured) throws Exception
+ protected boolean isDeployed(String deploymentName, boolean secured) throws
Exception
{
- deployment = deployment.replace("/",
System.getProperty("file.separator"));
+ deploymentName = deploymentName.replace("/",
System.getProperty("file.separator"));
ManagementView currentProfileView = getCurrentProfileView(secured);
@@ -1098,21 +1098,36 @@
for( String name: deploymentNames )
log.debug(" "+name); /**/
- Set<String> matchingNames =
currentProfileView.getMatchingDeploymentName(deployment);
- log.debug( String.format("Regex '%s' matched %d deployment names.",
deployment, matchingNames.size()) );
- if( matchingNames.size() > 0 )
- return true;
+ log.debug("Querying the profile view for
'"+deploymentName+"'.");
+ try {
+ /*ManagedDeployment managedDeployment = null;
+ log.info("Calling
ManagementView#getDeployment('"+deploymentName+"')");
+ managedDeployment = currentProfileView.getDeployment(deploymentName);
+ return managedDeployment != null; */
- ManagedDeployment managedDeployment = null;
- try {
- log.info("Calling
ManagementView#getDeployment('"+deployment+"')");
- managedDeployment = currentProfileView.getDeployment(deployment);
- } catch (NoSuchDeploymentException e) {
- return false;
+ // Using regexp will hopefully make it bullet-proof for future wild name changes as
was common during AS 5.x developement.
+ String regex = ".*"+deploymentName+".*";
+ Set<String> matchingNames =
currentProfileView.getMatchingDeploymentName(regex);
+ log.debug( String.format("Regex '%s' matched %d deployment
names.", regex, matchingNames.size()) );
+ return matchingNames.size() > 0;
}
+ catch( Exception ex ){
+ if( isNoSuchDeploymentException(ex) ) return false;
+ else throw ex;
+ }
- return managedDeployment != null;
+
}
+
+ private static final boolean isNoSuchDeploymentException( NoSuchDeploymentException ex
){ return true; }
+ private static final boolean isNoSuchDeploymentException( Exception ex ){
+ if( ex.getCause() != null && ex.getCause().getCause() != null
+ && ex.getCause().getCause() instanceof NoSuchDeploymentException ){
+ return true;
+ }
+ return false;
+ }
+
/**
* Get the profile service.
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryCreationTest.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryCreationTest.java 2009-10-28
02:10:23 UTC (rev 822)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/as5/connfactories/ConnFactoryCreationTest.java 2009-10-28
03:07:16 UTC (rev 823)
@@ -96,6 +96,7 @@
//assertTrue("Connection Factory is not deployed (isDeployed() returned
false).", isDeployed(jndiName + "-ds.xml"));
//String deploymentName =
String.format("vfsfile:/home/ondra/work/JOPRembedded/embjopr-svn-trunk/jsfunit/target/jboss5x/deploy/%s-ds.xml",
jndiName.replace('/', '_') );
+ //vfsfile:/home/ondra/work/JOPRembedded/embjopr-svn-trunk/jsfunit/target/jboss5x/deploy/EJtest_CreateTxConnFactory-ds.xml
String deploymentName = jndiName.replace('/', '_');
assertTrue("Connection Factory is not deployed
(isDeployed('"+deploymentName+"') returned false).",
isDeployed(deploymentName));