Skip to content

Commit

Permalink
Fix failing test after refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
jperedadnr committed Oct 16, 2024
1 parent b88174e commit 4d6b6ea
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017, 2022, Gluon and/or its affiliates.
* Copyright (c) 2017, 2024, Gluon and/or its affiliates.
* Copyright (c) 2012, 2014, Oracle and/or its affiliates.
* All rights reserved. Use is subject to license terms.
*
Expand Down Expand Up @@ -120,7 +120,7 @@ private void handleUnknownAndMissingCauses(Exception x) throws IOException {
}

private void handleKnownCauses(Exception x) throws IOException {
if (x.getCause().getClass() == XMLStreamException.class) {
if (x.getCause() instanceof XMLStreamException) {
knownErrorsHandler.accept(x);
} else {
handleUnknownAndMissingCauses(x);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Gluon and/or its affiliates.
* Copyright (c) 2022, 2024, Gluon and/or its affiliates.
* All rights reserved. Use is subject to license terms.
*
* This file is available and licensed under the following license:
Expand Down Expand Up @@ -38,6 +38,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import javax.xml.stream.XMLStreamException;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand All @@ -58,7 +59,7 @@ public void that_LoadException_caused_by_XMLStreamException_is_handled() throws
String validFxmlText = FXOMDocument.readContentFromURL(validResource);
FXOMDocument document = new FXOMDocument(validFxmlText, validResource, null, null);

// When there are exceptions, than the error handler should store these here
// When there are exceptions, then the error handler should store these here
Map<Class<?>, Throwable> handledErrors = new HashMap<>();

// In Scene Builder, the error is displayed in an error dialog.
Expand All @@ -73,7 +74,7 @@ public void that_LoadException_caused_by_XMLStreamException_is_handled() throws
FXOMLoader classUnderTest = new FXOMLoader(document, errorHandler);
assertDoesNotThrow(()->classUnderTest.load(invalidXmlText));

assertTrue(handledErrors.containsKey(javax.xml.stream.XMLStreamException.class));
assertTrue(handledErrors.values().stream().anyMatch(v -> v instanceof XMLStreamException));
assertTrue(handledErrors.containsKey(javafx.fxml.LoadException.class));
}
}

0 comments on commit 4d6b6ea

Please sign in to comment.