Author: ozizka(a)redhat.com
Date: 2009-11-10 12:38:40 -0500 (Tue, 10 Nov 2009)
New Revision: 850
Modified:
trunk/jsfunit/pom.xml
trunk/jsfunit/src/main/resources/labels--common.properties
trunk/jsfunit/src/main/resources/labels-jopr-2.3.0.GA.properties
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EjtsSelfTest.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/Labels.java
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EjtsEnvironmentInfo.java
Log:
* JBQA-2770, JBQA-2774:
* Modified the labels-* files which keep the strings for different versions.
* Added Labels class which keeps the strings, depending on versions.
* Added EjtsEnvironmentInfo which probes and stores what versions we are running with
(currently reads from the manifest, where the info is put by Maven).
* EjtsSelfTest is a debugging class, will be removed.
* POM: Added "pause" profile which keeps the server on for 4 minutes.
* POM: Added manifest modification - puts deps versions in there.
Modified: trunk/jsfunit/pom.xml
===================================================================
--- trunk/jsfunit/pom.xml 2009-11-07 07:24:09 UTC (rev 849)
+++ trunk/jsfunit/pom.xml 2009-11-10 17:38:40 UTC (rev 850)
@@ -90,7 +90,7 @@
<!-- Test cases deps. -->
<dependency>
<groupId>org.jboss.qa.jbcache</groupId>
- <artifactId>jboss-cache-testop-client</artifactId>
+ <artifactId>jboss-cache-test-client</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${basedir}/testdata/jbcache/JBossCacheTest-by-fdrabek-client.jar</systemPath>
@@ -102,7 +102,7 @@
<groupId>net.sourceforge.htmlunit</groupId>
<artifactId>htmlunit</artifactId>
<scope>compile</scope>
- <version>2.5</version>
+ <version>2.6</version>
</dependency>
<dependency>
<groupId>rhino</groupId>
@@ -144,19 +144,19 @@
<dependency>
<groupId>javax.faces</groupId>
<artifactId>jsf-api</artifactId>
- <version>1.2</version>
+ <version>1.2</version> <!-- 2.0 -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.jbossas</groupId>
<artifactId>jboss-as-j2se</artifactId>
- <version>5.0.1.GA</version>
+ <version>5.0.1.GA</version> <!-- 5.1.0.GA -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
- <version>2.4</version>
+ <version>2.4</version> <!-- 2.5 -->
<scope>provided</scope>
</dependency>
<dependency>
@@ -169,12 +169,12 @@
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<scope>provided</scope>
- <version>2.8.1</version>
+ <version>2.8.1</version> <!-- 2.9.1 -->
</dependency>
<dependency>
<groupId>jdom</groupId>
<artifactId>jdom</artifactId>
- <version>1.0</version>
+ <version>1.0</version> <!-- 1.1 -->
</dependency>
<dependency>
<groupId>commons-lang</groupId>
@@ -184,13 +184,13 @@
<dependency>
<groupId>org.jboss.integration</groupId>
<artifactId>jboss-profileservice-spi</artifactId>
- <version>5.1.0.GA</version>
+ <version>5.1.0.GA</version> <!-- 5.1.0.SP1 -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.man</groupId>
<artifactId>jboss-metatype</artifactId>
- <version>2.1.0.SP1</version>
+ <version>2.1.0.SP1</version> <!-- 2.1.1.GA -->
<scope>provided</scope>
</dependency>
<dependency>
@@ -208,7 +208,7 @@
<dependency>
<groupId>org.jboss.javaee</groupId>
<artifactId>jboss-javaee</artifactId>
- <version>5.0.1.GA</version>
+ <version>5.0.1.GA</version> <!-- 5.2.0.Beta1 -->
<scope>provided</scope>
</dependency>
</dependencies>
@@ -393,10 +393,10 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
+ <!-- Extract WAR - SEAM bug. -->
<execution>
<id>extract_war_for_cargo</id>
- <phase>package</phase>
- <goals><goal>run</goal></goals>
+ <phase>package</phase>
<goals><goal>run</goal></goals>
<configuration><tasks>
<echo>Exctracting war...</echo>
<move
file="${project.build.directory}/${project.build.finalName}.${project.packaging}"
@@ -405,6 +405,7 @@
dest="${project.build.directory}/${project.build.finalName}.${project.packaging}"/>
</tasks></configuration>
</execution>
+ <!-- Write "Don't kill" to hudson log/ -->
<execution>
<id>dont_kill_appeal</id>
<phase>pre-integration-test</phase>
<goals><goal>run</goal></goals>
@@ -413,6 +414,17 @@
<echo>########################## There's no logging
visible on Hudson during test run.</echo>
</tasks></configuration>
</execution>
+ <!-- Delete the exploded WAR and rename the archive back. -->
+ <execution>
+ <id>rename-the-artifact-back</id>
+ <phase>post-integration-test</phase>
<goals><goal>run</goal></goals>
+ <configuration><tasks>
+ <echo>Renaming exploded war and renaming the zip back to the
artifact name.</echo>
+ <move
file="${project.build.directory}/${project.build.finalName}.${project.packaging}"
toFile="${project.build.directory}/${project.build.finalName}_exploded.${project.packaging}"/>
+ <move
file="${project.build.directory}/${project.build.finalName}_archive.${project.packaging}"
+
toFile="${project.build.directory}/${project.build.finalName}.${project.packaging}"/>
+ </tasks></configuration>
+ </execution>
</executions>
</plugin>
@@ -843,7 +855,26 @@
<build>
<plugins>
- <!-- TODO: Change web.xml to set up MyFaces instead of RichFaces.
+
+ <!-- AntRun - move the modified web.xml - overwrite the original
(MOJO-1453 workaround) . -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <execution>
+ <!-- This has to be named this way, otherwise it would execute AFTER
web.xml XSLT processing. That's Maven. -->
+ <id>move-new-web.xml-overwrite-the-original-one</id>
<!-- move-new-web.xml-overwrite-the-original-one -->
+ <phase>package</phase>
+ <configuration><tasks>
+ <echo>Moving
${project.build.directory}/war/work/org.jboss.jopr/jopr-embedded-jbas5/web.xml to
${project.build.directory}/war/work/org.jboss.jopr/jopr-embedded-jbas5/WEB-INF/web.xml</echo>
+ <move
file="${project.build.directory}/war/work/org.jboss.jopr/jopr-embedded-jbas5/web.xml"
todir="${project.build.directory}/war/work/org.jboss.jopr/jopr-embedded-jbas5/WEB-INF"
/>
+ </tasks></configuration>
+ <goals><goal>run</goal></goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <!-- Change web.xml to set up MyFaces instead of RichFaces.
http://fisheye.jboss.org/browse/EMBJOPR/branches/EmbJopr_1_3_3_MyFaces/co...
<plugin>
<groupId>org.codehaus.mojo</groupId>
@@ -871,24 +902,33 @@
</executions>
</plugin>
- <!-- AntRun - move the modified web.xml - overwrite the original
(MOJO-1453 workaround) . -->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-antrun-plugin</artifactId>
- <executions>
- <execution>
- <!-- This has to be named this way, otherwise it would execute AFTER
web.xml XSLT processing. That's Maven. -->
- <id>delete_bundled_admin_console_war</id> <!--
move-new-web.xml-overwrite-the-original-one -->
- <phase>package</phase>
- <configuration><tasks>
- <echo>Moving
${project.build.directory}/war/work/org.jboss.jopr/jopr-embedded-jbas5/web.xml to
${project.build.directory}/war/work/org.jboss.jopr/jopr-embedded-jbas5/WEB-INF/web.xml</echo>
- <move
file="${project.build.directory}/war/work/org.jboss.jopr/jopr-embedded-jbas5/web.xml"
todir="${project.build.directory}/war/work/org.jboss.jopr/jopr-embedded-jbas5/WEB-INF"
/>
- </tasks></configuration>
- <goals><goal>run</goal></goals>
- </execution>
- </executions>
- </plugin>
+ </plugins>
+ </build>
+ </profile>
+
+ <!-- Sleep after build, before killing JBoss AS. -->
+ <profile>
+ <id>pause</id>
+ <build>
+ <plugins>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-antrun-plugin</artifactId>
+ <executions>
+ <!-- Pause - debug purposes - to be able to inspect JBoss AS
instance made by Cargo. -->
+ <execution>
+ <id>pause-after-tests</id>
+ <phase>integration-test</phase>
<goals><goal>run</goal></goals>
+ <configuration><tasks>
+ <echo>Sleep for a minute...</echo>
+ <sleep seconds="240"/>
+ </tasks></configuration>
+ </execution>
+ </executions>
+ </plugin>
+
</plugins>
</build>
</profile>
@@ -896,7 +936,6 @@
-
<!-- Hudson profile (commented out - hesitating to hard-code version dir to
pom.xml)
<profile>
<id>running-in-hudson</id>
@@ -932,18 +971,27 @@
<resource>
<directory>${basedir}/src/build/resources</directory>
<excludes><exclude>**/*</exclude></excludes>
+ <filtering>true</filtering>
</resource>
</resources>
<plugins>
- <!-- WAR -->
+ <!-- WAR: Add data to manifest, add JBoss Cache client JAR. -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<useCache>false</useCache>
<archive>
+ <manifestEntries>
+ <Test-Test>testvalue</Test-Test>
+ <rhq-version>${rhq.version}</rhq-version>
+ <jopr-version>${jopr.version}</jopr-version>
+ <embjopr-version>${project.version}</embjopr-version>
+ <seam-version>${seam.version}</seam-version>
+ <richfaces-version>${richfaces.version}</richfaces-version>
+ </manifestEntries>
<manifest>
<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
Modified: trunk/jsfunit/src/main/resources/labels--common.properties
===================================================================
--- trunk/jsfunit/src/main/resources/labels--common.properties 2009-11-07 07:24:09 UTC
(rev 849)
+++ trunk/jsfunit/src/main/resources/labels--common.properties 2009-11-10 17:38:40 UTC
(rev 850)
@@ -53,20 +53,21 @@
### Navigation. ###
-
NAV_APPLICATIONS = Applications
##NAV_EJB = EJB Application (EJB JAR)s
-NAV_EJB2 = EJB2 JARs
-NAV_EJB3 = EJB3 JARs
-NAV_EAR = EARs
-NAV_SAR = SARs
+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 = RARs
-NAV_WAR = WARs
-NAV_EMB_WAR = Embedded WARs
-NAV_EMB_RAR = Embedded RARs
+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
+#NAV_EMB_JAR = EJB 2.x Application (EJB JAR)
+
## Non-app resource types.
NAV_SBM = Service Binding Manager
NAV_SBM_SETS = Service Binding Sets
Modified: trunk/jsfunit/src/main/resources/labels-jopr-2.3.0.GA.properties
===================================================================
--- trunk/jsfunit/src/main/resources/labels-jopr-2.3.0.GA.properties 2009-11-07 07:24:09
UTC (rev 849)
+++ trunk/jsfunit/src/main/resources/labels-jopr-2.3.0.GA.properties 2009-11-10 17:38:40
UTC (rev 850)
@@ -2,3 +2,40 @@
JBCACHE_MVCC_ENTITY = "mvcc-entity"
JBCACHE_PESSIMISTIC_SHARED = "pessimistic-shared"
JBCACHE_TIMESTAMPS = "timestamps-cache"
+
+
+
+#
http://fisheye.jboss.org/browse/JOPR/tags/Jopr_2_3_0_EmbJopr_1_2_0-1/modu...
+#r640 - shorten names for deployment ResourceTypes
+# tag Jopr_2_3_0_EmbJopr_1_2_0-1
+
+NAV_EJB2 = EJB2 JARs
+NAV_EJB3 = EJB3 JARs
+NAV_EAR = EARs
+NAV_SAR = SARs
+NAV_MC = MC Beans
+NAV_PAR = PARs
+NAV_RAR = RARs
+NAV_WAR = WARs
+NAV_EMB_WAR = Embedded WARs
+NAV_EMB_RAR = Embedded RARs
+
+
+#
http://fisheye.jboss.org/browse/JOPR/trunk/modules/plugins/jboss-as-5/src...
+# r473 -
+#NAV_EMB_EJB2 = Embedded EJB 2.x Application (EJB JAR)
+#NAV_EMB_EJB3 = Embedded EJB 3.x Application (EJB JAR)
+#NAV_EMB_RAR = Embedded Resource Adaptor (RAR)
+
+# r587 - add new "Web Application Context" ResourceType as child of "Web
Application (WAR)" ResourceType
+
+# r593 - added JBoss Web, Connector, and Virtual Host Resource types; did some misc
cleanup & refactoring of the descriptor and the code
+
+# r598 - "resource adaptor" -> "resource adapter"
+
+# r626 - Script service added.
+
+# r737 - JOPR-172 JVM of the JBossAs added.
+
+# r1042 - rename EAR and WAR ResourceTypes so they have the same names as the EAR and WAR
ResourceTypes in the AS4 plugin (
https://jira.jboss.org/jira/browse/JOPR-320)
+# tag Jopr_2_3_0
Modified: trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EjtsSelfTest.java
===================================================================
--- trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EjtsSelfTest.java 2009-11-07
07:24:09 UTC (rev 849)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/EjtsSelfTest.java 2009-11-10
17:38:40 UTC (rev 850)
@@ -1,6 +1,16 @@
package org.jboss.jopr.jsfunit;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.Map.Entry;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+import java.util.logging.Level;
import org.apache.cactus.ServletTestCase;
import org.jboss.jopr.jsfunit.exceptions.EmbJoprTestException;
import org.jboss.jopr.jsfunit.util.EjtsEnvironmentInfo;
@@ -16,9 +26,24 @@
/** */
public void testEnvironmentInfo() throws EmbJoprTestException, Exception {
+
+
EjtsEnvironmentInfo eei = EjtsEnvironmentInfo.createFromLocalServer();
log.info( eei.toString() );
+
+ log.info("Classloader: "+
EjtsEnvironmentInfo.class.getClassLoader().getClass() );
+ log.info("Classloader: "+
EjtsEnvironmentInfo.class.getClassLoader().toString() );
+
+ log.info("Manifest content: ");
+ InputStream is =
EjtsEnvironmentInfo.class.getResourceAsStream("/META-INF/MANIFEST.MF");
+ logInputStream(is);
+
+
+ log.info("Manifest loaded: ");
+ logManifest( new Manifest( is ) );
+
+
doCompareVersions("2.3.0.GA", "2.4.0-SNAPSHOT", -1);
doCompareVersions("2.4.0.GA", "2.4.0-SNAPSHOT", 1);
doCompareVersions("2.4.1.GA", "2.4.0-SNAPSHOT", 1);
@@ -30,7 +55,8 @@
doCompareVersions("2.4.CR1", "2.4.0", -1);
}
- private void doCompareVersions( String v1, String v2, int expectedSignum ){
+
+ private void doCompareVersions( String v1, String v2, int expectedSignum ){
log.info( String.format("Comparing versions: %s and %s produces: %d",
v1, v2, EjtsEnvironmentInfo.compareVersions(v1, v2) ) );
}
@@ -43,6 +69,33 @@
}
+
+
+
+ private void logManifest( Manifest mf ){
+ Attributes attrs = mf.getMainAttributes();
+ log.info("Manifest attributes: ");
+ for( Entry e : attrs.entrySet() ){
+ log.info( String.format(" %s : %s", e.getKey(), e.getValue() ) );
+ }
+ }
+
+ private void logInputStream( InputStream is ) {
+ try {
+ BufferedReader br = new BufferedReader(new InputStreamReader(is));
+ String line;
+ while (br.ready()) {
+ log.info(" " + br.readLine());
+ }
+ } catch (IOException ex) {
+ log.warn( ex );
+ }
+ finally {
+ try{ is.close(); } catch( Throwable t ){ }
+ }
+ }
+
+
}// 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-07 07:24:09 UTC
(rev 849)
+++ trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/Labels.java 2009-11-10 17:38:40 UTC
(rev 850)
@@ -7,7 +7,6 @@
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.math.NumberUtils;
-import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.jboss.jopr.jsfunit.util.EjtsEnvironmentInfo;
import org.jboss.logging.Logger;
@@ -39,8 +38,9 @@
ret.props = loadProperties("labels--common.properties");
EjtsEnvironmentInfo si = EjtsEnvironmentInfo.getInstance();
- //String joprVersion = JBossASDiscoveryComponent.class.getPackage().getVersion();
- String curJoprVersion = System.getProperty("jopr.version");
+ //String curJoprVersion = JBossASDiscoveryComponent.class.getPackage().getVersion();
+ //String curJoprVersion = System.getProperty("jopr.version");
+ String curJoprVersion = si.getJoprVersion();
@@ -54,13 +54,13 @@
// EAP / AS version.
for( String buildNumber : StringUtils.split("") ){ // TODO: Load
dynamically.
- if( NumberUtils.toLong(buildNumber) > NumberUtils.toLong(si.getBuildNumber()) )
+ if( NumberUtils.toLong(buildNumber) > NumberUtils.toLong(si.getAsBuildNumber())
)
break;
String buildPropsFile =
"labels-"+serverEdition+"-"+buildNumber+".properties";
ret.mergeProperties( loadProperties( buildPropsFile ) ) ;
}
- // JOPR
+ // JOPR - compare versions.
for( String joprVersion : StringUtils.split("2.3.0.GA") ){ // TODO: Load
dynamically.
if( EjtsEnvironmentInfo.compareVersions(joprVersion, curJoprVersion) > 0 )
break;
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-07
07:24:09 UTC (rev 849)
+++
trunk/jsfunit/src/test/java/org/jboss/jopr/jsfunit/util/EjtsEnvironmentInfo.java 2009-11-10
17:38:40 UTC (rev 850)
@@ -19,6 +19,11 @@
package org.jboss.jopr.jsfunit.util;
+import java.net.URL;
+import java.util.jar.Attributes;
+import java.util.jar.Manifest;
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.lang.math.NumberUtils;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.jboss.jopr.jsfunit.JMXUtils;
@@ -37,21 +42,33 @@
}
- private String versionName;
- private String versionNumber;
- private String buildNumber;
+ private String asVersionName;
+ private String asVersionNumber;
+ private String asBuildNumber;
+
+ private String rhqVersion;
private String joprVersion;
+ private String embJoprVersion;
+ private String seamVersion;
+ private String richfacesVersion;
- public String getBuildNumber() { return buildNumber; }
- public String getVersionName() { return versionName; }
- public String getVersionNumber() { return versionNumber; }
+
+ public String getAsBuildNumber() { return asBuildNumber; }
+ public String getAsVersionName() { return asVersionName; }
+ public String getAsVersionNumber() { return asVersionNumber; }
+
+ public String getRhqVersion() { return rhqVersion; }
public String getJoprVersion() { return joprVersion; }
+ public String getEmbJoprVersion() { return embJoprVersion; }
+ public String getRichfacesVersion() { return richfacesVersion; }
+ public String getSeamVersion() { return seamVersion; }
- public boolean isEAP(){ return "EAP".equals( this.versionName ); }
+ public boolean isEAP(){ return "EAP".equals( this.asVersionName ); }
public String toString(){
- return String.format("EJTS environment info:\n versionName: %s\n
versionNumber: %s\n buildNumber: %s\n Jopr Version: %s",
- versionName, versionNumber, buildNumber, joprVersion
+ 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",
+ asVersionName, asVersionNumber, asBuildNumber, rhqVersion, joprVersion,
embJoprVersion, seamVersion, richfacesVersion
);
}
@@ -64,17 +81,45 @@
public static EjtsEnvironmentInfo createFromLocalServer() throws Exception
{
EjtsEnvironmentInfo envInfo = new EjtsEnvironmentInfo();
+
+ // Server info
try {
JMXUtils jmx = JMXUtils.getInstanceForLocalJBoss();
- envInfo.versionName = (String)
jmx.getMBeanAttribute("jboss.system:type=Server", "VersionName");
- envInfo.versionNumber = (String)
jmx.getMBeanAttribute("jboss.system:type=Server", "VersionNumber");
- envInfo.buildNumber = (String)
jmx.getMBeanAttribute("jboss.system:type=Server", "BuildNumber");
+ envInfo.asVersionName = (String)
jmx.getMBeanAttribute("jboss.system:type=Server", "VersionName");
+ envInfo.asVersionNumber = (String)
jmx.getMBeanAttribute("jboss.system:type=Server", "VersionNumber");
+ envInfo.asBuildNumber = (String)
jmx.getMBeanAttribute("jboss.system:type=Server", "BuildNumber");
}catch ( Exception ex ){
throw new Exception("Error getting server info via JMX: "+ex.getMessage(),
ex);
}
- envInfo.joprVersion = System.getProperty("jopr.version");
+ //envInfo.joprVersion = System.getProperty("jopr.version");
+ /*
+ envInfo.joprVersion =
EjtsEnvironmentInfo.class.getPackage().getImplementationVersion();
+ envInfo.embJoprVersion =
EjtsEnvironmentInfo.class.getPackage().getImplementationVersion();
+ /*/
+ //Manifest mf = new Manifest(
EjtsEnvironmentInfo.class.getResourceAsStream("/META-INF/MANIFEST.MF") );
+ // OMG!
http://forums.sun.com/thread.jspa?threadID=642761
+ String classContainer =
EjtsEnvironmentInfo.class.getProtectionDomain().getCodeSource().getLocation().toString();
+ String urlString;
+ if( true /* EXPLODED */ ){
+ urlString = classContainer + "../../META-INF/MANIFEST.MF";
+ }else{
+ urlString = "jar:"+classContainer+"!/META-INF/MANIFEST.MF";
+ }
+
+ URL manifestUrl = new URL( urlString );
+ Manifest manifest = new Manifest(manifestUrl.openStream());
+
+ Attributes attrs = manifest.getMainAttributes();
+ envInfo.rhqVersion = (String) attrs.getValue("rhq-version");
+ envInfo.joprVersion = attrs.getValue("jopr-version");
+ envInfo.embJoprVersion = attrs.getValue("embjopr-version");
+ envInfo.seamVersion = attrs.getValue("seam-version");
+ envInfo.richfacesVersion = attrs.getValue("richfaces-version");
+ //envInfo.Version = attrs.getValue(".version");
+
+
return envInfo;
}
@@ -84,29 +129,78 @@
* Compares two version strings, like compareTo() does.
* TODO: Maven comparison algorithm works bad; Code own one.
*/
- public static int compareVersions(String v1s, String v2s){
+ public static int compareVersions(String aStr, String bStr){
- /*
- int v1n = 0;
- int v2n = 0;
+ //*
+ String[] aParts = StringUtils.split(aStr.toUpperCase(), ".-_");
+ String[] bParts = StringUtils.split(bStr.toUpperCase(), ".-_");
- String[] v1parts = StringUtils.split(v1, ".-");
- String[] v2parts = StringUtils.split(v2, ".-");
+ int aOff= 0;
+ int bOff = 0;
- int longer =
+ //int longer = 0;
+ //for( int i = v1parts.length-1; i >= 0; i--){ }
- for( int i = v1parts.length-1; i >= 0; i--){
- }
+ do {
+ String a = aParts[aOff];
+ String b = bParts[bOff];
+
+ if( "GA".equals(a) ) a = "0";
+ if( "GA".equals(b) ) b = "0";
- throw new UnsupportedOperationException();
- */
+ boolean aIsNum = NumberUtils.isDigits( a );
+ boolean bIsNum = NumberUtils.isDigits( b );
+ Integer aNum = aIsNum ? NumberUtils.createInteger( a ) : null;
+ Integer bNum = bIsNum ? NumberUtils.createInteger( b ) : null;
+ if( aIsNum && bIsNum ){
+ int diff = aNum - bNum;
+ // Different numbers - return the diff.
+ if( diff != 0 ) return diff;
+ // The same numbers - skip to next position.
+ aOff++; bOff++; continue;
+ }
+
+ else if( aIsNum ^ bIsNum ){
+
+ if( aIsNum ){
+ // Skip aditional "decimal" zeros - e.g. 2.0.0.FOO vs. 2.0.BAR .
+ if ( aNum == 0 ){ aOff++; continue; }
+ // A non-zero number is always bigger than any string (except GA).
+ else { return 1; }
+ }
+
+ else /* vice versa for ( bIsNum ) */ {
+ // Skip aditional "decimal" zeros - e.g. 2.0.0.FOO vs. 2.0.BAR .
+ if ( bNum == 0 ){ bOff++; continue; }
+ // A non-zero number is always bigger than any string (except GA).
+ else { return -1; }
+ }
+ }
+
+ // Neither is a number -> Compare two strings.
+ return a.compareTo(b);
+
+
+ } while( aOff < aParts.length && bOff < bParts.length );
+
+ /*
// Maven's algorithm.
DefaultArtifactVersion v1 = new DefaultArtifactVersion(v1s);
DefaultArtifactVersion v2 = new DefaultArtifactVersion(v2s);
return v1.compareTo(v2);
+ /**/
}
+ class VersionInfo{
+ public VersionInfo( String str ){
+
+
+ }
+
+ }
+
+
}// class