Skip to content

Commit e7d7fb5

Browse files
committed
Some unit test work
1 parent 96ebac1 commit e7d7fb5

4 files changed

Lines changed: 242 additions & 0 deletions

File tree

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
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+
// with 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+
package com.cloud.async;
18+
19+
import org.mockito.Mockito;
20+
import org.springframework.context.annotation.Bean;
21+
import org.springframework.context.annotation.Configuration;
22+
23+
import com.cloud.api.ApiDispatcher;
24+
import com.cloud.async.dao.AsyncJobDao;
25+
import com.cloud.async.dao.AsyncJobDaoImpl;
26+
import com.cloud.async.dao.SyncQueueDao;
27+
import com.cloud.async.dao.SyncQueueDaoImpl;
28+
import com.cloud.async.dao.SyncQueueItemDao;
29+
import com.cloud.async.dao.SyncQueueItemDaoImpl;
30+
import com.cloud.cluster.ClusterManager;
31+
import com.cloud.configuration.ConfigurationManager;
32+
import com.cloud.configuration.dao.ConfigurationDao;
33+
import com.cloud.dao.EntityManager;
34+
import com.cloud.user.AccountManager;
35+
import com.cloud.user.dao.AccountDao;
36+
37+
@Configuration
38+
public class AsyncJobTestConfiguration {
39+
40+
@Bean
41+
public ClusterManager clusterManager() {
42+
return Mockito.mock(ClusterManager.class);
43+
}
44+
45+
@Bean
46+
public AsyncJobDao asyncJobDao() {
47+
return new AsyncJobDaoImpl();
48+
}
49+
50+
@Bean
51+
public AccountManager accountManager() {
52+
return Mockito.mock(AccountManager.class);
53+
}
54+
55+
@Bean
56+
public ApiDispatcher apiDispatcher() {
57+
return Mockito.mock(ApiDispatcher.class);
58+
}
59+
60+
@Bean
61+
public EntityManager entityManager() {
62+
return Mockito.mock(EntityManager.class);
63+
}
64+
65+
@Bean
66+
public SyncQueueManager syncQueueManager() {
67+
return new SyncQueueManagerImpl();
68+
}
69+
70+
@Bean
71+
public AccountDao accountDao() {
72+
return Mockito.mock(AccountDao.class);
73+
}
74+
75+
@Bean
76+
public SyncQueueDao syncQueueDao() {
77+
return new SyncQueueDaoImpl();
78+
}
79+
80+
@Bean
81+
public SyncQueueItemDao syncQueueItemDao() {
82+
return new SyncQueueItemDaoImpl();
83+
}
84+
85+
@Bean
86+
public ConfigurationDao configurationDao() {
87+
return Mockito.mock(ConfigurationDao.class);
88+
}
89+
90+
@Bean
91+
public ConfigurationManager configurationManager() {
92+
return Mockito.mock(ConfigurationManager.class);
93+
}
94+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
// with 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+
package com.cloud.async;
18+
19+
import org.mockito.Mockito;
20+
import org.springframework.context.annotation.Bean;
21+
import org.springframework.context.annotation.Configuration;
22+
23+
import com.cloud.async.dao.SyncQueueDao;
24+
import com.cloud.async.dao.SyncQueueDaoImpl;
25+
import com.cloud.async.dao.SyncQueueItemDao;
26+
import com.cloud.async.dao.SyncQueueItemDaoImpl;
27+
import com.cloud.configuration.ConfigurationManager;
28+
import com.cloud.configuration.dao.ConfigurationDao;
29+
30+
@Configuration
31+
public class SyncQueueTestConfiguration {
32+
33+
@Bean
34+
public SyncQueueManager syncQueueManager() {
35+
return new SyncQueueManagerImpl();
36+
}
37+
38+
@Bean
39+
public SyncQueueDao syncQueueDao() {
40+
return new SyncQueueDaoImpl();
41+
}
42+
43+
@Bean
44+
public SyncQueueItemDao syncQueueItemDao() {
45+
return new SyncQueueItemDaoImpl();
46+
}
47+
48+
@Bean
49+
public ConfigurationDao configurationDao() {
50+
return Mockito.mock(ConfigurationDao.class);
51+
}
52+
53+
@Bean
54+
public ConfigurationManager configurationManager() {
55+
return Mockito.mock(ConfigurationManager.class);
56+
}
57+
}
58+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
2+
license agreements. See the NOTICE file distributed with this work for additional
3+
information regarding copyright ownership. The ASF licenses this file to
4+
you under the Apache License, Version 2.0 (the "License"); you may not use
5+
this file except in compliance with the License. You may obtain a copy of
6+
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
7+
by applicable law or agreed to in writing, software distributed under the
8+
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9+
OF ANY KIND, either express or implied. See the License for the specific
10+
language governing permissions and limitations under the License. -->
11+
<beans xmlns="http://www.springframework.org/schema/beans"
12+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
13+
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
14+
xsi:schemaLocation="http://www.springframework.org/schema/beans
15+
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
16+
http://www.springframework.org/schema/tx
17+
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
18+
http://www.springframework.org/schema/aop
19+
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
20+
http://www.springframework.org/schema/context
21+
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
22+
23+
<context:annotation-config />
24+
25+
<!-- @DB support -->
26+
27+
<bean id="componentContext" class="com.cloud.utils.component.ComponentContext" />
28+
29+
<bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
30+
<bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
31+
<bean id="instantiatePostProcessor" class="com.cloud.utils.component.ComponentInstantiationPostProcessor">
32+
<property name="Interceptors">
33+
<list>
34+
<ref bean="transactionContextBuilder" />
35+
<ref bean="actionEventInterceptor" />
36+
</list>
37+
</property>
38+
</bean>
39+
40+
<bean id="asyncJobManagerImpl" class="com.cloud.async.AsyncJobManagerImpl">
41+
<property name="defaultDispatcher" value="ApiAsyncJobDispatcher" />
42+
</bean>
43+
<bean id="ApiAsyncJobDispatcher" class="com.cloud.api.ApiAsyncJobDispatcher">
44+
<property name="name" value="ApiAsyncJobDispatcher" />
45+
</bean>
46+
47+
<bean class="com.cloud.async.AsyncJobTestConfiguration" />
48+
49+
</beans>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
2+
license agreements. See the NOTICE file distributed with this work for additional
3+
information regarding copyright ownership. The ASF licenses this file to
4+
you under the Apache License, Version 2.0 (the "License"); you may not use
5+
this file except in compliance with the License. You may obtain a copy of
6+
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
7+
by applicable law or agreed to in writing, software distributed under the
8+
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
9+
OF ANY KIND, either express or implied. See the License for the specific
10+
language governing permissions and limitations under the License. -->
11+
<beans xmlns="http://www.springframework.org/schema/beans"
12+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
13+
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
14+
xsi:schemaLocation="http://www.springframework.org/schema/beans
15+
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
16+
http://www.springframework.org/schema/tx
17+
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
18+
http://www.springframework.org/schema/aop
19+
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
20+
http://www.springframework.org/schema/context
21+
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
22+
23+
<context:annotation-config />
24+
25+
<!-- @DB support -->
26+
27+
<bean id="componentContext" class="com.cloud.utils.component.ComponentContext" />
28+
29+
<bean id="transactionContextBuilder" class="com.cloud.utils.db.TransactionContextBuilder" />
30+
<bean id="actionEventInterceptor" class="com.cloud.event.ActionEventInterceptor" />
31+
<bean id="instantiatePostProcessor" class="com.cloud.utils.component.ComponentInstantiationPostProcessor">
32+
<property name="Interceptors">
33+
<list>
34+
<ref bean="transactionContextBuilder" />
35+
<ref bean="actionEventInterceptor" />
36+
</list>
37+
</property>
38+
</bean>
39+
<bean class="com.cloud.async.SyncQueueTestConfiguration" />
40+
41+
</beans>

0 commit comments

Comments
 (0)