activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbert...@apache.org
Subject [1/2] activemq-artemis git commit: Fixing runtime CLI on windows
Date Mon, 11 May 2015 18:45:24 GMT
Repository: activemq-artemis
Updated Branches:
  refs/heads/master efd6261d2 -> e2e1c3f95


Fixing runtime CLI on windows


Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo
Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/5a3727c8
Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/5a3727c8
Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/5a3727c8

Branch: refs/heads/master
Commit: 5a3727c8f3e6ce21013c915d16b97db495830dbc
Parents: efd6261
Author: Clebert Suconic <clebertsuconic@apache.org>
Authored: Mon May 11 13:25:50 2015 -0400
Committer: Clebert Suconic <clebertsuconic@apache.org>
Committed: Mon May 11 14:23:27 2015 -0400

----------------------------------------------------------------------
 artemis-cli/pom.xml                             |  4 +-
 .../activemq/artemis/cli/commands/Create.java   | 57 +++++++++++++-------
 .../artemis/cli/commands/bin/artemis.cmd        |  2 +-
 .../artemis/test/StreamClassPathTest.java       | 55 +++++++++++++++++++
 artemis-cli/src/test/resources/broker.xml       |  2 +-
 5 files changed, 98 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5a3727c8/artemis-cli/pom.xml
----------------------------------------------------------------------
diff --git a/artemis-cli/pom.xml b/artemis-cli/pom.xml
index 4006d34..44a38b4 100644
--- a/artemis-cli/pom.xml
+++ b/artemis-cli/pom.xml
@@ -131,8 +131,8 @@
                    <version>1.9</version>
                    <classifier>bin</classifier>
                    <type>exe</type>
-                   <outputDirectory>${basedir}/target/classes/org/apache/artemis/cli/commands/bin</outputDirectory>
-                   <destFileName>activemq-service.exe</destFileName>
+                   <outputDirectory>${basedir}/target/classes/org/apache/activemq/artemis/cli/commands/bin/</outputDirectory>
+                   <destFileName>artemis-service.exe</destFileName>
                  </artifactItem>
                </artifactItems>
              </configuration>

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5a3727c8/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
index 074ced0..c3eb44b 100644
--- a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
+++ b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
@@ -61,6 +61,19 @@ public class Create implements Action
 
    private static final Integer HQ_PORT = 5445;
 
+   public static final String BIN_ARTEMIS_CMD = "bin/artemis.cmd";
+   public static final String BIN_ARTEMIS_SERVICE_EXE = "bin/artemis-service.exe";
+   public static final String BIN_ARTEMIS_SERVICE_XML = "bin/artemis-service.xml";
+   public static final String ETC_ARTEMIS_PROFILE_CMD = "etc/artemis.profile.cmd";
+   public static final String BIN_ARTEMIS = "bin/artemis";
+   public static final String BIN_ARTEMIS_SERVICE = "bin/artemis-service";
+   public static final String ETC_ARTEMIS_PROFILE = "etc/artemis.profile";
+   public static final String ETC_LOGGING_PROPERTIES = "etc/logging.properties";
+   public static final String ETC_BOOTSTRAP_XML = "etc/bootstrap.xml";
+   public static final String ETC_BROKER_XML = "etc/broker.xml";
+   public static final String ETC_ARTEMIS_ROLES_PROPERTIES = "etc/artemis-roles.properties";
+   public static final String ETC_ARTEMIS_USERS_PROPERTIES = "etc/artemis-users.properties";
+
    @Arguments(description = "The instance directory to hold the broker's configuration and
data", required = true)
    File directory;
 
@@ -116,6 +129,14 @@ public class Create implements Action
       }
    }
 
