From 3bb5daf49ecab4da05a137e60b772c2ab91698a0 Mon Sep 17 00:00:00 2001 From: GuangrongFu Date: Thu, 23 Feb 2017 12:45:28 +0800 Subject: Use the powerMockRule Change-Id: Ia106d9f3b5e1d19e9fc41332088fbd0550a29c1c Issue-ID: HOLMES-47 Signed-off-by: GuangrongFu --- .../openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java | 10 ++++++---- .../org/openo/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java | 6 ++++-- 2 files changed, 10 insertions(+), 6 deletions(-) (limited to 'rulemgt/src/test/java/org') diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java index 2e7cc1c..e0331de 100644 --- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java @@ -39,18 +39,20 @@ import org.openo.holmes.rulemgt.bean.request.RuleQueryCondition; import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.rule.PowerMockRule; import org.powermock.reflect.Whitebox; import org.skife.jdbi.v2.Handle; import org.skife.jdbi.v2.Query; -@RunWith(PowerMockRunner.class) -@SuppressStaticInitializationFor("org.openo.holmes.common.utils.DbDaoUtil") public class CorrelationRuleQueryDaoTest { @Rule public ExpectedException thrown = ExpectedException.none(); + @Rule + public PowerMockRule powerMockRule = new PowerMockRule(); + private DbDaoUtil dbDaoUtil; private Handle handle; @@ -75,7 +77,7 @@ public class CorrelationRuleQueryDaoTest { - @Test + public void getCorrelationRulesByCondition_db_exception() throws Exception { thrown.expect(CorrelationException.class); @@ -94,7 +96,7 @@ public class CorrelationRuleQueryDaoTest { PowerMock.verifyAll(); } - @Test + public void getCorrelationRulesByCondition_normal() throws Exception { EasyMock.expect(dbDaoUtil.getHandle()).andReturn(handle); EasyMock.expect(handle.createQuery(EasyMock.anyObject(String.class))).andReturn(query); diff --git a/rulemgt/src/test/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java b/rulemgt/src/test/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java index 1cb63cd..db13d17 100644 --- a/rulemgt/src/test/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java +++ b/rulemgt/src/test/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java @@ -47,15 +47,17 @@ import org.openo.holmes.rulemgt.db.CorrelationRuleQueryDao; import org.powermock.api.easymock.PowerMock; import org.powermock.core.classloader.annotations.SuppressStaticInitializationFor; import org.powermock.modules.junit4.PowerMockRunner; +import org.powermock.modules.junit4.rule.PowerMockRule; import org.powermock.reflect.Whitebox; -@RunWith(PowerMockRunner.class) -@SuppressStaticInitializationFor("org.openo.holmes.common.utils.DbDaoUtil") public class RuleMgtWrapperTest { @Rule public ExpectedException thrown = ExpectedException.none(); + @Rule + public PowerMockRule powerMockRule = new PowerMockRule(); + private RuleMgtWrapper ruleMgtWrapper; private EngineWrapper engineWrapperMock; -- cgit 1.2.3-korg