You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by cl...@apache.org on 2022/03/21 23:00:35 UTC

[activemq-artemis] branch main updated: NO-JIRA fix ManifestTest

This is an automated email from the ASF dual-hosted git repository.

clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git


The following commit(s) were added to refs/heads/main by this push:
     new 2a26e46  NO-JIRA fix ManifestTest
2a26e46 is described below

commit 2a26e46a8c93635222b42107e307c7f17690fdf0
Author: Tiago Bueno <49...@users.noreply.github.com>
AuthorDate: Fri Jan 21 14:38:18 2022 -0300

    NO-JIRA fix ManifestTest
    
    As the test needs the generated jms jars to be verified I moved it from
    unit-tests to smoke-tests.
    Updated the test to look for the correct jars as the originally
    specified does not exist.
    Update the test to assert against Implementation-Version instead of
    ActiveMQ-Version in the manifest file as the ActiveMQ-Version property does not exist.
---
 tests/pom.xml                                      |  4 --
 tests/smoke-tests/pom.xml                          |  3 +-
 .../artemis/tests/smoke/jms}/ManifestTest.java     | 52 ++++++++++++----------
 3 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/tests/pom.xml b/tests/pom.xml
index b248346..016c5e4 100644
--- a/tests/pom.xml
+++ b/tests/pom.xml
@@ -85,10 +85,6 @@
             <configuration>
                <skipTests>${skipUnitTests}</skipTests>
                <argLine>${activemq-surefire-argline}</argLine>
-               <excludes>
-                  <!--todo this test is dependent on the jar so needs to be run post package as an integration test-->
-                  <exclude>**/ManifestTest.java</exclude>
-               </excludes>
             </configuration>
          </plugin>
       </plugins>
diff --git a/tests/smoke-tests/pom.xml b/tests/smoke-tests/pom.xml
index d9f1d01..aa7a305 100644
--- a/tests/smoke-tests/pom.xml
+++ b/tests/smoke-tests/pom.xml
@@ -29,6 +29,7 @@
    <properties>
       <activemq.basedir>${project.basedir}/../../</activemq.basedir>
       <sts-surefire-extra-args />
+      <artemis-distribuiton-lib-dir>-Ddistribution.lib="${activemq.basedir}/artemis-distribution/target/apache-artemis-${project.version}-bin/apache-artemis-${project.version}/lib"</artemis-distribuiton-lib-dir>
    </properties>
 
    <dependencies>
@@ -1209,7 +1210,7 @@
             <artifactId>maven-surefire-plugin</artifactId>
             <configuration>
                <skipTests>${skipSmokeTests}</skipTests>
-               <argLine>${sts-surefire-extra-args} ${activemq-surefire-argline}</argLine>
+               <argLine>${sts-surefire-extra-args} ${activemq-surefire-argline} ${artemis-distribuiton-lib-dir}</argLine>
             </configuration>
          </plugin>
       </plugins>
diff --git a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/misc/ManifestTest.java b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jms/ManifestTest.java
similarity index 57%
rename from tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/misc/ManifestTest.java
rename to tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jms/ManifestTest.java
index c5a9d08..b63af7b 100644
--- a/tests/unit-tests/src/test/java/org/apache/activemq/artemis/tests/unit/jms/misc/ManifestTest.java
+++ b/tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jms/ManifestTest.java
@@ -14,10 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.activemq.artemis.tests.unit.jms.misc;
+package org.apache.activemq.artemis.tests.smoke.jms;
 
 import javax.jms.ConnectionMetaData;
 import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 import java.util.Properties;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
@@ -25,42 +28,43 @@ import java.util.jar.Manifest;
 
 import org.apache.activemq.artemis.core.server.ActiveMQServer;
 import org.apache.activemq.artemis.core.server.ActiveMQServers;
+import org.apache.activemq.artemis.core.version.Version;
 import org.apache.activemq.artemis.jms.client.ActiveMQConnectionMetaData;
-import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
+import org.apache.activemq.artemis.tests.smoke.common.SmokeTestBase;
 import org.jboss.logging.Logger;
 import org.junit.Assert;
 import org.junit.Test;
 
-public class ManifestTest extends ActiveMQTestBase {
+public class ManifestTest extends SmokeTestBase {
 
    private static final Logger log = Logger.getLogger(ManifestTest.class);
-
-
+   private static List<String> jarFiles = new ArrayList<>(Arrays.asList(
+           "artemis-jms-client-", "artemis-jms-server-"));
 
    @Test
    public void testManifestEntries() throws Exception {
-      Properties props = System.getProperties();
-      String userDir = props.getProperty("build.lib");
-
-      log.trace("userDir is " + userDir);
-
-      // The jar must be there
-      File file = new File("build/jars", "activemq-core.jar");
-      Assert.assertTrue(file.exists());
 
-      // Open the jar and load MANIFEST.MF
-      JarFile jar = new JarFile(file);
-      Manifest manifest = jar.getManifest();
+      Properties props = System.getProperties();
+      String distributionLibDir = props.getProperty("distribution.lib");
 
       ActiveMQServer server = ActiveMQServers.newActiveMQServer(createBasicConfig());
-
-      ConnectionMetaData meta = new ActiveMQConnectionMetaData(server.getVersion());
-
-      // Compare the value from ConnectionMetaData and MANIFEST.MF
-      Attributes attrs = manifest.getMainAttributes();
-
-      Assert.assertEquals(meta.getProviderVersion(), attrs.getValue("ActiveMQ-Version"));
+      Version serverVersion = server.getVersion();
+      String serverFullVersion = serverVersion.getFullVersion();
+      ConnectionMetaData meta = new ActiveMQConnectionMetaData(serverVersion);
+
+      for (String jarFile : jarFiles) {
+         // The jar must be there
+         File file = new File(distributionLibDir, jarFile + serverFullVersion + ".jar");
+         Assert.assertTrue(file.exists());
+
+         // Open the jar and load MANIFEST.MF
+         JarFile jar = new JarFile(file);
+         Manifest manifest = jar.getManifest();
+
+         // Compare the value from ConnectionMetaData and MANIFEST.MF
+         Attributes attrs = manifest.getMainAttributes();
+         Assert.assertEquals(meta.getProviderVersion(), attrs.getValue("Implementation-Version"));
+      }
    }
 
-
 }