|
| 1 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +// or more contributor license agreements. See the NOTICE file |
| 3 | +// distributed with this work for additional information |
| 4 | +// regarding copyright ownership. The ASF licenses this file |
| 5 | +// to you under the Apache License, Version 2.0 (the |
| 6 | +// "License"); you may not use this file except in compliance |
| 7 | +// the License. You may obtain a copy of the License at |
| 8 | +// |
| 9 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +// |
| 11 | +// Unless required by applicable law or agreed to in writing, |
| 12 | +// software distributed under the License is distributed on an |
| 13 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +// KIND, either express or implied. See the License for the |
| 15 | +// specific language governing permissions and limitations |
| 16 | +// under the License. |
| 17 | + |
| 18 | +package com.cloud.snapshot; |
| 19 | + |
| 20 | +import java.io.IOException; |
| 21 | + |
| 22 | +import org.springframework.context.annotation.ComponentScan; |
| 23 | +import org.springframework.context.annotation.ComponentScan.Filter; |
| 24 | +import org.springframework.context.annotation.Configuration; |
| 25 | +import org.springframework.context.annotation.FilterType; |
| 26 | +import org.springframework.core.type.classreading.MetadataReader; |
| 27 | +import org.springframework.core.type.classreading.MetadataReaderFactory; |
| 28 | +import org.springframework.core.type.filter.TypeFilter; |
| 29 | + |
| 30 | +import com.cloud.cluster.agentlb.dao.HostTransferMapDaoImpl; |
| 31 | +import com.cloud.dc.dao.ClusterDaoImpl; |
| 32 | +import com.cloud.dc.dao.HostPodDaoImpl; |
| 33 | +import com.cloud.host.dao.HostDaoImpl; |
| 34 | +import com.cloud.host.dao.HostDetailsDaoImpl; |
| 35 | +import com.cloud.host.dao.HostTagsDaoImpl; |
| 36 | +import com.cloud.storage.dao.SnapshotDaoImpl; |
| 37 | +import com.cloud.storage.dao.VolumeDaoImpl; |
| 38 | +import com.cloud.tags.dao.ResourceTagsDaoImpl; |
| 39 | +import com.cloud.utils.component.SpringComponentScanUtils; |
| 40 | +import com.cloud.vm.dao.NicDaoImpl; |
| 41 | +import com.cloud.vm.dao.VMInstanceDaoImpl; |
| 42 | + |
| 43 | +@Configuration |
| 44 | +@ComponentScan(basePackageClasses={ |
| 45 | + SnapshotDaoImpl.class, |
| 46 | + ResourceTagsDaoImpl.class, |
| 47 | + VMInstanceDaoImpl.class, |
| 48 | + VolumeDaoImpl.class, |
| 49 | + NicDaoImpl.class, |
| 50 | + HostDaoImpl.class, |
| 51 | + HostDetailsDaoImpl.class, |
| 52 | + HostTagsDaoImpl.class, |
| 53 | + HostTransferMapDaoImpl.class, |
| 54 | + ClusterDaoImpl.class, |
| 55 | + HostPodDaoImpl.class}, |
| 56 | + includeFilters={@Filter(value=SnapshotDaoTestConfiguration.Library.class, type=FilterType.CUSTOM)}, |
| 57 | + useDefaultFilters=false |
| 58 | + ) |
| 59 | +public class SnapshotDaoTestConfiguration { |
| 60 | + |
| 61 | + |
| 62 | + public static class Library implements TypeFilter { |
| 63 | + |
| 64 | + @Override |
| 65 | + public boolean match(MetadataReader mdr, MetadataReaderFactory arg1) throws IOException { |
| 66 | + mdr.getClassMetadata().getClassName(); |
| 67 | + ComponentScan cs = SnapshotDaoTestConfiguration.class.getAnnotation(ComponentScan.class); |
| 68 | + return SpringComponentScanUtils.includedInBasePackageClasses(mdr.getClassMetadata().getClassName(), cs); |
| 69 | + } |
| 70 | + |
| 71 | + } |
| 72 | +} |
0 commit comments