Replace PowerMock/EasyMock by Jmockit (4/4) (#2784)
This commit replaces the PowerMock/EasyMock in our unit tests. (All)
This commit is contained in:
@ -17,6 +17,7 @@
|
||||
|
||||
package org.apache.doris.catalog;
|
||||
|
||||
import mockit.Expectations;
|
||||
import org.apache.doris.alter.AlterJob;
|
||||
import org.apache.doris.alter.AlterJob.JobType;
|
||||
import org.apache.doris.alter.SchemaChangeJob;
|
||||
@ -30,10 +31,6 @@ import org.apache.doris.meta.MetaContext;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.DataInputStream;
|
||||
@ -49,14 +46,18 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockIgnore({ "org.apache.log4j.*", "javax.management.*" })
|
||||
@PrepareForTest(Catalog.class)
|
||||
public class CatalogTest {
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
MetaContext metaContext = new MetaContext();
|
||||
new Expectations(metaContext) {
|
||||
{
|
||||
MetaContext.get();
|
||||
minTimes = 0;
|
||||
result = metaContext;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void mkdir(String dirString) {
|
||||
|
||||
@ -17,40 +17,37 @@
|
||||
|
||||
package org.apache.doris.common.proc;
|
||||
|
||||
import mockit.Expectations;
|
||||
import mockit.Mocked;
|
||||
import org.apache.doris.catalog.Catalog;
|
||||
import org.apache.doris.catalog.Database;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class DbsProcDirTest {
|
||||
private static Database db1;
|
||||
private static Database db2;
|
||||
private Database db1;
|
||||
private Database db2;
|
||||
@Mocked
|
||||
private Catalog catalog;
|
||||
|
||||
// construct test case
|
||||
// catalog
|
||||
// | - db1
|
||||
// | - db2
|
||||
@BeforeClass
|
||||
public static void setUpClass() {
|
||||
db1 = new Database(10000L, "db1");
|
||||
db2 = new Database(10001L, "db2");
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
catalog = EasyMock.createNiceMock(Catalog.class);
|
||||
db1 = new Database(10000L, "db1");
|
||||
db2 = new Database(10001L, "db2");
|
||||
}
|
||||
|
||||
@After
|
||||
@ -68,13 +65,33 @@ public class DbsProcDirTest {
|
||||
|
||||
@Test(expected = AnalysisException.class)
|
||||
public void testLookupNormal() throws AnalysisException {
|
||||
EasyMock.expect(catalog.getDb("db1")).andReturn(db1);
|
||||
EasyMock.expect(catalog.getDb("db2")).andReturn(db2);
|
||||
EasyMock.expect(catalog.getDb("db3")).andReturn(null);
|
||||
EasyMock.expect(catalog.getDb(db1.getId())).andReturn(db1);
|
||||
EasyMock.expect(catalog.getDb(db2.getId())).andReturn(db2);
|
||||
EasyMock.expect(catalog.getDb(10002L)).andReturn(null);
|
||||
EasyMock.replay(catalog);
|
||||
new Expectations(catalog) {
|
||||
{
|
||||
catalog.getDb("db1");
|
||||
minTimes = 0;
|
||||
result = db1;
|
||||
|
||||
catalog.getDb("db2");
|
||||
minTimes = 0;
|
||||
result = db2;
|
||||
|
||||
catalog.getDb("db3");
|
||||
minTimes = 0;
|
||||
result = null;
|
||||
|
||||
catalog.getDb(db1.getId());
|
||||
minTimes = 0;
|
||||
result = db1;
|
||||
|
||||
catalog.getDb(db2.getId());
|
||||
minTimes = 0;
|
||||
result = db2;
|
||||
|
||||
catalog.getDb(anyLong);
|
||||
minTimes = 0;
|
||||
result = null;
|
||||
}
|
||||
};
|
||||
|
||||
DbsProcDir dir;
|
||||
ProcNodeInterface node;
|
||||
@ -126,14 +143,37 @@ public class DbsProcDirTest {
|
||||
|
||||
@Test
|
||||
public void testFetchResultNormal() throws AnalysisException {
|
||||
EasyMock.expect(catalog.getDbNames()).andReturn(Lists.newArrayList("db1", "db2"));
|
||||
EasyMock.expect(catalog.getDb("db1")).andReturn(db1);
|
||||
EasyMock.expect(catalog.getDb("db2")).andReturn(db2);
|
||||
EasyMock.expect(catalog.getDb("db3")).andReturn(null);
|
||||
EasyMock.expect(catalog.getDb(db1.getId())).andReturn(db1);
|
||||
EasyMock.expect(catalog.getDb(db2.getId())).andReturn(db2);
|
||||
EasyMock.expect(catalog.getDb(10002L)).andReturn(null);
|
||||
EasyMock.replay(catalog);
|
||||
new Expectations(catalog) {
|
||||
{
|
||||
catalog.getDbNames();
|
||||
minTimes = 0;
|
||||
result = Lists.newArrayList("db1", "db2");
|
||||
|
||||
catalog.getDb("db1");
|
||||
minTimes = 0;
|
||||
result = db1;
|
||||
|
||||
catalog.getDb("db2");
|
||||
minTimes = 0;
|
||||
result = db2;
|
||||
|
||||
catalog.getDb("db3");
|
||||
minTimes = 0;
|
||||
result = null;
|
||||
|
||||
catalog.getDb(db1.getId());
|
||||
minTimes = 0;
|
||||
result = db1;
|
||||
|
||||
catalog.getDb(db2.getId());
|
||||
minTimes = 0;
|
||||
result = db2;
|
||||
|
||||
catalog.getDb(anyLong);
|
||||
minTimes = 0;
|
||||
result = null;
|
||||
}
|
||||
};
|
||||
|
||||
DbsProcDir dir;
|
||||
ProcResult result;
|
||||
@ -153,8 +193,13 @@ public class DbsProcDirTest {
|
||||
|
||||
@Test
|
||||
public void testFetchResultInvalid() throws AnalysisException {
|
||||
EasyMock.expect(catalog.getDbNames()).andReturn(null);
|
||||
EasyMock.replay(catalog);
|
||||
new Expectations(catalog) {
|
||||
{
|
||||
catalog.getDbNames();
|
||||
minTimes = 0;
|
||||
result = null;
|
||||
}
|
||||
};
|
||||
|
||||
DbsProcDir dir;
|
||||
ProcResult result;
|
||||
|
||||
@ -17,6 +17,10 @@
|
||||
|
||||
package org.apache.doris.http;
|
||||
|
||||
import mockit.Expectations;
|
||||
import mockit.Mock;
|
||||
import mockit.MockUp;
|
||||
import mockit.Mocked;
|
||||
import org.apache.doris.alter.MaterializedViewHandler;
|
||||
import org.apache.doris.alter.SchemaChangeHandler;
|
||||
import org.apache.doris.catalog.Catalog;
|
||||
@ -38,6 +42,7 @@ import org.apache.doris.catalog.TabletInvertedIndex;
|
||||
import org.apache.doris.catalog.TabletMeta;
|
||||
import org.apache.doris.common.AnalysisException;
|
||||
import org.apache.doris.common.DdlException;
|
||||
import org.apache.doris.common.jmockit.Deencapsulation;
|
||||
import org.apache.doris.load.Load;
|
||||
import org.apache.doris.mysql.privilege.PaloAuth;
|
||||
import org.apache.doris.persist.EditLog;
|
||||
@ -47,33 +52,22 @@ import org.apache.doris.system.SystemInfoService;
|
||||
import org.apache.doris.thrift.TStorageMedium;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import mockit.internal.startup.Startup;
|
||||
import okhttp3.Credentials;
|
||||
import okhttp3.MediaType;
|
||||
import okhttp3.OkHttpClient;
|
||||
import org.easymock.EasyMock;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.api.easymock.PowerMock;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.net.ServerSocket;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import junit.framework.AssertionFailedError;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockIgnore({"org.apache.log4j.*", "javax.management.*", "javax.net.ssl.*"})
|
||||
@PrepareForTest({Catalog.class})
|
||||
abstract public class DorisHttpTestCase {
|
||||
|
||||
public OkHttpClient networkClient = new OkHttpClient.Builder()
|
||||
@ -114,6 +108,9 @@ abstract public class DorisHttpTestCase {
|
||||
|
||||
protected String rootAuth = Credentials.basic("root", "");
|
||||
|
||||
@Mocked
|
||||
private static EditLog editLog;
|
||||
|
||||
public static OlapTable newTable(String name) {
|
||||
Catalog.getCurrentInvertedIndex().clear();
|
||||
Column k1 = new Column("k1", PrimitiveType.BIGINT);
|
||||
@ -186,9 +183,9 @@ abstract public class DorisHttpTestCase {
|
||||
|
||||
private static Catalog newDelegateCatalog() {
|
||||
try {
|
||||
Catalog catalog = EasyMock.createMock(Catalog.class);
|
||||
Catalog catalog = Deencapsulation.newInstance(Catalog.class);
|
||||
PaloAuth paloAuth = new PaloAuth();
|
||||
EasyMock.expect(catalog.getAuth()).andReturn(paloAuth).anyTimes();
|
||||
//EasyMock.expect(catalog.getAuth()).andReturn(paloAuth).anyTimes();
|
||||
Database db = new Database(testDbId, "default_cluster:testDb");
|
||||
OlapTable table = newTable(TABLE_NAME);
|
||||
db.createTable(table);
|
||||
@ -196,22 +193,60 @@ abstract public class DorisHttpTestCase {
|
||||
db.createTable(table1);
|
||||
EsTable esTable = newEsTable("es_table");
|
||||
db.createTable(esTable);
|
||||
EasyMock.expect(catalog.getDb(db.getId())).andReturn(db).anyTimes();
|
||||
EasyMock.expect(catalog.getDb("default_cluster:" + DB_NAME)).andReturn(db).anyTimes();
|
||||
EasyMock.expect(catalog.isMaster()).andReturn(true).anyTimes();
|
||||
EasyMock.expect(catalog.getDb("default_cluster:emptyDb")).andReturn(null).anyTimes();
|
||||
EasyMock.expect(catalog.getDb(EasyMock.isA(String.class))).andReturn(new Database()).anyTimes();
|
||||
EasyMock.expect(catalog.getDbNames()).andReturn(Lists.newArrayList("default_cluster:testDb")).anyTimes();
|
||||
EasyMock.expect(catalog.getLoadInstance()).andReturn(new Load()).anyTimes();
|
||||
EasyMock.expect(catalog.getSchemaChangeHandler()).andReturn(new SchemaChangeHandler()).anyTimes();
|
||||
EasyMock.expect(catalog.getRollupHandler()).andReturn(new MaterializedViewHandler()).anyTimes();
|
||||
EasyMock.expect(catalog.getEditLog()).andReturn(EasyMock.createMock(EditLog.class)).anyTimes();
|
||||
EasyMock.expect(catalog.getClusterDbNames("default_cluster")).andReturn(Lists.newArrayList("default_cluster:testDb")).anyTimes();
|
||||
catalog.changeDb(EasyMock.isA(ConnectContext.class), EasyMock.eq("blockDb"));
|
||||
EasyMock.expectLastCall().andThrow(new DdlException("failed.")).anyTimes();
|
||||
catalog.changeDb(EasyMock.isA(ConnectContext.class), EasyMock.isA(String.class));
|
||||
catalog.initDefaultCluster();
|
||||
EasyMock.replay(catalog);
|
||||
new Expectations(catalog) {
|
||||
{
|
||||
catalog.getAuth();
|
||||
minTimes = 0;
|
||||
result = paloAuth;
|
||||
|
||||
catalog.getDb(db.getId());
|
||||
minTimes = 0;
|
||||
result = db;
|
||||
|
||||
catalog.getDb("default_cluster:" + DB_NAME);
|
||||
minTimes = 0;
|
||||
result = db;
|
||||
|
||||
catalog.isMaster();
|
||||
minTimes = 0;
|
||||
result = true;
|
||||
|
||||
catalog.getDb("default_cluster:emptyDb");
|
||||
minTimes = 0;
|
||||
result = null;
|
||||
|
||||
catalog.getDb(anyString);
|
||||
minTimes = 0;
|
||||
result = new Database();
|
||||
|
||||
catalog.getDbNames();
|
||||
minTimes = 0;
|
||||
result = Lists.newArrayList("default_cluster:testDb");
|
||||
|
||||
catalog.getLoadInstance();
|
||||
minTimes = 0;
|
||||
result = new Load();
|
||||
|
||||
catalog.getEditLog();
|
||||
minTimes = 0;
|
||||
result = editLog;
|
||||
|
||||
catalog.getClusterDbNames("default_cluster");
|
||||
minTimes = 0;
|
||||
result = Lists.newArrayList("default_cluster:testDb");
|
||||
|
||||
catalog.changeDb((ConnectContext) any, "blockDb");
|
||||
minTimes = 0;
|
||||
|
||||
catalog.changeDb((ConnectContext) any, anyString);
|
||||
minTimes = 0;
|
||||
|
||||
catalog.initDefaultCluster();
|
||||
minTimes = 0;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return catalog;
|
||||
} catch (DdlException e) {
|
||||
return null;
|
||||
@ -267,12 +302,32 @@ abstract public class DorisHttpTestCase {
|
||||
Catalog catalog = newDelegateCatalog();
|
||||
SystemInfoService systemInfoService = new SystemInfoService();
|
||||
TabletInvertedIndex tabletInvertedIndex = new TabletInvertedIndex();
|
||||
PowerMock.mockStatic(Catalog.class);
|
||||
EasyMock.expect(Catalog.getInstance()).andReturn(catalog).anyTimes();
|
||||
EasyMock.expect(Catalog.getCurrentCatalog()).andReturn(catalog).anyTimes();
|
||||
EasyMock.expect(Catalog.getCurrentSystemInfo()).andReturn(systemInfoService).anyTimes();
|
||||
EasyMock.expect(Catalog.getCurrentInvertedIndex()).andReturn(tabletInvertedIndex).anyTimes();
|
||||
PowerMock.replay(Catalog.class);
|
||||
new MockUp<Catalog>() {
|
||||
@Mock
|
||||
SchemaChangeHandler getSchemaChangeHandler() {
|
||||
return new SchemaChangeHandler();
|
||||
}
|
||||
@Mock
|
||||
MaterializedViewHandler getRollupHandler() {
|
||||
return new MaterializedViewHandler();
|
||||
}
|
||||
@Mock
|
||||
Catalog getInstance() {
|
||||
return catalog;
|
||||
}
|
||||
@Mock
|
||||
Catalog getCurrentCatalog() {
|
||||
return catalog;
|
||||
}
|
||||
@Mock
|
||||
SystemInfoService getCurrentSystemInfo() {
|
||||
return systemInfoService;
|
||||
}
|
||||
@Mock
|
||||
TabletInvertedIndex getCurrentInvertedIndex() {
|
||||
return tabletInvertedIndex;
|
||||
}
|
||||
};
|
||||
assignBackends();
|
||||
doSetUp();
|
||||
}
|
||||
|
||||
@ -17,22 +17,18 @@
|
||||
|
||||
package org.apache.doris.load;
|
||||
|
||||
import mockit.Expectations;
|
||||
import mockit.Mocked;
|
||||
import org.apache.doris.common.Config;
|
||||
import org.apache.doris.common.util.CommandResult;
|
||||
import org.apache.doris.common.util.UnitTestUtil;
|
||||
import org.apache.doris.common.util.Util;
|
||||
import org.apache.doris.thrift.TEtlState;
|
||||
|
||||
import org.easymock.EasyMock;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.api.easymock.PowerMock;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
@ -42,18 +38,18 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockIgnore({ "org.apache.log4j.*", "javax.management.*" })
|
||||
@PrepareForTest(Util.class)
|
||||
public class DppSchedulerTest {
|
||||
private DppScheduler dppScheduler;
|
||||
|
||||
@Mocked
|
||||
private Util util;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
// mock palo home env
|
||||
PowerMock.mockStatic(System.class);
|
||||
EasyMock.expect(System.getenv("DORIS_HOME")).andReturn(".").anyTimes();
|
||||
PowerMock.replay(System.class);
|
||||
// PowerMock.mockStatic(System.class);
|
||||
// EasyMock.expect(System.getenv("DORIS_HOME")).andReturn(".").anyTimes();
|
||||
// PowerMock.replay(System.class);
|
||||
|
||||
UnitTestUtil.initDppConfig();
|
||||
dppScheduler = new DppScheduler(Load.dppDefaultConfig);
|
||||
@ -65,13 +61,16 @@ public class DppSchedulerTest {
|
||||
// mock hadoop count
|
||||
String fileInfos = " 0 1 1000000000 /label2/export/label2.10007.10007.10005\n"
|
||||
+ " 0 1 1000000001 /label2/export/label2.10007.10007.10006";
|
||||
CommandResult result = new CommandResult();
|
||||
result.setReturnCode(0);
|
||||
result.setStdout(fileInfos);
|
||||
PowerMock.mockStatic(Util.class);
|
||||
EasyMock.expect(Util.executeCommand(EasyMock.anyString(),
|
||||
EasyMock.isA(String[].class))).andReturn(result).times(3);
|
||||
PowerMock.replay(Util.class);
|
||||
CommandResult commandResult = new CommandResult();
|
||||
commandResult.setReturnCode(0);
|
||||
commandResult.setStdout(fileInfos);
|
||||
new Expectations(util) {
|
||||
{
|
||||
Util.executeCommand(anyString, (String[]) any);
|
||||
times = 3;
|
||||
result = commandResult;
|
||||
}
|
||||
};
|
||||
|
||||
// get method
|
||||
Method calcReduceNumByInputSize = UnitTestUtil.getPrivateMethod(
|
||||
@ -94,8 +93,6 @@ public class DppSchedulerTest {
|
||||
Assert.assertTrue(true);
|
||||
}
|
||||
Config.load_input_size_limit_gb = 0;
|
||||
|
||||
PowerMock.verifyAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -140,19 +137,21 @@ public class DppSchedulerTest {
|
||||
+ " Map-Reduce Framework\n"
|
||||
+ " Map input records=4085933\n"
|
||||
+ " Map output bytes=503053858";
|
||||
CommandResult result = new CommandResult();
|
||||
result.setReturnCode(0);
|
||||
result.setStdout(jobStatus);
|
||||
PowerMock.mockStatic(Util.class);
|
||||
EasyMock.expect(Util.executeCommand(EasyMock.anyString(),
|
||||
EasyMock.isA(String[].class))).andReturn(result).times(1);
|
||||
PowerMock.replay(Util.class);
|
||||
CommandResult commandResult = new CommandResult();
|
||||
commandResult.setReturnCode(0);
|
||||
commandResult.setStdout(jobStatus);
|
||||
new Expectations(util) {
|
||||
{
|
||||
Util.executeCommand(anyString, (String[]) any);
|
||||
times = 1;
|
||||
result = commandResult;
|
||||
}
|
||||
};
|
||||
|
||||
EtlStatus status = dppScheduler.getEtlJobStatus("etlJobId");
|
||||
Assert.assertEquals(TEtlState.RUNNING, status.getState());
|
||||
Assert.assertEquals("0", status.getCounters().get("dpp.abnorm.ALL"));
|
||||
Assert.assertEquals("0.9036233", status.getStats().get("map() completion"));
|
||||
PowerMock.verifyAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -167,53 +166,50 @@ public class DppSchedulerTest {
|
||||
CommandResult failTestDirResult = new CommandResult();
|
||||
failTestDirResult.setReturnCode(-1);
|
||||
|
||||
// success
|
||||
PowerMock.mockStatic(Util.class);
|
||||
String files = "-rw-r--r-- 3 palo palo 29896160 2015-02-03 13:10 /label_0/export/label_0.32241.32241.0\n"
|
||||
+ "-rw-r--r-- 3 palo palo 29896161 2015-02-03 13:10 /label_0/export/label_0.32241.32241.1";
|
||||
successLsResult.setStdout(files);
|
||||
EasyMock.expect(Util.executeCommand(EasyMock.anyString(),
|
||||
EasyMock.isA(String[].class))).andReturn(successLsResult).times(1);
|
||||
PowerMock.replay(Util.class);
|
||||
new Expectations(util) {
|
||||
{
|
||||
Util.executeCommand(anyString, (String[]) any);
|
||||
times = 6;
|
||||
returns(
|
||||
// success
|
||||
successLsResult,
|
||||
// ls fail
|
||||
failLsResult,
|
||||
// outputPath not exist
|
||||
failTestDirResult,
|
||||
// ls fail
|
||||
failLsResult,
|
||||
// success
|
||||
successTestDirResult,
|
||||
// fileDir not exist
|
||||
failTestDirResult
|
||||
);
|
||||
}
|
||||
};
|
||||
Map<String, Long> fileMap = dppScheduler.getEtlFiles(outputPath);
|
||||
Assert.assertEquals(2, fileMap.size());
|
||||
PowerMock.verifyAll();
|
||||
|
||||
// ls fail and outputPath not exist
|
||||
PowerMock.mockStatic(Util.class);
|
||||
EasyMock.expect(Util.executeCommand(EasyMock.anyString(),
|
||||
EasyMock.isA(String[].class))).andReturn(failLsResult).times(1);
|
||||
EasyMock.expect(Util.executeCommand(EasyMock.anyString(),
|
||||
EasyMock.isA(String[].class))).andReturn(failTestDirResult).times(1);
|
||||
PowerMock.replay(Util.class);
|
||||
Assert.assertNull(dppScheduler.getEtlFiles(outputPath));
|
||||
PowerMock.verifyAll();
|
||||
|
||||
// ls fail and fileDir not exist
|
||||
PowerMock.mockStatic(Util.class);
|
||||
EasyMock.expect(Util.executeCommand(EasyMock.anyString(),
|
||||
EasyMock.isA(String[].class))).andReturn(failLsResult).times(1);
|
||||
EasyMock.expect(Util.executeCommand(EasyMock.anyString(),
|
||||
EasyMock.isA(String[].class))).andReturn(successTestDirResult).times(1);
|
||||
EasyMock.expect(Util.executeCommand(EasyMock.anyString(),
|
||||
EasyMock.isA(String[].class))).andReturn(failTestDirResult).times(1);
|
||||
PowerMock.replay(Util.class);
|
||||
|
||||
fileMap = dppScheduler.getEtlFiles(outputPath);
|
||||
Assert.assertNotNull(fileMap);
|
||||
Assert.assertTrue(fileMap.isEmpty());
|
||||
PowerMock.verifyAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKillEtlJob() {
|
||||
CommandResult result = new CommandResult();
|
||||
PowerMock.mockStatic(Util.class);
|
||||
EasyMock.expect(Util.executeCommand(EasyMock.anyString(),
|
||||
EasyMock.isA(String[].class))).andReturn(result).times(1);
|
||||
PowerMock.replay(Util.class);
|
||||
CommandResult commandResult = new CommandResult();
|
||||
new Expectations(util) {
|
||||
{
|
||||
Util.executeCommand(anyString, (String[]) any);
|
||||
times = 1;
|
||||
result = commandResult;
|
||||
}
|
||||
};
|
||||
|
||||
dppScheduler.killEtlJob("etlJobId");
|
||||
PowerMock.verifyAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@ -17,6 +17,8 @@
|
||||
|
||||
package org.apache.doris.qe;
|
||||
|
||||
import mockit.Expectations;
|
||||
import mockit.Injectable;
|
||||
import org.apache.doris.common.UserException;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
@ -24,10 +26,6 @@ import com.google.common.collect.Maps;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
@ -35,9 +33,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RunWith(PowerMockRunner.class)
|
||||
@PowerMockIgnore({"javax.management.*", "org.apache.log4j.*"})
|
||||
@PrepareForTest({HelpModule.class, HelpObjectLoader.class})
|
||||
public class HelpModuleTest {
|
||||
private List<HelpCategory> categories;
|
||||
private List<HelpTopic> topics;
|
||||
|
||||
Reference in New Issue
Block a user