mirror of https://github.com/apache/cloudstack.git
fix unittest SecurityGroupManagerImpl2Test
This commit is contained in:
parent
80cbda5791
commit
bd2a130251
|
|
@ -19,6 +19,8 @@ package com.cloud.network.security;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.After;
|
||||
|
|
@ -29,13 +31,18 @@ import com.cloud.agent.MockAgentManagerImpl;
|
|||
import com.cloud.configuration.DefaultInterceptorLibrary;
|
||||
import com.cloud.configuration.dao.ConfigurationDaoImpl;
|
||||
import com.cloud.domain.dao.DomainDaoImpl;
|
||||
import com.cloud.event.dao.UsageEventDaoImpl;
|
||||
import com.cloud.network.MockNetworkManagerImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupRuleDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupRulesDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupVMMapDaoImpl;
|
||||
import com.cloud.network.security.dao.SecurityGroupWorkDaoImpl;
|
||||
import com.cloud.network.security.dao.VmRulesetLogDaoImpl;
|
||||
import com.cloud.projects.MockProjectManagerImpl;
|
||||
import com.cloud.tags.dao.ResourceTagsDaoImpl;
|
||||
import com.cloud.user.MockAccountManagerImpl;
|
||||
import com.cloud.user.MockDomainManagerImpl;
|
||||
import com.cloud.user.dao.AccountDaoImpl;
|
||||
import com.cloud.utils.Profiler;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
|
|
@ -58,7 +65,7 @@ public class SecurityGroupManagerImpl2Test extends TestCase {
|
|||
locator.addDao("ConfigurationDao", ConfigurationDaoImpl.class);
|
||||
locator.addDao("SecurityGroupDao", SecurityGroupDaoImpl.class);
|
||||
|
||||
//locator.addDao("IngressRuleDao", IngressRuleDaoImpl.class);
|
||||
locator.addDao("SecurityGroupRuleDao", SecurityGroupRuleDaoImpl.class);
|
||||
locator.addDao("SecurityGroupVMMapDao", SecurityGroupVMMapDaoImpl.class);
|
||||
locator.addDao("SecurityGroupRulesDao", SecurityGroupRulesDaoImpl.class);
|
||||
locator.addDao("UserVmDao", UserVmDaoImpl.class);
|
||||
|
|
@ -68,14 +75,18 @@ public class SecurityGroupManagerImpl2Test extends TestCase {
|
|||
locator.addDao("VmRulesetLogDao", VmRulesetLogDaoImpl.class);
|
||||
locator.addDao("VMInstanceDao", VMInstanceDaoImpl.class);
|
||||
locator.addDao("DomainDao", DomainDaoImpl.class);
|
||||
locator.addDao("UsageEventDao", UsageEventDaoImpl.class);
|
||||
locator.addDao("ResourceTagDao", ResourceTagsDaoImpl.class);
|
||||
locator.addManager("AgentManager", MockAgentManagerImpl.class);
|
||||
locator.addManager("VirtualMachineManager", MockVirtualMachineManagerImpl.class);
|
||||
locator.addManager("UserVmManager", MockUserVmManagerImpl.class);
|
||||
locator.addManager("NetworkManager", MockNetworkManagerImpl.class);
|
||||
locator.addManager("AccountManager", MockAccountManagerImpl.class);
|
||||
locator.addManager("DomainManager", MockDomainManagerImpl.class);
|
||||
locator.addManager("ProjectManager", MockProjectManagerImpl.class);
|
||||
locator.makeActive(new DefaultInterceptorLibrary());
|
||||
_sgMgr = ComponentLocator.inject(SecurityGroupManagerImpl2.class);
|
||||
|
||||
_sgMgr._mBean = new SecurityManagerMBeanImpl(_sgMgr);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -98,12 +109,12 @@ public class SecurityGroupManagerImpl2Test extends TestCase {
|
|||
}
|
||||
|
||||
@Ignore
|
||||
public void testSchedule() {
|
||||
public void testSchedule() throws ConfigurationException {
|
||||
_schedule(1000);
|
||||
}
|
||||
|
||||
public void testWork() {
|
||||
_schedule(100);
|
||||
public void testWork() throws ConfigurationException {
|
||||
_schedule(1000);
|
||||
_sgMgr.work();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,231 @@
|
|||
// 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 com.cloud.projects;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.exception.ConcurrentOperationException;
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.projects.ProjectAccount.Role;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
@Local(value = { ProjectManager.class })
|
||||
public class MockProjectManagerImpl implements ProjectManager, Manager {
|
||||
|
||||
@Override
|
||||
public Project createProject(String name, String displayText,
|
||||
String accountName, Long domainId)
|
||||
throws ResourceAllocationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteProject(long id) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project getProject(long id) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Project> listProjects(Long id, String name,
|
||||
String displayText, String state, String accountName,
|
||||
Long domainId, String keyword, Long startIndex, Long pageSize,
|
||||
boolean listAll, boolean isRecursive) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ProjectAccount assignAccountToProject(Project project,
|
||||
long accountId, Role accountRole) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Account getProjectOwner(long projectId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unassignAccountFromProject(long projectId, long accountId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project findByProjectAccountId(long projectAccountId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project findByNameAndDomainId(String name, long domainId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project updateProject(long id, String displayText,
|
||||
String newOwnerName) throws ResourceAllocationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAccountToProject(long projectId, String accountName,
|
||||
String email) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAccountFromProject(long projectId, String accountName) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends ProjectAccount> listProjectAccounts(long projectId,
|
||||
String accountName, String role, Long startIndex, Long pageSizeVal) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends ProjectInvitation> listProjectInvitations(Long id,
|
||||
Long projectId, String accountName, Long domainId, String state,
|
||||
boolean activeOnly, Long startIndex, Long pageSizeVal,
|
||||
boolean isRecursive, boolean listAll) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateInvitation(long projectId, String accountName,
|
||||
String token, boolean accept) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project activateProject(long projectId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project suspendProject(long projectId)
|
||||
throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Project enableProject(long projectId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteProjectInvitation(long invitationId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAccessProjectAccount(Account caller, long accountId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canModifyProjectAccount(Account caller, long accountId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAccountFromProject(long projectId, long accountId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> listPermittedProjectAccounts(long accountId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean projectInviteRequired() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowUserToCreateProject() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteProject(Account caller, long callerUserId,
|
||||
ProjectVO project) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,141 @@
|
|||
// 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 com.cloud.user;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.api.commands.ListDomainChildrenCmd;
|
||||
import com.cloud.api.commands.ListDomainsCmd;
|
||||
import com.cloud.domain.Domain;
|
||||
import com.cloud.domain.DomainVO;
|
||||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.utils.component.Manager;
|
||||
|
||||
@Local(value = { DomainManager.class })
|
||||
public class MockDomainManagerImpl implements Manager, DomainManager {
|
||||
|
||||
@Override
|
||||
public Domain createDomain(String name, Long parentId, String networkDomain) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Domain getDomain(long id) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChildDomain(Long parentId, Long childId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDomain(long domainId, Boolean cleanup) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Domain> searchForDomains(ListDomainsCmd cmd)
|
||||
throws PermissionDeniedException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Domain> searchForDomainChildren(
|
||||
ListDomainChildrenCmd cmd) throws PermissionDeniedException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> getDomainChildrenIds(String parentDomainPath) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Domain createDomain(String name, Long parentId, Long ownerId,
|
||||
String networkDomain) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DomainVO findDomainByPath(String domainPath) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<Long> getDomainParentIds(long domainId) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeDomain(long domainId) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<? extends Domain> findInactiveDomains() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDomain(DomainVO domain, Boolean cleanup) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean configure(String name, Map<String, Object> params)
|
||||
throws ConfigurationException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue