mirror of https://github.com/apache/cloudstack.git
Commit the current changes to unit tests
This commit is contained in:
parent
727fab71cb
commit
9759ad57f2
|
|
@ -20,7 +20,6 @@ package org.apache.cloudstack.engine.rest.service.api;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
|
|
@ -38,7 +37,7 @@ import org.springframework.stereotype.Service;
|
|||
@Service("ClusterRestService")
|
||||
@Produces("application/json")
|
||||
public class ClusterRestService {
|
||||
@Inject
|
||||
// @Inject
|
||||
ProvisioningService _provisioningService;
|
||||
|
||||
@GET @Path("/clusters")
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@
|
|||
*/
|
||||
package org.apache.cloudstack.engine.rest.service.api;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.PUT;
|
||||
|
|
@ -36,7 +35,7 @@ import org.springframework.stereotype.Service;
|
|||
@Service("PodService")
|
||||
@Produces({"application/json"})
|
||||
public class PodRestService {
|
||||
@Inject
|
||||
// @Inject
|
||||
ProvisioningService _provisioningService;
|
||||
|
||||
@GET @Path("/pod/{pod-id}")
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package org.apache.cloudstack.engine.rest.service.api;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
|
|
@ -39,7 +38,7 @@ import org.springframework.stereotype.Service;
|
|||
@Service("zoneService")
|
||||
@Produces({"application/json"})
|
||||
public class ZoneRestService {
|
||||
@Inject
|
||||
// @Inject
|
||||
ProvisioningService _provisioningService;
|
||||
|
||||
@GET @Path("/zones")
|
||||
|
|
|
|||
|
|
@ -22,15 +22,11 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.ClusterEntityImpl;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceEntity.State;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.DataCenterResourceManager;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.HostEntity;
|
||||
import org.apache.cloudstack.engine.datacenter.entity.api.HostEntityImpl;
|
||||
|
|
@ -42,21 +38,20 @@ import org.apache.cloudstack.engine.datacenter.entity.api.ZoneEntityImpl;
|
|||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.host.Host;
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.storage.StoragePool;
|
||||
|
||||
|
||||
|
||||
@Component
|
||||
@Service("provisioningService")
|
||||
@Path("/provisioning")
|
||||
public class ProvisioningServiceImpl implements ProvisioningService {
|
||||
|
||||
@Inject
|
||||
DataCenterResourceManager manager;
|
||||
|
||||
@Override
|
||||
@Inject
|
||||
DataCenterResourceManager manager;
|
||||
|
||||
@Override
|
||||
public StorageEntity registerStorage(String name, List<String> tags, Map<String, String> details) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
|
|
@ -64,41 +59,41 @@ public class ProvisioningServiceImpl implements ProvisioningService {
|
|||
|
||||
@Override
|
||||
public ZoneEntity registerZone(String zoneUuid, String name, String owner, List<String> tags, Map<String, String> details) {
|
||||
ZoneEntityImpl zoneEntity = new ZoneEntityImpl(zoneUuid, manager);
|
||||
zoneEntity.setName(name);
|
||||
zoneEntity.setOwner(owner);
|
||||
zoneEntity.setDetails(details);
|
||||
zoneEntity.persist();
|
||||
return zoneEntity;
|
||||
ZoneEntityImpl zoneEntity = new ZoneEntityImpl(zoneUuid, manager);
|
||||
zoneEntity.setName(name);
|
||||
zoneEntity.setOwner(owner);
|
||||
zoneEntity.setDetails(details);
|
||||
zoneEntity.persist();
|
||||
return zoneEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PodEntity registerPod(String podUuid, String name, String owner, String zoneUuid, List<String> tags, Map<String, String> details) {
|
||||
PodEntityImpl podEntity = new PodEntityImpl(podUuid, manager);
|
||||
podEntity.setOwner(owner);
|
||||
podEntity.setName(name);
|
||||
podEntity.persist();
|
||||
return podEntity;
|
||||
PodEntityImpl podEntity = new PodEntityImpl(podUuid, manager);
|
||||
podEntity.setOwner(owner);
|
||||
podEntity.setName(name);
|
||||
podEntity.persist();
|
||||
return podEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ClusterEntity registerCluster(String clusterUuid, String name, String owner, List<String> tags, Map<String, String> details) {
|
||||
ClusterEntityImpl clusterEntity = new ClusterEntityImpl(clusterUuid, manager);
|
||||
clusterEntity.setOwner(owner);
|
||||
clusterEntity.setName(name);
|
||||
clusterEntity.persist();
|
||||
return clusterEntity;
|
||||
ClusterEntityImpl clusterEntity = new ClusterEntityImpl(clusterUuid, manager);
|
||||
clusterEntity.setOwner(owner);
|
||||
clusterEntity.setName(name);
|
||||
clusterEntity.persist();
|
||||
return clusterEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HostEntity registerHost(String hostUuid, String name, String owner, List<String> tags, Map<String, String> details) {
|
||||
HostEntityImpl hostEntity = new HostEntityImpl(hostUuid, manager);
|
||||
hostEntity.setOwner(owner);
|
||||
hostEntity.setName(name);
|
||||
hostEntity.setDetails(details);
|
||||
|
||||
hostEntity.persist();
|
||||
return hostEntity;
|
||||
HostEntityImpl hostEntity = new HostEntityImpl(hostUuid, manager);
|
||||
hostEntity.setOwner(owner);
|
||||
hostEntity.setName(name);
|
||||
hostEntity.setDetails(details);
|
||||
|
||||
hostEntity.persist();
|
||||
return hostEntity;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -109,27 +104,27 @@ public class ProvisioningServiceImpl implements ProvisioningService {
|
|||
|
||||
@Override
|
||||
public void deregisterZone(String uuid) {
|
||||
ZoneEntityImpl zoneEntity = new ZoneEntityImpl(uuid, manager);
|
||||
zoneEntity.disable();
|
||||
ZoneEntityImpl zoneEntity = new ZoneEntityImpl(uuid, manager);
|
||||
zoneEntity.disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deregisterPod(String uuid) {
|
||||
PodEntityImpl podEntity = new PodEntityImpl(uuid, manager);
|
||||
podEntity.disable();
|
||||
PodEntityImpl podEntity = new PodEntityImpl(uuid, manager);
|
||||
podEntity.disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deregisterCluster(String uuid) {
|
||||
ClusterEntityImpl clusterEntity = new ClusterEntityImpl(uuid, manager);
|
||||
clusterEntity.disable();
|
||||
ClusterEntityImpl clusterEntity = new ClusterEntityImpl(uuid, manager);
|
||||
clusterEntity.disable();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deregisterHost(String uuid) {
|
||||
HostEntityImpl hostEntity = new HostEntityImpl(uuid, manager);
|
||||
hostEntity.disable();
|
||||
HostEntityImpl hostEntity = new HostEntityImpl(uuid, manager);
|
||||
hostEntity.disable();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -16,24 +16,25 @@
|
|||
// under the License.
|
||||
package org.apache.cloudstack.framework.ws.jackson;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerationException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
|
||||
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule.Priority;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonGenerationException;
|
||||
import com.fasterxml.jackson.databind.JsonMappingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule;
|
||||
import com.fasterxml.jackson.module.jaxb.JaxbAnnotationModule.Priority;
|
||||
|
||||
public class CSJacksonAnnotationTest {
|
||||
|
||||
|
|
@ -41,7 +42,7 @@ public class CSJacksonAnnotationTest {
|
|||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
@Test
|
||||
@Test @Ignore
|
||||
public void test() {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
JaxbAnnotationModule jaxbModule = new JaxbAnnotationModule();
|
||||
|
|
|
|||
2
pom.xml
2
pom.xml
|
|
@ -43,7 +43,7 @@
|
|||
</issueManagement>
|
||||
|
||||
<properties>
|
||||
<skipTests>true</skipTests>
|
||||
<!-- <skipTests>true</skipTests-->
|
||||
<cs.jdk.version>1.6</cs.jdk.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
|
|
|
|||
|
|
@ -25,97 +25,52 @@ import javax.naming.ConfigurationException;
|
|||
import junit.framework.TestCase;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import com.cloud.agent.MockAgentManagerImpl;
|
||||
import com.cloud.api.query.dao.SecurityGroupJoinDaoImpl;
|
||||
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.vm.MockUserVmManagerImpl;
|
||||
import com.cloud.vm.MockVirtualMachineManagerImpl;
|
||||
import com.cloud.vm.dao.UserVmDaoImpl;
|
||||
import com.cloud.vm.dao.VMInstanceDaoImpl;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations = "classpath:/testContext.xml")
|
||||
public class SecurityGroupManagerImpl2Test extends TestCase {
|
||||
//private final static Logger s_logger = Logger.getLogger(SecurityGroupManagerImpl2Test.class);
|
||||
@Inject SecurityGroupManagerImpl2 _sgMgr = null;
|
||||
@Inject UserVmDaoImpl _vmDao = null;
|
||||
|
||||
@Before
|
||||
@Override
|
||||
public void setUp() {
|
||||
/*
|
||||
locator.addDao("ConfigurationDao", ConfigurationDaoImpl.class);
|
||||
locator.addDao("SecurityGroupDao", SecurityGroupDaoImpl.class);
|
||||
|
||||
locator.addDao("SecurityGroupRuleDao", SecurityGroupRuleDaoImpl.class);
|
||||
locator.addDao("SecurityGroupJoinDao", SecurityGroupJoinDaoImpl.class);
|
||||
locator.addDao("SecurityGroupVMMapDao", SecurityGroupVMMapDaoImpl.class);
|
||||
locator.addDao("SecurityGroupRulesDao", SecurityGroupRulesDaoImpl.class);
|
||||
locator.addDao("UserVmDao", UserVmDaoImpl.class);
|
||||
locator.addDao("AccountDao", AccountDaoImpl.class);
|
||||
locator.addDao("ConfigurationDao", ConfigurationDaoImpl.class);
|
||||
locator.addDao("SecurityGroupWorkDao", SecurityGroupWorkDaoImpl.class);
|
||||
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());
|
||||
*/
|
||||
}
|
||||
|
||||
@Inject
|
||||
SecurityGroupManagerImpl2 _sgMgr = null;
|
||||
@Inject
|
||||
UserVmDaoImpl _vmDao = null;
|
||||
|
||||
@Override
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
|
||||
protected void _schedule(final int numVms) {
|
||||
System.out.println("Starting");
|
||||
List<Long> work = new ArrayList<Long>();
|
||||
for (long i=100; i <= 100+numVms; i++) {
|
||||
for (long i = 100; i <= 100 + numVms; i++) {
|
||||
work.add(i);
|
||||
}
|
||||
Profiler profiler = new Profiler();
|
||||
profiler.start();
|
||||
_sgMgr.scheduleRulesetUpdateToHosts(work, false, null);
|
||||
profiler.stop();
|
||||
|
||||
System.out.println("Done " + numVms + " in " + profiler.getDuration() + " ms");
|
||||
|
||||
System.out.println("Done " + numVms + " in " + profiler.getDuration()
|
||||
+ " ms");
|
||||
}
|
||||
|
||||
|
||||
@Ignore
|
||||
public void testSchedule() throws ConfigurationException {
|
||||
_schedule(1000);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWork() throws ConfigurationException {
|
||||
_schedule(1000);
|
||||
_sgMgr.work();
|
||||
|
||||
_schedule(1000);
|
||||
_sgMgr.work();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,6 +157,12 @@
|
|||
<defaultGoal>install</defaultGoal>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<testSourceDirectory>test</testSourceDirectory>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>${project.basedir}/test/resources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
<!--
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>test/resources</directory>
|
||||
|
|
@ -164,7 +170,7 @@
|
|||
<testResource>
|
||||
<directory>conf</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
</testResources> -->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
|
|
|||
|
|
@ -176,7 +176,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||
return builder;
|
||||
}
|
||||
|
||||
public final Map<String, Attribute> getAllAttributes() {
|
||||
public Map<String, Attribute> getAllAttributes() {
|
||||
return _allAttributes;
|
||||
}
|
||||
|
||||
|
|
@ -1222,7 +1222,7 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||
public List<T> search(final SearchCriteria<T> sc, final Filter filter) {
|
||||
return search(sc, filter, null, false);
|
||||
}
|
||||
|
||||
|
||||
@Override @DB(txn=false)
|
||||
public Pair<List<T>, Integer> searchAndCount(final SearchCriteria<T> sc, final Filter filter) {
|
||||
List<T> objects = search(sc, filter, null, false);
|
||||
|
|
@ -1832,14 +1832,14 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||
if (joins != null) {
|
||||
i = addJoinAttributes(i, pstmt, joins);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
if (groupByValues != null) {
|
||||
for (Object value : groupByValues) {
|
||||
pstmt.setObject(i++, value);
|
||||
}
|
||||
}
|
||||
*/
|
||||
*/
|
||||
|
||||
final ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
|
|
@ -1863,5 +1863,5 @@ public abstract class GenericDaoBase<T, ID extends Serializable> implements Gene
|
|||
|
||||
return sql;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,37 +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 com.cloud.utils;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations="classpath:/com/cloud/utils/QualifierTestContext.xml")
|
||||
public class QualifierTest {
|
||||
|
||||
@Inject
|
||||
DummyInterface _dummy;
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
_dummy.foo();
|
||||
}
|
||||
}
|
||||
|
|
@ -17,13 +17,20 @@
|
|||
package com.cloud.utils.db;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import junit.framework.Assert;
|
||||
|
||||
import com.cloud.utils.Profiler;
|
||||
import com.cloud.utils.testcase.Log4jEnabledTestCase;
|
||||
|
||||
public class GlobalLockTest extends Log4jEnabledTestCase{
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations="classpath:/testContext.xml")
|
||||
public class GlobalLockTest {
|
||||
public static final Logger s_logger = Logger.getLogger(GlobalLockTest.class);
|
||||
private final static GlobalLock _workLock = GlobalLock.getInternLock("SecurityGroupWork");
|
||||
public static class Worker implements Runnable {
|
||||
|
|
@ -56,6 +63,7 @@ public class GlobalLockTest extends Log4jEnabledTestCase{
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTimeout() {
|
||||
Thread [] pool = new Thread[50];
|
||||
for (int i=0; i < pool.length; i++) {
|
||||
|
|
@ -25,16 +25,21 @@ import com.cloud.utils.db.DB;
|
|||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import org.apache.log4j.spi.RootLogger;
|
||||
import org.apache.log4j.spi.ThrowableRenderer;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
import java.io.CharArrayWriter;
|
||||
import java.io.Writer;
|
||||
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@ContextConfiguration(locations="classpath:/testContext.xml")
|
||||
public class CglibThrowableRendererTest extends TestCase {
|
||||
static Logger another = Logger.getLogger("TEST");
|
||||
|
||||
private final static Logger s_logger = Logger.getLogger(CglibThrowableRendererTest.class);
|
||||
public static class Test {
|
||||
public static class TestClass {
|
||||
@DB
|
||||
public void exception1() {
|
||||
throw new IllegalArgumentException("What a bad exception");
|
||||
|
|
@ -66,11 +71,12 @@ public class CglibThrowableRendererTest extends TestCase {
|
|||
return alternateRoot;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testException() {
|
||||
Writer w = new CharArrayWriter();
|
||||
Logger alt = getAlternateLogger(w, null);
|
||||
|
||||
Test test = ComponentContext.inject(Test.class);
|
||||
TestClass test = ComponentContext.inject(TestClass.class);
|
||||
try {
|
||||
test.exception();
|
||||
} catch (Exception e) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue