diff --git a/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORGenerator.java b/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORGenerator.java index 59977dbf9..2ceb648a0 100644 --- a/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORGenerator.java +++ b/cbor/src/main/java/com/fasterxml/jackson/dataformat/cbor/CBORGenerator.java @@ -450,13 +450,13 @@ public JsonGenerator overrideFormatFeatures(int values, int mask) { /********************************************************** */ - @Override // since 2.13 - public Object currentValue() { - return _streamWriteContext.getCurrentValue(); + @Override + public JsonStreamContext getOutputContext() { + return _streamWriteContext; } - @Override - public Object getCurrentValue() { + @Override // since 2.13 + public Object currentValue() { return _streamWriteContext.getCurrentValue(); } @@ -465,15 +465,13 @@ public void assignCurrentValue(Object v) { _streamWriteContext.setCurrentValue(v); } + @Deprecated // since 2.17 @Override - public void setCurrentValue(Object v) { - _streamWriteContext.setCurrentValue(v); - } + public Object getCurrentValue() { return currentValue(); } + @Deprecated // since 2.17 @Override - public JsonStreamContext getOutputContext() { - return _streamWriteContext; - } + public void setCurrentValue(Object v) { assignCurrentValue(v); } /* /********************************************************** diff --git a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonGeneratorTest.java b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonGeneratorTest.java index f4a7dd83a..f2c18269d 100644 --- a/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonGeneratorTest.java +++ b/ion/src/test/java/com/fasterxml/jackson/dataformat/ion/IonGeneratorTest.java @@ -14,10 +14,8 @@ package com.fasterxml.jackson.dataformat.ion; -import org.junit.Rule; import org.junit.Test; import org.junit.Before; -import org.junit.rules.ExpectedException; import com.fasterxml.jackson.core.JsonGenerationException; import com.fasterxml.jackson.databind.JsonNode; @@ -33,6 +31,8 @@ import static org.hamcrest.Matchers.is; import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; public class IonGeneratorTest { private static final Map testObject; @@ -59,9 +59,6 @@ public class IonGeneratorTest { private IonValue testObjectIon; private JsonNode testObjectTree; - @Rule - public ExpectedException thrown = ExpectedException.none(); - @Before public void setUp() throws Exception { final IonFactory factory = new IonFactory(); @@ -127,16 +124,24 @@ public void testTreeWriteVerifiesOnce() throws Exception { @Test public void testWriteFieldNameFailsInSexp() throws Exception { joiGenerator.writeStartSexp(); - thrown.expect(JsonGenerationException.class); - thrown.expectMessage("Can not write a field name, expecting a value"); - joiGenerator.writeFieldName("foo"); + try { + joiGenerator.writeFieldName("foo"); + fail("Should not pass"); + } catch (JsonGenerationException e) { + assertEquals("Can not write a field name, expecting a value", + e.getMessage()); + } } @Test public void testWriteStartSexpFailsWithoutWriteFieldName() throws Exception { joiGenerator.writeStartObject(); - thrown.expect(JsonGenerationException.class); - thrown.expectMessage("Can not start a sexp, expecting field name"); - joiGenerator.writeStartSexp(); + try { + joiGenerator.writeStartSexp(); + fail("Should not pass"); + } catch (JsonGenerationException e) { + assertEquals("Can not start a sexp, expecting field name", + e.getMessage()); + } } } diff --git a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufGenerator.java b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufGenerator.java index 6882b4332..d738ff404 100644 --- a/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufGenerator.java +++ b/protobuf/src/main/java/com/fasterxml/jackson/dataformat/protobuf/ProtobufGenerator.java @@ -158,31 +158,6 @@ public void setSchema(ProtobufSchema schema) _pbContext = _rootContext = ProtobufWriteContext.createRootContext(schema.getRootType()); } - @Override - public StreamWriteConstraints streamWriteConstraints() { - return _streamWriteConstraints; - } - - @Override // since 2.13 - public Object currentValue() { - return _pbContext.getCurrentValue(); - } - - @Override - public Object getCurrentValue() { - return _pbContext.getCurrentValue(); - } - - @Override // since 2.13 - public void assignCurrentValue(Object v) { - _pbContext.setCurrentValue(v); - } - - @Override - public void setCurrentValue(Object v) { - _pbContext.setCurrentValue(v); - } - /* /********************************************************** /* Versioned @@ -221,6 +196,11 @@ public boolean canUseSchema(FormatSchema schema) { /********************************************************** */ + @Override + public StreamWriteConstraints streamWriteConstraints() { + return _streamWriteConstraints; + } + /** * Not sure whether to throw an exception or just do no-op; for now, * latter. @@ -265,6 +245,30 @@ public void setSchema(FormatSchema schema) setSchema((ProtobufSchema) schema); } + /* + /********************************************************** + /* Overridden methods, output context (and related) + /********************************************************** + */ + + @Override // since 2.13 + public Object currentValue() { + return _pbContext.getCurrentValue(); + } + + @Override // since 2.13 + public void assignCurrentValue(Object v) { + _pbContext.setCurrentValue(v); + } + + @Deprecated // since 2.17 + @Override + public Object getCurrentValue() { return currentValue(); } + + @Deprecated // since 2.17 + @Override + public void setCurrentValue(Object v) { assignCurrentValue(v); } + /* /********************************************************************** /* Overridden methods; writing field names diff --git a/smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileGenerator.java b/smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileGenerator.java index a3398c51b..f935f3a81 100644 --- a/smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileGenerator.java +++ b/smile/src/main/java/com/fasterxml/jackson/dataformat/smile/SmileGenerator.java @@ -470,13 +470,13 @@ public JsonGenerator overrideFormatFeatures(int values, int mask) { /********************************************************** */ - @Override // since 2.13 - public Object currentValue() { - return _streamWriteContext.getCurrentValue(); + @Override + public JsonStreamContext getOutputContext() { + return _streamWriteContext; } - @Override - public Object getCurrentValue() { + @Override // since 2.13 + public Object currentValue() { return _streamWriteContext.getCurrentValue(); } @@ -485,15 +485,13 @@ public void assignCurrentValue(Object v) { _streamWriteContext.setCurrentValue(v); } + @Deprecated // since 2.17 @Override - public void setCurrentValue(Object v) { - _streamWriteContext.setCurrentValue(v); - } + public Object getCurrentValue() { return currentValue(); } + @Deprecated // since 2.17 @Override - public JsonStreamContext getOutputContext() { - return _streamWriteContext; - } + public void setCurrentValue(Object v) { assignCurrentValue(v); } /* /**********************************************************