Removing hard coded agent properties
Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/3df27e0b Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/3df27e0b Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/3df27e0b Branch: refs/heads/master Commit: 3df27e0b2fcef14fa0b6aa2d5a6c35436dad40b9 Parents: 282dd23 Author: Akila Perera <[email protected]> Authored: Wed Aug 26 14:53:05 2015 +0530 Committer: Akila Perera <[email protected]> Committed: Wed Aug 26 14:53:05 2015 +0530 ---------------------------------------------------------------------- .../org.apache.stratos.cartridge.agent/pom.xml | 2 -- .../agent/test/JavaCartridgeAgentTest.java | 23 ++++++++++++++++---- .../test/resources/test-conf/test.properties | 20 +++++++++++++++++ pom.xml | 3 +++ .../modules/distribution/pom.xml | 5 +++-- .../distribution/src/main/assembly/bin.xml | 1 - .../python-cartridge-agent/distribution/pom.xml | 3 ++- .../distribution/src/main/assembly/bin.xml | 6 +++-- 8 files changed, 51 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/3df27e0b/components/org.apache.stratos.cartridge.agent/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cartridge.agent/pom.xml b/components/org.apache.stratos.cartridge.agent/pom.xml index 4f094e2..accad57 100644 --- a/components/org.apache.stratos.cartridge.agent/pom.xml +++ b/components/org.apache.stratos.cartridge.agent/pom.xml @@ -30,7 +30,6 @@ <packaging>jar</packaging> <name>Apache Stratos - Cartridge Agent</name> <description>Apache Stratos Cartridge Agent</description> - <url>http://apache.org</url> <build> <plugins> @@ -92,7 +91,6 @@ <dependency> <groupId>org.eclipse.jgit.wso2</groupId> <artifactId>org.eclipse.jgit</artifactId> - <!--version>2.1.0.wso2v1</version--> <version>2.3.1.wso2v2</version> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/stratos/blob/3df27e0b/components/org.apache.stratos.cartridge.agent/src/test/java/org/apache/stratos/cartridge/agent/test/JavaCartridgeAgentTest.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cartridge.agent/src/test/java/org/apache/stratos/cartridge/agent/test/JavaCartridgeAgentTest.java b/components/org.apache.stratos.cartridge.agent/src/test/java/org/apache/stratos/cartridge/agent/test/JavaCartridgeAgentTest.java index a10c323..7db8f70 100644 --- a/components/org.apache.stratos.cartridge.agent/src/test/java/org/apache/stratos/cartridge/agent/test/JavaCartridgeAgentTest.java +++ b/components/org.apache.stratos.cartridge.agent/src/test/java/org/apache/stratos/cartridge/agent/test/JavaCartridgeAgentTest.java @@ -77,7 +77,8 @@ public class JavaCartridgeAgentTest { private static final String PARTITION_ID = "partition-1"; private static final String TENANT_ID = "-1234"; private static final String SERVICE_NAME = "php"; - public static final String AGENT_NAME = "apache-stratos-cartridge-agent-4.1.2"; + public static final String AGENT_NAME = "distribution.name"; + public static final String AGENT_VERSION = "distribution.version"; private static HashMap<String, Executor> executorList; private static ArrayList<ServerSocket> serverSocketList; private final ArtifactUpdatedEvent artifactUpdatedEvent; @@ -87,10 +88,24 @@ public class JavaCartridgeAgentTest { private ByteArrayOutputStreamLocal outputStream; private TopologyEventReceiver topologyEventReceiver; private InstanceStatusEventReceiver instanceStatusEventReceiver; + private String agentName; + private String agentVersion; + private Properties testProperties = new Properties(); public JavaCartridgeAgentTest(ArtifactUpdatedEvent artifactUpdatedEvent, Boolean expectedResult) { this.artifactUpdatedEvent = artifactUpdatedEvent; this.expectedResult = expectedResult; + try { + testProperties + .load(JavaCartridgeAgentTest.class.getResourceAsStream("/test.properties")); + agentName = testProperties.getProperty(AGENT_NAME); + agentVersion = testProperties.getProperty(AGENT_VERSION); + log.info("Java Cartridge Agent test properties: " + testProperties.toString()); + } + catch (IOException e) { + log.error("Error loading test.properties file from classpath. Please make sure that file " + + "exists in classpath.", e); + } } @BeforeClass @@ -232,9 +247,9 @@ public class JavaCartridgeAgentTest { private String setupJavaAgent() { try { log.info("Setting up Java cartridge agent test setup"); - String jcaZipSource = getResourcesFolderPath() + "/../../../../products/cartridge-agent/modules/distribution/target/" + AGENT_NAME + ".zip"; + String jcaZipSource = getResourcesFolderPath() + "/../../../../products/cartridge-agent/modules/distribution/target/" + agentName + ".zip"; String testHome = getResourcesFolderPath() + "/../" + UUID.randomUUID() + "/"; - File agentHome = new File(testHome + AGENT_NAME); + File agentHome = new File(testHome + agentName); log.info("Extracting Java Cartridge Agent to test folder"); ZipFile agentZip = new ZipFile(jcaZipSource); ProgressMonitor zipProgresMonitor = agentZip.getProgressMonitor(); @@ -249,7 +264,7 @@ public class JavaCartridgeAgentTest { } log.info("Copying agent jar"); - String agentJar = "org.apache.stratos.cartridge.agent-4.1.2.jar"; + String agentJar = "org.apache.stratos.cartridge.agent-" + agentVersion + ".jar"; String agentJarSource = getResourcesFolderPath() + "/../" + agentJar; String agentJarDest = agentHome.getCanonicalPath() + "/lib/" + agentJar; FileUtils.copyFile(new File(agentJarSource), new File(agentJarDest)); http://git-wip-us.apache.org/repos/asf/stratos/blob/3df27e0b/components/org.apache.stratos.cartridge.agent/src/test/resources/test-conf/test.properties ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.cartridge.agent/src/test/resources/test-conf/test.properties b/components/org.apache.stratos.cartridge.agent/src/test/resources/test-conf/test.properties new file mode 100644 index 0000000..1aee0b8 --- /dev/null +++ b/components/org.apache.stratos.cartridge.agent/src/test/resources/test-conf/test.properties @@ -0,0 +1,20 @@ +# 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. + +# Stratos distribution properties added via filters during the build +distribution.name=${java.cartridge.agent.distribution.name}-${project.version} +distribution.version=${project.version} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/stratos/blob/3df27e0b/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index 9ba2735..479806d 100644 --- a/pom.xml +++ b/pom.xml @@ -738,6 +738,9 @@ <!-- product distribution properties --> <stratos.distribution.name>apache-stratos</stratos.distribution.name> <load.balancer.distribution.name>apache-stratos-load-balancer</load.balancer.distribution.name> + <java.cartridge.agent.distribution.name>apache-stratos-cartridge-agent</java.cartridge.agent.distribution.name> + <python.cartridge.agent.distribution.name>apache-stratos-python-cartridge-agent + </python.cartridge.agent.distribution.name> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> http://git-wip-us.apache.org/repos/asf/stratos/blob/3df27e0b/products/cartridge-agent/modules/distribution/pom.xml ---------------------------------------------------------------------- diff --git a/products/cartridge-agent/modules/distribution/pom.xml b/products/cartridge-agent/modules/distribution/pom.xml index 15e416a..67c9c43 100644 --- a/products/cartridge-agent/modules/distribution/pom.xml +++ b/products/cartridge-agent/modules/distribution/pom.xml @@ -27,8 +27,8 @@ <relativePath>../../pom.xml</relativePath> </parent> - <artifactId>apache-stratos-cartridge-agent</artifactId> - <name>Apache Stratos - Cartridge Agent Distribution</name> + <artifactId>java-cartridge-agent-distribution</artifactId> + <name>Apache Stratos - Java Cartridge Agent Distribution</name> <dependencies> <dependency> @@ -55,6 +55,7 @@ <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <configuration> + <finalName>${java.cartridge.agent.distribution.name}-${project.version}</finalName> <descriptors> <descriptor>src/main/assembly/bin.xml</descriptor> </descriptors> http://git-wip-us.apache.org/repos/asf/stratos/blob/3df27e0b/products/cartridge-agent/modules/distribution/src/main/assembly/bin.xml ---------------------------------------------------------------------- diff --git a/products/cartridge-agent/modules/distribution/src/main/assembly/bin.xml b/products/cartridge-agent/modules/distribution/src/main/assembly/bin.xml index 1c8486b..2b5767f 100644 --- a/products/cartridge-agent/modules/distribution/src/main/assembly/bin.xml +++ b/products/cartridge-agent/modules/distribution/src/main/assembly/bin.xml @@ -16,7 +16,6 @@ ~ specific language governing permissions and limitations ~ under the License. --> - <assembly xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd"> http://git-wip-us.apache.org/repos/asf/stratos/blob/3df27e0b/products/python-cartridge-agent/distribution/pom.xml ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/distribution/pom.xml b/products/python-cartridge-agent/distribution/pom.xml index 65e3527..10826e0 100644 --- a/products/python-cartridge-agent/distribution/pom.xml +++ b/products/python-cartridge-agent/distribution/pom.xml @@ -27,7 +27,7 @@ <relativePath>../pom.xml</relativePath> </parent> - <artifactId>apache-stratos-python-cartridge-agent</artifactId> + <artifactId>python-cartridge-agent-distribution</artifactId> <packaging>pom</packaging> <name>Apache Stratos - Python Cartridge Agent</name> <description>Apache Stratos Python Cartridge Agent Distribution</description> @@ -45,6 +45,7 @@ <goal>attached</goal> </goals> <configuration> + <finalName>${python.cartridge.agent.distribution.name}-${project.version}</finalName> <descriptors> <descriptor>src/main/assembly/bin.xml</descriptor> </descriptors> http://git-wip-us.apache.org/repos/asf/stratos/blob/3df27e0b/products/python-cartridge-agent/distribution/src/main/assembly/bin.xml ---------------------------------------------------------------------- diff --git a/products/python-cartridge-agent/distribution/src/main/assembly/bin.xml b/products/python-cartridge-agent/distribution/src/main/assembly/bin.xml index bca0b25..fa8874c 100644 --- a/products/python-cartridge-agent/distribution/src/main/assembly/bin.xml +++ b/products/python-cartridge-agent/distribution/src/main/assembly/bin.xml @@ -24,7 +24,9 @@ </formats> <fileSets> <fileSet> - <directory>${project.basedir}/../../../components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent</directory> + <directory> + ${project.basedir}/../../../components/org.apache.stratos.python.cartridge.agent/src/main/python/cartridge.agent/cartridge.agent + </directory> <outputDirectory>.</outputDirectory> <includes> <include>**/*</include> @@ -52,4 +54,4 @@ <fileMode>644</fileMode> </file> </files> -</assembly> +</assembly> \ No newline at end of file
