Updated Branches: refs/heads/master f50908341 -> b18c72626
Moved the SprintUtils which is for testing only to be in test directory. Changed pom.xml for different projects to use the utils test-jar. Removed some @Component annotations. Moved majority of the dependencies from cloudstack pom to utils pom Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/b18c7262 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/b18c7262 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/b18c7262 Branch: refs/heads/master Commit: b18c72626bbb8670b7488f2931230eb6efecbc41 Parents: f509083 Author: Alex Huang <[email protected]> Authored: Thu Jul 18 21:53:51 2013 -0700 Committer: Alex Huang <[email protected]> Committed: Thu Jul 18 21:53:51 2013 -0700 ---------------------------------------------------------------------- agent/pom.xml | 14 --- awsapi/pom.xml | 5 + .../rest/service/api/ClusterRestService.java | 4 - .../rest/service/api/NetworkRestService.java | 4 - .../engine/rest/service/api/PodRestService.java | 4 - .../service/api/VirtualMachineRestService.java | 4 - .../rest/service/api/VolumeRestService.java | 4 - .../rest/service/api/ZoneRestService.java | 4 - .../subsystem/api/storage/type/DataDisk.java | 4 +- .../engine/subsystem/api/storage/type/Iso.java | 4 +- .../subsystem/api/storage/type/RootDisk.java | 4 +- .../api/storage/type/VolumeTypeHelper.java | 3 - .../datastore/db/PrimaryDataStoreDaoImpl.java | 5 - .../cloudstack/storage/image/format/ISO.java | 2 - plugins/event-bus/rabbitmq/pom.xml | 1 - plugins/pom.xml | 48 ++++---- pom.xml | 26 ----- server/pom.xml | 14 ++- usage/pom.xml | 15 ++- utils/pom.xml | 23 +++- .../cloudstack/test/utils/SpringUtils.java | 113 ------------------- .../cloudstack/test/utils/SpringUtils.java | 113 +++++++++++++++++++ 22 files changed, 189 insertions(+), 229 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/agent/pom.xml ---------------------------------------------------------------------- diff --git a/agent/pom.xml b/agent/pom.xml index c2b1502..9a59518 100644 --- a/agent/pom.xml +++ b/agent/pom.xml @@ -43,22 +43,8 @@ </dependency> </dependencies> <build> - <defaultGoal>install</defaultGoal> - <sourceDirectory>src</sourceDirectory> - <testSourceDirectory>test</testSourceDirectory> <plugins> <plugin> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-jar-plugin</artifactId> - <executions> - <execution> - <goals> - <goal>test-jar</goal> - </goals> - </execution> - </executions> - </plugin> - <plugin> <artifactId>maven-antrun-plugin</artifactId> <version>1.7</version> <executions> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/awsapi/pom.xml ---------------------------------------------------------------------- diff --git a/awsapi/pom.xml b/awsapi/pom.xml index bcae072..2fe2089 100644 --- a/awsapi/pom.xml +++ b/awsapi/pom.xml @@ -33,6 +33,11 @@ <version>${project.version}</version> </dependency> <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${org.springframework.version}</version> + </dependency> + <dependency> <groupId>org.apache.axis2</groupId> <artifactId>axis2</artifactId> <version>${cs.axis2.version}</version> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ClusterRestService.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ClusterRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ClusterRestService.java index 2718e2f..9ed686f 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ClusterRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ClusterRestService.java @@ -30,11 +30,7 @@ import javax.ws.rs.QueryParam; import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity; import org.apache.cloudstack.engine.service.api.ProvisioningService; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -@Component -@Service("ClusterRestService") @Produces("application/json") public class ClusterRestService { // @Inject http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/api/src/org/apache/cloudstack/engine/rest/service/api/NetworkRestService.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/NetworkRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/NetworkRestService.java index b75600e..82dc833 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/NetworkRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/NetworkRestService.java @@ -29,11 +29,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.apache.cloudstack.engine.cloud.entity.api.NetworkEntity; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -@Service("NetworkRestService") -@Component @Produces("application/json") public class NetworkRestService { @PUT @Path("/network/create") http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/api/src/org/apache/cloudstack/engine/rest/service/api/PodRestService.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/PodRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/PodRestService.java index 9c009b9..73f84bb 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/PodRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/PodRestService.java @@ -28,11 +28,7 @@ import javax.ws.rs.QueryParam; import org.apache.cloudstack.engine.datacenter.entity.api.PodEntity; import org.apache.cloudstack.engine.service.api.ProvisioningService; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -@Component -@Service("PodService") @Produces({"application/json"}) public class PodRestService { // @Inject http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VirtualMachineRestService.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VirtualMachineRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VirtualMachineRestService.java index f3f7bad..f793de0 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VirtualMachineRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VirtualMachineRestService.java @@ -28,11 +28,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -@Component -@Service("VirtualMachineRestService") @Produces("application/xml") public class VirtualMachineRestService { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VolumeRestService.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VolumeRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VolumeRestService.java index cb1a0d3..ff8b0a4 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VolumeRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/VolumeRestService.java @@ -30,11 +30,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import org.apache.cloudstack.engine.cloud.entity.api.VolumeEntity; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -@Component -@Service("VolumeRestService") @Produces("application/json") public class VolumeRestService { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ZoneRestService.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ZoneRestService.java b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ZoneRestService.java index bd6980e..8eb662a 100755 --- a/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ZoneRestService.java +++ b/engine/api/src/org/apache/cloudstack/engine/rest/service/api/ZoneRestService.java @@ -31,11 +31,7 @@ import javax.ws.rs.QueryParam; import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntity; import org.apache.cloudstack.engine.service.api.ProvisioningService; -import org.springframework.stereotype.Component; -import org.springframework.stereotype.Service; -@Component -@Service("zoneService") @Produces({"application/json"}) public class ZoneRestService { // @Inject http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/DataDisk.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/DataDisk.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/DataDisk.java index a533f55..f94cb2e 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/DataDisk.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/DataDisk.java @@ -16,11 +16,9 @@ // under the License. package org.apache.cloudstack.engine.subsystem.api.storage.type; -import org.springframework.stereotype.Component; -@Component public class DataDisk extends VolumeTypeBase { public DataDisk() { - this.type = "DataDisk"; + type = "DataDisk"; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/Iso.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/Iso.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/Iso.java index 85c6272..f94c4b5 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/Iso.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/Iso.java @@ -16,11 +16,9 @@ // under the License. package org.apache.cloudstack.engine.subsystem.api.storage.type; -import org.springframework.stereotype.Component; -@Component public class Iso extends VolumeTypeBase { public Iso() { - this.type = "iso"; + type = "iso"; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/RootDisk.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/RootDisk.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/RootDisk.java index e8f4ce5..6e094d3 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/RootDisk.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/RootDisk.java @@ -16,11 +16,9 @@ // under the License. package org.apache.cloudstack.engine.subsystem.api.storage.type; -import org.springframework.stereotype.Component; -@Component public class RootDisk extends VolumeTypeBase { public RootDisk() { - this.type = "Root"; + type = "Root"; } } http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelper.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelper.java b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelper.java index 6dc2cd4..5057203 100644 --- a/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelper.java +++ b/engine/api/src/org/apache/cloudstack/engine/subsystem/api/storage/type/VolumeTypeHelper.java @@ -20,9 +20,6 @@ import java.util.List; import javax.inject.Inject; -import org.springframework.stereotype.Component; - -@Component public class VolumeTypeHelper { static private List<VolumeType> types; private static VolumeType defaultType = new Unknown(); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java index 96e18fc..1032526 100644 --- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java +++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java @@ -28,14 +28,10 @@ import javax.ejb.Local; import javax.inject.Inject; import javax.naming.ConfigurationException; -import org.springframework.stereotype.Component; - import com.cloud.host.Status; import com.cloud.hypervisor.Hypervisor.HypervisorType; - import com.cloud.storage.ScopeType; import com.cloud.storage.StoragePoolStatus; - import com.cloud.utils.db.DB; import com.cloud.utils.db.GenericDaoBase; import com.cloud.utils.db.GenericSearchBuilder; @@ -48,7 +44,6 @@ import com.cloud.utils.db.SearchCriteriaService; import com.cloud.utils.db.Transaction; import com.cloud.utils.exception.CloudRuntimeException; -@Component @Local(value = { PrimaryDataStoreDao.class }) @DB(txn = false) public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long> implements PrimaryDataStoreDao { http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/engine/storage/src/org/apache/cloudstack/storage/image/format/ISO.java ---------------------------------------------------------------------- diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/format/ISO.java b/engine/storage/src/org/apache/cloudstack/storage/image/format/ISO.java index 2f01a27..c2c1d93 100644 --- a/engine/storage/src/org/apache/cloudstack/storage/image/format/ISO.java +++ b/engine/storage/src/org/apache/cloudstack/storage/image/format/ISO.java @@ -19,9 +19,7 @@ package org.apache.cloudstack.storage.image.format; import org.apache.cloudstack.storage.BaseType; -import org.springframework.stereotype.Component; -@Component public class ISO extends BaseType implements ImageFormat { private final String type = "ISO"; http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/plugins/event-bus/rabbitmq/pom.xml ---------------------------------------------------------------------- diff --git a/plugins/event-bus/rabbitmq/pom.xml b/plugins/event-bus/rabbitmq/pom.xml index bd4d097..30dee37 100644 --- a/plugins/event-bus/rabbitmq/pom.xml +++ b/plugins/event-bus/rabbitmq/pom.xml @@ -41,6 +41,5 @@ </dependencies> <build> <defaultGoal>install</defaultGoal> - <sourceDirectory>src</sourceDirectory> </build> </project> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/plugins/pom.xml ---------------------------------------------------------------------- diff --git a/plugins/pom.xml b/plugins/pom.xml index 261e8e8..ff1e9c9 100755 --- a/plugins/pom.xml +++ b/plugins/pom.xml @@ -1,22 +1,15 @@ <?xml version="1.0" encoding="UTF-8"?> -<!-- - 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. ---><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> +<!-- 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. --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>cloudstack-plugins</artifactId> <name>Apache CloudStack Plugin POM</name> @@ -26,16 +19,15 @@ <artifactId>cloudstack</artifactId> <version>4.2.0-SNAPSHOT</version> </parent> + <build> <defaultGoal>install</defaultGoal> - <sourceDirectory>src</sourceDirectory> - <testSourceDirectory>test</testSourceDirectory> </build> <modules> <module>api/rate-limit</module> <module>api/discovery</module> <module>acl/static-role-based</module> - <module>affinity-group-processors/host-anti-affinity</module> + <module>affinity-group-processors/host-anti-affinity</module> <module>affinity-group-processors/explicit-dedication</module> <module>deployment-planners/user-concentrated-pod</module> <module>deployment-planners/user-dispersing</module> @@ -78,6 +70,18 @@ <artifactId>cloud-server</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.apache.cloudstack</groupId> + <artifactId>cloud-api</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>org.apache.cloudstack</groupId> + <artifactId>cloud-utils</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> </dependencies> <profiles> @@ -158,6 +162,6 @@ <modules> <module>hypervisors/simulator</module> </modules> - </profile> + </profile> </profiles> </project> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index ff1d3c0..ed95151 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,6 @@ </issueManagement> <properties> - <!--skipTests>true</skipTests --> <cs.jdk.version>1.6</cs.jdk.version> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> @@ -198,16 +197,6 @@ <version>${org.springframework.version}</version> </dependency> <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-context</artifactId> - <version>${org.springframework.version}</version> - </dependency> - <dependency> - <groupId>org.springframework</groupId> - <artifactId>spring-web</artifactId> - <version>${org.springframework.version}</version> - </dependency> - <dependency> <groupId>org.mockito</groupId> <artifactId>mockito-all</artifactId> <version>1.9.5</version> @@ -219,21 +208,6 @@ <version>${org.springframework.version}</version> <scope>test</scope> </dependency> - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>aspectjrt</artifactId> - <version>1.7.1</version> - </dependency> - <dependency> - <groupId>org.aspectj</groupId> - <artifactId>aspectjweaver</artifactId> - <version>1.7.1</version> - </dependency> - <dependency> - <groupId>javax.inject</groupId> - <artifactId>javax.inject</artifactId> - <version>1</version> - </dependency> </dependencies> <build> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/server/pom.xml ---------------------------------------------------------------------- diff --git a/server/pom.xml b/server/pom.xml index 497e4c9..56b0402 100644 --- a/server/pom.xml +++ b/server/pom.xml @@ -24,6 +24,11 @@ <version>${cs.commons-io.version}</version> </dependency> <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-web</artifactId> + <version>${org.springframework.version}</version> + </dependency> + <dependency> <groupId>org.apache.cloudstack</groupId> <artifactId>cloud-core</artifactId> <version>${project.version}</version> @@ -81,14 +86,21 @@ <version>${project.version}</version> </dependency> <dependency> + <groupId>org.apache.cloudstack</groupId> + <artifactId>cloud-utils</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> <groupId>org.reflections</groupId> <artifactId>reflections</artifactId> <version>0.9.8</version> </dependency> <dependency> <groupId>org.apache.cloudstack</groupId> - <artifactId>cloud-engine-api</artifactId> + <artifactId>cloud-utils</artifactId> <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> </dependency> <dependency> <groupId>org.apache.cloudstack</groupId> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/usage/pom.xml ---------------------------------------------------------------------- diff --git a/usage/pom.xml b/usage/pom.xml index e35d0eb..af08f53 100644 --- a/usage/pom.xml +++ b/usage/pom.xml @@ -28,6 +28,13 @@ <dependencies> <dependency> <groupId>org.apache.cloudstack</groupId> + <artifactId>cloud-utils</artifactId> + <version>${project.version}</version> + <type>test-jar</type> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.cloudstack</groupId> <artifactId>cloud-server</artifactId> <version>${project.version}</version> </dependency> @@ -44,14 +51,6 @@ </dependency> </dependencies> <build> - <defaultGoal>install</defaultGoal> - <sourceDirectory>src</sourceDirectory> - <testSourceDirectory>test</testSourceDirectory> - <testResources> - <testResource> - <directory>test/resources</directory> - </testResource> - </testResources> <resources> <resource> <directory>resources</directory> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/utils/pom.xml ---------------------------------------------------------------------- diff --git a/utils/pom.xml b/utils/pom.xml index 63bcbab..fb723dc 100644 --- a/utils/pom.xml +++ b/utils/pom.xml @@ -26,7 +26,28 @@ <version>4.2.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> - <dependencies> + <dependencies> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-core</artifactId> + <version>${org.springframework.version}</version> + </dependency> + <dependency> + <groupId>org.springframework</groupId> + <artifactId>spring-context</artifactId> + <version>${org.springframework.version}</version> + </dependency> + <dependency> + <groupId>javax.inject</groupId> + <artifactId>javax.inject</artifactId> + <version>1</version> + </dependency> + + <dependency> + <groupId>org.aspectj</groupId> + <artifactId>aspectjrt</artifactId> + <version>1.7.1</version> + </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/utils/src/org/apache/cloudstack/test/utils/SpringUtils.java ---------------------------------------------------------------------- diff --git a/utils/src/org/apache/cloudstack/test/utils/SpringUtils.java b/utils/src/org/apache/cloudstack/test/utils/SpringUtils.java deleted file mode 100644 index 220bd80..0000000 --- a/utils/src/org/apache/cloudstack/test/utils/SpringUtils.java +++ /dev/null @@ -1,113 +0,0 @@ -// 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 -// 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.cloudstack.test.utils; - -import java.util.ArrayList; -import java.util.List; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; - -import com.cloud.utils.component.ComponentContext; -import com.cloud.utils.component.ComponentInstantiationPostProcessor; -import com.cloud.utils.component.ComponentMethodInterceptor; -import com.cloud.utils.db.TransactionContextBuilder; -import com.cloud.utils.exception.CloudRuntimeException; - -public class SpringUtils { - - /** - * This method allows you to use @ComponentScan for your unit testing but - * it limits the scope of the classes found to the class specified in - * the @ComponentScan annotation. - * - * Without using this method, the default behavior of @ComponentScan is - * to actually scan in the package of the class specified rather than - * only the class. This can cause extra classes to be loaded which causes - * the classes these extra classes depend on to be loaded. The end effect - * is often most of the project gets loaded. - * - * In order to use this method properly, you must do the following: <li> - * - Specify @ComponentScan with basePackageClasses, includeFilters, and - * useDefaultFilters=true. See the following example. - * - * <pre> - * @ComponentScan(basePackageClasses={AffinityGroupServiceImpl.class, EventUtils.class}, - * includeFilters={@Filter(value=TestConfiguration.Library.class, type=FilterType.CUSTOM)}, - * useDefaultFilters=false) - * </pre> - * - * - Create a Library class and use that to call this method. See the - * following example. The Library class you define here is the Library - * class being added in the filter above. - * - * <pre> - * public static class Library implements TypeFilter { - * @Override - * public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException { - * ComponentScan cs = TestConfiguration.class.getAnnotation(ComponentScan.class); - * return SpringUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs); - * } - * } - * </pre> - * - * @param clazzName name of the class that should be included in the Spring components - * @param cs ComponentScan annotation that was declared on the configuration - * - * @return - */ - public static boolean includedInBasePackageClasses(String clazzName, ComponentScan cs) { - Class<?> clazzToCheck; - try { - clazzToCheck = Class.forName(clazzName); - } catch (ClassNotFoundException e) { - throw new CloudRuntimeException("Unable to find " + clazzName); - } - Class<?>[] clazzes = cs.basePackageClasses(); - for (Class<?> clazz : clazzes) { - if (clazzToCheck.isAssignableFrom(clazz)) { - return true; - } - } - return false; - } - - public static class CloudStackTestConfiguration { - - @Bean - public ComponentContext componentContext() { - return new ComponentContext(); - } - - @Bean - public TransactionContextBuilder transactionContextBuilder() { - return new TransactionContextBuilder(); - } - - @Bean - public ComponentInstantiationPostProcessor instantiatePostProcessor() { - ComponentInstantiationPostProcessor processor = new ComponentInstantiationPostProcessor(); - - List<ComponentMethodInterceptor> interceptors = new ArrayList<ComponentMethodInterceptor>(); - interceptors.add(new TransactionContextBuilder()); - processor.setInterceptors(interceptors); - - return processor; - } - } -} http://git-wip-us.apache.org/repos/asf/cloudstack/blob/b18c7262/utils/test/org/apache/cloudstack/test/utils/SpringUtils.java ---------------------------------------------------------------------- diff --git a/utils/test/org/apache/cloudstack/test/utils/SpringUtils.java b/utils/test/org/apache/cloudstack/test/utils/SpringUtils.java new file mode 100644 index 0000000..220bd80 --- /dev/null +++ b/utils/test/org/apache/cloudstack/test/utils/SpringUtils.java @@ -0,0 +1,113 @@ +// 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 +// 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.cloudstack.test.utils; + +import java.util.ArrayList; +import java.util.List; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.ComponentScan; + +import com.cloud.utils.component.ComponentContext; +import com.cloud.utils.component.ComponentInstantiationPostProcessor; +import com.cloud.utils.component.ComponentMethodInterceptor; +import com.cloud.utils.db.TransactionContextBuilder; +import com.cloud.utils.exception.CloudRuntimeException; + +public class SpringUtils { + + /** + * This method allows you to use @ComponentScan for your unit testing but + * it limits the scope of the classes found to the class specified in + * the @ComponentScan annotation. + * + * Without using this method, the default behavior of @ComponentScan is + * to actually scan in the package of the class specified rather than + * only the class. This can cause extra classes to be loaded which causes + * the classes these extra classes depend on to be loaded. The end effect + * is often most of the project gets loaded. + * + * In order to use this method properly, you must do the following: <li> + * - Specify @ComponentScan with basePackageClasses, includeFilters, and + * useDefaultFilters=true. See the following example. + * + * <pre> + * @ComponentScan(basePackageClasses={AffinityGroupServiceImpl.class, EventUtils.class}, + * includeFilters={@Filter(value=TestConfiguration.Library.class, type=FilterType.CUSTOM)}, + * useDefaultFilters=false) + * </pre> + * + * - Create a Library class and use that to call this method. See the + * following example. The Library class you define here is the Library + * class being added in the filter above. + * + * <pre> + * public static class Library implements TypeFilter { + * @Override + * public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException { + * ComponentScan cs = TestConfiguration.class.getAnnotation(ComponentScan.class); + * return SpringUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs); + * } + * } + * </pre> + * + * @param clazzName name of the class that should be included in the Spring components + * @param cs ComponentScan annotation that was declared on the configuration + * + * @return + */ + public static boolean includedInBasePackageClasses(String clazzName, ComponentScan cs) { + Class<?> clazzToCheck; + try { + clazzToCheck = Class.forName(clazzName); + } catch (ClassNotFoundException e) { + throw new CloudRuntimeException("Unable to find " + clazzName); + } + Class<?>[] clazzes = cs.basePackageClasses(); + for (Class<?> clazz : clazzes) { + if (clazzToCheck.isAssignableFrom(clazz)) { + return true; + } + } + return false; + } + + public static class CloudStackTestConfiguration { + + @Bean + public ComponentContext componentContext() { + return new ComponentContext(); + } + + @Bean + public TransactionContextBuilder transactionContextBuilder() { + return new TransactionContextBuilder(); + } + + @Bean + public ComponentInstantiationPostProcessor instantiatePostProcessor() { + ComponentInstantiationPostProcessor processor = new ComponentInstantiationPostProcessor(); + + List<ComponentMethodInterceptor> interceptors = new ArrayList<ComponentMethodInterceptor>(); + interceptors.add(new TransactionContextBuilder()); + processor.setInterceptors(interceptors); + + return processor; + } + } +}
