Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions core/src/org/sbml/jsbml/SBMLDocument.java
Original file line number Diff line number Diff line change
Expand Up @@ -336,9 +336,9 @@ private void removePackageDeclaration(String packageName) {
* flag in the individual SBMLError objects returned by
* {@link SBMLDocument#getError(int)} to determine the nature of the failures.
*
* <p>The offline validator is not yet as complete as the online one so it is not
* currently used by default when calling {@link #checkConsistency()} but it might be
* in future versions. To get an up to date status, please check the page
* <p>The offline validator was initially less complete than the online one but
* has evolved and is now used by default when calling {@link #checkConsistency()}.
* The online validator remains available via {@link #checkConsistencyOnline()}.
* <a href="https://github.com/sbmlteam/jsbml/wiki/Offline-validator-status">Offline-validator-status</a>.</p>
*
* @return the number of errors found
Expand Down Expand Up @@ -580,9 +580,11 @@ public int checkConsistencyOnline() {

/**
* Validates the {@link SBMLDocument}.
*
* <p> The validation is currently performed using the
* SBML.org online validator (http://sbml.org/validator/).</p>
*
* <p>The validation is currently performed using the JSBML internal
* offline validator, see {@link #checkConsistencyOffline()}. The SBML.org
* online validator (http://sbml.org/validator/) is still available via
* {@link #checkConsistencyOnline()}.</p>
*
* <p>
* You can control the consistency checks that are performed when
Expand Down
69 changes: 69 additions & 0 deletions core/test/org/sbml/jsbml/test/SBMLDocumentValidationModeTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* ----------------------------------------------------------------------------
* This file is part of JSBML. Please visit <http://sbml.org/Software/JSBML>
* for the latest version of JSBML and more information about SBML.
*
* Copyright (C) 2009-2022 jointly by the following organizations:
* 1. The University of Tuebingen, Germany
* 2. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK
* 3. The California Institute of Technology, Pasadena, CA, USA
* 4. The University of California, San Diego, La Jolla, CA, USA
* 5. The Babraham Institute, Cambridge, UK
*
* This library is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation. A copy of the license agreement is provided
* in the file named "LICENSE.txt" included with this software distribution
* and also available online as <http://sbml.org/Software/JSBML/License>.
* ----------------------------------------------------------------------------
*/

package org.sbml.jsbml.test;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.junit.Test;
import org.sbml.jsbml.SBMLDocument;

/**
* Tests that {@link SBMLDocument#checkConsistency()} uses the offline
* validator by default.
*/
public class SBMLDocumentValidationModeTest {

/**
* Small test subclass of {@link SBMLDocument} that records whether the
* offline or online validation methods are called.
*/
private static class TestDocument extends SBMLDocument {

boolean offlineCalled = false;
boolean onlineCalled = false;

@Override
public int checkConsistencyOffline() {
offlineCalled = true;
// return a distinctive value so we can verify it is propagated
return 7;
}

@Override
public int checkConsistencyOnline() {
onlineCalled = true;
return 13;
}
}

@Test
public void checkConsistencyUsesOfflineValidatorByDefault() {
TestDocument doc = new TestDocument();

int result = doc.checkConsistency();

assertTrue("Offline validator should be used by default.", doc.offlineCalled);
assertFalse("Online validator should not be used when calling checkConsistency().", doc.onlineCalled);
assertEquals("checkConsistency() should return the offline validator result.", 7, result);
}
}