summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml1
-rw-r--r--rulemgt/pom.xml16
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/db/CorrelationRuleQueryDaoTest.java10
-rw-r--r--rulemgt/src/test/java/org/openo/holmes/rulemgt/wrapper/RuleMgtWrapperTest.java6
4 files changed, 25 insertions, 8 deletions
diff --git a/pom.xml b/pom.xml
index a699c30..1a0b116 100644
--- a/pom.xml
+++ b/pom.xml
@@ -43,6 +43,7 @@
<pkgzip.dir>${basedir}/../release/pkgzip</pkgzip.dir>
<excludesFile>**/*$*</excludesFile>
<nexusproxy>https://nexus.open-o.org/content</nexusproxy>
+ <powermock.version>1.6.5</powermock.version>
<stringtemplate.version>3.2.1</stringtemplate.version>
diff --git a/rulemgt/pom.xml b/rulemgt/pom.xml
index 2de04ae..7159332 100644
--- a/rulemgt/pom.xml
+++ b/rulemgt/pom.xml
@@ -73,13 +73,25 @@
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
- <version>1.4.10</version>
+ <version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-easymock</artifactId>
- <version>1.4.10</version>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4-rule</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-classloading-xstream</artifactId>
+ <version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
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;