GP-2185 - removed JMockit usage from some tests (part 5)

This commit is contained in:
dragonmacher 2022-06-16 12:03:06 -04:00
parent 0e3fe30c67
commit 0f633960fa
14 changed files with 835 additions and 248 deletions

View file

@ -15,15 +15,13 @@
*/
package ghidra.feature.vt.api.markupitem;
import static ghidra.feature.vt.db.VTTestUtils.createProgramCorrelator;
import static ghidra.feature.vt.db.VTTestUtils.createRandomMarkupItemStub;
import static org.junit.Assert.assertEquals;
import static ghidra.feature.vt.db.VTTestUtils.*;
import static org.junit.Assert.*;
import java.util.Collection;
import org.junit.*;
import ghidra.feature.vt.api.db.AssociationDatabaseManager;
import ghidra.feature.vt.api.main.*;
import ghidra.feature.vt.api.util.VTAssociationStatusException;
import ghidra.feature.vt.api.util.VersionTrackingApplyException;
@ -31,18 +29,15 @@ import ghidra.feature.vt.db.VTBaseTestCase;
import ghidra.feature.vt.db.VTTestUtils;
import ghidra.program.model.address.Address;
import ghidra.util.task.TaskMonitor;
import ghidra.util.task.TaskMonitorAdapter;
public class VTMarkupItemResetTest extends VTBaseTestCase {
private int testTransactionID;
private AssociationDatabaseManager associationDBM;
@Override
@Before
public void setUp() throws Exception {
super.setUp();
associationDBM = db.getAssociationManagerDBM();
testTransactionID = db.startTransaction("Test Match Set Setup");
}
@ -253,7 +248,7 @@ public class VTMarkupItemResetTest extends VTBaseTestCase {
Object markupItemManager = getInstanceField("markupManager", association);
return (Collection<VTMarkupItem>) invokeInstanceMethod("getStoredMarkupItems",
markupItemManager, new Class[] { TaskMonitor.class },
new Object[] { TaskMonitorAdapter.DUMMY_MONITOR });
new Object[] { TaskMonitor.DUMMY });
}
private VTMarkupItemApplyActionType createRandomApplyAction(VTMarkupItem item) {

View file

@ -15,10 +15,8 @@
*/
package ghidra.feature.vt.db;
import static ghidra.feature.vt.db.VTTestUtils.createProgramCorrelator;
import static ghidra.feature.vt.db.VTTestUtils.createRandomMarkupItemStub;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static ghidra.feature.vt.db.VTTestUtils.*;
import static org.junit.Assert.*;
import java.util.Collection;
@ -38,10 +36,6 @@ public class UnappliedMarkupItemStorageDBTest extends VTBaseTestCase {
private int testTransactionID;
public UnappliedMarkupItemStorageDBTest() {
super();
}
@Override
@Before
public void setUp() throws Exception {

View file

@ -16,8 +16,7 @@
package ghidra.feature.vt.db;
import static ghidra.feature.vt.db.VTTestUtils.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import java.util.Collection;
import java.util.Collections;
@ -33,18 +32,11 @@ import ghidra.feature.vt.api.util.VersionTrackingApplyException;
import ghidra.program.model.address.Address;
import ghidra.util.exception.CancelledException;
import ghidra.util.task.TaskMonitor;
import ghidra.util.task.TaskMonitorAdapter;
import mockit.Mocked;
import mockit.Verifications;
public class VTAssociationDBTest extends VTBaseTestCase {
private int testTransactionID;
public VTAssociationDBTest() {
super();
}
@Override
@Before
public void setUp() throws Exception {
@ -57,7 +49,6 @@ public class VTAssociationDBTest extends VTBaseTestCase {
public void tearDown() throws Exception {
db.endTransaction(testTransactionID, false);
db.release(VTTestUtils.class);
}
@Test
@ -143,7 +134,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
Object markupItemManager = getInstanceField("markupManager", association);
return (Collection<VTMarkupItem>) invokeInstanceMethod("getStoredMarkupItems",
markupItemManager, new Class[] { TaskMonitor.class },
new Object[] { TaskMonitorAdapter.DUMMY_MONITOR });
new Object[] { TaskMonitor.DUMMY });
}
@Test
@ -597,8 +588,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
createRandomMarkupItemStub(match, addr());// second item
VTAssociation association = match.getAssociation();
Collection<VTMarkupItem> items =
association.getMarkupItems(TaskMonitorAdapter.DUMMY_MONITOR);
Collection<VTMarkupItem> items = association.getMarkupItems(TaskMonitor.DUMMY);
assertEquals("Did not find multiple markup items as expected", 2, items.size());
VTMarkupItemApplyActionType applyAction = createRandomSuccessfulApplyAction(markupItem);
@ -637,8 +627,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
VTMarkupItem secondAppliedItem = createRandomMarkupItemStub(match, addr());// second item
VTAssociation association = match.getAssociation();
Collection<VTMarkupItem> items =
association.getMarkupItems(TaskMonitorAdapter.DUMMY_MONITOR);
Collection<VTMarkupItem> items = association.getMarkupItems(TaskMonitor.DUMMY);
assertEquals("Did not find multiple markup items as expected", 2, items.size());
VTMarkupItemApplyActionType applyAction = createRandomSuccessfulApplyAction(markupItem);
@ -706,23 +695,20 @@ public class VTAssociationDBTest extends VTBaseTestCase {
}
@Test
public void testAssociationHook(@Mocked final AssociationHook mockHook) throws Exception {
public void testAssociationHook() throws Exception {
VTMatchSet matchSet = db.createMatchSet(
createProgramCorrelator(null, db.getSourceProgram(), db.getDestinationProgram()));
VTMatchInfo mainMatchInfo = createRandomMatch(db);
VTMatch mainMatch = addMatch(matchSet, mainMatchInfo);
final VTAssociation association = mainMatch.getAssociation();
SpyAssociationHook spyHook = new SpyAssociationHook();
db.addAssociationHook(mockHook);
db.addAssociationHook(spyHook);
mainMatch.getAssociation().setAccepted();
mainMatch.getAssociation().clearStatus();
new Verifications() {
{
mockHook.associationAccepted(association);
mockHook.associationCleared(association);
}
};
assertTrue(spyHook.acceptedCalled);
assertTrue(spyHook.clearedCalled);
}
@Test
@ -756,8 +742,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
assertEquals(VTAssociationStatus.AVAILABLE, mainAssociation.getStatus());
VTMarkupItem markupItem = VTTestUtils.createRandomMarkupItemStub(mainMatch);
Collection<VTMarkupItem> items =
mainAssociation.getMarkupItems(TaskMonitorAdapter.DUMMY_MONITOR);
Collection<VTMarkupItem> items = mainAssociation.getMarkupItems(TaskMonitor.DUMMY);
assertEquals(1, items.size());
mainAssociation.setRejected();
@ -784,8 +769,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
assertEquals(VTAssociationStatus.AVAILABLE, mainAssociation.getStatus());
VTMarkupItem markupItem = VTTestUtils.createRandomMarkupItemStub(mainMatch);
Collection<VTMarkupItem> items =
mainAssociation.getMarkupItems(TaskMonitorAdapter.DUMMY_MONITOR);
Collection<VTMarkupItem> items = mainAssociation.getMarkupItems(TaskMonitor.DUMMY);
assertEquals(1, items.size());
mainAssociation.setAccepted();
@ -831,7 +815,7 @@ public class VTAssociationDBTest extends VTBaseTestCase {
// implementation for a test dummy.
VTAssociationDB associationDB = (VTAssociationDB) newMatch.getAssociation();
setInstanceField("markupManager", associationDB,
new MarkupItemManagerImplDummy(associationDB));
new DummyMarkupItemManagerImpl(associationDB));
return newMatch;
}
@ -847,9 +831,9 @@ public class VTAssociationDBTest extends VTBaseTestCase {
// Inner Classes
//==================================================================================================
private class MarkupItemManagerImplDummy extends MarkupItemManagerImpl {
private class DummyMarkupItemManagerImpl extends MarkupItemManagerImpl {
MarkupItemManagerImplDummy(VTAssociationDB associationDB) {
DummyMarkupItemManagerImpl(VTAssociationDB associationDB) {
super(associationDB);
}
@ -859,4 +843,26 @@ public class VTAssociationDBTest extends VTBaseTestCase {
return Collections.emptyList();
}
}
private class SpyAssociationHook implements AssociationHook {
boolean acceptedCalled;
boolean clearedCalled;
@Override
public void associationAccepted(VTAssociation association) {
acceptedCalled = true;
}
@Override
public void associationCleared(VTAssociation association) {
clearedCalled = true;
}
@Override
public void markupItemStatusChanged(VTMarkupItem markupItem) {
// stub
}
}
}

View file

@ -16,7 +16,6 @@
package ghidra.feature.vt.db;
import java.io.IOException;
import java.util.ArrayList;
import org.junit.After;
import org.junit.Before;
@ -25,27 +24,41 @@ import generic.test.AbstractGenericTest;
import ghidra.feature.vt.api.db.VTSessionDB;
import ghidra.feature.vt.api.main.*;
import ghidra.framework.model.DomainFile;
import ghidra.framework.model.TestDummyDomainFile;
import ghidra.program.database.map.AddressMap;
import ghidra.program.model.StubFunctionManager;
import ghidra.program.model.StubProgram;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.Memory;
import ghidra.program.model.mem.StubMemory;
import ghidra.program.model.symbol.*;
import mockit.*;
public class VTBaseTestCase extends AbstractGenericTest {
@Injectable
Program sourceProgram, destinationProgram;
@Mocked
FunctionManager functionManager;
@Mocked
Listing listing;
@Mocked
SymbolTable symbolTable;
@Injectable
DomainFile sourceDomainFile, destinationDomainFile;
@Mocked
Memory memory;
AddressMap addressMap = new AddressMapTestDummy();
private DomainFile sourceDomainFile = new TestDummyDomainFile(null, "SourceDomainFile") {
@Override
public String getFileID() {
return "Source Program " + testID;
}
};
private DomainFile destinationDomainFile =
new TestDummyDomainFile(null, "DestinationDomainFile") {
@Override
public String getFileID() {
return "Destination Program " + testID;
}
};
private Program sourceProgram = new VTStubProgram(sourceDomainFile);
private Program destinationProgram = new VTStubProgram(destinationDomainFile);
private FunctionManager functionManager = new VTSTubFunctionManager();
private Listing listing = new VTStubListing();
private SymbolTable symbolTable = new VTStubSymbolTable();
private Memory memory = new VTStubMemory();
private AddressMap addressMap = new AddressMapTestDummy();
private static String[] randomTags = { "TAG1", "TAG2", "TAG3" };
private static GenericAddressSpace space =
new GenericAddressSpace("Test", 32, AddressSpace.TYPE_RAM, 3);
@ -57,9 +70,6 @@ public class VTBaseTestCase extends AbstractGenericTest {
@Before
public void setUp() throws Exception {
testID++;
setupCommonExpectations();
setupSourceProgramExpectations();
setupDestinationProgramExpectations();
db = createVTSession();
transactionID = db.startTransaction("Test");
}
@ -75,107 +85,6 @@ public class VTBaseTestCase extends AbstractGenericTest {
VTTestUtils.class);
}
private void setupCommonExpectations() {
new Expectations() {
{
functionManager.getFunctionContaining((Address) any);
minTimes = 0;
result = null;
functionManager.getFunctionAt((Address) any);
minTimes = 0;
result = null;
}
};
new Expectations() {
{
listing.getCodeUnitAt((Address) any);
minTimes = 0;
result = null;
listing.getCommentAddressIterator(anyInt, null, true);
minTimes = 0;
result = new EmptyAddressIterator();
}
};
new Expectations() {
{
symbolTable.getPrimarySymbolIterator((AddressSetView) any, true);
minTimes = 0;
result = new SymbolIteratorAdapter(new ArrayList<Symbol>().iterator());
}
};
}
private void setupDestinationProgramExpectations() {
new Expectations() {
{
destinationDomainFile.getFileID();
result = "Destination Program " + testID;
destinationProgram.getDomainFile();
result = destinationDomainFile;
}
};
setupProgramExpectations(destinationProgram);
}
private void setupSourceProgramExpectations() {
new Expectations() {
{
sourceDomainFile.getFileID();
result = "Source Program " + testID;
sourceProgram.getDomainFile();
result = sourceDomainFile;
}
};
setupProgramExpectations(sourceProgram);
}
private void setupProgramExpectations(final Program program) {
new Expectations() {
{
program.addConsumer(any);
minTimes = 0;
program.release(any);
minTimes = 0;
program.getUniqueProgramID();
minTimes = 0;
result = testID;
program.getMemory();
minTimes = 0;
result = memory;
program.getAddressMap();
minTimes = 0;
result = addressMap;
program.getFunctionManager();
minTimes = 0;
result = functionManager;
program.getListing();
minTimes = 0;
result = listing;
program.getAddressFactory();
minTimes = 0;
result = null;
program.getSymbolTable();
minTimes = 0;
result = symbolTable;
program.getModificationNumber();
minTimes = 0;
result = 0;
}
};
}
public static int getRandomInt() {
return getRandomInt(0, Integer.MAX_VALUE);
}
@ -200,7 +109,8 @@ public class VTBaseTestCase extends AbstractGenericTest {
/**
* Create a random match
* @param association the association to use for the source and destination address.
* @param sourceAddress the source address
* @param destinationAddress the destination address
* @param session the match set manager to use when creating a random tag or
* null if you don't want to create a random tag.
* @return the match
@ -237,4 +147,111 @@ public class VTBaseTestCase extends AbstractGenericTest {
String name = randomTags[randomInt];
return session.createMatchTag(name);
}
//=================================================================================================
// Inner Classes
//=================================================================================================
private class VTStubMemory extends StubMemory {
@Override
public AddressRangeIterator getAddressRanges() {
return new EmptyAddressRangeIterator();
}
}
private class VTStubSymbolTable extends StubSymbolTable {
@Override
public SymbolIterator getPrimarySymbolIterator(AddressSetView asv, boolean forward) {
return SymbolIterator.EMPTY_ITERATOR;
}
}
private class VTStubListing extends StubListing {
@Override
public CodeUnit getCodeUnitAt(Address addr) {
return null;
}
@Override
public AddressIterator getCommentAddressIterator(int commentType, AddressSetView addrSet,
boolean forward) {
return new EmptyAddressIterator();
}
}
private class VTSTubFunctionManager extends StubFunctionManager {
@Override
public Function getFunctionContaining(Address addr) {
return null;
}
@Override
public Function getFunctionAt(Address entryPoint) {
return null;
}
}
private class VTStubProgram extends StubProgram {
private DomainFile domainFile;
VTStubProgram(DomainFile domainFile) {
this.domainFile = domainFile;
}
@Override
public DomainFile getDomainFile() {
return domainFile;
}
@Override
public long getUniqueProgramID() {
return testID;
}
@Override
public boolean addConsumer(Object consumer) {
return true;
}
@Override
public void release(Object consumer) {
// stub
}
@Override
public Memory getMemory() {
return memory;
}
@Override
public AddressMap getAddressMap() {
return addressMap;
}
@Override
public FunctionManager getFunctionManager() {
return functionManager;
}
@Override
public Listing getListing() {
return listing;
}
@Override
public AddressFactory getAddressFactory() {
return null;
}
@Override
public SymbolTable getSymbolTable() {
return symbolTable;
}
@Override
public long getModificationNumber() {
return 0;
}
}
}

View file

@ -15,8 +15,8 @@
*/
package ghidra.feature.vt.db;
import static ghidra.feature.vt.db.VTTestUtils.createProgramCorrelator;
import static org.junit.Assert.assertEquals;
import static ghidra.feature.vt.db.VTTestUtils.*;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
@ -31,8 +31,6 @@ import ghidra.feature.vt.api.util.VTAssociationStatusException;
import ghidra.framework.model.*;
import ghidra.program.model.address.Address;
import ghidra.util.Msg;
import mockit.Mock;
import mockit.MockUp;
public class VTDomainObjectEventsTest extends VTBaseTestCase {
@ -52,10 +50,6 @@ public class VTDomainObjectEventsTest extends VTBaseTestCase {
}
};
public VTDomainObjectEventsTest() {
super();
}
@Override
@Before
public void setUp() throws Exception {
@ -77,13 +71,8 @@ public class VTDomainObjectEventsTest extends VTBaseTestCase {
// synchronize events when we flush them. Here we mock the timer, preventing it
// from starting. Without the timer, we can rely on our flushing of the queued events.
new MockUp<T>() {
@Mock
public void start() {
// never let the timer start
}
};
// TODO Not sure we need to disable this timer any more. Leaving this comment here for
// a while in case we get sporadic test failures
}
@Override

View file

@ -28,28 +28,23 @@ import ghidra.feature.vt.api.impl.VersionTrackingChangeRecord;
import ghidra.feature.vt.api.main.*;
import ghidra.feature.vt.db.DummyTestProgramCorrelator;
import ghidra.feature.vt.db.VTBaseTestCase;
import ghidra.feature.vt.gui.plugin.VTController;
import ghidra.feature.vt.gui.plugin.VTControllerListener;
import ghidra.feature.vt.gui.plugin.*;
import ghidra.feature.vt.gui.util.MatchInfo;
import ghidra.framework.data.DummyDomainObject;
import ghidra.framework.model.*;
import ghidra.framework.model.DomainObjectChangeRecord;
import ghidra.framework.model.DomainObjectChangedEvent;
import ghidra.framework.options.Options;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.program.model.listing.Program;
import mockit.*;
public class TagFilterTest extends VTBaseTestCase {
@Mocked
VTController controller;
@Mocked
DomainFile domainFile;
private VTController controller;
private TagFilter tagFilter;
private TestTagFilterChooser excludedTagChooser;
private VTControllerListener listener;
public TagFilterTest() {
super();
}
private VTControllerListener listener = new StubControllerListener();
@Override
@Before
@ -338,23 +333,54 @@ public class TagFilterTest extends VTBaseTestCase {
// controller creation
private VTController createController() {
final VTSession session = createSession();
VTSession session = createSession();
return new StubVTController() {
@Override
public VTSession getSession() {
return session;
}
new Expectations() {
{
controller.addListener(with(new ListenerDelegate()));
controller.getSession();
result = session;
@Override
public void addListener(VTControllerListener l) {
// stub
}
};
return controller;
}
class ListenerDelegate implements Delegate<VTControllerListener> {
class StubControllerListener implements VTControllerListener {
void validate(VTControllerListener l) {
listener = l;
}
@Override
public void sessionChanged(VTSession session) {
// stub
}
@Override
public void matchSelected(MatchInfo matchInfo) {
// stub
}
@Override
public void sessionUpdated(DomainObjectChangedEvent ev) {
// stub
}
@Override
public void markupItemSelected(VTMarkupItem markupItem) {
// stub
}
@Override
public void optionsChanged(Options options) {
// stub
}
@Override
public void disposed() {
// stub
}
}
private VTSessionDB createSession() {

View file

@ -0,0 +1,251 @@
/* ###
* IP: GHIDRA
*
* Licensed 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 ghidra.feature.vt.gui.plugin;
import java.awt.Component;
import java.util.List;
import docking.ActionContext;
import ghidra.app.plugin.core.colorizer.ColorizingService;
import ghidra.feature.vt.api.main.*;
import ghidra.feature.vt.gui.task.VtTask;
import ghidra.feature.vt.gui.util.MatchInfo;
import ghidra.framework.model.DomainFile;
import ghidra.framework.model.DomainObjectChangedEvent;
import ghidra.framework.options.SaveState;
import ghidra.framework.options.ToolOptions;
import ghidra.framework.plugintool.PluginTool;
import ghidra.framework.plugintool.ServiceProvider;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.listing.*;
import ghidra.program.model.symbol.Symbol;
import ghidra.program.util.AddressCorrelation;
import ghidra.program.util.ProgramLocation;
public class StubVTController implements VTController {
@Override
public void addListener(VTControllerListener listener) {
throw new UnsupportedOperationException();
}
@Override
public void removeListener(VTControllerListener listener) {
throw new UnsupportedOperationException();
}
@Override
public VTSession getSession() {
throw new UnsupportedOperationException();
}
@Override
public void openVersionTrackingSession(DomainFile domainFile) {
throw new UnsupportedOperationException();
}
@Override
public void openVersionTrackingSession(VTSession session) {
throw new UnsupportedOperationException();
}
@Override
public boolean closeVersionTrackingSession() {
throw new UnsupportedOperationException();
}
@Override
public void closeCurrentSessionIgnoringChanges() {
throw new UnsupportedOperationException();
}
@Override
public void dispose() {
throw new UnsupportedOperationException();
}
@Override
public void readConfigState(SaveState saveState) {
throw new UnsupportedOperationException();
}
@Override
public void writeConfigState(SaveState saveState) {
throw new UnsupportedOperationException();
}
@Override
public Program getSourceProgram() {
throw new UnsupportedOperationException();
}
@Override
public Program getDestinationProgram() {
throw new UnsupportedOperationException();
}
@Override
public boolean checkForUnSavedChanges() {
throw new UnsupportedOperationException();
}
@Override
public AddressCorrelation getCorrelator(Function source, Function destination) {
throw new UnsupportedOperationException();
}
@Override
public AddressCorrelation getCorrelator(Data source, Data destination) {
throw new UnsupportedOperationException();
}
@Override
public VTMarkupItem getCurrentMarkupForLocation(ProgramLocation location, Program program) {
throw new UnsupportedOperationException();
}
@Override
public List<VTMarkupItem> getMarkupItems(ActionContext context) {
throw new UnsupportedOperationException();
}
@Override
public ToolOptions getOptions() {
throw new UnsupportedOperationException();
}
@Override
public Component getParentComponent() {
throw new UnsupportedOperationException();
}
@Override
public ServiceProvider getServiceProvider() {
throw new UnsupportedOperationException();
}
@Override
public String getVersionTrackingSessionName() {
throw new UnsupportedOperationException();
}
@Override
public void refresh() {
throw new UnsupportedOperationException();
}
@Override
public MatchInfo getMatchInfo() {
throw new UnsupportedOperationException();
}
@Override
public PluginTool getTool() {
throw new UnsupportedOperationException();
}
@Override
public void setSelectedMatch(VTMatch match) {
throw new UnsupportedOperationException();
}
@Override
public MatchInfo getMatchInfo(VTMatch match) {
throw new UnsupportedOperationException();
}
@Override
public void setSelectedMarkupItem(VTMarkupItem markupItem) {
throw new UnsupportedOperationException();
}
@Override
public AddressCorrelatorManager getCorrelator() {
throw new UnsupportedOperationException();
}
@Override
public void domainObjectChanged(DomainObjectChangedEvent ev) {
throw new UnsupportedOperationException();
}
@Override
public void optionsChanged(ToolOptions options, String optionName, Object oldValue,
Object newValue) {
throw new UnsupportedOperationException();
}
@Override
public void gotoSourceLocation(ProgramLocation location) {
throw new UnsupportedOperationException();
}
@Override
public void gotoDestinationLocation(ProgramLocation location) {
throw new UnsupportedOperationException();
}
@Override
public void runVTTask(VtTask task) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getSourceSymbol(VTAssociation association) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getDestinationSymbol(VTAssociation association) {
throw new UnsupportedOperationException();
}
@Override
public AddressSetView getSelectionInSourceTool() {
throw new UnsupportedOperationException();
}
@Override
public AddressSetView getSelectionInDestinationTool() {
throw new UnsupportedOperationException();
}
@Override
public void setSelectionInSourceTool(AddressSetView sourceSet) {
throw new UnsupportedOperationException();
}
@Override
public void setSelectionInDestinationTool(AddressSetView destinationSet) {
throw new UnsupportedOperationException();
}
@Override
public void markupItemStatusChanged(VTMarkupItem markupItem) {
throw new UnsupportedOperationException();
}
@Override
public ColorizingService getSourceColorizingService() {
throw new UnsupportedOperationException();
}
@Override
public ColorizingService getDestinationColorizingService() {
throw new UnsupportedOperationException();
}
}

View file

@ -20,7 +20,8 @@ import java.util.List;
import ghidra.program.database.function.OverlappingFunctionException;
import ghidra.program.model.address.*;
import ghidra.program.model.data.*;
import ghidra.program.model.data.DataType;
import ghidra.program.model.data.DataTypeManager;
import ghidra.program.model.lang.*;
import ghidra.program.model.mem.MemBuffer;
import ghidra.program.model.symbol.Namespace;
@ -35,7 +36,7 @@ import ghidra.util.task.TaskMonitor;
* for all methods in the Listing interface. Any method that is needed for your test can then
* be overridden so it can provide its own test implementation and return value.
*/
public class ListingStub implements Listing {
public class StubListing implements Listing {
@Override
public CodeUnit getCodeUnitAt(Address addr) {
@ -304,8 +305,7 @@ public class ListingStub implements Listing {
}
@Override
public Data createData(Address addr, DataType dataType)
throws CodeUnitInsertionException {
public Data createData(Address addr, DataType dataType) throws CodeUnitInsertionException {
throw new UnsupportedOperationException();
}

View file

@ -32,15 +32,15 @@ import ghidra.util.task.TaskMonitor;
* for all methods in the Memory interface. Any method that is needed for your test can then
* be overridden so it can provide its own test implementation and return value.
*/
public class MemoryStub extends AddressSet implements Memory {
public class StubMemory extends AddressSet implements Memory {
byte[] myMemoryBytes;
MemoryBlock myMemoryBlock;
public MemoryStub() {
public StubMemory() {
this(new byte[] { 0, 0, 0, 0, 0, 0, 0, 0 });
}
public MemoryStub(byte[] bytes) {
public StubMemory(byte[] bytes) {
super();
this.myMemoryBytes = bytes;
AddressSpace space = new GenericAddressSpace("Mem", 32, AddressSpace.TYPE_RAM, 0);

View file

@ -31,7 +31,7 @@ import ghidra.util.exception.CancelledException;
import ghidra.util.exception.InvalidInputException;
import ghidra.util.task.TaskMonitor;
public class FunctionManagerTestDouble implements FunctionManager {
public class StubFunctionManager implements FunctionManager {
@Override
public ProgramDB getProgram() {

View file

@ -39,7 +39,7 @@ import ghidra.util.exception.CancelledException;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.task.TaskMonitor;
public class ProgramTestDouble implements Program {
public class StubProgram implements Program {
@Override
public int startTransaction(String description) {

View file

@ -21,7 +21,7 @@ import static org.junit.Assert.assertTrue;
import org.junit.*;
import generic.test.AbstractGTest;
import ghidra.program.model.ProgramTestDouble;
import ghidra.program.model.StubProgram;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.program.model.mem.*;
@ -249,7 +249,7 @@ public class DataUtilitiesTest extends AbstractGTest {
//================================================================
private Program createProgram() {
return new ProgramTestDouble() {
return new StubProgram() {
@Override
public AddressFactory getAddressFactory() {
@ -268,7 +268,7 @@ public class DataUtilitiesTest extends AbstractGTest {
};
}
private class MyMemory extends MemoryStub {
private class MyMemory extends StubMemory {
@Override
public MemoryBlock getBlock(Address addr) {
@ -335,7 +335,7 @@ public class DataUtilitiesTest extends AbstractGTest {
}
}
private class MyListing extends ListingStub {
private class MyListing extends StubListing {
@Override
public Data getDataContaining(Address address) {

View file

@ -0,0 +1,309 @@
/* ###
* IP: GHIDRA
*
* Licensed 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 ghidra.program.model.symbol;
import java.util.Iterator;
import java.util.List;
import ghidra.program.model.address.*;
import ghidra.program.model.listing.*;
import ghidra.util.exception.DuplicateNameException;
import ghidra.util.exception.InvalidInputException;
public class StubSymbolTable implements SymbolTable {
@Override
public Symbol createLabel(Address addr, String name, SourceType source)
throws InvalidInputException {
throw new UnsupportedOperationException();
}
@Override
public Symbol createLabel(Address addr, String name, Namespace namespace, SourceType source)
throws InvalidInputException {
throw new UnsupportedOperationException();
}
@Override
public boolean removeSymbolSpecial(Symbol sym) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getSymbol(long symbolID) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getSymbol(String name, Address addr, Namespace namespace) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getGlobalSymbol(String name, Address addr) {
throw new UnsupportedOperationException();
}
@Override
public List<Symbol> getGlobalSymbols(String name) {
throw new UnsupportedOperationException();
}
@Override
public List<Symbol> getLabelOrFunctionSymbols(String name, Namespace namespace) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getNamespaceSymbol(String name, Namespace namespace) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getLibrarySymbol(String name) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getClassSymbol(String name, Namespace namespace) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getParameterSymbol(String name, Namespace namespace) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getLocalVariableSymbol(String name, Namespace namespace) {
throw new UnsupportedOperationException();
}
@Override
public List<Symbol> getSymbols(String name, Namespace namespace) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getVariableSymbol(String name, Function function) {
throw new UnsupportedOperationException();
}
@Override
public Namespace getNamespace(String name, Namespace namespace) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getSymbols(String name) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getAllSymbols(boolean includeDynamicSymbols) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getSymbol(Reference ref) {
throw new UnsupportedOperationException();
}
@Override
public Symbol getPrimarySymbol(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public Symbol[] getSymbols(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getSymbolsAsIterator(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public Symbol[] getUserSymbols(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getSymbols(Namespace namespace) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getSymbols(long namespaceID) {
throw new UnsupportedOperationException();
}
@Override
public boolean hasSymbol(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public long getDynamicSymbolID(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getSymbolIterator(String searchStr, boolean caseSensitive) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getSymbols(AddressSetView set, SymbolType type, boolean forward) {
throw new UnsupportedOperationException();
}
@Override
public int getNumSymbols() {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getSymbolIterator() {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getDefinedSymbols() {
throw new UnsupportedOperationException();
}
@Override
public Symbol getExternalSymbol(String name) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getExternalSymbols(String name) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getExternalSymbols() {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getSymbolIterator(boolean forward) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getSymbolIterator(Address startAddr, boolean forward) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getPrimarySymbolIterator(boolean forward) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getPrimarySymbolIterator(Address startAddr, boolean forward) {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getPrimarySymbolIterator(AddressSetView asv, boolean forward) {
throw new UnsupportedOperationException();
}
@Override
public void addExternalEntryPoint(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public void removeExternalEntryPoint(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public boolean isExternalEntryPoint(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public AddressIterator getExternalEntryPointIterator() {
throw new UnsupportedOperationException();
}
@Override
public LabelHistory[] getLabelHistory(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public Iterator<LabelHistory> getLabelHistory() {
throw new UnsupportedOperationException();
}
@Override
public boolean hasLabelHistory(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public Namespace getNamespace(Address addr) {
throw new UnsupportedOperationException();
}
@Override
public Iterator<GhidraClass> getClassNamespaces() {
throw new UnsupportedOperationException();
}
@Override
public GhidraClass createClass(Namespace parent, String name, SourceType source)
throws DuplicateNameException, InvalidInputException {
throw new UnsupportedOperationException();
}
@Override
public SymbolIterator getChildren(Symbol parentSymbol) {
throw new UnsupportedOperationException();
}
@Override
public Library createExternalLibrary(String name, SourceType source)
throws DuplicateNameException, InvalidInputException {
throw new UnsupportedOperationException();
}
@Override
public Namespace createNameSpace(Namespace parent, String name, SourceType source)
throws DuplicateNameException, InvalidInputException {
throw new UnsupportedOperationException();
}
@Override
public GhidraClass convertNamespaceToClass(Namespace namespace) {
throw new UnsupportedOperationException();
}
@Override
public Namespace getOrCreateNameSpace(Namespace parent, String name, SourceType source)
throws DuplicateNameException, InvalidInputException {
throw new UnsupportedOperationException();
}
}

View file

@ -284,7 +284,7 @@ public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
}
private FunctionManager createFunctionManager() {
return new FunctionManagerTestDouble() {
return new StubFunctionManager() {
@Override
public Function getFunctionAt(Address addr) {
return functionMap.get(addr);
@ -294,7 +294,7 @@ public class AcyclicCallGraphBuilderTest extends AbstractGenericTest {
private Program createProgram() {
final FunctionManager funMgr = createFunctionManager();
return new ProgramTestDouble() {
return new StubProgram() {
@Override
public ReferenceManager getReferenceManager() {
return refState;