backport fix for a broken test from upstream

This commit is contained in:
Fabio Valentini 2019-10-15 06:21:25 +02:00
parent 8d086ed766
commit b6f623fe3a
No known key found for this signature in database
GPG Key ID: 5AC5F572E5D410AF
2 changed files with 69 additions and 1 deletions

View File

@ -0,0 +1,61 @@
diff --git a/src/test/java/org/yaml/snakeyaml/error/WrappedExceptionsTest.java b/src/test/java/org/yaml/snakeyaml/error/WrappedExceptionsTest.java
index f8b72a1..7ed8328 100644
--- a/src/test/java/org/yaml/snakeyaml/error/WrappedExceptionsTest.java
+++ b/src/test/java/org/yaml/snakeyaml/error/WrappedExceptionsTest.java
@@ -15,43 +15,32 @@
*/
package org.yaml.snakeyaml.error;
-import org.hamcrest.CoreMatchers;
-import org.junit.Before;
-import org.junit.Rule;
import org.junit.Test;
-import org.junit.rules.ExpectedException;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.Yaml;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
public class WrappedExceptionsTest {
private static final String INVALID_YAML = "!!seq abc";
- @Rule
- public final ExpectedException expectedException = ExpectedException.none();
-
- @Before
- public void configureExpectedExceptions() {
- expectedException.expectMessage("org.yaml.snakeyaml.nodes.ScalarNode");
- expectedException.expectMessage("org.yaml.snakeyaml.nodes.SequenceNode");
- }
-
@Test
public void testWrapped() {
- expectedException.expect(YAMLException.class);
- expectedException
- .expectCause(CoreMatchers.<Throwable> instanceOf(ClassCastException.class));
-
- LoaderOptions options = new LoaderOptions();
- options.setWrappedToRootException(true);
- Yaml yaml = new Yaml(options);
- yaml.load(INVALID_YAML);
+ try {
+ LoaderOptions options = new LoaderOptions();
+ options.setWrappedToRootException(true);
+ Yaml yaml = new Yaml(options);
+ yaml.load(INVALID_YAML);
+ fail();
+ } catch (YAMLException e) {
+ assertEquals(ClassCastException.class, e.getCause().getClass());
+ }
}
- @Test
+ @Test(expected = ClassCastException.class)
public void testUnWrapped() {
- expectedException.expect(ClassCastException.class);
-
LoaderOptions options = new LoaderOptions();
options.setWrappedToRootException(false);
Yaml yaml = new Yaml(options);

View File

@ -5,7 +5,7 @@
Name: snakeyaml
Summary: YAML parser and emitter for Java
Version: 1.25
Release: 1%{?dist}
Release: 2%{?dist}
License: ASL 2.0
URL: https://bitbucket.org/asomov/%{name}
@ -20,6 +20,9 @@ Source0: %{url}/get/%{name}-%{version}.tar.gz
Patch0: 0001-Replace-bundled-base64-implementation.patch
# We don't have gdata-java in Fedora any longer, use commons-codec instead
Patch1: 0002-Replace-bundled-gdata-java-client-classes-with-commo.patch
# Fix a broken test, change backported from upstream:
# https://bitbucket.org/asomov/snakeyaml/commits/345408c
Patch2: 0003-fix-broken-test.patch
BuildArch: noarch
@ -61,6 +64,7 @@ This package contains %{summary}.
%setup -q -n asomov-%{name}-%{vertag}
%patch0 -p1
%patch1 -p1
%patch2 -p1
%mvn_file : %{name}
@ -114,6 +118,9 @@ rm src/test/java/org/yaml/snakeyaml/helpers/FileTestHelper.java
%changelog
* Tue Oct 15 2019 Fabio Valentini <decathorpe@gmail.com> - 1.25-2
- Backport fix for a broken test from upstream.
* Thu Aug 22 2019 Fabio Valentini <decathorpe@gmail.com> - 1.25-1
- Update to version 1.25.