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

@ -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;