Skip to content

Commit

Permalink
fix some code to make unit tests pass CompEvol#834
Browse files Browse the repository at this point in the history
  • Loading branch information
rbouckaert committed Apr 4, 2022
1 parent cc12546 commit 7aa04ed
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion beast.app/src/beast/app/draw/Document.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ boolean sanitiseIDs() {

public Document() {
// load all parsers
Set<String> plugInNames = BEASTClassLoader.listServices("beast.base.core.BEASTInterface");
Set<String> plugInNames = PackageManager.listServices("beast.base.core.BEASTInterface");
m_sPlugInNames = plugInNames.toArray(new String[0]);
tabulist = new HashSet<>();
Properties properties = new Properties();
Expand Down
2 changes: 1 addition & 1 deletion beast.app/src/beast/app/tools/DocMaker.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public DocMaker(String[] args) {

public DocMaker() {
// find plug ins to document
m_beastObjectNames = BEASTClassLoader.listServices("beast.base.core.BEASTInterface");
m_beastObjectNames = PackageManager.listServices("beast.base.core.BEASTInterface");
/** determine hierarchical relation between plug-ins **/
m_isa = new HashMap<>();
m_ancestors = new HashMap<>();
Expand Down
4 changes: 2 additions & 2 deletions beast.app/test/test/beast/integration/DocumentationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public class DocumentationTest extends TestCase {
*/
@Test
public void testDescriptions() {
final Set<String> pluginNames = BEASTClassLoader.listServices("beast.base.core.BEASTInterface");
final Set<String> pluginNames = PackageManager.listServices("beast.base.core.BEASTInterface");
final List<String> undocumentedPlugins = new ArrayList<String>();
for (final String beastObjectName : pluginNames) {
try {
Expand Down Expand Up @@ -60,7 +60,7 @@ public void testDescriptions() {
*/
@Test
public void testInputTipText() {
final Set<String> pluginNames = BEASTClassLoader.listServices("beast.base.core.BEASTInterface");
final Set<String> pluginNames = PackageManager.listServices("beast.base.core.BEASTInterface");
final List<String> undocumentedInputs = new ArrayList<String>();
for (final String beastObjectName : pluginNames) {
try {
Expand Down
4 changes: 2 additions & 2 deletions beast.app/test/test/beast/integration/InputTypeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class InputTypeTest extends TestCase {
*/
@Test
public void testInputTypeCanBeSet() throws Exception {
final Set<String> beastObjectNames = BEASTClassLoader.listServices("beast.base.core.BEASTInterface");
final Set<String> beastObjectNames = PackageManager.listServices("beast.base.core.BEASTInterface");
List<String> failingInputs = new ArrayList<String>();
for (String beastObjectName : beastObjectNames) {
try {
Expand Down Expand Up @@ -63,7 +63,7 @@ public void testInputTypeCanBeSet() throws Exception {

@Test
public void testAnnotatedInputHasGetters() throws Exception {
final Set<String> beastObjectNames = BEASTClassLoader.listServices("beast.base.core.BEASTInterface");
final Set<String> beastObjectNames = PackageManager.listServices("beast.base.core.BEASTInterface");
System.err.println("Testing " + beastObjectNames.size() + " classes");
List<String> failingInputs = new ArrayList<String>();
for (String beastObject : beastObjectNames) {
Expand Down
4 changes: 2 additions & 2 deletions beast.app/test/test/beast/integration/XMLElementNameTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class XMLElementNameTest extends TestCase {
*/
@Test
public void test_NameUniqueness() {
final Set<String> pluginNames = BEASTClassLoader.listServices("beast.base.core.BEASTInterface");
final Set<String> pluginNames = PackageManager.listServices("beast.base.core.BEASTInterface");
List<String> improperInputs = new ArrayList<String>();
for (String beastObjectName : pluginNames) {
try {
Expand Down Expand Up @@ -67,7 +67,7 @@ public void test_ReservedElementNames() {
element2ClassMap.put("parameter", "beast.core.parameter.Parameter");

// check each beastObject
final Set<String> pluginNames = BEASTClassLoader.listServices("beast.base.core.BEASTInterface");
final Set<String> pluginNames = PackageManager.listServices("beast.base.core.BEASTInterface");
List<String> improperInputs = new ArrayList<String>();
for (String beastObjectName : pluginNames) {
try {
Expand Down
2 changes: 1 addition & 1 deletion beast.app/test/test/beast/util/XMLParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void testClassMap() throws IOException {

// create new version.xml
PrintStream out = new PrintStream(new File(versionFile));
out.println("<package name='BEAST' version='" + new BEASTVersion().getVersion() + "'>");
out.println("<package name='BEAST.base' version='" + new BEASTVersion().getVersion() + "'>");
out.println("<map from='beast.base.evolution.substitutionmodel.JoMamma' to='beast.base.evolution.substitutionmodel.JukesCantor'/>");
out.println("</package>");
out.close();
Expand Down
3 changes: 3 additions & 0 deletions beast.base/src/beast/base/parser/XMLParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,9 @@ BEASTInterface createObject(final Node node, final String classname) throws XMLP

// sanity check
try {
if (oldClass2ClassMap.containsKey(clazzName)) {
clazzName = oldClass2ClassMap.get(clazzName);
}
Class<?> clazz = BEASTClassLoader.forName(clazzName, BEASTInterface.class.getName());
if (!BEASTInterface.class.isAssignableFrom(clazz)) {
// throw new XMLParserException(node, "Expected object to be instance of BEASTObject", 108);
Expand Down
2 changes: 1 addition & 1 deletion beast.base/src/beast/base/parser/XMLParserUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
*/
public class XMLParserUtils {

final static public Set<String> beastObjectNames = BEASTClassLoader.listServices("beast.base.core.BEASTInterface");
final static public Set<String> beastObjectNames = PackageManager.listServices("beast.base.core.BEASTInterface");

/**
* Expand plates in XML by duplicating the containing XML and replacing
Expand Down
4 changes: 2 additions & 2 deletions beast.pkgmgmt/src/beast/pkgmgmt/BEASTClassLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,8 @@ private static void addServices(String versionFile) {
}
}

public static Set<String> listServices(String service) {
return BEASTClassLoader.services.get(service);
public static Map<String, Set<String>> getServices() {
return services;
}

public void addServices(String packageName, Map<String, Set<String>> services) {
Expand Down
14 changes: 14 additions & 0 deletions beast.pkgmgmt/src/beast/pkgmgmt/PackageManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,20 @@ public static Map<String, Set<String>> parseServices(Document doc) {
return serviceMap;
}


public static Set<String> listServices(String service) {
Set<String> services = BEASTClassLoader.getServices().get(service);
if (services == null) {
try {
loadExternalJars();
} catch (IOException e) {
// ignore
}
}
services = BEASTClassLoader.getServices().get(service);
return services;
}

/**
* Populate given map with versions of packages to install which satisfy dependencies
* of those already present.
Expand Down

0 comments on commit 7aa04ed

Please sign in to comment.