You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2022/01/25 16:28:08 UTC

[GitHub] [activemq-artemis] tlbueno opened a new pull request #3929: NO-JIRA - fix ManifestTest to look for the correct client jms jar files / move it from unit to integration tests

tlbueno opened a new pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929


   This PR contains a fix to the jms jar manifest test:
   - As the test needs the generated jms jars to be verified I moved it from unit-tests to integration-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.
   
   @brusdev could you review ??


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3929: NO-JIRA - fix ManifestTest to look for the correct client jms jar files / move it from unit to integration tests

Posted by GitBox <gi...@apache.org>.
gemmellr commented on a change in pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929#discussion_r798477756



##########
File path: tests/integration-tests/pom.xml
##########
@@ -557,7 +557,10 @@
                   <exclude>**/ReplicatedJMSFailoverTest.java</exclude>
                   <exclude>org.apache.activemq/tests/util/*.java</exclude>
                </excludes>
-               <argLine>-Djgroups.bind_addr=::1 ${activemq-surefire-argline} ${its-surefire-extra-args} -Dorg.apache.activemq.SERIALIZABLE_PACKAGES="java.lang,javax.security,java.util,org.apache.activemq,org.fusesource.hawtbuf"</argLine>
+               <argLine>-Djgroups.bind_addr=::1 ${activemq-surefire-argline} ${its-surefire-extra-args}
+                  -Dorg.apache.activemq.SERIALIZABLE_PACKAGES="java.lang,javax.security,java.util,org.apache.activemq,org.fusesource.hawtbuf"
+                  -Dbuild.lib="${activemq.basedir}/artemis-distribution/target/apache-artemis-${project.version}-bin/apache-artemis-${project.version}/lib"

Review comment:
       I dont think the integration-tests module has a ordered dependency on the artemis-distribution module to ensure it is always built before the tests are run. Even if it did, it wouldnt necessarily mean it was packaged, so this property value is questionable.

##########
File path: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ManifestTest.java
##########
@@ -31,36 +24,44 @@
 import org.junit.Assert;
 import org.junit.Test;
 
+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;
+import java.util.jar.Manifest;
+
 public class ManifestTest extends ActiveMQTestBase {
 
    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();
-
       ActiveMQServer server = ActiveMQServers.newActiveMQServer(createBasicConfig());
-
       ConnectionMetaData meta = new ActiveMQConnectionMetaData(server.getVersion());
 
-      // Compare the value from ConnectionMetaData and MANIFEST.MF
-      Attributes attrs = manifest.getMainAttributes();
+      for (String jarFile : jarFiles) {
+         // The jar must be there
+         File file = new File(userDir, jarFile + meta.getProviderVersion() + ".jar");
+         Assert.assertTrue(file.exists());

Review comment:
       The jar may not have been packaged before the integration tests are run (the tests are always run against the classes when built in the same reactor, not jars). That, coupled with the reactor ordering issue from my earlier comment, make this assertion questionable. It would really need to be an Assume check instead I think.
   
   The smoke tests module does depend on the actual distribution module, and already fails during execution if it doesnt find it built locally, so I think it may be a better place for this test which requires a packaged jar. You then wounldt even need the 'build.lib' property to be defined and the test could use a specific path (as e.g other smoke tests do).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3929: NO-JIRA - fix ManifestTest to look for the correct client jms jar files / move it from unit to integration tests

Posted by GitBox <gi...@apache.org>.
gemmellr commented on a change in pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929#discussion_r798485877



##########
File path: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ManifestTest.java
##########
@@ -31,36 +24,44 @@
 import org.junit.Assert;
 import org.junit.Test;
 
+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;
+import java.util.jar.Manifest;
+
 public class ManifestTest extends ActiveMQTestBase {
 
    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();
-
       ActiveMQServer server = ActiveMQServers.newActiveMQServer(createBasicConfig());
-
       ConnectionMetaData meta = new ActiveMQConnectionMetaData(server.getVersion());
 
-      // Compare the value from ConnectionMetaData and MANIFEST.MF
-      Attributes attrs = manifest.getMainAttributes();
+      for (String jarFile : jarFiles) {
+         // The jar must be there
+         File file = new File(userDir, jarFile + meta.getProviderVersion() + ".jar");
+         Assert.assertTrue(file.exists());

Review comment:
       The jar may not have been packaged before the integration tests are run (the tests are always run against the classes when built in the same reactor, not jars). That, coupled with the reactor ordering issue from my earlier comment, make this assertion questionable. It would really need to be an Assume check instead I think if remaining in the integration-tests module.
   
   However, the smoke tests module _does_ depend on the actual distribution module, and already fails during execution if it doesnt find it built locally, so I think it may be a better place for this test which requires a packaged jar. You then wouldn't even need the 'build.lib' property to be defined and the test could use a specific path (as e.g other smoke tests do).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] tlbueno commented on a change in pull request #3929: NO-JIRA - fix ManifestTest

Posted by GitBox <gi...@apache.org>.
tlbueno commented on a change in pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929#discussion_r824974558



##########
File path: tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jms/ManifestTest.java
##########
@@ -14,53 +14,58 @@
  * 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.Properties;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 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();
 
       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);
+
+      String distributionDir = basedir + "/../../artemis-distribution/target/apache-artemis-" +
+         serverFullVersion + "-bin/apache-artemis-" + serverFullVersion;

Review comment:
       Ok, so I added the property in the smoke test pom. So, @brusdev @gemmellr let me know if any other change will be required.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3929: NO-JIRA - fix ManifestTest

Posted by GitBox <gi...@apache.org>.
gemmellr commented on a change in pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929#discussion_r824777407



##########
File path: tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jms/ManifestTest.java
##########
@@ -14,53 +14,58 @@
  * 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.Properties;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 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();
 
       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);
+
+      String distributionDir = basedir + "/../../artemis-distribution/target/apache-artemis-" +
+         serverFullVersion + "-bin/apache-artemis-" + serverFullVersion;

Review comment:
       Not offhand no, I actually thought the smoke tests bits already had that value, but it seems like its actually only artemis-maven-plugin that does (perhaps from [1]) which in turn puts it in the generated profile file as you noted, with the smoke tests only knowing the path to the configs. So adding a 'distribution lib' style property in the pom as you had before may indeed be the simplest for now after all unfortunately.
   
   [1] https://github.com/apache/activemq-artemis/blob/2.20.0/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java#L66




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] tlbueno commented on a change in pull request #3929: NO-JIRA - fix ManifestTest

Posted by GitBox <gi...@apache.org>.
tlbueno commented on a change in pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929#discussion_r824692227



##########
File path: tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jms/ManifestTest.java
##########
@@ -14,53 +14,58 @@
  * 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.Properties;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 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();
 
       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);
+
+      String distributionDir = basedir + "/../../artemis-distribution/target/apache-artemis-" +
+         serverFullVersion + "-bin/apache-artemis-" + serverFullVersion;

Review comment:
       @gemmellr I made few changes as you suggested. Moved it from integration to smoke. Now there is no need for the build.lib paramerter but I didn't find a way to get the artemis-distribution path. If I use the artemis-maven-plugin to generate a server the generated server folder has a profile file that points to the distrubution directory where I can look for the jars inside the lib directory but I cannot find a way to retrieve this directory in the code. So, for now as you can see it is partially hardcoded. Any suggestions to void this hardcoded part?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3929: NO-JIRA - fix ManifestTest

Posted by GitBox <gi...@apache.org>.
gemmellr commented on a change in pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929#discussion_r825757340



##########
File path: tests/smoke-tests/pom.xml
##########
@@ -28,7 +28,7 @@
 
    <properties>
       <activemq.basedir>${project.basedir}/../../</activemq.basedir>
-      <sts-surefire-extra-args />
+      <sts-surefire-extra-args>-Ddistribution.lib="${activemq.basedir}/artemis-distribution/target/apache-artemis-${project.version}-bin/apache-artemis-${project.version}/lib"</sts-surefire-extra-args>

Review comment:
       This isnt the right place to declare this, as its used as a profile property to add extra args on JVMs that need them [1], so putting it here actually means those JVMs wont get this config. Add a specific property for this and reference it in the surefire config at: https://github.com/apache/activemq-artemis/blob/main/tests/smoke-tests/pom.xml#L1335
   
   [1] https://github.com/apache/activemq-artemis/blob/main/tests/smoke-tests/pom.xml#L1348




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] clebertsuconic merged pull request #3929: NO-JIRA - fix ManifestTest

Posted by GitBox <gi...@apache.org>.
clebertsuconic merged pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] brusdev commented on pull request #3929: NO-JIRA - fix ManifestTest to look for the correct client jms jar files / move it from unit to integration tests

Posted by GitBox <gi...@apache.org>.
brusdev commented on pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929#issuecomment-1028678918


   @tlbueno thanks for this fix, could you add `NO-JIRA` prefix to the commit message and rebase the branch?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] tlbueno commented on a change in pull request #3929: NO-JIRA - fix ManifestTest to look for the correct client jms jar files / move it from unit to integration tests

Posted by GitBox <gi...@apache.org>.
tlbueno commented on a change in pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929#discussion_r798606927



##########
File path: tests/integration-tests/src/test/java/org/apache/activemq/artemis/tests/integration/jms/ManifestTest.java
##########
@@ -31,36 +24,44 @@
 import org.junit.Assert;
 import org.junit.Test;
 
+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;
+import java.util.jar.Manifest;
+
 public class ManifestTest extends ActiveMQTestBase {
 
    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();
-
       ActiveMQServer server = ActiveMQServers.newActiveMQServer(createBasicConfig());
-
       ConnectionMetaData meta = new ActiveMQConnectionMetaData(server.getVersion());
 
-      // Compare the value from ConnectionMetaData and MANIFEST.MF
-      Attributes attrs = manifest.getMainAttributes();
+      for (String jarFile : jarFiles) {
+         // The jar must be there
+         File file = new File(userDir, jarFile + meta.getProviderVersion() + ".jar");
+         Assert.assertTrue(file.exists());

Review comment:
       thanks for the input @gemmellr. That approach make sense and I will work on this and update the PR.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] tlbueno commented on a change in pull request #3929: NO-JIRA - fix ManifestTest

Posted by GitBox <gi...@apache.org>.
tlbueno commented on a change in pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929#discussion_r824692227



##########
File path: tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jms/ManifestTest.java
##########
@@ -14,53 +14,58 @@
  * 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.Properties;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 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();
 
       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);
+
+      String distributionDir = basedir + "/../../artemis-distribution/target/apache-artemis-" +
+         serverFullVersion + "-bin/apache-artemis-" + serverFullVersion;

Review comment:
       @gemmellr I made few changes as you suggested. Moved it from integration to smoke. No there is no need for the build.lib paramerter but I didn't find a way to get the artemis-distribution path. If I use the artemis-maven-plugin to generate a server the generated server folder has a profile file that points to the distrubution directory where I can look for the jars inside the lib directory. But I cannot find a way to retrieve this directory in the code. So, for now as you can see it is partially hardcoded. Any suggestions to void this hardcoded part?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [activemq-artemis] gemmellr commented on a change in pull request #3929: NO-JIRA - fix ManifestTest

Posted by GitBox <gi...@apache.org>.
gemmellr commented on a change in pull request #3929:
URL: https://github.com/apache/activemq-artemis/pull/3929#discussion_r824777407



##########
File path: tests/smoke-tests/src/test/java/org/apache/activemq/artemis/tests/smoke/jms/ManifestTest.java
##########
@@ -14,53 +14,58 @@
  * 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.Properties;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
 import java.util.jar.Attributes;
 import java.util.jar.JarFile;
 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();
 
       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);
+
+      String distributionDir = basedir + "/../../artemis-distribution/target/apache-artemis-" +
+         serverFullVersion + "-bin/apache-artemis-" + serverFullVersion;

Review comment:
       Not offhand no, I actually thought the smoke tests bits already had that value, but it seems like its actually only artemis-maven-plugin that does (perhaps from [1]) which in turn puts it in the generated profile file as you noted, with the smoke tests only knowing the path to the configs. So adding a 'distribution lib' style property as you had before may indeed be the simplest for now after all unfortunately.
   
   [1] https://github.com/apache/activemq-artemis/blob/2.20.0/artemis-maven-plugin/src/main/java/org/apache/activemq/artemis/maven/ArtemisCreatePlugin.java#L66




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: gitbox-unsubscribe@activemq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org