Author: ozizka(a)redhat.com
Date: 2009-11-16 15:51:36 -0500 (Mon, 16 Nov 2009)
New Revision: 855
Added:
trunk/jsfunit/src/main/resources/labels-jopr-2.4.0-SNAPSHOT.properties
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstantsLoaded.java
Modified:
trunk/jsfunit/pom.xml
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/Labels.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EjtsEnvironmentInfo.java
trunk/jsfunit/testdata/jboss-configuration/conf/jboss-log4j.xml
Log:
* JBQA-2774 - Modify TS to work with different versions of AS out of the box.
Now the TS checks the versions of AS/EAP, Jopr, EmbJopr etc. and loads the respective
properties files incrementally.
Not sure whether I caught all the differences, let me know if not / feel free to
modify the properties files after consideration.
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-11-11 18:06:00 UTC (rev 854)
+++ trunk/jsfunit/pom.xml 2009-11-16 20:51:36 UTC (rev 855)
@@ -102,7 +102,7 @@
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<scope>compile</scope>
- <version>2.6</version>
+ <version>2.5</version>
</dependency>
<dependency>
<groupId>rhino</groupId>
@@ -125,20 +125,14 @@
<version>1.1.0.GA</version>
<scope>compile</scope>
<exclusions>
- <exclusion>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- </exclusion>
- <exclusion>
- <groupId>net.sourceforge.htmlunit</groupId>
- <artifactId>htmlunit</artifactId>
- </exclusion>
+ <exclusion> <groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId> </exclusion>
+ <exclusion> <groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId> </exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jboss.jsfunit</groupId>
<artifactId>jboss-jsfunit-richfaces</artifactId>
- <version>1.0.0.GA</version>
+ <version>1.1.0.GA</version>
<scope>compile</scope>
</dependency>
<dependency>
Added: trunk/jsfunit/src/main/resources/labels-jopr-2.4.0-SNAPSHOT.properties
===================================================================
--- trunk/jsfunit/src/main/resources/labels-jopr-2.4.0-SNAPSHOT.properties
(rev 0)
+++ trunk/jsfunit/src/main/resources/labels-jopr-2.4.0-SNAPSHOT.properties 2009-11-16
20:51:36 UTC (rev 855)
@@ -0,0 +1,13 @@
+
+## JOPR 2.4.0-SNAPSHOT
+
+NAV_EJB2 = EJB 2.x Application (EJB JAR)s
+NAV_EJB3 = EJB 3.x Application (EJB JAR)s
+NAV_EAR = Enterprise Application (EAR)s
+NAV_SAR = JBoss Service (SAR)s
+NAV_MC = MC Beans
+NAV_PAR = PARs
+NAV_RAR = Resource Adaptor (RAR)s
+NAV_WAR = Web Application (WAR)s
+NAV_EMB_WAR = Embedded Web Application (WAR)s
+NAV_EMB_RAR = Embedded Resource Adaptor (RAR)s
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-11-11
18:06:00 UTC (rev 854)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstants.java 2009-11-16
20:51:36 UTC (rev 855)
@@ -39,6 +39,7 @@
// Nav tree link label, EmbJopr display name, testdata/$dir, extension, suffix, mime
type.
EAR(AppConstants.NAV_EAR, "EARs", "ear",
".ear", null, "application/ear"),
+ //EAR( AppConstantsLoaded.getLabels().get("NAV_EAR"), "EARs",
"ear", ".ear", null, "application/ear"),
WAR(AppConstants.NAV_WAR, "WARs ", "war",
".war", null, "application/war"),
EJB2(AppConstants.NAV_EJB2, "EJB2 JARs", "ejb2",
".jar", null, "application/java-archive"),
EJB3(AppConstants.NAV_EJB3, "EJB3 JARs", "ejb3",
".jar", null, "application/java-archive"),
@@ -128,12 +129,14 @@
//public static final String NAV_EJB = "EJB Application (EJB JAR)s";
public static final String NAV_EJB2 = "EJB2 JARs";
public static final String NAV_EJB3 = "EJB3 JARs";
- public static final String NAV_EAR = "EARs";
+ //public static final String NAV_EAR = "EARs";
+ public static final String NAV_EAR =
AppConstantsLoaded.getLabels().get("NAV_EAR");
public static final String NAV_SAR = "SARs";
public static final String NAV_MC = "MC Beans";
public static final String NAV_PAR = "PARs";
public static final String NAV_RAR = "RARs";
- public static final String NAV_WAR = "WARs";
+ //public static final String NAV_WAR = "WARs";
+ public static final String NAV_WAR =
AppConstantsLoaded.getLabels().get("NAV_WAR");
public static final String NAV_EMB_WAR = "Embedded WARs";
public static final String NAV_EMB_RAR = "Embedded RARs";
Added: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstantsLoaded.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstantsLoaded.java
(rev 0)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/AppConstantsLoaded.java 2009-11-16
20:51:36 UTC (rev 855)
@@ -0,0 +1,25 @@
+
+package org.jboss.jopr.jsfunit;
+
+import org.apache.log4j.*;
+
+
+/**
+ *
+ * @author Ondrej Zizka
+ */
+public class AppConstantsLoaded {
+
+ private static Labels labels;
+ public static Labels getLabels() { return labels; }
+
+
+ static {
+ try {
+ AppConstantsLoaded.labels = Labels.createDefault();
+ } catch (Exception ex) {
+ Logger.getLogger(AppConstantsLoaded.class).error(ex);
+ }
+ }
+
+}// class
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/Labels.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/Labels.java 2009-11-11 18:06:00 UTC
(rev 854)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/Labels.java 2009-11-16 20:51:36 UTC
(rev 855)
@@ -21,10 +21,12 @@
Properties props; // = new Properties();
+ public String get( String name ) { return props.getProperty( name ); }
private Labels(){}
+
/**
* Returns a properties object with labels for the current environment:
* Server edition and version, Jopr version.
@@ -34,18 +36,20 @@
Labels ret = new Labels();
+
// Common
ret.props = loadProperties("labels--common.properties");
- EjtsEnvironmentInfo si = EjtsEnvironmentInfo.getInstance();
+ EjtsEnvironmentInfo envInfo = EjtsEnvironmentInfo.getInstance();
+ log.info("Environment info:\n"+envInfo.toString());
//String curJoprVersion = JBossASDiscoveryComponent.class.getPackage().getVersion();
//String curJoprVersion = System.getProperty("jopr.version");
- String curJoprVersion = si.getJoprVersion();
+ String curJoprVersion = envInfo.getJoprVersion();
// EAP / AS
- String serverEdition = si.isEAP() ? "eap" : "as";
+ String serverEdition = envInfo.isEAP() ? "eap" : "as";
String editionPropsFile = "labels-"+serverEdition+".properties";
ret.mergeProperties( loadProperties( editionPropsFile ) ) ;
@@ -54,14 +58,14 @@
// EAP / AS version.
for( String buildNumber : StringUtils.split("") ){ // TODO: Load
dynamically.
- if( NumberUtils.toLong(buildNumber) > NumberUtils.toLong(si.getAsBuildNumber())
)
+ if( NumberUtils.toLong(buildNumber) >
NumberUtils.toLong(envInfo.getAsBuildNumber()) )
break;
String buildPropsFile =
"labels-"+serverEdition+"-"+buildNumber+".properties";
ret.mergeProperties( loadProperties( buildPropsFile ) ) ;
}
// JOPR - compare versions.
- for( String joprVersion : StringUtils.split("2.3.0.GA") ){ // TODO: Load
dynamically.
+ for( String joprVersion : StringUtils.split("2.3.0.GA 2.4.0-SNAPSHOT") ){ //
TODO: Load dynamically.
if( EjtsEnvironmentInfo.compareVersions(joprVersion, curJoprVersion) > 0 )
break;
String buildPropsFile = "labels-jopr-"+joprVersion+".properties";
@@ -74,6 +78,7 @@
+
/** Merge properties - rewrite old ones with the new ones. */
public void mergeProperties( Properties props ){
for( Entry e : props.entrySet() ){
@@ -85,6 +90,7 @@
/** Loads properties. */
public static Properties loadProperties(String name) throws IOException {
try {
+ log.info("Loading properties from "+name);
InputStream in = getInputStream(name);
Properties props = new Properties();
props.load(in);
Modified:
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EjtsEnvironmentInfo.java
===================================================================
---
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EjtsEnvironmentInfo.java 2009-11-11
18:06:00 UTC (rev 854)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EjtsEnvironmentInfo.java 2009-11-16
20:51:36 UTC (rev 855)
@@ -67,6 +67,7 @@
public boolean isEAP(){ return "EAP".equals( this.asVersionName ); }
+ /** Returns multiline environment info. */
public String toString(){
return String.format("EJTS environment info:\n AS versionName: %s\n AS
versionNumber: %s\n AS buildNumber: %s" +
"\n RHQ Version: %s\n Jopr Version: %s\n EmbJopr Version: %s\n Seam
Version: %s\n RichFaces Version: %s",
@@ -170,12 +171,12 @@
*/
public static int compareVersions(String aStr, String bStr){
- log.info( String.format(" ----- Comparing versions: %s and %s ... ------
", aStr, bStr) );
+ log.debug( String.format(" ----- Comparing versions: %s and %s ... ------
", aStr, bStr) );
final String[] aParts = StringUtils.split(aStr.toUpperCase(), ".-_");
final String[] bParts = StringUtils.split(bStr.toUpperCase(), ".-_");
- log.info( String.format(" aLen = %d, bLen = %d", aParts.length,
bParts.length) );
+ //log.debug( String.format(" aLen = %d, bLen = %d", aParts.length,
bParts.length) );
int aOff = 0;
int bOff = 0;
@@ -183,27 +184,35 @@
//int longer = 0;
//for( int i = v1parts.length-1; i >= 0; i--){ }
+
parts: do {
- String a = aParts[aOff];
- String b = bParts[bOff];
- log.debug( String.format("A[%d] = '%s', B[%d] = '%s'", aOff,
a, bOff, b) );
-
- if( "GA".equals(a) ) a = "0";
- if( "GA".equals(b) ) b = "0";
-
- boolean aIsNum = NumberUtils.isDigits( a );
- boolean bIsNum = NumberUtils.isDigits( b );
- Integer aNum = aIsNum ? NumberUtils.createInteger( a ) : null;
- Integer bNum = bIsNum ? NumberUtils.createInteger( b ) : null;
boolean aIsLast = aOff >= aParts.length - 1;
boolean bIsLast = bOff >= bParts.length - 1;
- log.debug( String.format("A[%d] = '%s', B[%d] = '%s'", aOff,
a, bOff, b) );
+ String a = aParts[aOff];
+ String b = bParts[bOff];
+ // a pseudo-loop - just to use "continue".
thisPart: do {
+ if( StringUtils.equals(a, b) )
+ continue;
+ log.debug( String.format("A[%d] = '%s', B[%d] = '%s'",
aOff, a, bOff, b) );
+
+ if( "GA".equals(a) ) a = "0";
+ if( "GA".equals(b) ) b = "0";
+
+ boolean aIsNum = NumberUtils.isDigits( a );
+ boolean bIsNum = NumberUtils.isDigits( b );
+ Integer aNum = aIsNum ? NumberUtils.createInteger( a ) : null;
+ Integer bNum = bIsNum ? NumberUtils.createInteger( b ) : null;
+
+ log.debug( String.format("A[%d] = '%s', B[%d] = '%s'",
aOff, a, bOff, b) );
+
+
+
if( aIsNum && bIsNum ){
log.debug("aIsNum && bIsNum");
int diff = aNum - bNum;
Modified: trunk/jsfunit/testdata/jboss-configuration/conf/jboss-log4j.xml
===================================================================
--- trunk/jsfunit/testdata/jboss-configuration/conf/jboss-log4j.xml 2009-11-11 18:06:00
UTC (rev 854)
+++ trunk/jsfunit/testdata/jboss-configuration/conf/jboss-log4j.xml 2009-11-16 20:51:36
UTC (rev 855)
@@ -241,7 +241,12 @@
<priority value="DEBUG"/>
</category>
+ <!-- Mute compareVersions()'s debug output. -->
+ <category name="org.jboss.jopr.jsfunit.util.EjtsEnvironmentInfo">
+ <priority value="INFO"/>
+ </category>
+