+
+   /** This method is made public for the testsuite */
+   public InputStream openStream(String source)
+   {
+      return this.getClass().getResourceAsStream(source);
+   }
+
+
    public Object run(ActionContext context) throws Exception
    {
       this.context = context;
@@ -205,34 +226,34 @@ public class Create implements Action
 
       if (IS_WINDOWS)
       {
-         write("bin/artemis.cmd", null, false);
-         write("bin/artemis-service.exe");
-         write("bin/artemis-service.xml", filters, false);
-         write("etc/artemis.profile.cmd", filters, false);
+         write(BIN_ARTEMIS_CMD, null, false);
+         write(BIN_ARTEMIS_SERVICE_EXE);
+         write(BIN_ARTEMIS_SERVICE_XML, filters, false);
+         write(ETC_ARTEMIS_PROFILE_CMD, filters, false);
       }
 
       if (!IS_WINDOWS || IS_CYGWIN)
       {
-         write("bin/artemis", null, true);
-         makeExec("bin/artemis");
-         write("bin/artemis-service", null, true);
-         makeExec("bin/artemis-service");
-         write("etc/artemis.profile", filters, true);
-         makeExec("etc/artemis.profile");
+         write(BIN_ARTEMIS, null, true);
+         makeExec(BIN_ARTEMIS);
+         write(BIN_ARTEMIS_SERVICE, null, true);
+         makeExec(BIN_ARTEMIS_SERVICE);
+         write(ETC_ARTEMIS_PROFILE, filters, true);
+         makeExec(ETC_ARTEMIS_PROFILE);
       }
 
-      write("etc/logging.properties", null, false);
-      write("etc/bootstrap.xml", null, false);
-      write("etc/broker.xml", filters, false);
-      write("etc/artemis-roles.properties", null, false);
-      write("etc/artemis-users.properties", null, false);
+      write(ETC_LOGGING_PROPERTIES, null, false);
+      write(ETC_BOOTSTRAP_XML, null, false);
+      write(ETC_BROKER_XML, filters, false);
+      write(ETC_ARTEMIS_ROLES_PROPERTIES, null, false);
+      write(ETC_ARTEMIS_USERS_PROPERTIES, null, false);
 
       context.out.println("");
       context.out.println("You can now start the broker by executing:  ");
       context.out.println("");
       context.out.println(String.format("   \"%s\" run", path(new File(directory, "bin/artemis"),
true)));
 
-      File service = new File(directory, "bin/artemis-service");
+      File service = new File(directory, BIN_ARTEMIS_SERVICE);
       context.out.println("");
 
       if (!IS_WINDOWS || IS_CYGWIN)
@@ -351,7 +372,7 @@ public class Create implements Action
    private String readTextFile(String source) throws IOException
    {
       ByteArrayOutputStream out = new ByteArrayOutputStream();
-      try (InputStream in = this.getClass().getResourceAsStream(source))
+      try (InputStream in = openStream(source))
       {
          copy(in, out);
       }
@@ -367,7 +388,7 @@ public class Create implements Action
       }
       try (FileOutputStream fout = new FileOutputStream(target))
       {
-         try (InputStream in = this.getClass().getResourceAsStream(source))
+         try (InputStream in = openStream(source))
          {
             copy(in, fout);
          }

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5a3727c8/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
----------------------------------------------------------------------
diff --git a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
index 5e8f500..c9384ca 100755
--- a/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
+++ b/artemis-cli/src/main/resources/org/apache/activemq/artemis/cli/commands/bin/artemis.cmd
@@ -25,7 +25,7 @@ set ARTEMIS_INSTANCE=%CD%
 POPD
 
 :CHECK_ARTEMIS_INSTANCE
-if exist "%ARTEMIS_INSTANCE%\bin\activemq.cmd" goto CHECK_JAVA
+if exist "%ARTEMIS_INSTANCE%\bin\artemis.cmd" goto CHECK_JAVA
 
 :NO_HOME
 echo ARTEMIS_INSTANCE environment variable is set incorrectly. Please set ARTEMIS_INSTANCE.

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5a3727c8/artemis-cli/src/test/java/org/apache/activemq/artemis/test/StreamClassPathTest.java
----------------------------------------------------------------------
diff --git a/artemis-cli/src/test/java/org/apache/activemq/artemis/test/StreamClassPathTest.java
b/artemis-cli/src/test/java/org/apache/activemq/artemis/test/StreamClassPathTest.java
new file mode 100644
index 0000000..d46d3c6
--- /dev/null
+++ b/artemis-cli/src/test/java/org/apache/activemq/artemis/test/StreamClassPathTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.activemq.artemis.test;
+
+import java.io.InputStream;
+
+import org.apache.activemq.artemis.cli.commands.Create;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class StreamClassPathTest
+{
+
+   /** Validate if all the known resources are available on the classpath for the jar */
+   @Test
+   public void testFindStreams() throws Exception
+   {
+      openStream(Create.BIN_ARTEMIS_CMD);
+      openStream(Create.BIN_ARTEMIS_SERVICE_EXE);
+      openStream(Create.BIN_ARTEMIS_SERVICE_XML);
+      openStream(Create.ETC_ARTEMIS_PROFILE_CMD);
+      openStream(Create.BIN_ARTEMIS);
+      openStream(Create.BIN_ARTEMIS_SERVICE);
+      openStream(Create.ETC_ARTEMIS_PROFILE);
+      openStream(Create.ETC_LOGGING_PROPERTIES);
+      openStream(Create.ETC_BOOTSTRAP_XML);
+      openStream(Create.ETC_BROKER_XML);
+      openStream(Create.ETC_ARTEMIS_ROLES_PROPERTIES);
+      openStream(Create.ETC_ARTEMIS_USERS_PROPERTIES);
+   }
+
+
+   private void openStream(String source) throws Exception
+   {
+      Create create = new Create();
+      InputStream in = create.openStream(source);
+      Assert.assertNotNull(source + " not found", in);
+      in.close();
+   }
+}

http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/5a3727c8/artemis-cli/src/test/resources/broker.xml
----------------------------------------------------------------------
diff --git a/artemis-cli/src/test/resources/broker.xml b/artemis-cli/src/test/resources/broker.xml
index b420ad8..df5610d 100644
--- a/artemis-cli/src/test/resources/broker.xml
+++ b/artemis-cli/src/test/resources/broker.xml
@@ -30,7 +30,7 @@ under the License.
 
       <journal-directory>./target/journal</journal-directory>
 
-      <journal-min-files>10</journal-min-files>
+      <journal-min-files>2</journal-min-files>
 
       <large-messages-directory>./target/large-messages</large-messages-directory>
 


Mime
View raw message