From 29b5ada96a4b3f7d2b95c930bb6442091e05dcdf Mon Sep 17 00:00:00 2001 From: Ilya Kaznacheev Date: Wed, 23 Mar 2022 15:23:56 +0300 Subject: [PATCH] Improvements of YAML parser based on Kubernetes config examples closes #402 closes #413 Make some internal non-interface methods of TextWire protected * Harmonize Text & Yaml wire writers * Support anchor/alias in YAML parser * Allow reading of literal text blocks * Remove redundant tests, switch TEXT tests to YAML * Fix parsing of text fields depending on quotes * Support parsing of multi-document files * Allow empty values treated as null * Fix octal and trailing whitespace * Deprecate TextWire's ValueOut implementation --- pom.xml | 2 +- .../net/openhft/chronicle/wire/TextWire.java | 30 +- .../net/openhft/chronicle/wire/WireType.java | 47 +-- .../net/openhft/chronicle/wire/YamlToken.java | 1 + .../openhft/chronicle/wire/YamlTokeniser.java | 63 +-- .../net/openhft/chronicle/wire/YamlWire.java | 216 ++++++++-- .../chronicle/wire/BinaryWireTest.java | 3 + .../chronicle/wire/KubernetesYamlTest.java | 191 +++++++++ .../openhft/chronicle/wire/TextWireTest.java | 3 + .../net/openhft/chronicle/wire/WireTests.java | 3 + .../openhft/chronicle/wire/YamlSpecTest.java | 247 +---------- .../chronicle/wire/YamlSpecificationTest.java | 116 +++--- .../chronicle/wire/YamlTokeniserTest.java | 155 +++++-- .../openhft/chronicle/wire/YamlWireTest.java | 392 ++++-------------- src/test/resources/exception.yaml | 9 + .../resources/specification/example2_10.yaml | 8 - .../resources/specification/example2_11.yaml | 9 - .../resources/specification/example2_12.yaml | 8 - .../resources/specification/example2_13.yaml | 4 - .../resources/specification/example2_14.yaml | 4 - .../resources/specification/example2_15.yaml | 8 - .../specification/example2_15_dumped.yaml | 7 - .../resources/specification/example2_16.yaml | 7 - .../specification/example2_17.out.yaml | 7 - .../specification/example2_17_control.yaml | 2 - .../specification/example2_17_hexesc.yaml | 2 - .../specification/example2_17_quoted.yaml | 2 - .../specification/example2_17_single.yaml | 1 - .../example2_17_tie_fighter.yaml | 1 - .../specification/example2_17_unicode.yaml | 2 - .../resources/specification/example2_18.yaml | 6 - .../resources/specification/example2_19.yaml | 5 - .../resources/specification/example2_2.yaml | 3 - .../resources/specification/example2_20.yaml | 6 - .../specification/example2_22.out.yaml | 4 - .../resources/specification/example2_22.yaml | 4 - .../resources/specification/example2_23.yaml | 14 - .../example2_23_application.yaml | 5 - .../specification/example2_23_non_date.yaml | 3 - .../specification/example2_23_picture.yaml | 7 - .../resources/specification/example2_24.yaml | 14 - .../specification/example2_24_dumped.yaml | 11 - .../resources/specification/example2_25.yaml | 7 - .../resources/specification/example2_26.yaml | 7 - .../resources/specification/example2_27.yaml | 29 -- .../specification/example2_27_dumped.yaml | 20 - .../resources/specification/example2_28.yaml | 27 -- .../resources/specification/example2_3.yaml | 8 - .../resources/specification/example2_4.yaml | 8 - .../resources/specification/example2_5.yaml | 3 - .../resources/specification/example2_6.yaml | 5 - .../specification/example2_7.out.yaml | 3 - .../resources/specification/example2_7.yaml | 10 - .../resources/specification/example2_8.yaml | 10 - .../resources/specification/example2_9.yaml | 8 - src/test/resources/yaml/k8s/example1.yaml | 25 ++ src/test/resources/yaml/k8s/example2.yaml | 29 ++ src/test/resources/yaml/k8s/example3.yaml | 19 + src/test/resources/yaml/k8s/example4.yaml | 66 +++ src/test/resources/yaml/k8s/example5.yaml | 253 +++++++++++ src/test/resources/yaml/k8s/example6.yaml | 259 ++++++++++++ src/test/resources/yaml/k8s/example7.yaml | 6 + src/test/resources/yaml/k8s/example8.yaml | 92 ++++ src/test/resources/yaml/k8s/example9.yaml | 39 ++ ...0_NodeAppearsTwiceInThisDocument.out.yaml} | 4 +- .../2_10_NodeAppearsTwiceInThisDocument.yaml | 2 +- .../spec/2_11MappingBetweenSequences.yaml | 2 +- .../spec/2_12CompactNestedMapping.out.yaml | 12 + .../yaml/spec/2_12CompactNestedMapping.yaml | 2 +- .../spec/2_12CompactNestedMappingFixed.yaml | 8 - ..._13InLiteralsNewlinesArePreserved.out.yaml | 1 + .../2_13InLiteralsNewlinesArePreserved.yaml | 2 +- .../yaml/spec/2_14InThefoldedScalars.out.yaml | 1 + .../yaml/spec/2_14InThefoldedScalars.yaml | 2 +- .../spec/2_14InThefoldedScalarsFixed.yaml | 3 - .../yaml/spec/2_15FoldedNewlines.yaml | 2 +- .../2_16IndentationDeterminesScopeFixed.yaml | 7 - .../spec/2_17QuotedScalars.out.yaml} | 7 +- .../yaml/spec/2_17QuotedScalars.yaml | 2 +- .../yaml/spec/2_17QuotedScalarsFixed.yaml | 6 - .../spec/2_19Integers.out.yaml} | 2 +- .../resources/yaml/spec/2_19Integers.yaml | 5 +- .../yaml/spec/2_1_SequenceOfScalars.yaml | 2 +- .../yaml/spec/2_20FloatingPoint.yaml | 5 +- .../spec/2_21MiscellaneousBis.out.yaml} | 0 .../spec/2_21MiscellaneousBis.yaml} | 0 .../resources/yaml/spec/2_22Timestamps.yaml | 2 +- .../resources/yaml/spec/2_24GlobalTags.yaml | 2 +- .../yaml/spec/2_25UnorderedSets.yaml | 2 +- .../yaml/spec/2_26OrderedMappings.yaml | 5 +- src/test/resources/yaml/spec/2_27Invoice.yaml | 2 +- .../2_2_MappingScalarsToScalars.out.yaml} | 0 .../spec/2_2_MappingScalarsToScalars.yaml | 2 +- .../2_3_MappingScalarsToSequences.out.yaml} | 4 +- .../spec/2_4_SequenceOfMappings-fixed.yaml | 12 - .../yaml/spec/2_4_SequenceOfMappings.out.yaml | 10 + .../yaml/spec/2_4_SequenceOfMappings.yaml | 2 +- .../spec/2_5_SequenceOfSequences.out.yaml | 15 + .../yaml/spec/2_5_SequenceOfSequences.yaml | 2 +- .../yaml/spec/2_6_MappingOfMappings.out.yaml | 8 + .../yaml/spec/2_6_MappingOfMappings.yaml | 2 +- .../spec/2_7_TwoDocumentsInAStream.out.yaml} | 0 .../yaml/spec/2_7_TwoDocumentsInAStream.yaml | 2 +- .../spec/2_7_TwoDocumentsInAStreamFixed.yaml | 10 - .../yaml/spec/2_8_PlayByPlayFeed.yaml | 2 +- .../yaml/spec/2_8_PlayByPlayFeedFixed.yaml | 12 - ..._9_SingleDocumentWithTwoComments.out.yaml} | 6 +- .../2_9_SingleDocumentWithTwoComments.yaml | 2 +- ..._9_SingleDocumentWithTwoCommentsFixed.yaml | 8 - .../spec}/types/map.yaml | 0 .../spec}/types/map_mixed_tags.yaml | 0 .../spec}/types/merge.yaml | 0 .../spec}/types/omap.yaml | 0 .../spec}/types/pairs.yaml | 0 .../spec}/types/seq.yaml | 0 .../spec}/types/set.yaml | 0 .../{specification => yaml/spec}/types/v.yaml | 0 .../spec}/types/value.yaml | 0 118 files changed, 1626 insertions(+), 1128 deletions(-) create mode 100644 src/test/java/net/openhft/chronicle/wire/KubernetesYamlTest.java create mode 100644 src/test/resources/exception.yaml delete mode 100644 src/test/resources/specification/example2_10.yaml delete mode 100644 src/test/resources/specification/example2_11.yaml delete mode 100644 src/test/resources/specification/example2_12.yaml delete mode 100644 src/test/resources/specification/example2_13.yaml delete mode 100644 src/test/resources/specification/example2_14.yaml delete mode 100644 src/test/resources/specification/example2_15.yaml delete mode 100644 src/test/resources/specification/example2_15_dumped.yaml delete mode 100644 src/test/resources/specification/example2_16.yaml delete mode 100644 src/test/resources/specification/example2_17.out.yaml delete mode 100644 src/test/resources/specification/example2_17_control.yaml delete mode 100644 src/test/resources/specification/example2_17_hexesc.yaml delete mode 100644 src/test/resources/specification/example2_17_quoted.yaml delete mode 100644 src/test/resources/specification/example2_17_single.yaml delete mode 100644 src/test/resources/specification/example2_17_tie_fighter.yaml delete mode 100644 src/test/resources/specification/example2_17_unicode.yaml delete mode 100644 src/test/resources/specification/example2_18.yaml delete mode 100644 src/test/resources/specification/example2_19.yaml delete mode 100644 src/test/resources/specification/example2_2.yaml delete mode 100644 src/test/resources/specification/example2_20.yaml delete mode 100644 src/test/resources/specification/example2_22.out.yaml delete mode 100644 src/test/resources/specification/example2_22.yaml delete mode 100644 src/test/resources/specification/example2_23.yaml delete mode 100644 src/test/resources/specification/example2_23_application.yaml delete mode 100644 src/test/resources/specification/example2_23_non_date.yaml delete mode 100644 src/test/resources/specification/example2_23_picture.yaml delete mode 100644 src/test/resources/specification/example2_24.yaml delete mode 100644 src/test/resources/specification/example2_24_dumped.yaml delete mode 100644 src/test/resources/specification/example2_25.yaml delete mode 100644 src/test/resources/specification/example2_26.yaml delete mode 100644 src/test/resources/specification/example2_27.yaml delete mode 100644 src/test/resources/specification/example2_27_dumped.yaml delete mode 100644 src/test/resources/specification/example2_28.yaml delete mode 100644 src/test/resources/specification/example2_3.yaml delete mode 100644 src/test/resources/specification/example2_4.yaml delete mode 100644 src/test/resources/specification/example2_5.yaml delete mode 100644 src/test/resources/specification/example2_6.yaml delete mode 100644 src/test/resources/specification/example2_7.out.yaml delete mode 100644 src/test/resources/specification/example2_7.yaml delete mode 100644 src/test/resources/specification/example2_8.yaml delete mode 100644 src/test/resources/specification/example2_9.yaml create mode 100644 src/test/resources/yaml/k8s/example1.yaml create mode 100644 src/test/resources/yaml/k8s/example2.yaml create mode 100644 src/test/resources/yaml/k8s/example3.yaml create mode 100644 src/test/resources/yaml/k8s/example4.yaml create mode 100644 src/test/resources/yaml/k8s/example5.yaml create mode 100644 src/test/resources/yaml/k8s/example6.yaml create mode 100644 src/test/resources/yaml/k8s/example7.yaml create mode 100644 src/test/resources/yaml/k8s/example8.yaml create mode 100644 src/test/resources/yaml/k8s/example9.yaml rename src/test/resources/{specification/example2_9.out.yaml => yaml/spec/2_10_NodeAppearsTwiceInThisDocument.out.yaml} (94%) create mode 100644 src/test/resources/yaml/spec/2_12CompactNestedMapping.out.yaml delete mode 100644 src/test/resources/yaml/spec/2_12CompactNestedMappingFixed.yaml create mode 100644 src/test/resources/yaml/spec/2_13InLiteralsNewlinesArePreserved.out.yaml create mode 100644 src/test/resources/yaml/spec/2_14InThefoldedScalars.out.yaml delete mode 100644 src/test/resources/yaml/spec/2_14InThefoldedScalarsFixed.yaml delete mode 100644 src/test/resources/yaml/spec/2_16IndentationDeterminesScopeFixed.yaml rename src/test/resources/{specification/example2_17.yaml => yaml/spec/2_17QuotedScalars.out.yaml} (52%) delete mode 100644 src/test/resources/yaml/spec/2_17QuotedScalarsFixed.yaml rename src/test/resources/{specification/example2_19.out.yaml => yaml/spec/2_19Integers.out.yaml} (67%) rename src/test/resources/{specification/example2_21.out.yaml => yaml/spec/2_21MiscellaneousBis.out.yaml} (100%) rename src/test/resources/{specification/example2_21.yaml => yaml/spec/2_21MiscellaneousBis.yaml} (100%) rename src/test/resources/{specification/example2_2.out.yaml => yaml/spec/2_2_MappingScalarsToScalars.out.yaml} (100%) rename src/test/resources/{specification/example2_3.out.yaml => yaml/spec/2_3_MappingScalarsToSequences.out.yaml} (96%) delete mode 100644 src/test/resources/yaml/spec/2_4_SequenceOfMappings-fixed.yaml create mode 100644 src/test/resources/yaml/spec/2_4_SequenceOfMappings.out.yaml create mode 100644 src/test/resources/yaml/spec/2_5_SequenceOfSequences.out.yaml create mode 100644 src/test/resources/yaml/spec/2_6_MappingOfMappings.out.yaml rename src/test/resources/{specification/example2_1.yaml => yaml/spec/2_7_TwoDocumentsInAStream.out.yaml} (100%) delete mode 100644 src/test/resources/yaml/spec/2_7_TwoDocumentsInAStreamFixed.yaml delete mode 100644 src/test/resources/yaml/spec/2_8_PlayByPlayFeedFixed.yaml rename src/test/resources/{specification/example2_10.out.yaml => yaml/spec/2_9_SingleDocumentWithTwoComments.out.yaml} (60%) delete mode 100644 src/test/resources/yaml/spec/2_9_SingleDocumentWithTwoCommentsFixed.yaml rename src/test/resources/{specification => yaml/spec}/types/map.yaml (100%) rename src/test/resources/{specification => yaml/spec}/types/map_mixed_tags.yaml (100%) rename src/test/resources/{specification => yaml/spec}/types/merge.yaml (100%) rename src/test/resources/{specification => yaml/spec}/types/omap.yaml (100%) rename src/test/resources/{specification => yaml/spec}/types/pairs.yaml (100%) rename src/test/resources/{specification => yaml/spec}/types/seq.yaml (100%) rename src/test/resources/{specification => yaml/spec}/types/set.yaml (100%) rename src/test/resources/{specification => yaml/spec}/types/v.yaml (100%) rename src/test/resources/{specification => yaml/spec}/types/value.yaml (100%) diff --git a/pom.xml b/pom.xml index 1a6a906e09..96129a7932 100644 --- a/pom.xml +++ b/pom.xml @@ -185,7 +185,7 @@ 2.23ea0 https://teamcity.chronicle.software/repository/download - 99.9 + 99.8 diff --git a/src/main/java/net/openhft/chronicle/wire/TextWire.java b/src/main/java/net/openhft/chronicle/wire/TextWire.java index ec9de58736..b1732a59f7 100644 --- a/src/main/java/net/openhft/chronicle/wire/TextWire.java +++ b/src/main/java/net/openhft/chronicle/wire/TextWire.java @@ -628,8 +628,23 @@ private boolean notNewLine(int readCode) { protected void consumeDocumentStart() { if (bytes.readRemaining() > 4) { long pos = bytes.readPosition(); - if (bytes.readByte(pos) == '-' && bytes.readByte(pos + 1) == '-' && bytes.readByte(pos + 2) == '-') + if (bytes.readByte(pos) == '-' && bytes.readByte(pos + 1) == '-' && bytes.readByte(pos + 2) == '-') { bytes.readSkip(3); + + consumeWhiteSpace(); + + pos = bytes.readPosition(); + @NotNull String word = bytes.parseUtf8(StopCharTesters.SPACE_STOP); + switch (word) { + case "!!data": + case "!!data-not-ready": + case "!!meta-data": + case "!!meta-data-not-ready": + break; + default: + bytes.readPosition(pos); + } + } } } @@ -1030,9 +1045,7 @@ public void append(@NotNull CharSequence cs, int offset, int length) { @Nullable public Object readObject() { - consumePadding(); - consumeDocumentStart(); - return readObject(0); + return getValueIn().object(Object.class); } @Nullable @@ -1182,6 +1195,11 @@ public TextWire trimFirstCurly(boolean trimFirstCurly) { enum NoObject {NO_OBJECT} + /** + * @deprecated Will be replaced with a different implementation in the future, + * which will generate correct Yaml but may introduce some behavior changes. + */ + @Deprecated(/* To be removed and replaced by YamlWire.TextValueOut in 2.24 #411 */) class TextValueOut implements ValueOut, CommentAnnotationNotifier { protected boolean hasCommentAnnotation = false; @@ -1978,7 +1996,7 @@ public WireOut marshallable(@NotNull WriteMarshallable object) { } else if (!seps.isEmpty()) { popSep = seps.get(seps.size() - 1); popState(); - sep = NEW_LINE; + newLine(); } if (sep.startsWith(',')) { append(sep, 1, sep.length() - 1); @@ -2031,7 +2049,7 @@ public WireOut marshallable(@NotNull Serializable object) { } else if (seps.size() > 0) { popSep = seps.get(seps.size() - 1); popState(); - sep = NEW_LINE; + newLine(); } if (sep.startsWith(',')) { append(sep, 1, sep.length() - 1); diff --git a/src/main/java/net/openhft/chronicle/wire/WireType.java b/src/main/java/net/openhft/chronicle/wire/WireType.java index ee97f9730d..8216432803 100644 --- a/src/main/java/net/openhft/chronicle/wire/WireType.java +++ b/src/main/java/net/openhft/chronicle/wire/WireType.java @@ -18,9 +18,7 @@ package net.openhft.chronicle.wire; import net.openhft.chronicle.bytes.Bytes; -import net.openhft.chronicle.bytes.BytesStore; import net.openhft.chronicle.bytes.BytesUtil; -import net.openhft.chronicle.bytes.StopCharTesters; import net.openhft.chronicle.bytes.ref.*; import net.openhft.chronicle.core.Jvm; import net.openhft.chronicle.core.LicenceCheck; @@ -72,36 +70,19 @@ public Supplier newLongArrayReference() { @Nullable @Override - public T fromString(@NotNull CharSequence cs) { + public T fromString(Class tClass, @NotNull CharSequence cs) { Bytes bytes = Bytes.allocateElasticDirect(cs.length()); try { bytes.appendUtf8(cs); - if (bytes.startsWith(PREABLE)) { - truncatePreable(bytes); - } - @NotNull Wire wire = apply(bytes); - //noinspection unchecked - return (T) wire.getValueIn().object(); + @NotNull TextWire wire = (TextWire) apply(bytes); + wire.consumePadding(); + wire.consumeDocumentStart(); + return wire.getValueIn().object(tClass); } finally { bytes.releaseLast(); } } - public void truncatePreable(@NotNull Bytes bytes) { - bytes.readSkip(4); - long pos = bytes.readPosition(); - @NotNull String word = bytes.parseUtf8(StopCharTesters.SPACE_STOP); - switch (word) { - case "!!data": - case "!!data-not-ready": - case "!!meta-data": - case "!!meta-data-not-ready": - break; - default: - bytes.readPosition(pos); - } - } - @Override public boolean isText() { return true; @@ -307,6 +288,21 @@ public Wire apply(@NotNull Bytes bytes) { return new YamlWire(bytes).useBinaryDocuments(); } + @Nullable + @Override + public T fromString(Class tClass, @NotNull CharSequence cs) { + Bytes bytes = Bytes.allocateElasticDirect(cs.length()); + try { + bytes.appendUtf8(cs); + @NotNull YamlWire wire = (YamlWire) apply(bytes); + wire.consumePadding(); + wire.consumeDocumentStart(); + return wire.getValueIn().object(tClass); + } finally { + bytes.releaseLast(); + } + } + @Override public boolean isText() { return true; @@ -351,7 +347,6 @@ public Wire apply(@NotNull Bytes bytes) { } }; - static final BytesStore PREABLE = BytesStore.from("--- "); private static final int COMPRESSED_SIZE = Integer.getInteger("WireType.compressedSize", 128); private static final boolean IS_DELTA_AVAILABLE = isDeltaAvailable(); private static final boolean IS_DEFAULT_ZERO_AVAILABLE = isDefaultZeroAvailable(); @@ -483,7 +478,7 @@ else if (marshallable instanceof Serializable) */ @Nullable public T fromString(@NotNull CharSequence cs) { - return (T) fromString(Object.class, cs); + return (T) fromString(/* Allow Marshallable tuples by not requesting Object */ null, cs); } /** diff --git a/src/main/java/net/openhft/chronicle/wire/YamlToken.java b/src/main/java/net/openhft/chronicle/wire/YamlToken.java index 1c27b024c7..03030aedff 100644 --- a/src/main/java/net/openhft/chronicle/wire/YamlToken.java +++ b/src/main/java/net/openhft/chronicle/wire/YamlToken.java @@ -31,6 +31,7 @@ public enum YamlToken { SEQUENCE_ENTRY, SEQUENCE_START(SEQUENCE_END), TEXT, + LITERAL, ANCHOR, ALIAS, RESERVED, diff --git a/src/main/java/net/openhft/chronicle/wire/YamlTokeniser.java b/src/main/java/net/openhft/chronicle/wire/YamlTokeniser.java index 2a37b9b95f..3e7a4c0c28 100644 --- a/src/main/java/net/openhft/chronicle/wire/YamlTokeniser.java +++ b/src/main/java/net/openhft/chronicle/wire/YamlTokeniser.java @@ -66,7 +66,7 @@ void reset() { freeContexts.addAll(contexts); contexts.clear(); if (temp != null) temp.clear(); - lineStart = 0; + lineStart = in.readPosition(); flowDepth = Integer.MAX_VALUE; blockQuote = 0; hasSequenceEntry = false; @@ -127,7 +127,7 @@ YamlToken next0(int minIndent) { if (wouldChangeContext(minIndent, indent2)) return dontRead(); lastKeyPosition = in.readPosition() - 1; - readQuoted('"'); + readDoublyQuoted(); if (isFieldEnd()) return indent(YamlToken.MAPPING_START, YamlToken.MAPPING_KEY, YamlToken.TEXT, indent2); return YamlToken.TEXT; @@ -135,7 +135,7 @@ YamlToken next0(int minIndent) { if (wouldChangeContext(minIndent, indent2)) return dontRead(); lastKeyPosition = in.readPosition() - 1; - readQuoted('\''); + readSinglyQuoted(); if (isFieldEnd()) return indent(YamlToken.MAPPING_START, YamlToken.MAPPING_KEY, YamlToken.TEXT, indent2); @@ -155,10 +155,12 @@ YamlToken next0(int minIndent) { if (next <= ' ') { if (wouldChangeContext(minIndent, indent2 + 1)) return dontRead(); + + hasSequenceEntry = true; return indent(YamlToken.SEQUENCE_START, YamlToken.SEQUENCE_ENTRY, YamlToken.STREAM_START, indent2 + 1); } if (next == '-' && in.peekUnsignedByte(in.readPosition() + 1) == '-' && in.peekUnsignedByte(in.readPosition() + 2) <= ' ') { - if (contextIndent() <= minIndent) + if (contextIndent() <= minIndent && minIndent >= 0) return dontRead(); in.readSkip(2); pushed.add(YamlToken.DIRECTIVES_END); @@ -184,29 +186,28 @@ YamlToken next0(int minIndent) { unreadLast(); return readText(indent2); } -/* TODO case '&': if (in.peekUnsignedByte() > ' ') { - readAnchor(); + readWord(); return YamlToken.ANCHOR; } break; case '*': if (in.peekUnsignedByte() > ' ') { - readAnchor(); + readWord(); return YamlToken.ALIAS; } -*/ + break; case '|': if (in.peekUnsignedByte() <= ' ') { readLiteral(); - return seq(YamlToken.TEXT); + return seq(YamlToken.LITERAL); } break; case '>': if (in.peekUnsignedByte() <= ' ') { readFolded(); - return seq(YamlToken.TEXT); + return seq(YamlToken.LITERAL); } case '%': readDirective(); @@ -294,7 +295,7 @@ private YamlToken flowPop(YamlToken start, char end) { private YamlToken flow(YamlToken token) { pushed.add(token); - if (!hasSequenceEntry && context() == YamlToken.SEQUENCE_START) { + if (!hasSequenceEntry && token != YamlToken.SEQUENCE_START && context() == YamlToken.SEQUENCE_START) { hasSequenceEntry = true; pushed.add(YamlToken.SEQUENCE_ENTRY); } @@ -345,14 +346,16 @@ private void readLiteral(boolean withNewLines) { if (withNewLines) readNewline(); temp.write(in, start, in.readPosition() - start); - if (!withNewLines) - if (temp.peekUnsignedByte(temp.writePosition() - 1) > ' ') - temp.append(' '); readIndent(); int indent3 = Math.toIntExact(in.readPosition() - lineStart); if (indent3 < indent2) return; + + if (!withNewLines) + if (temp.peekUnsignedByte(temp.writePosition() - 1) > ' ') + temp.append(' '); + if (indent3 > indent2) in.readPosition(lineStart + indent2); start = in.readPosition(); @@ -381,16 +384,6 @@ private void readNewline() { } } - private void readAnchor() { - blockStart = in.readPosition(); - while (true) { - blockEnd = in.readPosition(); - int ch = in.readUnsignedByte(); - if (ch <= ' ') - return; - } - } - private YamlToken indent( @NotNull YamlToken indented, @NotNull YamlToken key, @@ -561,18 +554,32 @@ private void contextPush(YamlToken context, int indent) { pushContext0(context, indent); } - private void readQuoted(char stop) { - blockQuote = stop; + private void readDoublyQuoted() { + blockQuote = '"'; blockStart = in.readPosition(); while (in.readRemaining() > 0) { int ch = in.readUnsignedByte(); if (ch == '\\') { ch = in.readUnsignedByte(); + } else if (ch == blockQuote) { + blockEnd = in.readPosition() - 1; + return; + } + if (ch < 0) { + throw new IllegalStateException("Unterminated quotes " + in.subBytes(blockStart - 1, in.readPosition())); } - if (ch == stop) { + } + } + + private void readSinglyQuoted() { + blockQuote = '\''; + blockStart = in.readPosition(); + while (in.readRemaining() > 0) { + int ch = in.readUnsignedByte(); + if (ch == blockQuote) { // ignore double single quotes. int ch2 = in.peekUnsignedByte(); - if (ch2 == stop) { + if (ch2 == blockQuote) { in.readSkip(1); continue; } diff --git a/src/main/java/net/openhft/chronicle/wire/YamlWire.java b/src/main/java/net/openhft/chronicle/wire/YamlWire.java index 0241f4bb28..1144561034 100644 --- a/src/main/java/net/openhft/chronicle/wire/YamlWire.java +++ b/src/main/java/net/openhft/chronicle/wire/YamlWire.java @@ -81,9 +81,12 @@ public class YamlWire extends AbstractWire implements Wire { private final TextValueIn valueIn = createValueIn(); private final StringBuilder sb = new StringBuilder(); private final YamlTokeniser yt; + private final Map anchorValues = new HashMap<>(); private DefaultValueIn defaultValueIn; private WriteDocumentContext writeContext; private ReadDocumentContext readContext; + private boolean addTimeStamps = false; + private boolean trimFirstCurly = true; public YamlWire(@NotNull Bytes bytes, boolean use8bit) { super(bytes, use8bit); @@ -123,12 +126,19 @@ public static String asText(@NotNull Wire wire) { } } - public static void unescape(@NotNull ACS sb) { + private static void unescape(@NotNull ACS sb, + char blockQuote) { int end = 0; int length = sb.length(); + boolean skip = false; for (int i = 0; i < length; i++) { + if (skip) { + skip = false; + continue; + } + char ch = sb.charAt(i); - if (ch == '\\' && i < length - 1) { + if (blockQuote == '\"' && ch == '\\' && i < length - 1) { char ch3 = sb.charAt(++i); switch (ch3) { case '0': @@ -180,6 +190,14 @@ public static void unescape(@NotNull ACS ch = ch3; } } + + if (blockQuote == '\'' && ch == '\'' && i < length - 1) { + char ch2 = sb.charAt(i + 1); + if (ch2 == ch) { + skip = true; + } + } + AppendableUtil.setCharAt(sb, end++, ch); } if (length != sb.length()) @@ -193,6 +211,15 @@ public boolean hintReadInputOrder() { return true; } + public boolean addTimeStamps() { + return addTimeStamps; + } + + public YamlWire addTimeStamps(boolean addTimeStamps) { + this.addTimeStamps = addTimeStamps; + return this; + } + @Override @NotNull public T methodWriter(@NotNull Class tClass, Class... additional) { @@ -358,6 +385,7 @@ protected StringBuilder readField(@NotNull StringBuilder sb) { yt.next(); if (yt.current() == YamlToken.TEXT) { sb.append(yt.text()); + unescape(sb, yt.blockQuote()); yt.next(); } else { throw new IllegalStateException(yt.toString()); @@ -365,7 +393,6 @@ protected StringBuilder readField(@NotNull StringBuilder sb) { } else { return sb; } - unescape(sb); return sb; } @@ -378,8 +405,8 @@ public K readEvent(@NotNull Class expectedClass) { if (next == YamlToken.TEXT) { sb.setLength(0); sb.append(yt.text()); + unescape(sb, yt.blockQuote); yt.next(); - unescape(sb); return toExpected(expectedClass, sb); } } @@ -485,12 +512,12 @@ private boolean checkForMatch(@NotNull String keyName) { if (next == YamlToken.TEXT) { sb.setLength(0); sb.append(yt.text()); + unescape(sb, yt.blockQuote()); yt.next(); } else { throw new IllegalStateException(next.toString()); } - unescape(sb); return (sb.length() == 0 || StringUtils.isEqual(sb, keyName)); } @@ -706,6 +733,29 @@ protected Quotes needsQuotes(@NotNull CharSequence s) { return quotes; } + protected void consumeDocumentStart() { + if (bytes.readRemaining() > 4) { + long pos = bytes.readPosition(); + if (bytes.readByte(pos) == '-' && bytes.readByte(pos + 1) == '-' && bytes.readByte(pos + 2) == '-') + bytes.readSkip(3); + + pos = bytes.readPosition(); + @NotNull String word = bytes.parseUtf8(StopCharTesters.SPACE_STOP); + switch (word) { + case "!!data": + case "!!data-not-ready": + case "!!meta-data": + case "!!meta-data-not-ready": + break; + default: + bytes.readPosition(pos); + } + } + + if (yt.current() == YamlToken.NONE) + yt.next(); + } + @NotNull @Override public LongValue newLongReference() { @@ -778,6 +828,23 @@ private Map readMap(Class valueType) { return map; } + public void writeObject(Object o) { + if (o instanceof Iterable) { + for (Object o2 : (Iterable) o) { + writeObject(o2, 2); + } + } else if (o instanceof Map) { + for (@NotNull Map.Entry entry : ((Map) o).entrySet()) { + write(() -> entry.getKey().toString()).object(entry.getValue()); + } + } else if (o instanceof WriteMarshallable) { + valueOut.typedMarshallable((WriteMarshallable) o); + + } else { + valueOut.object(o); + } + } + private void writeObject(Object o, int indentation) { writeTwo('-', ' '); indentation(indentation - 2); @@ -805,6 +872,21 @@ void writeTwo(char ch1, char ch2) { bytes.writeUnsignedByte(ch2); } + /** + * @return whether the top level curly brackets is dropped + */ + public boolean trimFirstCurly() { + return trimFirstCurly; + } + + /** + * @param trimFirstCurly whether the top level curly brackets is dropped + */ + public YamlWire trimFirstCurly(boolean trimFirstCurly) { + this.trimFirstCurly = trimFirstCurly; + return this; + } + @Override public void startEvent() { consumePadding(); @@ -862,6 +944,7 @@ public void endEvent() { public void reset() { bytes.readPosition(0); yt.reset(); + anchorValues.clear(); } class TextValueOut implements ValueOut, CommentAnnotationNotifier { @@ -1054,8 +1137,13 @@ public WireOut bytes(@NotNull String type, byte[] byteArray) { } prependSeparator(); typePrefix(type); + if (getClass() != TextValueOut.class) + bytes.append('"'); append(Base64.getEncoder().encodeToString(byteArray)); + if (getClass() != TextValueOut.class) + bytes.append('"'); elementSeparator(); + endTypePrefix(); return YamlWire.this; } @@ -1069,6 +1157,7 @@ public WireOut bytes(@NotNull String type, @Nullable BytesStore bytesStore) { prependSeparator(); typePrefix(type); append(Base64.getEncoder().encodeToString(bytesStore.toByteArray())); + endTypePrefix(); append(END_FIELD); elementSeparator(); @@ -1192,6 +1281,12 @@ public WireOut int64(long i64) { prependSeparator(); bytes.append(i64); elementSeparator(); + // 2001 to 2100 best effort basis. + boolean addTimeStamp = YamlWire.this.addTimeStamps && !leaf; + if (addTimeStamp) { + addTimeStamp(i64); + } + return YamlWire.this; } @@ -1201,6 +1296,31 @@ public WireOut int128forBinding(long i64x0, long i64x1, TwoLongValue longValue) throw new UnsupportedOperationException(yt.toString()); } + public void addTimeStamp(long i64) { + if ((long) 1e12 < i64 && i64 < (long) 4.111e12) { + bytes.append(", # "); + bytes.appendDateMillis(i64); + bytes.append("T"); + bytes.appendTimeMillis(i64); + sep = NEW_LINE; + } else if ((long) 1e18 < i64 && i64 < (long) 4.111e18) { + long millis = i64 / 1_000_000; + long nanos = i64 % 1_000_000; + bytes.append(", # "); + bytes.appendDateMillis(millis); + bytes.append("T"); + bytes.appendTimeMillis(millis); + bytes.append((char) ('0' + nanos / 100000)); + bytes.append((char) ('0' + nanos / 100000 % 10)); + bytes.append((char) ('0' + nanos / 10000 % 10)); + bytes.append((char) ('0' + nanos / 1000 % 10)); + bytes.append((char) ('0' + nanos / 100 % 10)); + bytes.append((char) ('0' + nanos / 10 % 10)); + bytes.append((char) ('0' + nanos % 10)); + sep = NEW_LINE; + } + } + @NotNull @Override public WireOut int64_0x(long i64) { @@ -1347,13 +1467,23 @@ private WireOut asText(@Nullable Object stringable) { nu11(); } else { prependSeparator(); - append(stringable.toString()); + final String s = stringable.toString(); + final Quotes quotes = needsQuotes(s); + asTestQuoted(s, quotes); elementSeparator(); } return YamlWire.this; } + protected void asTestQuoted(String s, Quotes quotes) { + if (quotes == Quotes.NONE) { + append(s); + } else { + escape0(s, quotes); + } + } + @NotNull @Override public ValueOut optionalTyped(Class aClass) { @@ -1502,11 +1632,12 @@ public WireOut sequence(T t, @NotNull BiConsumer writer) { addNewLine(pos); popState(); + this.leaf = leaf; if (!leaf) indent(); else addSpace(pos); - endBlock(this.leaf, ']'); + endBlock(']'); return wireOut(); } @@ -1542,13 +1673,13 @@ public WireOut sequence(T t, K kls, @NotNull TriConsumer popState(); if (!leaf) indent(); - endBlock(this.leaf, ']'); + endBlock(']'); return wireOut(); } - public void endBlock(boolean leaf, char c) { + protected void endBlock(char c) { bytes.writeUnsignedByte(c); - sep = leaf ? COMMA_SPACE : COMMA_NEW_LINE; + elementSeparator(); } protected void addNewLine(long pos) { @@ -1589,7 +1720,7 @@ public WireOut marshallable(@NotNull WriteMarshallable object) { if (dropDefault) { writeSavedEventName(); } - if (bytes.writePosition() == 0) { + if (trimFirstCurly && bytes.writePosition() == 0) { object.writeMarshallable(YamlWire.this); if (bytes.writePosition() == 0) bytes.append("{}"); @@ -1610,10 +1741,10 @@ public WireOut marshallable(@NotNull WriteMarshallable object) { append(" "); leaf = false; popState(); - } else if (seps.size() > 0) { + } else if (!seps.isEmpty()) { popSep = seps.get(seps.size() - 1); popState(); - sep = NEW_LINE; + newLine(); } if (sep.startsWith(',')) { append(sep, 1, sep.length() - 1); @@ -1623,18 +1754,13 @@ public WireOut marshallable(@NotNull WriteMarshallable object) { } else { prependSeparator(); } - endBlock(leaf, '}'); + endBlock('}'); leaf = wasLeaf0; if (popSep != null) sep = popSep; - if (indentation == 0) { - afterClose(); - } else { - elementSeparator(); - } return YamlWire.this; } @@ -1666,7 +1792,7 @@ public WireOut marshallable(@NotNull Serializable object) { } else if (seps.size() > 0) { popSep = seps.get(seps.size() - 1); popState(); - sep = NEW_LINE; + newLine(); } if (sep.startsWith(',')) { append(sep, 1, sep.length() - 1); @@ -1823,6 +1949,7 @@ public ClassLookup classLookup() { @Override public void resetState() { yt.reset(); + anchorValues.clear(); } @Nullable @@ -1874,6 +2001,7 @@ public BracketType getBracketType() { case SEQUENCE_ENTRY: case STREAM_START: case TEXT: + case LITERAL: return BracketType.NONE; } } @@ -1894,9 +2022,10 @@ StringBuilder textTo0(@NotNull StringBuilder a) { consumePadding(); if (yt.current() == YamlToken.SEQUENCE_ENTRY) yt.next(); - if (yt.current() == YamlToken.TEXT) { + if (yt.current() == YamlToken.TEXT || yt.current() == YamlToken.LITERAL) { a.append(yt.text()); - unescape(a); + if (yt.current() == YamlToken.TEXT) + unescape(a, yt.blockQuote()); yt.next(); } else if (yt.current() == YamlToken.TAG) { if (yt.isText("!null")) { @@ -2135,8 +2264,10 @@ long getALong() { if (yt.current() == YamlToken.TEXT) { String text = yt.text(); long l; - if (text.startsWith("0x") || text.startsWith("0X")) { + if ((text.startsWith("0x") || text.startsWith("0X")) && text.length() > 2) { l = Long.parseLong(text.substring(2), 16); + } else if (text.startsWith("0") && text.length() > 1) { + l = Long.parseLong(text.substring(text.length() > 2 && text.charAt(1) == 'o' ? 2 : 1), 8); } else { l = Long.parseLong(text); } @@ -2313,7 +2444,11 @@ public WireIn sequence(@NotNull T t, K kls, @NotNull TriConsumer 40 || "0123456789.+-".indexOf(s.charAt(0)) < 0) return s; + String ss = s; if (s.indexOf('_') >= 0) - ss = s.replace("_", ""); + ss = ss.replace("_", ""); + + // YAML octal notation + if (s.startsWith("0o")) + ss = "0" + s.substring(2); + try { return Long.decode(ss); } catch (NumberFormatException fallback) { @@ -2767,13 +2931,13 @@ protected Object readNumberOrText() { } @NotNull - private Object readSequence(@NotNull Class clazz) { + private Object readSequence(Class clazz) { @NotNull Collection coll = clazz == SortedSet.class ? new TreeSet<>() : clazz == Set.class ? new LinkedHashSet<>() : new ArrayList<>(); readCollection(coll); - if (clazz.isArray()) { + if (clazz != null && clazz.isArray()) { Object o = Array.newInstance(clazz.getComponentType(), coll.size()); if (clazz.getComponentType().isPrimitive()) { Iterator iter = coll.iterator(); diff --git a/src/test/java/net/openhft/chronicle/wire/BinaryWireTest.java b/src/test/java/net/openhft/chronicle/wire/BinaryWireTest.java index 91ac95c0e3..cab5b7704d 100644 --- a/src/test/java/net/openhft/chronicle/wire/BinaryWireTest.java +++ b/src/test/java/net/openhft/chronicle/wire/BinaryWireTest.java @@ -1449,4 +1449,7 @@ private static class DTO extends SelfDescribingMarshallable { this.text = text; } } + + class Circle implements Marshallable { + } } \ No newline at end of file diff --git a/src/test/java/net/openhft/chronicle/wire/KubernetesYamlTest.java b/src/test/java/net/openhft/chronicle/wire/KubernetesYamlTest.java new file mode 100644 index 0000000000..3263ae6515 --- /dev/null +++ b/src/test/java/net/openhft/chronicle/wire/KubernetesYamlTest.java @@ -0,0 +1,191 @@ +package net.openhft.chronicle.wire; + +import net.openhft.chronicle.bytes.Bytes; +import org.junit.Assert; +import org.junit.Test; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.Scanner; +import java.util.stream.Stream; + +import static net.openhft.chronicle.wire.WireType.TEXT; +import static net.openhft.chronicle.wire.WireType.YAML; +import static org.junit.Assert.assertEquals; + +@SuppressWarnings("rawtypes") +public class KubernetesYamlTest extends WireTestCommon { + static String DIR = "/yaml/k8s/"; + + public static void doTest(String file, String... expected) { + Bytes b = Bytes.elasticByteBuffer(); + try { + InputStream is = KubernetesYamlTest.class.getResourceAsStream(DIR + file); + + Scanner s = new Scanner(is).useDelimiter("\\A"); + Bytes bytes = Bytes.from(s.hasNext() ? s.next() : ""); + Stream stream = YAML.streamFromBytes(Object.class, bytes); + Object[] objects = stream.toArray(); + assertEquals(expected.length, objects.length); + + for (int i = 0; i < objects.length; i++) { + Object o = objects[i]; + String actual = o.toString(); + + assertEquals(expected[i], actual); + } + } finally { + b.releaseLast(); + } + } + + @Test + public void testExample1() { + doTest("example1.yaml", + "{apiVersion=v1, kind=Pod, metadata={name=frontend}, spec={containers=[" + + "{name=app, image=images.my-company.example/app:v4, resources={requests={memory=64Mi, cpu=250m}, limits={memory=128Mi, cpu=500m}}}, " + + "{name=log-aggregator, image=images.my-company.example/log-aggregator:v6, resources={requests={memory=64Mi, cpu=250m}, limits={memory=128Mi, cpu=500m}}}]}}"); + } + + @Test + public void testExample2() { + doTest("example2.yaml", + "{apiVersion=v1, kind=Pod, metadata={name=frontend}, spec={containers=[" + + "{name=app, image=images.my-company.example/app:v4, resources={requests={ephemeral-storage=2Gi}, limits={ephemeral-storage=4Gi}}, volumeMounts=[{name=ephemeral, mountPath=/tmp}]}, " + + "{name=log-aggregator, image=images.my-company.example/log-aggregator:v6, resources={requests={ephemeral-storage=2Gi}, limits={ephemeral-storage=4Gi}}, volumeMounts=[{name=ephemeral, mountPath=/tmp}]}], " + + "volumes=[{name=ephemeral, emptyDir={}}]}}"); + } + + @Test + public void testExample3() { + doTest("example3.yaml", + "{apiVersion=apps/v1, kind=Deployment, metadata={name=nginx-deployment}, spec={selector={matchLabels={app=nginx}}, " + + "replicas=2, template={metadata={labels={app=nginx}}, spec={containers=[{name=nginx, image=nginx:1.14.2, ports=[{containerPort=80}]}]}}}}"); + } + + @Test + public void testExample4() { + doTest("example4.yaml", + "{apiVersion=source.toolkit.fluxcd.io/v1beta1, kind=GitRepository, metadata={name=rook-ceph-source, namespace=flux-system}, " + + "spec={interval=10m, url=https://github.com/rook/rook.git, ref={tag=v1.5.5}, ignore=# exclude all\n/*\n# include deploy crds dir\n!/cluster/examples/kubernetes/ceph/crds.yaml\n}}", + + "{apiVersion=kustomize.toolkit.fluxcd.io/v1beta1, kind=Kustomization, metadata={name=rook-ceph-crds, namespace=flux-system}, spec={interval=5m, prune=false, sourceRef={kind=GitRepository, name=rook-ceph-source}, healthChecks=[" + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=cephblockpools.ceph.rook.io}, " + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=cephclients.ceph.rook.io}, " + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=cephclusters.ceph.rook.io}, " + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=cephfilesystems.ceph.rook.io}, " + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=cephnfses.ceph.rook.io}, " + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=cephobjectrealms.ceph.rook.io}, " + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=cephobjectstores.ceph.rook.io}, " + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=cephobjectstoreusers.ceph.rook.io}, " + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=cephobjectzonegroups.ceph.rook.io}, " + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=cephobjectzones.ceph.rook.io}, " + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=cephrbdmirrors.ceph.rook.io}, " + + "{apiVersion=apiextensions.k8s.io/v1, kind=CustomResourceDefinition, name=volumes.rook.io}]}}"); + } + + @Test + public void testExample5() { + doTest("example5.yaml", + "{apiVersion=rbac.istio.io/v1alpha1, kind=ServiceRole, metadata={name=hello-viewer, namespace=default}, " + + "spec={rules=[{services=[hello.default.svc.cluster.local], methods=[GET, HEAD]}]}}", + "{apiVersion=rbac.istio.io/v1alpha1, kind=ServiceRole, metadata={name=world-viewer, namespace=default}, " + + "spec={rules=[{services=[world.default.svc.cluster.local], methods=[GET, HEAD]}]}}", + "{apiVersion=rbac.istio.io/v1alpha1, kind=ServiceRole, metadata={name=world-2-viewer, namespace=default}, " + + "spec={rules=[{services=[world-2.default.svc.cluster.local], methods=[GET, HEAD]}]}}", + "{apiVersion=rbac.istio.io/v1alpha1, kind=ServiceRoleBinding, metadata={name=istio-ingress-binding, namespace=default}, " + + "spec={subjects=[{properties={source.namespace=istio-system}}], roleRef={kind=ServiceRole, name=hello-viewer}}}", + "{apiVersion=rbac.istio.io/v1alpha1, kind=ServiceRoleBinding, metadata={name=hello-user-binding, namespace=default}, " + + "spec={subjects=[{user=cluster.local/ns/default/sa/hello}], roleRef={kind=ServiceRole, name=world-viewer}}}", + "{apiVersion=rbac.istio.io/v1alpha1, kind=ServiceRoleBinding, metadata={name=world-user-binding, namespace=default}, " + + "spec={subjects=[{user=cluster.local/ns/default/sa/world}], roleRef={kind=ServiceRole, name=world-2-viewer}}}", + "{apiVersion=v1, kind=ServiceAccount, metadata={name=hello}}", + "{apiVersion=v1, kind=ServiceAccount, metadata={name=world}}", + "{apiVersion=apps/v1, kind=Deployment, metadata={name=hello}, " + + "spec={replicas=1, selector={matchLabels={app=hello}}, template={metadata={labels={app=hello, version=v1}}, " + + "spec={serviceAccountName=hello, containers=[{name=hello, image=wardviaene/http-echo, env=[" + + "{name=TEXT, value=hello}, {name=NEXT, value=world:8080}], ports=[{name=http, containerPort=8080}]}]}}}}", + "{apiVersion=v1, kind=Service, metadata={name=hello, labels={app=hello}}, spec={selector={app=hello}, ports=[{name=http, port=8080, targetPort=8080}]}}", + "{apiVersion=apps/v1, kind=Deployment, metadata={name=world}, spec={replicas=1, selector={matchLabels={app=world}}, " + + "template={metadata={labels={app=world, version=v1}}, spec={serviceAccountName=world, containers=[" + + "{name=world, image=wardviaene/http-echo, env=[{name=TEXT, value=world}, {name=NEXT, value=world-2:8080}], " + + "ports=[{name=http, containerPort=8080}]}]}}}}", + "{apiVersion=v1, kind=Service, metadata={name=world, labels={app=world}}, spec={selector={app=world}, " + + "ports=[{name=http, port=8080, targetPort=8080}]}}", + "{apiVersion=apps/v1, kind=Deployment, metadata={name=world-2}, " + + "spec={replicas=1, selector={matchLabels={app=world-2}}, template={metadata={labels={app=world-2, version=v1}}, " + + "spec={containers=[{name=world-2, image=wardviaene/http-echo, env=[{name=TEXT, value=!!!}], ports=[{name=http, containerPort=8080}]}]}}}}", + "{apiVersion=v1, kind=Service, metadata={name=world-2, labels={app=world-2}}, " + + "spec={selector={app=world-2}, ports=[{name=http, port=8080, targetPort=8080}]}}", + "{apiVersion=networking.istio.io/v1alpha3, kind=Gateway, metadata={name=helloworld-gateway}, " + + "spec={selector={istio=ingressgateway}, servers=[{port={number=80, name=http, protocol=HTTP}, hosts=[*]}]}}", + "{apiVersion=networking.istio.io/v1alpha3, kind=VirtualService, metadata={name=helloworld}, " + + "spec={hosts=[hello-rbac.example.com], gateways=[helloworld-gateway], " + + "http=[{route=[{destination={host=hello.default.svc.cluster.local, subset=v1, port={number=8080}}}]}]}}", + "{apiVersion=networking.istio.io/v1alpha3, kind=DestinationRule, metadata={name=hello}, " + + "spec={host=hello.default.svc.cluster.local, trafficPolicy={tls={mode=ISTIO_MUTUAL}}, subsets=[{name=v1, labels={version=v1}}]}}"); + } + + @Test + public void testExample6() { + doTest("example6.yaml", "{apiVersion=v1, items=[{apiVersion=v1, kind=Service, metadata={annotations={" + + "external-dns.alpha.kubernetes.io/cloudflare-proxied=false, external-dns.alpha.kubernetes.io/hostname=h.christine.website, external-dns.alpha.kubernetes.io/ttl=120}, " + + "labels={app=hlang}, name=hlang, namespace=apps}, spec={ports=[{port=5000, targetPort=5000}], selector={app=hlang}, type=ClusterIP}}, " + + "{apiVersion=apps/v1, kind=Deployment, metadata={name=hlang, namespace=apps}, spec={replicas=2, selector={matchLabels={app=hlang}}, " + + "template={metadata={labels={app=hlang}, name=hlang}, spec={containers=[{image=xena/hlang:latest, imagePullPolicy=Always, name=web, ports=[{containerPort=5000}]}], imagePullSecrets=[{name=regcred}]}}}}, " + + "{apiVersion=networking.k8s.io/v1beta1, kind=Ingress, metadata={annotations={certmanager.k8s.io/cluster-issuer=letsencrypt-prod, kubernetes.io/ingress.class=nginx}, " + + "labels={app=hlang}, name=hlang, namespace=apps}, spec={rules=[{host=h.christine.website, http={paths=[{backend={serviceName=hlang, servicePort=5000}}]}}], " + + "tls=[{hosts=[h.christine.website], secretName=prod-certs-hlang}]}}, " + + "{apiVersion=v1, kind=Service, metadata={annotations={external-dns.alpha.kubernetes.io/cloudflare-proxied=false, external-dns.alpha.kubernetes.io/hostname=olin.within.website, external-dns.alpha.kubernetes.io/ttl=120}, " + + "labels={app=olin}, name=olin, namespace=apps}, spec={ports=[{port=5000, targetPort=5000}], selector={app=olin}, type=ClusterIP}}, " + + "{apiVersion=apps/v1, kind=Deployment, metadata={name=olin, namespace=apps}, spec={replicas=2, selector={matchLabels={app=olin}}, " + + "template={metadata={labels={app=olin}, name=olin}, spec={containers=[{image=xena/olin:latest, imagePullPolicy=Always, name=web, ports=[{containerPort=5000}]}], imagePullSecrets=[{name=regcred}]}}}}, " + + "{apiVersion=networking.k8s.io/v1beta1, kind=Ingress, metadata={annotations={certmanager.k8s.io/cluster-issuer=letsencrypt-prod, kubernetes.io/ingress.class=nginx}, " + + "labels={app=olin}, name=olin, namespace=apps}, spec={rules=[{host=olin.within.website, http={paths=[{backend={serviceName=olin, servicePort=5000}}]}}], " + + "tls=[{hosts=[olin.within.website], secretName=prod-certs-olin}]}}, " + + "{apiVersion=v1, kind=Service, metadata={annotations={external-dns.alpha.kubernetes.io/cloudflare-proxied=false, external-dns.alpha.kubernetes.io/hostname=tulpaforce.xyz, external-dns.alpha.kubernetes.io/ttl=120}, " + + "labels={app=tulpaforcexyz}, name=tulpaforcexyz, namespace=apps}, spec={ports=[{port=80, targetPort=80}], selector={app=tulpaforcexyz}, type=ClusterIP}}, " + + "{apiVersion=apps/v1, kind=Deployment, metadata={name=tulpaforcexyz, namespace=apps}, spec={replicas=2, selector={matchLabels={app=tulpaforcexyz}}, " + + "template={metadata={labels={app=tulpaforcexyz}, name=tulpaforcexyz}, spec={containers=[{image=xena/tulpaforce:20190906, imagePullPolicy=Always, name=web, ports=[{containerPort=80}]}], imagePullSecrets=[{name=regcred}]}}}}, " + + "{apiVersion=networking.k8s.io/v1beta1, kind=Ingress, metadata={annotations={certmanager.k8s.io/cluster-issuer=letsencrypt-prod, kubernetes.io/ingress.class=nginx}, " + + "labels={app=tulpaforcexyz}, name=tulpaforcexyz, namespace=apps}, spec={rules=[{host=tulpaforce.xyz, http=" + + "{paths=[{backend={serviceName=tulpaforcexyz, servicePort=80}}]}}], tls=[{hosts=[tulpaforce.xyz], secretName=prod-certs-tulpaforcexyz}]}}, " + + "{apiVersion=v1, kind=Service, metadata={annotations={external-dns.alpha.kubernetes.io/cloudflare-proxied=false, external-dns.alpha.kubernetes.io/hostname=within.website, external-dns.alpha.kubernetes.io/ttl=120}, " + + "labels={app=withinwebsite}, name=withinwebsite, namespace=apps}, spec={ports=[{port=5000, targetPort=5000}], selector={app=withinwebsite}, type=ClusterIP}}, " + + "{apiVersion=apps/v1, kind=Deployment, metadata={name=withinwebsite, namespace=apps}, spec={replicas=2, selector={matchLabels={app=withinwebsite}}, " + + "template={metadata={labels={app=withinwebsite}, name=withinwebsite}, spec={containers=[{image=xena/within.website:013120201402, imagePullPolicy=Always, name=web, ports=[{containerPort=5000}]}], imagePullSecrets=[{name=regcred}]}}}}, " + + "{apiVersion=networking.k8s.io/v1beta1, kind=Ingress, metadata={annotations={certmanager.k8s.io/cluster-issuer=letsencrypt-prod, kubernetes.io/ingress.class=nginx}, labels={app=withinwebsite}, name=withinwebsite, namespace=apps}, " + + "spec={rules=[{host=within.website, http={paths=[{backend={serviceName=withinwebsite, servicePort=5000}}]}}], tls=[{hosts=[within.website], secretName=prod-certs-withinwebsite}]}}], kind=List}"); + } + + @Test + public void testExample7() { + doTest("example7.yaml", "{containers=[{env=[{name=POD_ID, valueFrom=null}, {name=LOG_PATH, value=/var/log/mycompany/$(POD_ID)/logs}]}]}"); + } + + @Test + public void testExample8() { + doTest("example8.yaml", "{kind=List, apiVersion=v1, items=[" + + "{kind=Secret, apiVersion=v1, type=kubernetes.io/basic-auth, metadata={name=secret1, annotations={build.openshift.io/source-secret-match-uri-1=*://*.example.com/*}}, data={username=AA==}}, " + + "{kind=Secret, apiVersion=v1, type=kubernetes.io/ssh-auth, metadata={name=secret2, annotations={build.openshift.io/source-secret-match-uri-1=*://*.example.com/*}}, data={ssh-privatekey=AA==}}, " + + "{kind=Secret, apiVersion=v1, type=kubernetes.io/basic-auth, metadata={name=secret3, annotations={build.openshift.io/source-secret-match-uri-1=https://*.com/*}}, data={username=AA==}}, " + + "{kind=BuildConfig, apiVersion=v1, metadata={name=test1}, spec={source={type=Git, git={uri=https://server1.example.com/path}}, strategy={type=Source, sourceStrategy={from={kind=ImageStream, name=test}}}}}, " + + "{kind=BuildConfig, apiVersion=v1, metadata={name=test2}, spec={source={type=Git, git={uri=ssh://server1.example.com/path}}, strategy={type=Source, sourceStrategy={from={kind=ImageStream, name=test}}}}}, " + + "{kind=BuildConfig, apiVersion=v1, metadata={name=test3}, spec={source={type=Git, git={uri=https://test.com/path}}, strategy={type=Source, sourceStrategy={from={kind=ImageStream, name=test}}}}}, " + + "{kind=BuildConfig, apiVersion=v1, metadata={name=test4}, spec={source={type=Git, git={uri=http://test.com/path}}, strategy={type=Source, sourceStrategy={from={kind=ImageStream, name=test}}}}}]}"); + } + + @Test + public void testExample9() { + doTest("example9.yaml", "{kind=List, apiVersion=v1, items=[" + + "{kind=ServiceAccount, apiVersion=v1, metadata={name=sdn, namespace=openshift-sdn}}, " + + "{apiVersion=authorization.openshift.io/v1, kind=ClusterRoleBinding, metadata={name=sdn-cluster-reader}, " + + "roleRef={name=cluster-reader}, subjects=[{kind=ServiceAccount, name=sdn, namespace=openshift-sdn}]}, " + + "{apiVersion=authorization.openshift.io/v1, kind=ClusterRoleBinding, metadata={name=sdn-reader}, " + + "roleRef={name=system:sdn-reader}, subjects=[{kind=ServiceAccount, name=sdn, namespace=openshift-sdn}]}, " + + "{apiVersion=authorization.openshift.io/v1, kind=ClusterRoleBinding, metadata={name=sdn-node-proxier}, " + + "roleRef={name=system:node-proxier}, subjects=[{kind=ServiceAccount, name=sdn, namespace=openshift-sdn}]}]}"); + } +} diff --git a/src/test/java/net/openhft/chronicle/wire/TextWireTest.java b/src/test/java/net/openhft/chronicle/wire/TextWireTest.java index ea99201415..4034e89940 100644 --- a/src/test/java/net/openhft/chronicle/wire/TextWireTest.java +++ b/src/test/java/net/openhft/chronicle/wire/TextWireTest.java @@ -2140,4 +2140,7 @@ public void testDuration() { DurationHolder dh2 = Marshallable.fromString(h); assertEquals(dh, dh2); } + + class Circle implements Marshallable { + } } diff --git a/src/test/java/net/openhft/chronicle/wire/WireTests.java b/src/test/java/net/openhft/chronicle/wire/WireTests.java index 47b969a0e5..73e50141a8 100644 --- a/src/test/java/net/openhft/chronicle/wire/WireTests.java +++ b/src/test/java/net/openhft/chronicle/wire/WireTests.java @@ -350,4 +350,7 @@ Class clazz() { return o; } } + + class Circle implements Marshallable { + } } diff --git a/src/test/java/net/openhft/chronicle/wire/YamlSpecTest.java b/src/test/java/net/openhft/chronicle/wire/YamlSpecTest.java index d7f86a1b99..9eb919d8c1 100644 --- a/src/test/java/net/openhft/chronicle/wire/YamlSpecTest.java +++ b/src/test/java/net/openhft/chronicle/wire/YamlSpecTest.java @@ -8,6 +8,7 @@ import java.io.InputStream; @SuppressWarnings("rawtypes") +@Deprecated(/* Should be fully covered by YamlSpecificationTest */) public class YamlSpecTest extends WireTestCommon { static String DIR = "/yaml/spec/"; @@ -27,184 +28,6 @@ public static void doTest(String file, String expected) { } } - @Test - public void test2_1_SequenceOfScalars() { - Bytes b = Bytes.elasticByteBuffer(); - try { - InputStream is = YamlSpecTest.class.getResourceAsStream - (DIR + "2_1_SequenceOfScalars.yaml"); - - String actual = Marshallable.fromString(is).toString(); - Assert.assertEquals("[Mark McGwire, Sammy Sosa, Ken Griffey]", actual); - - } finally { - b.releaseLast(); - } - } - - @Test - public void testMappingScalarsToScalars_2_2() { - doTest("2_2_MappingScalarsToScalars.yaml", "{hr=65, avg=0.278, rbi=147}"); - } - - @Test - public void test2_3_MappingScalarsToSequences() { - doTest("2_3_MappingScalarsToSequences.yaml", "{american=[Boston Red Sox, Detroit Tigers, New York Yankees], national=[New York Mets, Chicago Cubs, Atlanta Braves]}"); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_4_SequenceOfMappings() { - doTest("2_4_SequenceOfMappings.yaml", ""); - } - - @Test - public void test2_4_SequenceOfMappingsFixed() { - doTest("2_4_SequenceOfMappings-fixed.yaml", "[{name=Mark McGwire, hr=65, avg=0.278}, {name=Sammy Sosa, hr=63, avg=0.288}]"); - } - - @Test - public void test2_5_SequenceOfSequences() { - doTest("2_5_SequenceOfSequences.yaml", "[[name, hr, avg], [Mark McGwire, 65, 0.278], [Sammy Sosa, 63, 0.288]]"); - } - - @Test - public void test2_6_MappingOfMappings() { - doTest("2_6_MappingOfMappings.yaml", "{Mark McGwire={hr=65, avg=0.278}, Sammy Sosa={hr=63, avg=0.288}}"); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_7_TwoDocumentsInAStream() { - doTest("2_7_TwoDocumentsInAStream.yaml", ""); - } - - @Test - public void test2_7_TwoDocumentsInAStreamFixed() { - doTest("2_7_TwoDocumentsInAStreamFixed.yaml", "[[Mark McGwire, Sammy Sosa, Ken Griffey], [Chicago Cubs, St Louis Cardinals]]"); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_8_PlayByPlayFeed() { - doTest("2_8_PlayByPlayFeed.yaml", ""); - } - - @Test - public void test2_8_PlayByPlayFeedFixed() { - doTest("2_8_PlayByPlayFeedFixed.yaml", "[{time=20:03:20, player=Sammy Sosa, action=strike (miss)}, {time=20:03:47, player=Sammy Sosa, action=grand slam}]"); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_9_SingleDocumentWithTwoComments() { - doTest("2_9_SingleDocumentWithTwoComments.yaml", ""); - } - - @Test - public void test2_9_SingleDocumentWithTwoCommentsFixed() { - doTest("2_9_SingleDocumentWithTwoCommentsFixed.yaml", "{hr=[Mark McGwire, Sammy Sosa], rbi=[Sammy Sosa, Ken Griffey]}"); - } - - @Ignore("TODO FIX") - @Test - public void test2_10_NodeAppearsTwiceInThisDocumentFixed() { - doTest("2_10_NodeAppearsTwiceInThisDocument.yaml", ""); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_10_NodeAppearsTwiceInThisDocument() { - doTest("2_10_NodeAppearsTwiceInThisDocument.yaml", ""); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_11MappingBetweenSequences() { - doTest("2_11MappingBetweenSequences.yaml", ""); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_12CompactNestedMapping() { - doTest("2_12CompactNestedMapping.yaml", ""); - } - - @Test - public void test2_12CompactNestedMappingFixed() { - doTest("2_12CompactNestedMappingFixed.yaml", "[{item=Super Hoop, quantity=1}, {item=Basketball, quantity=4}, {item=Big Shoes, quantity=1}]"); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_13InLiteralsNewlinesArePreserved() { - doTest("2_13InLiteralsNewlinesArePreserved.yaml", ""); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_14InThefoldedScalars() { - doTest("2_14InThefoldedScalars.yaml", ""); - } - - @Test - public void test2_14InThefoldedScalarsFixed() { - doTest("2_14InThefoldedScalarsFixed.yaml", "[Mark McGwire's, year was crippled, by a knee injury.]"); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_15FoldedNewlines() { - doTest("2_15FoldedNewlines.yaml", ""); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_16IndentationDeterminesScope() { - doTest("2_16IndentationDeterminesScope.yaml", ""); - } - - @Test - public void test2_16IndentationDeterminesScopeFixed() { - doTest("2_16IndentationDeterminesScopeFixed.yaml", "{name=Mark McGwire, accomplishment=Mark set a major league home run record in 1998., stats=[65 Home Runs, 0.278 Batting Average]}"); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_17QuotedScalars() { - doTest("2_17QuotedScalars.yaml", ""); - } - - @Ignore("TODO FIX") - @Test - public void test2_17QuotedScalarsFixed() { - Bytes b = Bytes.elasticByteBuffer(); - try { - InputStream is = YamlSpecTest.class.getResourceAsStream - (DIR + "2_17QuotedScalarsFixed.yaml"); - - Object o = Marshallable.fromString(is); - Assert.assertNotNull(o); - String actual = o.toString(); - String expected = "{unicode: \"Sosa did fine.☺\", " + - "control: \"\\b1998\\t1999\\t2000\\n\", " + - "hex esc: \"\\x0d\\x0a is \\r\\n\", " + - "single: \"Howdy! he cried.\", " + - "quoted: \" # Not a ''comment''.\", " + - "tie-fighter: '|\\-*-/|'}"; - Assert.assertEquals(expected, actual); - - } finally { - b.releaseLast(); - } - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_18Multi_lineFlowScalars() { - doTest("2_18Multi_lineFlowScalars.yaml", " "); - } - @Test public void test2_18Multi_lineFlowScalarsFixed() { Bytes b = Bytes.elasticByteBuffer(); @@ -226,76 +49,8 @@ public void test2_18Multi_lineFlowScalarsFixed() { } } - @Test - public void test2_19Integers() { - doTest("2_19Integers.yaml", "{canonical=12345, decimal=12345, octal=0o14, hexadecimal=12}"); - } - - @Test - public void test2_20FloatingPoint() { - doTest("2_20FloatingPoint.yaml", "{canonical=1230.15, exponential=1230.15, fixed=1230.15, negative infinity=-.inf, not a number=.NaN}"); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_21Miscellaneous() { - doTest("2_21Miscellaneous.yaml", ""); - } - @Test public void test2_21MiscellaneousFixed() { doTest("2_21MiscellaneousFixed.yaml", "{null=, booleans=[true, false], string=012345}"); } - - @Test - public void test2_22Timestamps() { - doTest("2_22Timestamps.yaml", "{canonical=2001-12-15T02:59:43.100Z, iso8601=2001-12-14T21:59:43.100-05:00, spaced=2001-12-14 21:59:43.10 -5, date=2002-12-14}"); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_23VariousExplicitTags() { - doTest("2_23VariousExplicitTags.yaml", ""); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_24GlobalTags() { - doTest("2_24GlobalTags.yaml", ""); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_25UnorderedSets() { - doTest("2_25UnorderedSets.yaml", ""); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_26OrderedMappings() { - doTest("2_26OrderedMappings.yaml", "{Ken Griffy=58,Mark McGwire=65,Sammy Sosa=63}"); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_27Invoice() { - doTest("2_27Invoice.yaml", ""); - } - - @Ignore("todo see spec http://yaml.org/spec/1.2/spec.html#comment/") - @Test - public void test2_28LogFile() { - Bytes b = Bytes.elasticByteBuffer(); - try { - InputStream is = YamlSpecTest.class.getResourceAsStream - (DIR + "2_28LogFile.yaml"); - - Object o = Marshallable.fromString(is); - Assert.assertNotNull(o); - String actual = o.toString(); - - } finally { - b.releaseLast(); - } - } } diff --git a/src/test/java/net/openhft/chronicle/wire/YamlSpecificationTest.java b/src/test/java/net/openhft/chronicle/wire/YamlSpecificationTest.java index 8310ad53ea..81dcf47de8 100644 --- a/src/test/java/net/openhft/chronicle/wire/YamlSpecificationTest.java +++ b/src/test/java/net/openhft/chronicle/wire/YamlSpecificationTest.java @@ -21,27 +21,33 @@ import net.openhft.chronicle.core.pool.ClassAliasPool; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import java.io.IOException; import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.List; +import static net.openhft.chronicle.wire.WireType.TEXT; +import static net.openhft.chronicle.wire.WireType.YAML; import static org.junit.Assert.assertEquals; @SuppressWarnings("rawtypes") @RunWith(Parameterized.class) public class YamlSpecificationTest extends WireTestCommon { - static { + /*static { ClassAliasPool.CLASS_ALIASES.addAlias(String.class, "something"); ClassAliasPool.CLASS_ALIASES.addAlias(Circle.class, "circle"); ClassAliasPool.CLASS_ALIASES.addAlias(Shape.class, "shape"); ClassAliasPool.CLASS_ALIASES.addAlias(Line.class, "line"); ClassAliasPool.CLASS_ALIASES.addAlias(Label.class, "label"); - } + }*/ private final String input; @@ -49,61 +55,72 @@ public YamlSpecificationTest(String input) { this.input = input; } - @Parameterized.Parameters - public static Collection tests() { + @Parameterized.Parameters(name = "case={0}") + public static Collection tests() { return Arrays.asList(new String[][]{ - {"example2_1"}, - {"example2_2"}, - {"example2_3"}, - // {"example2_4"}, // TODO Fix map format - // {"example2_5"}, // Not supported - // {"example2_6"}, // TODO Fix map format - {"example2_7"},// TODO Fix for multiple --- - // {"example2_8"},// TODO Fix for multiple --- - {"example2_9"}, - // {"example2_10"}, // TODO FIx handling of anchors - // {"example2_11"}, // Not supported - // {"example2_12"}, // Not supported - // {"example2_13"}, // Not supported - // {"example2_14"}, // Not supported - // {"example2_15"}, // Not supported - // {"example2_16"}, // Not supported - // {"example2_17"}, // TODO Fix handling of double single quote. - // {"example2_18"}, // Not supported - // {"example2_19"}, // TODO fix handling of times. - // {"example2_20"}, // TODO fix handling of times. - {"example2_21"}, - // {"example2_22"}, // TODO fix handling of times. - // {"example2_23"}, // Not supported - // {"example2_24"}, // TODO FIx handling of anchors - // {"example2_25"}, // TODO support set - // {"example2_26"}, // TODO support omap - // {"example2_27"}, // Not supported - // {"example2_28"} // Not supported - }); + {"2_1_SequenceOfScalars"}, + {"2_2_MappingScalarsToScalars"}, + {"2_3_MappingScalarsToSequences"}, + {"2_4_SequenceOfMappings"}, + {"2_5_SequenceOfSequences"}, + {"2_6_MappingOfMappings"}, + {"2_7_TwoDocumentsInAStream"}, + // {"example2_8"}, + {"2_9_SingleDocumentWithTwoComments"}, + {"2_10_NodeAppearsTwiceInThisDocument"}, + // {"example2_11"}, // Not supported + {"2_12CompactNestedMapping"}, + {"2_13InLiteralsNewlinesArePreserved"}, + {"2_14InThefoldedScalars"}, + // {"example2_15"}, // Not supported + // {"example2_16"}, // Not supported + {"2_17QuotedScalars"}, + // {"example2_18"}, // Not supported + {"2_19Integers"}, + // {"example2_20"}, // TODO fix handling of times. + {"2_21MiscellaneousBis"}, + // {"example2_22"}, // TODO fix handling of times. + // {"example2_23"}, // Not supported + // {"example2_24"}, // TODO FIx handling of anchors + // {"example2_25"}, // TODO support set + // {"example2_26"}, // TODO support omap + // {"example2_27"}, // Not supported + // {"example2_28"} // Not supported + }); } @Test public void decodeAs() throws IOException { - @Nullable byte[] byteArr = getBytes(input + ".yaml"); - Bytes bytes = Bytes.wrapForRead(byteArr); - @NotNull TextWire tw = new TextWire(bytes); - @NotNull Bytes bytes2 = Bytes.allocateElasticOnHeap(); - @NotNull TextWire tw2 = new TextWire(bytes2); - - @Nullable Object o = tw.readObject(); - tw2.writeObject(o); - @Nullable byte[] byteArr2 = getBytes(input + ".out.yaml"); - if (byteArr2 == null) - byteArr2 = byteArr; - String expected = Bytes.wrapForRead(byteArr2).toString().replace("\r\n", "\n"); - String actual = bytes2.toString(); - assertEquals(input, expected, actual); + String snippet = new String(getBytes(input + ".yaml"), StandardCharsets.UTF_8); + String actual = parseWithYaml(snippet); + + byte[] expectedBytes = getBytes(input + ".out.yaml"); + String expected; + if (expectedBytes != null) { + assertEquals(actual, parseWithYaml(actual)); + + expected = new String(expectedBytes, StandardCharsets.UTF_8); + } else { + expected = snippet; + } + + assertEquals(input, Bytes.wrapForRead(expected.getBytes(StandardCharsets.UTF_8)).toString().replace("\r\n", "\n"), actual); + } + + @NotNull + private String parseWithYaml(String snippet) { + Object o = YAML.fromString(snippet); + Bytes bytes = Bytes.allocateElasticOnHeap(); + + YamlWire tw = new YamlWire(bytes); + tw.writeObject(o); + + return bytes.toString(); } @Nullable public byte[] getBytes(String file) throws IOException { - InputStream is = getClass().getResourceAsStream("/specification/" + file); + InputStream is = getClass().getResourceAsStream("/yaml/spec/" + file); if (is == null) return null; int len = is.available(); @NotNull byte[] byteArr = new byte[len]; @@ -126,7 +143,7 @@ public byte[] getBytes(String file) throws IOException { color: 0xFFEEBB text: Pretty vector drawing. */ - +/* class Shape implements Marshallable { } @@ -138,3 +155,4 @@ class Line implements Marshallable { class Label implements Marshallable { } +*/ \ No newline at end of file diff --git a/src/test/java/net/openhft/chronicle/wire/YamlTokeniserTest.java b/src/test/java/net/openhft/chronicle/wire/YamlTokeniserTest.java index 794aa53935..c50748b3b2 100644 --- a/src/test/java/net/openhft/chronicle/wire/YamlTokeniserTest.java +++ b/src/test/java/net/openhft/chronicle/wire/YamlTokeniserTest.java @@ -30,6 +30,72 @@ public static String doTest(String resource) { } } + @Test + public void exception() { + assertEquals("DIRECTIVES_END \n" + + "TAG !data\n" + + "MAPPING_START \n" + + "MAPPING_KEY \n" + + "TEXT exception\n" + + "TAG java.security.InvalidAlgorithmParameterException\n" + + "MAPPING_START \n" + + "MAPPING_KEY \n" + + "TEXT message\n" + + "TEXT Reference cannot be null\n" + + "MAPPING_KEY \n" + + "TEXT stackTrace\n" + + "SEQUENCE_START \n" + + "SEQUENCE_ENTRY \n" + + "MAPPING_START \n" + + "MAPPING_KEY \n" + + "TEXT class\n" + + "TEXT net.openhft.chronicle.wire.YamlWireTest\n" + + "MAPPING_KEY \n" + + "TEXT method\n" + + "TEXT testException\n" + + "MAPPING_KEY \n" + + "TEXT file\n" + + "TEXT YamlWireTest.java\n" + + "MAPPING_KEY \n" + + "TEXT line\n" + + "TEXT 783\n" + + "MAPPING_END \n" + + "SEQUENCE_ENTRY \n" + + "MAPPING_START \n" + + "MAPPING_KEY \n" + + "TEXT class\n" + + "TEXT net.openhft.chronicle.wire.YamlWireTest\n" + + "MAPPING_KEY \n" + + "TEXT method\n" + + "TEXT runTestException\n" + + "MAPPING_KEY \n" + + "TEXT file\n" + + "TEXT YamlWireTest.java\n" + + "MAPPING_KEY \n" + + "TEXT line\n" + + "TEXT 73\n" + + "MAPPING_END \n" + + "SEQUENCE_ENTRY \n" + + "MAPPING_START \n" + + "MAPPING_KEY \n" + + "TEXT class\n" + + "TEXT sun.reflect.NativeMethodAccessorImpl\n" + + "MAPPING_KEY \n" + + "TEXT method\n" + + "TEXT invoke0\n" + + "MAPPING_KEY \n" + + "TEXT file\n" + + "TEXT NativeMethodAccessorImpl.java\n" + + "MAPPING_KEY \n" + + "TEXT line\n" + + "TEXT -2\n" + + "MAPPING_END \n" + + "SEQUENCE_END \n" + + "MAPPING_END \n" + + "MAPPING_END \n" + + "DOCUMENT_END \n", doTest("exception.yaml")); + } + @Test public void eg2_1() { assertEquals("DIRECTIVES_END \n" + @@ -128,6 +194,39 @@ public void eg2_4() { doTest("yaml/spec/2_4_SequenceOfMappings.yaml")); } + @Test + public void eg2_4out() { + assertEquals("DIRECTIVES_END \n" + + "SEQUENCE_START \n" + + "SEQUENCE_ENTRY \n" + + "MAPPING_START \n" + + "MAPPING_KEY \n" + + "TEXT name\n" + + "TEXT Mark McGwire\n" + + "MAPPING_KEY \n" + + "TEXT hr\n" + + "TEXT 65\n" + + "MAPPING_KEY \n" + + "TEXT avg\n" + + "TEXT 0.278\n" + + "MAPPING_END \n" + + "SEQUENCE_ENTRY \n" + + "MAPPING_START \n" + + "MAPPING_KEY \n" + + "TEXT name\n" + + "TEXT Sammy Sosa\n" + + "MAPPING_KEY \n" + + "TEXT hr\n" + + "TEXT 63\n" + + "MAPPING_KEY \n" + + "TEXT avg\n" + + "TEXT 0.288\n" + + "MAPPING_END \n" + + "SEQUENCE_END \n" + + "DOCUMENT_END \n", + doTest("yaml/spec/2_4_SequenceOfMappings.out.yaml")); + } + @Test public void eg2_4B() { assertEquals("DIRECTIVES_END \n" + @@ -158,16 +257,14 @@ public void eg2_4B() { "MAPPING_END \n" + "SEQUENCE_END \n" + "DOCUMENT_END \n", - doTest("yaml/spec/2_4_SequenceOfMappings-fixed.yaml")); + doTest("yaml/spec/2_4_SequenceOfMappings.yaml")); } - @Ignore("TODO Handle properly") @Test public void eg2_5() { assertEquals("DIRECTIVES_END \n" + "SEQUENCE_START \n" + "SEQUENCE_ENTRY \n" + - "SEQUENCE_ENTRY \n" + "SEQUENCE_START \n" + "SEQUENCE_ENTRY \n" + "TEXT name\n" + @@ -177,7 +274,6 @@ public void eg2_5() { "TEXT avg\n" + "SEQUENCE_END \n" + "SEQUENCE_ENTRY \n" + - "SEQUENCE_ENTRY \n" + "SEQUENCE_START \n" + "SEQUENCE_ENTRY \n" + "TEXT Mark McGwire\n" + @@ -187,7 +283,6 @@ public void eg2_5() { "TEXT 0.278\n" + "SEQUENCE_END \n" + "SEQUENCE_ENTRY \n" + - "SEQUENCE_ENTRY \n" + "SEQUENCE_START \n" + "SEQUENCE_ENTRY \n" + "TEXT Sammy Sosa\n" + @@ -324,13 +419,14 @@ public void eg2_10() { "TEXT Mark McGwire\n" + "COMMENT Following node labeled SS\n" + "SEQUENCE_ENTRY \n" + - "TEXT &SS Sammy Sosa\n" + + "ANCHOR SS\n" + + "TEXT Sammy Sosa\n" + "SEQUENCE_END \n" + "MAPPING_KEY \n" + "TEXT rbi\n" + "SEQUENCE_START \n" + "SEQUENCE_ENTRY \n" + - "TEXT *SS\n" + + "ALIAS SS\n" + "COMMENT Subsequent occurrence\n" + "SEQUENCE_ENTRY \n" + "TEXT Ken Griffey\n" + @@ -419,8 +515,8 @@ public void eg2_13() { assertEquals( "COMMENT ASCII Art\n" + "DIRECTIVES_END \n" + - "TEXT \\//||\\/||\n" + - "// || ||__\n" + + "LITERAL \\//||\\/||\n" + + "// || ||__\n\n" + "DOCUMENT_END \n", doTest("yaml/spec/2_13InLiteralsNewlinesArePreserved.yaml").replace("\r", "")); } @@ -429,7 +525,7 @@ public void eg2_13() { public void eg2_14() { assertEquals( "DIRECTIVES_END \n" + - "TEXT Mark McGwire's year was crippled by a knee injury.\n" + + "LITERAL Mark McGwire's year was crippled by a knee injury.\n" + "DOCUMENT_END \n", doTest("yaml/spec/2_14InThefoldedScalars.yaml").replace("\r", "")); } @@ -437,7 +533,7 @@ public void eg2_14() { @Test public void eg2_15() { assertEquals( - "TEXT Sammy Sosa completed another fine season with great stats. 63 Home Runs 0.288 Batting Average What a year!\n", + "LITERAL Sammy Sosa completed another fine season with great stats. 63 Home Runs 0.288 Batting Average What a year!\n", doTest("yaml/spec/2_15FoldedNewlines.yaml").replace("\r", "")); } @@ -451,10 +547,10 @@ public void eg2_16() { "TEXT Mark McGwire\n" + "MAPPING_KEY \n" + "TEXT accomplishment\n" + - "TEXT Mark set a major league home run record in 1998. \n" + + "LITERAL Mark set a major league home run record in 1998.\n" + "MAPPING_KEY \n" + "TEXT stats\n" + - "TEXT 65 Home Runs\n" + + "LITERAL 65 Home Runs\n" + "0.278 Batting Average\n" + "\n" + "MAPPING_END \n" + @@ -517,7 +613,10 @@ public void eg2_19() { "TEXT 12345\n" + "MAPPING_KEY \n" + "TEXT decimal\n" + - "TEXT +12345\n" + + "TEXT +12_345\n" + + "MAPPING_KEY \n" + + "TEXT sexagesimal\n" + + "TEXT 3:25:45\n" + "MAPPING_KEY \n" + "TEXT octal\n" + "TEXT 0o14\n" + @@ -541,8 +640,11 @@ public void eg2_20() { "TEXT exponential\n" + "TEXT 12.3015e+02\n" + "MAPPING_KEY \n" + + "TEXT sexagesimal\n" + + "TEXT 20:30.15\n" + + "MAPPING_KEY \n" + "TEXT fixed\n" + - "TEXT 1230.15\n" + + "TEXT 1_230.15\n" + "MAPPING_KEY \n" + "TEXT negative infinity\n" + "TEXT -.inf\n" + @@ -611,7 +713,7 @@ public void eg2_23() { "MAPPING_KEY \n" + "TEXT picture\n" + "TAG !binary\n" + - "TEXT R0lGODlhDAAMAIQAAP//9/X\n" + + "LITERAL R0lGODlhDAAMAIQAAP//9/X\n" + "17unp5WZmZgAAAOfn515eXv\n" + "Pz7Y6OjuDg4J+fn5OTk6enp\n" + "56enmleECcgggoBADs=\n" + @@ -620,7 +722,7 @@ public void eg2_23() { "MAPPING_KEY \n" + "TEXT application specific tag\n" + "TAG something\n" + - "TEXT The semantics of the tag\n" + + "LITERAL The semantics of the tag\n" + "above may be different for\n" + "different documents.\n" + "\n" + @@ -644,7 +746,7 @@ public void eg2_24() { "MAPPING_START \n" + "MAPPING_KEY \n" + "TEXT center\n" + - "TEXT &ORIGIN\n" + + "ANCHOR ORIGIN\n" + "MAPPING_START \n" + "MAPPING_KEY \n" + "TEXT x\n" + @@ -662,7 +764,7 @@ public void eg2_24() { "MAPPING_START \n" + "MAPPING_KEY \n" + "TEXT start\n" + - "TEXT *ORIGIN\n" + + "ALIAS ORIGIN\n" + "MAPPING_KEY \n" + "TEXT finish\n" + "MAPPING_START \n" + @@ -679,7 +781,7 @@ public void eg2_24() { "MAPPING_START \n" + "MAPPING_KEY \n" + "TEXT start\n" + - "TEXT *ORIGIN\n" + + "ALIAS ORIGIN\n" + "MAPPING_KEY \n" + "TEXT color\n" + "TEXT 0xFFEEBB\n" + @@ -716,7 +818,10 @@ public void eg2_25() { @Test public void eg2_26() { assertEquals( - "DIRECTIVES_END \n" + + "COMMENT ordered maps are represented as\n" + + "COMMENT a sequence of mappings, with\n" + + "COMMENT each mapping having one key\n" + + "DIRECTIVES_END \n" + "TAG !omap\n" + "SEQUENCE_START \n" + "SEQUENCE_ENTRY \n" + @@ -756,7 +861,7 @@ public void eg2_27() { "TEXT 2001-01-23\n" + "MAPPING_KEY \n" + "TEXT bill-to\n" + - "TEXT &id001\n" + + "ANCHOR id001\n" + "MAPPING_START \n" + "MAPPING_KEY \n" + "TEXT given\n" + @@ -769,7 +874,7 @@ public void eg2_27() { "MAPPING_START \n" + "MAPPING_KEY \n" + "TEXT lines\n" + - "TEXT 458 Walkman Dr.\n" + + "LITERAL 458 Walkman Dr.\n" + "Suite #292\n" + "\n" + "MAPPING_KEY \n" + @@ -785,7 +890,7 @@ public void eg2_27() { "MAPPING_END \n" + "MAPPING_KEY \n" + "TEXT ship-to\n" + - "TEXT *id001\n" + + "ALIAS id001\n" + "MAPPING_KEY \n" + "TEXT product\n" + "SEQUENCE_START \n" + @@ -892,7 +997,7 @@ public void eg2_28() { "TEXT 23\n" + "MAPPING_KEY \n" + "TEXT code\n" + - "TEXT x = MoreObject(\"345\\n\")\n" + + "LITERAL x = MoreObject(\"345\\n\")\n" + "\n" + "MAPPING_END \n" + "SEQUENCE_ENTRY \n" + diff --git a/src/test/java/net/openhft/chronicle/wire/YamlWireTest.java b/src/test/java/net/openhft/chronicle/wire/YamlWireTest.java index a3bae52512..43e9a3f416 100644 --- a/src/test/java/net/openhft/chronicle/wire/YamlWireTest.java +++ b/src/test/java/net/openhft/chronicle/wire/YamlWireTest.java @@ -19,7 +19,6 @@ import net.openhft.chronicle.bytes.Bytes; import net.openhft.chronicle.bytes.NoBytesStore; -import net.openhft.chronicle.core.io.IORuntimeException; import net.openhft.chronicle.core.pool.ClassAliasPool; import org.easymock.EasyMock; import org.jetbrains.annotations.NotNull; @@ -49,8 +48,6 @@ import static java.nio.charset.StandardCharsets.ISO_8859_1; import static net.openhft.chronicle.bytes.Bytes.allocateElasticDirect; import static net.openhft.chronicle.bytes.Bytes.allocateElasticOnHeap; -import static net.openhft.chronicle.wire.TextWireTest.*; -import static net.openhft.chronicle.wire.WireType.TEXT; import static net.openhft.chronicle.wire.YamlTokeniserTest.doTest; import static org.easymock.EasyMock.replay; import static org.easymock.EasyMock.verify; @@ -80,86 +77,6 @@ public void testTypeInsteadOfField() { assertEquals(0, sb.length()); } - @Test - public void testFieldWithComment() { - FieldWithComment f = new FieldWithComment(); - f.field = "hello world"; - Assert.assertEquals("!net.openhft.chronicle.wire.YamlWireTest$FieldWithComment {\n" + - " field: hello world, \t\t# a comment where the value=hello world\n" + - "\n" + - "}\n", Marshallable.$toString(f)); - } - - @Test - public void testFieldWithComment2() { - FieldWithComment2 f = new FieldWithComment2(); - f.field = "hello world"; - Assert.assertEquals("!net.openhft.chronicle.wire.YamlWireTest$FieldWithComment2 {\n" + - " field: hello world, \t\t# a comment where the value=hello world\n" + - " field2: !!null \"\"\n" + - "}\n", Marshallable.$toString(f)); - } - - @Test - public void handleUnexpectedFields() { - TwoFields tf = Marshallable.fromString("!" + TwoFields.class.getName() + " {" + - "a: 1,\n" + - "b: two,\n" + - "c: three,\n" + - "d: 44,\n" + - "e: also,\n" + - "f: at the end\n" + - "}"); - assertEquals("a=1\n" + - "c=three\n" + - "e=also\n" + - "f=at the end", - asProperties(tf.others)); - - TwoFields tf2 = Marshallable.fromString("!" + TwoFields.class.getName() + " {" + - "a: 1,\n" + - "b: two,\n" + - "c: three,\n" + - "d: 44,\n" + - "e: also,\n" + - "}"); - assertEquals("a=1\n" + - "c=three\n" + - "e=also", - asProperties(tf2.others)); - - TwoFields tf3 = Marshallable.fromString("!" + TwoFields.class.getName() + " {" + - "A: 1,\n" + - "B: two,\n" + - "C: three,\n" + - "D: 44,\n" + - "E: also,\n" + - "}"); - assertEquals("a=1\n" + - "c=three\n" + - "e=also", - asProperties(tf3.others)); - } - - public String asProperties(Map map) { - return map.entrySet().stream().map(Object::toString).collect(Collectors.joining("\n")); - } - - @Test - public void licenseCheck() { - WireType.TEXT.licenceCheck(); - assertTrue(WireType.TEXT.isAvailable()); - - try { - expectException("A Chronicle-Wire-Enterprise licence is required to run this code because you are using DELTA_BINARY which is a licence product"); - WireType.DELTA_BINARY.licenceCheck(); - fail(); - } catch (IllegalStateException expected) { - // expected - } - assertFalse(WireType.DELTA_BINARY.isAvailable()); - } - @Ignore("TODO FIX") @Test public void writeObjectWithTreeMap() { @@ -184,9 +101,10 @@ public void writeObjectWithTreeMap() { assertEquals("{hello=world}", value4.map.toString()); } + @Ignore("TODO") @Test public void testFromString() { - @Nullable Object w = WireType.TEXT.fromString("changedRow: {\n" + + @Nullable Object w = WireType.YAML.fromString("changedRow: {\n" + " row: [\n" + " ],\n" + " oldRow: {\n" + @@ -213,6 +131,27 @@ public void testFromString2() { } } + @Test + public void testLargeHex() { + Wire w = YamlWire.from( + "magic: 0xCAFEBABE\n"); + assertEquals(3405691582L, w.read("magic").int64()); + } + + @Test + public void testCStyleOctal() { + // Do we need it? + Wire w = YamlWire.from("perms: 0644\n"); + assertEquals(420, w.read("perms").int64()); + } + + @Test + public void testYamlStyleOctal() { + Wire w = YamlWire.from("perms: 0o750\n"); + assertEquals(488, w.read("perms").int64()); + } + + @Ignore("TODO") @Test public void testWriteToBinaryAndTriesToConvertToText() { @@ -232,7 +171,7 @@ public void testWriteToBinaryAndTriesToConvertToText() { final String textYaml = Wires.fromSizePrefixedBlobs(b); // System.out.println(textYaml); - @Nullable Object o = WireType.TEXT.fromString(textYaml); + @Nullable Object o = WireType.YAML.fromString(textYaml); Assert.assertEquals("{map={some={key=value}, some-other={key=value}}}", o.toString()); b.releaseLast(); @@ -684,35 +623,6 @@ public void type() { wire.read(); } - @Test - public void testTypeWithEmpty() { - expectException("Expected a {} but was blank for type class net.openhft.chronicle.wire.YamlWireTest$YNestedB"); - - ClassAliasPool.CLASS_ALIASES.addAlias(YNestedA.class, YNestedB.class); - YNestedA a = Marshallable.fromString("!YNestedA {\n" + - " b: !YNestedB,\n" + - " value: 12345\n" + - "}"); - assertEquals("!YNestedA {\n" + - " b: {\n" + - " field1: 0.0\n" + - " },\n" + - " value: 12345\n" + - "}\n", a.toString()); - } - - @Test - public void testSingleQuote() { - expectException("Expected a {} but was blank for type class net.openhft.chronicle.wire.YamlWireTest$YNestedB"); - - ClassAliasPool.CLASS_ALIASES.addAlias(YNestedA.class); - YNestedA a = Marshallable.fromString("!YNestedA {\n" + - " b: !YNestedB,\n" + - " value: 12345\n" + - "}"); - assertNotNull(a); - } - @Test public void testBool() { @NotNull Wire wire = createWire(); @@ -859,22 +769,46 @@ public void testNANValue() { assertEquals(1.23, wire.read("B").float64(), 0); } + @Test + public void testQuoting() { + @NotNull Wire wire = createWire(); + wire.bytes().append( + "nonesingle: \\\n" + + "nonedouble: \\\\\n" + + "singleself: ''''\n" + + "singleselfself: ''''''\n" + + "singlesingle: '\\'\n" + + "singledouble: '\\\\'\n" + + "doubleself: \"\\\"\"\n" + + "doublesingle: \"\\\\\"\n" + + "doubledouble: \"\\\\\\\\\"\n"); + assertEquals("\\", wire.read("nonesingle").readString()); + assertEquals("\\\\", wire.read("nonedouble").readString()); + assertEquals("'", wire.read("singleself").readString()); + assertEquals("''", wire.read("singleselfself").readString()); + assertEquals("\\", wire.read("singlesingle").readString()); + assertEquals("\\\\", wire.read("singledouble").readString()); + assertEquals("\"", wire.read("doubleself").readString()); + assertEquals("\\", wire.read("doublesingle").readString()); + assertEquals("\\\\", wire.read("doubledouble").readString()); + } + @Ignore("TODO FIX") @Test public void testABCDBytes() { - @NotNull YamlWire wire = createWire(); +/* @NotNull YamlWire wire = createWire(); wire.bytes().append( "A: \"hi\",\n" + "B: 'hi',\n" + "C: hi,\n" + "D: bye,\n"); - ABCD abcd = new ABCD(); + TextWireTest.ABCD abcd = new TextWireTest.ABCD(); try { for (int i = 0; i < 5; i++) { wire.reset(); - ABCD object = wire.getValueIn() - .object(abcd, ABCD.class); + TextWireTest.ABCD object = wire.getValueIn() + .object(abcd, TextWireTest.ABCD.class); assertEquals("!net.openhft.chronicle.wire.YamlWireTest$ABCD {\n" + " A: hi,\n" + " B: hi,\n" + @@ -889,13 +823,13 @@ public void testABCDBytes() { WireMarshaller wm = WireMarshaller.WIRE_MARSHALLER_CL.get(ABCD.class); ABCD abcd0 = (ABCD) wm.defaultValue(); abcd0.releaseAll(); - } + }*/ } @Ignore("TODO FIX") @Test public void testABCStringBuilder() { - +/* @NotNull YamlWire wire = createWire(); wire.bytes().append( "A: \"hi\",\n" + @@ -912,7 +846,7 @@ public void testABCStringBuilder() { "}\n", wire.getValueIn() .object(abc, ABC.class) .toString()); - } + }*/ } @Test @@ -934,24 +868,6 @@ public void testBytes() { assertEquals(Bytes.wrapForRead(allBytes), allBytes2); } - @Test - @Ignore("unreleased bytes") - public void testBytesField() { - DtoWithBytesField dto = new DtoWithBytesField(), dto2 = null; - byte[] binaryData = new byte[]{1, 2, 3, 4}; - dto.bytes = Bytes.wrapForRead(binaryData); - dto.another = 123L; - - try { - String cs = dto.toString(); - dto2 = Marshallable.fromString(cs); - assertEquals(cs, dto2.toString()); - } finally { - dto.bytes.releaseLast(); - dto2.bytes.releaseLast(); - } - } - @Test public void testWriteMarshallable() { @NotNull Wire wire = createWire(); @@ -1038,14 +954,14 @@ public void testContextDump() { YamlWire yw = new YamlWire(from); assertEquals("[\n" + " { token: STREAM_START, indent: -1, keys: !!null \"\" }\n" + - "]", yw.dumpContext()); + "]\n", yw.dumpContext()); yw.read("C") .text(); assertEquals("[\n" + " { token: STREAM_START, indent: -1, keys: !!null \"\" },\n" + " { token: DIRECTIVES_END, indent: -1, keys: !!null \"\" },\n" + - " { token: MAPPING_START, indent: 0, keys: !net.openhft.chronicle.wire.YamlKeys { count: 2, offsets: [ 10, 41, 0, 0, 0, 0, 0 ]} }\n" + - "]", yw.dumpContext()); + " { token: MAPPING_START, indent: 0, keys: !net.openhft.chronicle.wire.YamlKeys { count: 2, offsets: [ 10, 41, 0, 0, 0, 0, 0 ] }}\n" + + "]\n", yw.dumpContext()); assertEquals("{c=lo, d=xyz}", "" + yw.read("B").object()); assertEquals("{b=1234, c=hi, d=abc}", "" + yw.read("A").object()); @@ -1063,8 +979,8 @@ public void testContextDump2() { assertEquals("[\n" + " { token: STREAM_START, indent: -1, keys: !!null \"\" },\n" + " { token: DIRECTIVES_END, indent: -1, keys: !!null \"\" },\n" + - " { token: MAPPING_START, indent: 0, keys: !net.openhft.chronicle.wire.YamlKeys { count: 4, offsets: [ 2, 8, 14, 32, 0, 0, 0 ]} }\n" + - "]", yw.dumpContext()); + " { token: MAPPING_START, indent: 0, keys: !net.openhft.chronicle.wire.YamlKeys { count: 4, offsets: [ 2, 8, 14, 32, 0, 0, 0 ] }}\n" + + "]\n", yw.dumpContext()); assertEquals("AA", "" + yw.read("b").object()); assertEquals("{}", "" + yw.read("c").object()); assertEquals("{A=1, B=2}", "" + yw.read("d").object()); @@ -1272,7 +1188,7 @@ public void testEnum() { @NotNull Wire wire = createWire(); wire.write().object(WireType.BINARY) - .write().object(TEXT) + .write().object(WireType.TEXT) .write().object(WireType.RAW); assertEquals("\"\": !WireType BINARY\n" + @@ -1280,7 +1196,7 @@ public void testEnum() { "\"\": !WireType RAW\n", bytes.toString()); assertEquals(WireType.BINARY, wire.read().object(Object.class)); - assertEquals(TEXT, wire.read().object(Object.class)); + assertEquals(WireType.TEXT, wire.read().object(Object.class)); assertEquals(WireType.RAW, wire.read().object(Object.class)); } @@ -1708,7 +1624,7 @@ public void testSortedSet() { " one,\n" + " three,\n" + " two\n" + - "]", wire.toString()); + "]\n", wire.toString()); @Nullable Object o = wire.read().object(); assertTrue(o instanceof SortedSet); assertEquals(set, o); @@ -1761,117 +1677,6 @@ public void testSetBytesAfterDeserialization() { bw.bytes.releaseLast(); } - @Test - public void testDoubleEngineering() { - ClassAliasPool.CLASS_ALIASES.addAlias(DoubleWrapper.class, "D"); - assertEquals("!D {\n" + - " d: 1.0,\n" + - " n: -1.0\n" + - "}\n", new DoubleWrapper(1.0).toString()); - assertEquals("!D {\n" + - " d: 11.0,\n" + - " n: -11.0\n" + - "}\n", new DoubleWrapper(11.0).toString()); - assertEquals("!D {\n" + - " d: 101.0,\n" + - " n: -101.0\n" + - "}\n", new DoubleWrapper(101.0).toString()); - assertEquals("!D {\n" + - " d: 1E3,\n" + - " n: -1E3\n" + - "}\n", new DoubleWrapper(1e3) - .toString()); - DoubleWrapper dw = Marshallable.fromString(new DoubleWrapper(1e3).toString()); - assertEquals(1e3, dw.d, 0); - assertEquals("!D {\n" + - " d: 10E3,\n" + - " n: -10E3\n" + - "}\n", new DoubleWrapper(10e3).toString()); - DoubleWrapper dw2 = Marshallable.fromString(new DoubleWrapper(10e3).toString()); - assertEquals(10e3, dw2.d, 0); - - assertEquals("!D {\n" + - " d: 100E3,\n" + - " n: -100E3\n" + - "}\n", new DoubleWrapper(100e3).toString()); - DoubleWrapper dw3 = Marshallable.fromString(new DoubleWrapper(100e3).toString()); - assertEquals(100e3, dw3.d, 0); - - assertEquals("!D {\n" + - " d: 1E6,\n" + - " n: -1E6\n" + - "}\n", new DoubleWrapper(1e6).toString()); - DoubleWrapper dw4 = Marshallable.fromString(new DoubleWrapper(1e6).toString()); - assertEquals(1e6, dw4.d, 0); - - assertEquals("!D {\n" + - " d: 10E6,\n" + - " n: -10E6\n" + - "}\n", new DoubleWrapper(10e6).toString()); - DoubleWrapper dw5 = Marshallable.fromString(new DoubleWrapper(10e6).toString()); - assertEquals(10e6, dw5.d, 0); - } - - @Test - public void testYNestedList() { - YNestedList nl = Marshallable.fromString("!" + YNestedList.class.getName() + " {\n" + - " name: name,\n" + - " listA: [ { a: 1, b: 1.2 } ],\n" + - " listB: [ { a: 1, b: 1.2 }, { a: 3, b: 2.3 } ]," + - " num: 128\n" + - "}\n"); - String expected = "!net.openhft.chronicle.wire.YamlWireTest$YNestedList {\n" + - " name: name,\n" + - " listA: [\n" + - " { a: 1, b: 1.2 }\n" + - " ],\n" + - " listB: [\n" + - " { a: 1, b: 1.2 },\n" + - " { a: 3, b: 2.3 }\n" + - " ],\n" + - " num: 128\n" + - "}\n"; - assertEquals(expected, nl.toString()); - - OUTER: - for (int i = 0; i < 64; i++) { - Set set = new HashSet<>(); - - String cs = "!net.openhft.chronicle.wire.YamlWireTest$YNestedList {\n"; - int z = i; - for (int j = 0; j < 4; j++) { - if (!set.add(z & 3)) - continue OUTER; - switch (z & 3) { - case 0: - cs += " name: name,\n"; - break; - - case 1: - cs += " listA: [\n" + - " { a: 1, b: 1.2 }\n" + - " ],\n"; - break; - - case 2: - cs += " listB: [\n" + - " { a: 1, b: 1.2 },\n" + - " { a: 3, b: 2.3 }\n" + - " ],\n"; - break; - - case 3: - cs += " num: 128,\n"; - break; - } - z /= 4; - } - cs += "}\n"; - YNestedList nl2 = Marshallable.fromString(cs); - assertEquals(expected, nl2.toString()); - } - } - @Test public void testArrayTypes() { Wire wire = createWire(); @@ -1922,16 +1727,16 @@ public void readMarshallableAsEnum() { public void nestedWithEnumSet() { Wire wire = createWire(); YNestedWithEnumSet n = new YNestedWithEnumSet(); - n.list.add(new WithEnumSet("none")); - n.list.add(new WithEnumSet("one", EnumSet.of(TimeUnit.DAYS))); - n.list.add(new WithEnumSet("two", EnumSet.of(TimeUnit.DAYS, TimeUnit.HOURS))); + n.list.add(new TextWireTest.WithEnumSet("none")); + n.list.add(new TextWireTest.WithEnumSet("one", EnumSet.of(TimeUnit.DAYS))); + n.list.add(new TextWireTest.WithEnumSet("two", EnumSet.of(TimeUnit.DAYS, TimeUnit.HOURS))); wire.write("hello") .object(YNestedWithEnumSet.class, n); assertEquals("hello: {\n" + " list: [\n" + " { name: none },\n" + - " { name: one, timeUnits: [ DAYS ]},\n" + - " { name: two, timeUnits: [ HOURS, DAYS ]}\n" + + " { name: one, timeUnits: [ DAYS ] },\n" + + " { name: two, timeUnits: [ HOURS, DAYS ] }\n" + " ]\n" + "}\n", wire.toString()); @@ -1941,36 +1746,11 @@ public void nestedWithEnumSet() { assertEquals(n, a); } - @Test - public void testParse2() { - - MyDto myDto1 = new MyDto(); - - myDto1.strings.add("hello"); - myDto1.strings.add("world"); - - String cs = myDto1.toString(); - MyDto o = Marshallable.fromString(cs); - assertEquals(cs, o.toString()); - - assert o.strings.size() == 2; - } - - @Test - public void longConverter() { - TwoLongs twoLongs = new TwoLongs(0x1234567890abcdefL, -1); - assertEquals("!net.openhft.chronicle.wire.TextWireTest$TwoLongs {\n" + - " hexadecimal: 1234567890abcdef,\n" + - " hexa2: ffffffffffffffff\n" + - "}\n", twoLongs.toString()); - assertEquals(twoLongs, Marshallable.fromString(twoLongs.toString())); - } - @Test public void testDoublePrecisionOverYamlWire() { final Bytes bytes = Wires.acquireBytes(); - final Wire wire = WireType.TEXT.apply(bytes); + final Wire wire = WireType.YAML.apply(bytes); final double d = 0.000212345678901; wire.getValueOut().float64(d); @@ -2013,11 +1793,6 @@ enum YWTSingleton { INSTANCE } - static class YNestedA extends SelfDescribingMarshallable { - YNestedB b; - long value; - } - static class StringArray implements Marshallable { String[] strings; } @@ -2032,33 +1807,10 @@ public void bytes(@NotNull CharSequence cs) { } } - static class YNestedB extends SelfDescribingMarshallable { - double field1; - } - - static class YNestedList extends SelfDescribingMarshallable { - String name; - List listA = new ArrayList<>(); - List listB = new ArrayList<>(); - transient List listA2 = new ArrayList<>(); - transient List listB2 = new ArrayList<>(); - int num; - - @Override - public void readMarshallable(@NotNull WireIn wire) throws IORuntimeException { - name = wire.read("name").text(); - wire.read("listA").sequence(listA, listA2, YNestedItem::new); - wire.read("listB").sequence(listB, listB2, YNestedItem::new); - num = wire.read("num").int32(); - } - } - - static class YNestedItem extends SelfDescribingMarshallable { - int a; - double b; + static class YNestedWithEnumSet extends SelfDescribingMarshallable { + List list = new ArrayList<>(); } - static class YNestedWithEnumSet extends SelfDescribingMarshallable { - List list = new ArrayList<>(); + class Circle implements Marshallable { } } diff --git a/src/test/resources/exception.yaml b/src/test/resources/exception.yaml new file mode 100644 index 0000000000..1f4aca68fd --- /dev/null +++ b/src/test/resources/exception.yaml @@ -0,0 +1,9 @@ +--- !!data +exception: !java.security.InvalidAlgorithmParameterException { + message: Reference cannot be null, + stackTrace: [ + { class: net.openhft.chronicle.wire.YamlWireTest, method: testException, file: YamlWireTest.java, line: 783 }, + { class: net.openhft.chronicle.wire.YamlWireTest, method: runTestException, file: YamlWireTest.java, line: 73 }, + { class: sun.reflect.NativeMethodAccessorImpl, method: invoke0, file: NativeMethodAccessorImpl.java, line: -2 } + ] +} \ No newline at end of file diff --git a/src/test/resources/specification/example2_10.yaml b/src/test/resources/specification/example2_10.yaml deleted file mode 100644 index 61808f678e..0000000000 --- a/src/test/resources/specification/example2_10.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -hr: - - Mark McGwire - # Following node labeled SS - - &SS Sammy Sosa -rbi: - - *SS # Subsequent occurrence - - Ken Griffey diff --git a/src/test/resources/specification/example2_11.yaml b/src/test/resources/specification/example2_11.yaml deleted file mode 100644 index 9123ce2134..0000000000 --- a/src/test/resources/specification/example2_11.yaml +++ /dev/null @@ -1,9 +0,0 @@ -? - Detroit Tigers - - Chicago cubs -: - - 2001-07-23 - -? [ New York Yankees, - Atlanta Braves ] -: [ 2001-07-02, 2001-08-12, - 2001-08-14 ] diff --git a/src/test/resources/specification/example2_12.yaml b/src/test/resources/specification/example2_12.yaml deleted file mode 100644 index 1fc33f9d77..0000000000 --- a/src/test/resources/specification/example2_12.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -# products purchased -- item : Super Hoop - quantity: 1 -- item : Basketball - quantity: 4 -- item : Big Shoes - quantity: 1 diff --git a/src/test/resources/specification/example2_13.yaml b/src/test/resources/specification/example2_13.yaml deleted file mode 100644 index 13fb656010..0000000000 --- a/src/test/resources/specification/example2_13.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# ASCII Art ---- | - \//||\/|| - // || ||__ diff --git a/src/test/resources/specification/example2_14.yaml b/src/test/resources/specification/example2_14.yaml deleted file mode 100644 index 59943def96..0000000000 --- a/src/test/resources/specification/example2_14.yaml +++ /dev/null @@ -1,4 +0,0 @@ ---- - Mark McGwire's - year was crippled - by a knee injury. diff --git a/src/test/resources/specification/example2_15.yaml b/src/test/resources/specification/example2_15.yaml deleted file mode 100644 index 80b89a6d9c..0000000000 --- a/src/test/resources/specification/example2_15.yaml +++ /dev/null @@ -1,8 +0,0 @@ -> - Sammy Sosa completed another - fine season with great stats. - - 63 Home Runs - 0.288 Batting Average - - What a year! diff --git a/src/test/resources/specification/example2_15_dumped.yaml b/src/test/resources/specification/example2_15_dumped.yaml deleted file mode 100644 index cc2d963e00..0000000000 --- a/src/test/resources/specification/example2_15_dumped.yaml +++ /dev/null @@ -1,7 +0,0 @@ -> - Sammy Sosa completed another fine season with great stats. - - 63 Home Runs - 0.288 Batting Average - - What a year! \ No newline at end of file diff --git a/src/test/resources/specification/example2_16.yaml b/src/test/resources/specification/example2_16.yaml deleted file mode 100644 index 9f66d881c4..0000000000 --- a/src/test/resources/specification/example2_16.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: Mark McGwire -accomplishment: > - Mark set a major league - home run record in 1998. -stats: | - 65 Home Runs - 0.278 Batting Average diff --git a/src/test/resources/specification/example2_17.out.yaml b/src/test/resources/specification/example2_17.out.yaml deleted file mode 100644 index 0e24ba1e58..0000000000 --- a/src/test/resources/specification/example2_17.out.yaml +++ /dev/null @@ -1,7 +0,0 @@ -unicode: Sosa did fine.\u263A -control: \b1998\t1999\t2000\n -hexesc: \r\n is \r\n -single: '"Howdy!" he cried.' -quoted: " # not a " -"comment''.'": tie-fighter -"": "|-*-/|" diff --git a/src/test/resources/specification/example2_17_control.yaml b/src/test/resources/specification/example2_17_control.yaml deleted file mode 100644 index 59398a61bb..0000000000 --- a/src/test/resources/specification/example2_17_control.yaml +++ /dev/null @@ -1,2 +0,0 @@ -control: "\b1998\t1999\t2000\n" - diff --git a/src/test/resources/specification/example2_17_hexesc.yaml b/src/test/resources/specification/example2_17_hexesc.yaml deleted file mode 100644 index 7ddff26cbf..0000000000 --- a/src/test/resources/specification/example2_17_hexesc.yaml +++ /dev/null @@ -1,2 +0,0 @@ -hexesc: "\x0D\x0A is \r\n" - diff --git a/src/test/resources/specification/example2_17_quoted.yaml b/src/test/resources/specification/example2_17_quoted.yaml deleted file mode 100644 index bedc4a5076..0000000000 --- a/src/test/resources/specification/example2_17_quoted.yaml +++ /dev/null @@ -1,2 +0,0 @@ -quoted: ' # not a ''comment''.' - diff --git a/src/test/resources/specification/example2_17_single.yaml b/src/test/resources/specification/example2_17_single.yaml deleted file mode 100644 index c3fe6aad26..0000000000 --- a/src/test/resources/specification/example2_17_single.yaml +++ /dev/null @@ -1 +0,0 @@ -single: '"Howdy!" he cried.' diff --git a/src/test/resources/specification/example2_17_tie_fighter.yaml b/src/test/resources/specification/example2_17_tie_fighter.yaml deleted file mode 100644 index 9d82173170..0000000000 --- a/src/test/resources/specification/example2_17_tie_fighter.yaml +++ /dev/null @@ -1 +0,0 @@ -tie-fighter: '|\-*-/|' diff --git a/src/test/resources/specification/example2_17_unicode.yaml b/src/test/resources/specification/example2_17_unicode.yaml deleted file mode 100644 index 2b378bd4a5..0000000000 --- a/src/test/resources/specification/example2_17_unicode.yaml +++ /dev/null @@ -1,2 +0,0 @@ -unicode: "Sosa did fine.\u263A" - diff --git a/src/test/resources/specification/example2_18.yaml b/src/test/resources/specification/example2_18.yaml deleted file mode 100644 index e0a8bfa992..0000000000 --- a/src/test/resources/specification/example2_18.yaml +++ /dev/null @@ -1,6 +0,0 @@ -plain: - This unquoted scalar - spans many lines. - -quoted: "So does this - quoted scalar.\n" diff --git a/src/test/resources/specification/example2_19.yaml b/src/test/resources/specification/example2_19.yaml deleted file mode 100644 index 8aeb1a481c..0000000000 --- a/src/test/resources/specification/example2_19.yaml +++ /dev/null @@ -1,5 +0,0 @@ -canonical: 12345 -decimal: +12_345 -sexagesimal: 3:25:45 -octal: 014 -hexadecimal: 0xC diff --git a/src/test/resources/specification/example2_2.yaml b/src/test/resources/specification/example2_2.yaml deleted file mode 100644 index 7b7ec948db..0000000000 --- a/src/test/resources/specification/example2_2.yaml +++ /dev/null @@ -1,3 +0,0 @@ -hr: 65 # Home runs -avg: 0.278 # Batting average -rbi: 147 # Runs Batted In diff --git a/src/test/resources/specification/example2_20.yaml b/src/test/resources/specification/example2_20.yaml deleted file mode 100644 index 60bfc06814..0000000000 --- a/src/test/resources/specification/example2_20.yaml +++ /dev/null @@ -1,6 +0,0 @@ -canonical: 1.23015e+3 -exponential: 12.3015e+02 -sexagesimal: 20:30.15 -fixed: 1_230.15 -negative infinity: -.inf -not a number: .NaN diff --git a/src/test/resources/specification/example2_22.out.yaml b/src/test/resources/specification/example2_22.out.yaml deleted file mode 100644 index 2459817cba..0000000000 --- a/src/test/resources/specification/example2_22.out.yaml +++ /dev/null @@ -1,4 +0,0 @@ -canonical: 2001-12-15T02:59:43.100Z -iso8601: 2001-12-14T21:59:43.100-05:00 -spaced: "2001-12-14 21:59:43.10 -5" -date: 2002-12-14 diff --git a/src/test/resources/specification/example2_22.yaml b/src/test/resources/specification/example2_22.yaml deleted file mode 100644 index aaac185a98..0000000000 --- a/src/test/resources/specification/example2_22.yaml +++ /dev/null @@ -1,4 +0,0 @@ -canonical: 2001-12-15T02:59:43.1Z -iso8601: 2001-12-14t21:59:43.10-05:00 -spaced: 2001-12-14 21:59:43.10 -5 -date: 2002-12-14 diff --git a/src/test/resources/specification/example2_23.yaml b/src/test/resources/specification/example2_23.yaml deleted file mode 100644 index adbe4e62b9..0000000000 --- a/src/test/resources/specification/example2_23.yaml +++ /dev/null @@ -1,14 +0,0 @@ ---- -not-date: !!str 2002-04-28 - -picture: !!binary "\ - R0lGODlhDAAMAIQAAP//9/X\ - 17unp5WZmZgAAAOfn515eXv\ - Pz7Y6OjuDg4J+fn5OTk6enp\ - 56enmleECcgggoBADs=" - -application specific tag: !something | - The semantics of the tag - above may be different for - different documents. - diff --git a/src/test/resources/specification/example2_23_application.yaml b/src/test/resources/specification/example2_23_application.yaml deleted file mode 100644 index 03cc760303..0000000000 --- a/src/test/resources/specification/example2_23_application.yaml +++ /dev/null @@ -1,5 +0,0 @@ ---- -application specific tag: !something | - The semantics of the tag - above may be different for - different documents. diff --git a/src/test/resources/specification/example2_23_non_date.yaml b/src/test/resources/specification/example2_23_non_date.yaml deleted file mode 100644 index 2e95415d94..0000000000 --- a/src/test/resources/specification/example2_23_non_date.yaml +++ /dev/null @@ -1,3 +0,0 @@ ---- -not-date: !!str 2002-04-28 - diff --git a/src/test/resources/specification/example2_23_picture.yaml b/src/test/resources/specification/example2_23_picture.yaml deleted file mode 100644 index 6146d250d5..0000000000 --- a/src/test/resources/specification/example2_23_picture.yaml +++ /dev/null @@ -1,7 +0,0 @@ ---- -picture: !!binary "\ - R0lGODlhDAAMAIQAAP//9/X\ - 17unp5WZmZgAAAOfn515eXv\ - Pz7Y6OjuDg4J+fn5OTk6enp\ - 56enmleECcgggoBADs=" - diff --git a/src/test/resources/specification/example2_24.yaml b/src/test/resources/specification/example2_24.yaml deleted file mode 100644 index 1180757d81..0000000000 --- a/src/test/resources/specification/example2_24.yaml +++ /dev/null @@ -1,14 +0,0 @@ -%TAG ! tag:clarkevans.com,2002: ---- !shape - # Use the ! handle for presenting - # tag:clarkevans.com,2002:circle -- !circle - center: &ORIGIN {x: 73, y: 129} - radius: 7 -- !line - start: *ORIGIN - finish: { x: 89, y: 102 } -- !label - start: *ORIGIN - color: 0xFFEEBB - text: Pretty vector drawing. diff --git a/src/test/resources/specification/example2_24_dumped.yaml b/src/test/resources/specification/example2_24_dumped.yaml deleted file mode 100644 index 1742cd2162..0000000000 --- a/src/test/resources/specification/example2_24_dumped.yaml +++ /dev/null @@ -1,11 +0,0 @@ -!shape -- !circle - center: &id001 {x: 73, y: 129} - radius: 7 -- !line - finish: {x: 89, y: 102} - start: *id001 -- !label - color: 0xFFEEBB - start: *id001 - text: Pretty vector drawing. \ No newline at end of file diff --git a/src/test/resources/specification/example2_25.yaml b/src/test/resources/specification/example2_25.yaml deleted file mode 100644 index 769ac31916..0000000000 --- a/src/test/resources/specification/example2_25.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# sets are represented as a -# mapping where each key is -# associated with the empty string ---- !!set -? Mark McGwire -? Sammy Sosa -? Ken Griff diff --git a/src/test/resources/specification/example2_26.yaml b/src/test/resources/specification/example2_26.yaml deleted file mode 100644 index 3143763dd0..0000000000 --- a/src/test/resources/specification/example2_26.yaml +++ /dev/null @@ -1,7 +0,0 @@ -# ordered maps are represented as -# a sequence of mappings, with -# each mapping having one key ---- !!omap -- Mark McGwire: 65 -- Sammy Sosa: 63 -- Ken Griffy: 58 diff --git a/src/test/resources/specification/example2_27.yaml b/src/test/resources/specification/example2_27.yaml deleted file mode 100644 index 395e79c440..0000000000 --- a/src/test/resources/specification/example2_27.yaml +++ /dev/null @@ -1,29 +0,0 @@ ---- ! -invoice: 34843 -date : 2001-01-23 -billTo: &id001 - given : Chris - family : Dumars - address: - lines: | - 458 Walkman Dr. - Suite #292 - city : Royal Oak - state : MI - postal : 48046 -shipTo: *id001 -product: - - sku : BL394D - quantity : 4 - description : Basketball - price : 450.00 - - sku : BL4438H - quantity : 1 - description : Super Hoop - price : 2392.00 -tax : 251.42 -total: 4443.52 -comments: - Late afternoon is best. - Backup contact is Nancy - Billsmer @ 338-4338. diff --git a/src/test/resources/specification/example2_27_dumped.yaml b/src/test/resources/specification/example2_27_dumped.yaml deleted file mode 100644 index 51a89b889e..0000000000 --- a/src/test/resources/specification/example2_27_dumped.yaml +++ /dev/null @@ -1,20 +0,0 @@ -!!org.yaml.snakeyaml.Invoice -billTo: &id001 - address: - city: Royal Oak - lines: | - 458 Walkman Dr. - Suite #292 - postal: '48046' - state: MI - family: Dumars - given: Chris -comments: Late afternoon is best. Backup contact is Nancy Billsmer @ 338-4338. -date: '2001-01-23' -invoice: 34843 -product: -- {description: Basketball, price: 450.0, quantity: 4, sku: BL394D} -- {description: Super Hoop, price: 2392.0, quantity: 1, sku: BL4438H} -shipTo: *id001 -tax: 251.42 -total: 4443.52 \ No newline at end of file diff --git a/src/test/resources/specification/example2_28.yaml b/src/test/resources/specification/example2_28.yaml deleted file mode 100644 index dcca369ae8..0000000000 --- a/src/test/resources/specification/example2_28.yaml +++ /dev/null @@ -1,27 +0,0 @@ ---- -Time: 2001-11-23 15:01:42 -5 -User: ed -Warning: - This is an error message - for the log file ---- -Time: 2001-11-23 15:02:31 -5 -User: ed -Warning: - A slightly different error - message. ---- -Date: 2001-11-23 15:03:17 -5 -User: ed -Fatal: - Unknown variable "bar" -Stack: - - file: TopClass.py - line: 23 - code: | - x = MoreObject("345\n") - - file: MoreClass.py - line: 58 - code: |- - foo = bar - diff --git a/src/test/resources/specification/example2_3.yaml b/src/test/resources/specification/example2_3.yaml deleted file mode 100644 index 2c884b7a2f..0000000000 --- a/src/test/resources/specification/example2_3.yaml +++ /dev/null @@ -1,8 +0,0 @@ -american: - - Boston Red Sox - - Detroit Tigers - - New York Yankees -national: - - New York Mets - - Chicago Cubs - - Atlanta Braves \ No newline at end of file diff --git a/src/test/resources/specification/example2_4.yaml b/src/test/resources/specification/example2_4.yaml deleted file mode 100644 index 430f6b3dbe..0000000000 --- a/src/test/resources/specification/example2_4.yaml +++ /dev/null @@ -1,8 +0,0 @@ -- - name: Mark McGwire - hr: 65 - avg: 0.278 -- - name: Sammy Sosa - hr: 63 - avg: 0.288 diff --git a/src/test/resources/specification/example2_5.yaml b/src/test/resources/specification/example2_5.yaml deleted file mode 100644 index cdd7770628..0000000000 --- a/src/test/resources/specification/example2_5.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- [name , hr, avg ] -- [Mark McGwire, 65, 0.278] -- [Sammy Sosa , 63, 0.288] diff --git a/src/test/resources/specification/example2_6.yaml b/src/test/resources/specification/example2_6.yaml deleted file mode 100644 index 7a957b23a1..0000000000 --- a/src/test/resources/specification/example2_6.yaml +++ /dev/null @@ -1,5 +0,0 @@ -Mark McGwire: {hr: 65, avg: 0.278} -Sammy Sosa: { - hr: 63, - avg: 0.288 - } diff --git a/src/test/resources/specification/example2_7.out.yaml b/src/test/resources/specification/example2_7.out.yaml deleted file mode 100644 index d12e67111b..0000000000 --- a/src/test/resources/specification/example2_7.out.yaml +++ /dev/null @@ -1,3 +0,0 @@ -- Mark McGwire -- Sammy Sosa -- Ken Griffey diff --git a/src/test/resources/specification/example2_7.yaml b/src/test/resources/specification/example2_7.yaml deleted file mode 100644 index bc711d547c..0000000000 --- a/src/test/resources/specification/example2_7.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# Ranking of 1998 home runs ---- -- Mark McGwire -- Sammy Sosa -- Ken Griffey - -# Team ranking ---- -- Chicago Cubs -- St Louis Cardinals diff --git a/src/test/resources/specification/example2_8.yaml b/src/test/resources/specification/example2_8.yaml deleted file mode 100644 index 05e102d8eb..0000000000 --- a/src/test/resources/specification/example2_8.yaml +++ /dev/null @@ -1,10 +0,0 @@ ---- -time: 20:03:20 -player: Sammy Sosa -action: strike (miss) -... ---- -time: 20:03:47 -player: Sammy Sosa -action: grand slam -... diff --git a/src/test/resources/specification/example2_9.yaml b/src/test/resources/specification/example2_9.yaml deleted file mode 100644 index e264180539..0000000000 --- a/src/test/resources/specification/example2_9.yaml +++ /dev/null @@ -1,8 +0,0 @@ ---- -hr: # 1998 hr ranking - - Mark McGwire - - Sammy Sosa -rbi: - # 1998 rbi ranking - - Sammy Sosa - - Ken Griffey diff --git a/src/test/resources/yaml/k8s/example1.yaml b/src/test/resources/yaml/k8s/example1.yaml new file mode 100644 index 0000000000..4cce6a6925 --- /dev/null +++ b/src/test/resources/yaml/k8s/example1.yaml @@ -0,0 +1,25 @@ +--- +apiVersion: v1 +kind: Pod +metadata: + name: frontend +spec: + containers: + - name: app + image: images.my-company.example/app:v4 + resources: + requests: + memory: "64Mi" + cpu: "250m" + limits: + memory: "128Mi" + cpu: "500m" + - name: log-aggregator + image: images.my-company.example/log-aggregator:v6 + resources: + requests: + memory: "64Mi" + cpu: "250m" + limits: + memory: "128Mi" + cpu: "500m" diff --git a/src/test/resources/yaml/k8s/example2.yaml b/src/test/resources/yaml/k8s/example2.yaml new file mode 100644 index 0000000000..c3cc474dde --- /dev/null +++ b/src/test/resources/yaml/k8s/example2.yaml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: Pod +metadata: + name: frontend +spec: + containers: + - name: app + image: images.my-company.example/app:v4 + resources: + requests: + ephemeral-storage: "2Gi" + limits: + ephemeral-storage: "4Gi" + volumeMounts: + - name: ephemeral + mountPath: "/tmp" + - name: log-aggregator + image: images.my-company.example/log-aggregator:v6 + resources: + requests: + ephemeral-storage: "2Gi" + limits: + ephemeral-storage: "4Gi" + volumeMounts: + - name: ephemeral + mountPath: "/tmp" + volumes: + - name: ephemeral + emptyDir: {} diff --git a/src/test/resources/yaml/k8s/example3.yaml b/src/test/resources/yaml/k8s/example3.yaml new file mode 100644 index 0000000000..9ef8b76071 --- /dev/null +++ b/src/test/resources/yaml/k8s/example3.yaml @@ -0,0 +1,19 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: nginx-deployment +spec: + selector: + matchLabels: + app: nginx + replicas: 2 # tells deployment to run 2 pods matching the template + template: + metadata: + labels: + app: nginx + spec: + containers: + - name: nginx + image: nginx:1.14.2 + ports: + - containerPort: 80 \ No newline at end of file diff --git a/src/test/resources/yaml/k8s/example4.yaml b/src/test/resources/yaml/k8s/example4.yaml new file mode 100644 index 0000000000..28abc81c83 --- /dev/null +++ b/src/test/resources/yaml/k8s/example4.yaml @@ -0,0 +1,66 @@ +--- +apiVersion: source.toolkit.fluxcd.io/v1beta1 +kind: GitRepository +metadata: + name: rook-ceph-source + namespace: flux-system +spec: + interval: 10m + url: https://github.com/rook/rook.git + ref: + tag: v1.5.5 + ignore: | + # exclude all + /* + # include deploy crds dir + !/cluster/examples/kubernetes/ceph/crds.yaml +--- +apiVersion: kustomize.toolkit.fluxcd.io/v1beta1 +kind: Kustomization +metadata: + name: rook-ceph-crds + namespace: flux-system +spec: + interval: 5m + prune: false + sourceRef: + kind: GitRepository + name: rook-ceph-source + healthChecks: + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: cephblockpools.ceph.rook.io + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: cephclients.ceph.rook.io + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: cephclusters.ceph.rook.io + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: cephfilesystems.ceph.rook.io + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: cephnfses.ceph.rook.io + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: cephobjectrealms.ceph.rook.io + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: cephobjectstores.ceph.rook.io + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: cephobjectstoreusers.ceph.rook.io + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: cephobjectzonegroups.ceph.rook.io + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: cephobjectzones.ceph.rook.io + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: cephrbdmirrors.ceph.rook.io + - apiVersion: apiextensions.k8s.io/v1 + kind: CustomResourceDefinition + name: volumes.rook.io +--- \ No newline at end of file diff --git a/src/test/resources/yaml/k8s/example5.yaml b/src/test/resources/yaml/k8s/example5.yaml new file mode 100644 index 0000000000..e1e68607d6 --- /dev/null +++ b/src/test/resources/yaml/k8s/example5.yaml @@ -0,0 +1,253 @@ +apiVersion: "rbac.istio.io/v1alpha1" +kind: ServiceRole +metadata: + name: hello-viewer + namespace: default +spec: + rules: + - services: ["hello.default.svc.cluster.local"] + methods: ["GET", "HEAD"] +--- +apiVersion: "rbac.istio.io/v1alpha1" +kind: ServiceRole +metadata: + name: world-viewer + namespace: default +spec: + rules: + - services: ["world.default.svc.cluster.local"] + methods: ["GET", "HEAD"] +--- +apiVersion: "rbac.istio.io/v1alpha1" +kind: ServiceRole +metadata: + name: world-2-viewer + namespace: default +spec: + rules: + - services: ["world-2.default.svc.cluster.local"] + methods: ["GET", "HEAD"] +--- +apiVersion: "rbac.istio.io/v1alpha1" +kind: ServiceRoleBinding +metadata: + name: istio-ingress-binding + namespace: default +spec: + subjects: + - properties: + source.namespace: "istio-system" + roleRef: + kind: ServiceRole + name: "hello-viewer" +--- +apiVersion: "rbac.istio.io/v1alpha1" +kind: ServiceRoleBinding +metadata: + name: hello-user-binding + namespace: default +spec: + subjects: + - user: "cluster.local/ns/default/sa/hello" + roleRef: + kind: ServiceRole + name: "world-viewer" +--- +apiVersion: "rbac.istio.io/v1alpha1" +kind: ServiceRoleBinding +metadata: + name: world-user-binding + namespace: default +spec: + subjects: + - user: "cluster.local/ns/default/sa/world" + roleRef: + kind: ServiceRole + name: "world-2-viewer" +--- +### +### Kubernetes Service accounts +### +apiVersion: v1 +kind: ServiceAccount +metadata: + name: hello +--- +apiVersion: v1 +kind: ServiceAccount +metadata: + name: world +--- +### +### helloworld.yaml deployments, including a serviceaccount +### for the hello deployment and the world deployment +### +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hello +spec: + replicas: 1 + selector: + matchLabels: + app: hello + template: + metadata: + labels: + app: hello + version: v1 + spec: + serviceAccountName: hello # service account + containers: + - name: hello + image: wardviaene/http-echo + env: + - name: TEXT + value: hello + - name: NEXT + value: "world:8080" + ports: + - name: http + containerPort: 8080 +--- +apiVersion: v1 +kind: Service +metadata: + name: hello + labels: + app: hello +spec: + selector: + app: hello + ports: + - name: http + port: 8080 + targetPort: 8080 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: world +spec: + replicas: 1 + selector: + matchLabels: + app: world + template: + metadata: + labels: + app: world + version: v1 + spec: + serviceAccountName: world # service account + containers: + - name: world + image: wardviaene/http-echo + env: + - name: TEXT + value: world + - name: NEXT + value: "world-2:8080" + ports: + - name: http + containerPort: 8080 +--- +apiVersion: v1 +kind: Service +metadata: + name: world + labels: + app: world +spec: + selector: + app: world + ports: + - name: http + port: 8080 + targetPort: 8080 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: world-2 +spec: + replicas: 1 + selector: + matchLabels: + app: world-2 + template: + metadata: + labels: + app: world-2 + version: v1 + spec: + containers: + - name: world-2 + image: wardviaene/http-echo + env: + - name: TEXT + value: "!!!" + ports: + - name: http + containerPort: 8080 +--- +apiVersion: v1 +kind: Service +metadata: + name: world-2 + labels: + app: world-2 +spec: + selector: + app: world-2 + ports: + - name: http + port: 8080 + targetPort: 8080 +--- +apiVersion: networking.istio.io/v1alpha3 +kind: Gateway +metadata: + name: helloworld-gateway +spec: + selector: + istio: ingressgateway # use istio default controller + servers: + - port: + number: 80 + name: http + protocol: HTTP + hosts: + - "*" +--- +apiVersion: networking.istio.io/v1alpha3 +kind: VirtualService +metadata: + name: helloworld +spec: + hosts: + - "hello-rbac.example.com" + gateways: + - helloworld-gateway + http: + - route: + - destination: + host: hello.default.svc.cluster.local + subset: v1 + port: + number: 8080 +--- +apiVersion: networking.istio.io/v1alpha3 +kind: DestinationRule +metadata: + name: hello +spec: + host: hello.default.svc.cluster.local + # uncomment to enable mutual TLS + trafficPolicy: + tls: + mode: ISTIO_MUTUAL + subsets: + - name: v1 + labels: + version: v1 diff --git a/src/test/resources/yaml/k8s/example6.yaml b/src/test/resources/yaml/k8s/example6.yaml new file mode 100644 index 0000000000..a356635709 --- /dev/null +++ b/src/test/resources/yaml/k8s/example6.yaml @@ -0,0 +1,259 @@ +apiVersion: v1 +items: + - apiVersion: v1 + kind: Service + metadata: + annotations: + "external-dns.alpha.kubernetes.io/cloudflare-proxied": "false" + "external-dns.alpha.kubernetes.io/hostname": h.christine.website + "external-dns.alpha.kubernetes.io/ttl": "120" + labels: + app: hlang + name: hlang + namespace: apps + spec: + ports: + - port: 5000 + targetPort: 5000 + selector: + app: hlang + type: ClusterIP + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: hlang + namespace: apps + spec: + replicas: 2 + selector: + matchLabels: + app: hlang + template: + metadata: + labels: + app: hlang + name: hlang + spec: + containers: + - image: "xena/hlang:latest" + imagePullPolicy: Always + name: web + ports: + - containerPort: 5000 + imagePullSecrets: + - name: regcred + - apiVersion: networking.k8s.io/v1beta1 + kind: Ingress + metadata: + annotations: + "certmanager.k8s.io/cluster-issuer": "letsencrypt-prod" + kubernetes.io/ingress.class: nginx + labels: + app: hlang + name: hlang + namespace: apps + spec: + rules: + - host: h.christine.website + http: + paths: + - backend: + serviceName: hlang + servicePort: 5000 + tls: + - hosts: + - h.christine.website + secretName: "prod-certs-hlang" + - apiVersion: v1 + kind: Service + metadata: + annotations: + "external-dns.alpha.kubernetes.io/cloudflare-proxied": "false" + "external-dns.alpha.kubernetes.io/hostname": olin.within.website + "external-dns.alpha.kubernetes.io/ttl": "120" + labels: + app: olin + name: olin + namespace: apps + spec: + ports: + - port: 5000 + targetPort: 5000 + selector: + app: olin + type: ClusterIP + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: olin + namespace: apps + spec: + replicas: 2 + selector: + matchLabels: + app: olin + template: + metadata: + labels: + app: olin + name: olin + spec: + containers: + - image: "xena/olin:latest" + imagePullPolicy: Always + name: web + ports: + - containerPort: 5000 + imagePullSecrets: + - name: regcred + - apiVersion: networking.k8s.io/v1beta1 + kind: Ingress + metadata: + annotations: + "certmanager.k8s.io/cluster-issuer": "letsencrypt-prod" + kubernetes.io/ingress.class: nginx + labels: + app: olin + name: olin + namespace: apps + spec: + rules: + - host: olin.within.website + http: + paths: + - backend: + serviceName: olin + servicePort: 5000 + tls: + - hosts: + - olin.within.website + secretName: "prod-certs-olin" + - apiVersion: v1 + kind: Service + metadata: + annotations: + "external-dns.alpha.kubernetes.io/cloudflare-proxied": "false" + "external-dns.alpha.kubernetes.io/hostname": tulpaforce.xyz + "external-dns.alpha.kubernetes.io/ttl": "120" + labels: + app: tulpaforcexyz + name: tulpaforcexyz + namespace: apps + spec: + ports: + - port: 80 + targetPort: 80 + selector: + app: tulpaforcexyz + type: ClusterIP + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: tulpaforcexyz + namespace: apps + spec: + replicas: 2 + selector: + matchLabels: + app: tulpaforcexyz + template: + metadata: + labels: + app: tulpaforcexyz + name: tulpaforcexyz + spec: + containers: + - image: "xena/tulpaforce:20190906" + imagePullPolicy: Always + name: web + ports: + - containerPort: 80 + imagePullSecrets: + - name: regcred + - apiVersion: networking.k8s.io/v1beta1 + kind: Ingress + metadata: + annotations: + "certmanager.k8s.io/cluster-issuer": "letsencrypt-prod" + kubernetes.io/ingress.class: nginx + labels: + app: tulpaforcexyz + name: tulpaforcexyz + namespace: apps + spec: + rules: + - host: tulpaforce.xyz + http: + paths: + - backend: + serviceName: tulpaforcexyz + servicePort: 80 + tls: + - hosts: + - tulpaforce.xyz + secretName: "prod-certs-tulpaforcexyz" + - apiVersion: v1 + kind: Service + metadata: + annotations: + "external-dns.alpha.kubernetes.io/cloudflare-proxied": "false" + "external-dns.alpha.kubernetes.io/hostname": within.website + "external-dns.alpha.kubernetes.io/ttl": "120" + labels: + app: withinwebsite + name: withinwebsite + namespace: apps + spec: + ports: + - port: 5000 + targetPort: 5000 + selector: + app: withinwebsite + type: ClusterIP + - apiVersion: apps/v1 + kind: Deployment + metadata: + name: withinwebsite + namespace: apps + spec: + replicas: 2 + selector: + matchLabels: + app: withinwebsite + template: + metadata: + labels: + app: withinwebsite + name: withinwebsite + spec: + containers: + - image: "xena/within.website:013120201402" + imagePullPolicy: Always + name: web + ports: + - containerPort: 5000 + imagePullSecrets: + - name: regcred + - apiVersion: networking.k8s.io/v1beta1 + kind: Ingress + metadata: + annotations: + "certmanager.k8s.io/cluster-issuer": "letsencrypt-prod" + kubernetes.io/ingress.class: nginx + labels: + app: withinwebsite + name: withinwebsite + namespace: apps + spec: + rules: + - host: within.website + http: + paths: + - backend: + serviceName: withinwebsite + servicePort: 5000 + tls: + - hosts: + - within.website + secretName: "prod-certs-withinwebsite" +kind: List diff --git a/src/test/resources/yaml/k8s/example7.yaml b/src/test/resources/yaml/k8s/example7.yaml new file mode 100644 index 0000000000..9708c2b0d3 --- /dev/null +++ b/src/test/resources/yaml/k8s/example7.yaml @@ -0,0 +1,6 @@ +containers: + - env: + - name: POD_ID + valueFrom: # etc etc + - name: LOG_PATH + value: /var/log/mycompany/$(POD_ID)/logs diff --git a/src/test/resources/yaml/k8s/example8.yaml b/src/test/resources/yaml/k8s/example8.yaml new file mode 100644 index 0000000000..d6ff040d66 --- /dev/null +++ b/src/test/resources/yaml/k8s/example8.yaml @@ -0,0 +1,92 @@ + + +kind: List +apiVersion: v1 +items: + - kind: Secret + apiVersion: v1 + type: kubernetes.io/basic-auth + metadata: + name: secret1 + annotations: + build.openshift.io/source-secret-match-uri-1: '*://*.example.com/*' + data: + username: AA== + - kind: Secret + apiVersion: v1 + type: kubernetes.io/ssh-auth + metadata: + name: secret2 + annotations: + build.openshift.io/source-secret-match-uri-1: '*://*.example.com/*' + data: + ssh-privatekey: AA== + - kind: Secret + apiVersion: v1 + type: kubernetes.io/basic-auth + metadata: + name: secret3 + annotations: + build.openshift.io/source-secret-match-uri-1: 'https://*.com/*' + data: + username: AA== + - kind: BuildConfig + apiVersion: v1 + metadata: + name: test1 + spec: + source: + type: Git + git: + uri: https://server1.example.com/path + strategy: + type: Source + sourceStrategy: + from: + kind: ImageStream + name: test + - kind: BuildConfig + apiVersion: v1 + metadata: + name: test2 + spec: + source: + type: Git + git: + uri: ssh://server1.example.com/path + strategy: + type: Source + sourceStrategy: + from: + kind: ImageStream + name: test + - kind: BuildConfig + apiVersion: v1 + metadata: + name: test3 + spec: + source: + type: Git + git: + uri: https://test.com/path + strategy: + type: Source + sourceStrategy: + from: + kind: ImageStream + name: test + - kind: BuildConfig + apiVersion: v1 + metadata: + name: test4 + spec: + source: + type: Git + git: + uri: http://test.com/path + strategy: + type: Source + sourceStrategy: + from: + kind: ImageStream + name: test diff --git a/src/test/resources/yaml/k8s/example9.yaml b/src/test/resources/yaml/k8s/example9.yaml new file mode 100644 index 0000000000..aeda418604 --- /dev/null +++ b/src/test/resources/yaml/k8s/example9.yaml @@ -0,0 +1,39 @@ +kind: List +apiVersion: v1 +items: + - kind: ServiceAccount + apiVersion: v1 + metadata: + name: sdn + namespace: openshift-sdn + - apiVersion: authorization.openshift.io/v1 + kind: ClusterRoleBinding + metadata: + name: sdn-cluster-reader + roleRef: + name: cluster-reader + subjects: + - kind: ServiceAccount + name: sdn + namespace: openshift-sdn + - apiVersion: authorization.openshift.io/v1 + kind: ClusterRoleBinding + metadata: + name: sdn-reader + roleRef: + name: system:sdn-reader + subjects: + - kind: ServiceAccount + name: sdn + namespace: openshift-sdn + - apiVersion: authorization.openshift.io/v1 + kind: ClusterRoleBinding + metadata: + name: sdn-node-proxier + roleRef: + name: system:node-proxier + subjects: + - kind: ServiceAccount + name: sdn + namespace: openshift-sdn +# TODO: PSP binding \ No newline at end of file diff --git a/src/test/resources/specification/example2_9.out.yaml b/src/test/resources/yaml/spec/2_10_NodeAppearsTwiceInThisDocument.out.yaml similarity index 94% rename from src/test/resources/specification/example2_9.out.yaml rename to src/test/resources/yaml/spec/2_10_NodeAppearsTwiceInThisDocument.out.yaml index 75ca57a4a0..45407f5aed 100644 --- a/src/test/resources/specification/example2_9.out.yaml +++ b/src/test/resources/yaml/spec/2_10_NodeAppearsTwiceInThisDocument.out.yaml @@ -1,8 +1,8 @@ hr: [ Mark McGwire, Sammy Sosa -], +] rbi: [ Sammy Sosa, Ken Griffey -] \ No newline at end of file +] diff --git a/src/test/resources/yaml/spec/2_10_NodeAppearsTwiceInThisDocument.yaml b/src/test/resources/yaml/spec/2_10_NodeAppearsTwiceInThisDocument.yaml index bf46f753c0..61808f678e 100644 --- a/src/test/resources/yaml/spec/2_10_NodeAppearsTwiceInThisDocument.yaml +++ b/src/test/resources/yaml/spec/2_10_NodeAppearsTwiceInThisDocument.yaml @@ -5,4 +5,4 @@ hr: - &SS Sammy Sosa rbi: - *SS # Subsequent occurrence - - Ken Griffey \ No newline at end of file + - Ken Griffey diff --git a/src/test/resources/yaml/spec/2_11MappingBetweenSequences.yaml b/src/test/resources/yaml/spec/2_11MappingBetweenSequences.yaml index 83fabe1c7b..9123ce2134 100644 --- a/src/test/resources/yaml/spec/2_11MappingBetweenSequences.yaml +++ b/src/test/resources/yaml/spec/2_11MappingBetweenSequences.yaml @@ -6,4 +6,4 @@ ? [ New York Yankees, Atlanta Braves ] : [ 2001-07-02, 2001-08-12, - 2001-08-14 ] \ No newline at end of file + 2001-08-14 ] diff --git a/src/test/resources/yaml/spec/2_12CompactNestedMapping.out.yaml b/src/test/resources/yaml/spec/2_12CompactNestedMapping.out.yaml new file mode 100644 index 0000000000..e90cf25f78 --- /dev/null +++ b/src/test/resources/yaml/spec/2_12CompactNestedMapping.out.yaml @@ -0,0 +1,12 @@ +- { + item: Super Hoop, + quantity: 1 +} +- { + item: Basketball, + quantity: 4 +} +- { + item: Big Shoes, + quantity: 1 +} diff --git a/src/test/resources/yaml/spec/2_12CompactNestedMapping.yaml b/src/test/resources/yaml/spec/2_12CompactNestedMapping.yaml index 8a26671bab..63a8ed7e65 100644 --- a/src/test/resources/yaml/spec/2_12CompactNestedMapping.yaml +++ b/src/test/resources/yaml/spec/2_12CompactNestedMapping.yaml @@ -5,4 +5,4 @@ - item : Basketball quantity: 4 - item : Big Shoes - quantity: 1 \ No newline at end of file + quantity: 1 diff --git a/src/test/resources/yaml/spec/2_12CompactNestedMappingFixed.yaml b/src/test/resources/yaml/spec/2_12CompactNestedMappingFixed.yaml deleted file mode 100644 index a06ebdb03a..0000000000 --- a/src/test/resources/yaml/spec/2_12CompactNestedMappingFixed.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# Products purchased -- {item: Super Hoop, - quantity: 1} -- {item: Basketball, - quantity: 4} -- {item: Big Shoes, - quantity: 1} - \ No newline at end of file diff --git a/src/test/resources/yaml/spec/2_13InLiteralsNewlinesArePreserved.out.yaml b/src/test/resources/yaml/spec/2_13InLiteralsNewlinesArePreserved.out.yaml new file mode 100644 index 0000000000..6f981a5a69 --- /dev/null +++ b/src/test/resources/yaml/spec/2_13InLiteralsNewlinesArePreserved.out.yaml @@ -0,0 +1 @@ +"\\//||\\/||\n// || ||__\n" diff --git a/src/test/resources/yaml/spec/2_13InLiteralsNewlinesArePreserved.yaml b/src/test/resources/yaml/spec/2_13InLiteralsNewlinesArePreserved.yaml index f65d60fc1c..13fb656010 100644 --- a/src/test/resources/yaml/spec/2_13InLiteralsNewlinesArePreserved.yaml +++ b/src/test/resources/yaml/spec/2_13InLiteralsNewlinesArePreserved.yaml @@ -1,4 +1,4 @@ # ASCII Art --- | \//||\/|| - // || ||__ \ No newline at end of file + // || ||__ diff --git a/src/test/resources/yaml/spec/2_14InThefoldedScalars.out.yaml b/src/test/resources/yaml/spec/2_14InThefoldedScalars.out.yaml new file mode 100644 index 0000000000..bf9af4d41d --- /dev/null +++ b/src/test/resources/yaml/spec/2_14InThefoldedScalars.out.yaml @@ -0,0 +1 @@ +Mark McGwire's year was crippled by a knee injury. diff --git a/src/test/resources/yaml/spec/2_14InThefoldedScalars.yaml b/src/test/resources/yaml/spec/2_14InThefoldedScalars.yaml index d2ee70390c..fb4ed4a3f2 100644 --- a/src/test/resources/yaml/spec/2_14InThefoldedScalars.yaml +++ b/src/test/resources/yaml/spec/2_14InThefoldedScalars.yaml @@ -1,4 +1,4 @@ --- > Mark McGwire's year was crippled - by a knee injury. \ No newline at end of file + by a knee injury. diff --git a/src/test/resources/yaml/spec/2_14InThefoldedScalarsFixed.yaml b/src/test/resources/yaml/spec/2_14InThefoldedScalarsFixed.yaml deleted file mode 100644 index aee890dfb1..0000000000 --- a/src/test/resources/yaml/spec/2_14InThefoldedScalarsFixed.yaml +++ /dev/null @@ -1,3 +0,0 @@ -[Mark McGwire's - year was crippled - by a knee injury.] \ No newline at end of file diff --git a/src/test/resources/yaml/spec/2_15FoldedNewlines.yaml b/src/test/resources/yaml/spec/2_15FoldedNewlines.yaml index 3d298103ef..80b89a6d9c 100644 --- a/src/test/resources/yaml/spec/2_15FoldedNewlines.yaml +++ b/src/test/resources/yaml/spec/2_15FoldedNewlines.yaml @@ -5,4 +5,4 @@ 63 Home Runs 0.288 Batting Average - What a year! \ No newline at end of file + What a year! diff --git a/src/test/resources/yaml/spec/2_16IndentationDeterminesScopeFixed.yaml b/src/test/resources/yaml/spec/2_16IndentationDeterminesScopeFixed.yaml deleted file mode 100644 index e5030a9786..0000000000 --- a/src/test/resources/yaml/spec/2_16IndentationDeterminesScopeFixed.yaml +++ /dev/null @@ -1,7 +0,0 @@ -name: Mark McGwire -accomplishment: - Mark set a major league home run record in 1998. -stats: -- 65 Home Runs, -- 0.278 Batting Average - diff --git a/src/test/resources/specification/example2_17.yaml b/src/test/resources/yaml/spec/2_17QuotedScalars.out.yaml similarity index 52% rename from src/test/resources/specification/example2_17.yaml rename to src/test/resources/yaml/spec/2_17QuotedScalars.out.yaml index 3e899c0861..ad65073b5c 100644 --- a/src/test/resources/specification/example2_17.yaml +++ b/src/test/resources/yaml/spec/2_17QuotedScalars.out.yaml @@ -1,7 +1,6 @@ unicode: "Sosa did fine.\u263A" control: "\b1998\t1999\t2000\n" -hexesc: "\x0D\x0A is \r\n" - +hex esc: "\r\n is \r\n" single: '"Howdy!" he cried.' -quoted: ' # not a ''comment''.' -tie-fighter: '|\-*-/|' +quoted: " # Not a 'comment'." +tie-fighter: "|\\-*-/|" diff --git a/src/test/resources/yaml/spec/2_17QuotedScalars.yaml b/src/test/resources/yaml/spec/2_17QuotedScalars.yaml index a155278e06..c5c2a18151 100644 --- a/src/test/resources/yaml/spec/2_17QuotedScalars.yaml +++ b/src/test/resources/yaml/spec/2_17QuotedScalars.yaml @@ -4,4 +4,4 @@ hex esc: "\x0d\x0a is \r\n" single: '"Howdy!" he cried.' quoted: ' # Not a ''comment''.' -tie-fighter: '|\-*-/|' \ No newline at end of file +tie-fighter: '|\-*-/|' diff --git a/src/test/resources/yaml/spec/2_17QuotedScalarsFixed.yaml b/src/test/resources/yaml/spec/2_17QuotedScalarsFixed.yaml deleted file mode 100644 index c73dc4ac47..0000000000 --- a/src/test/resources/yaml/spec/2_17QuotedScalarsFixed.yaml +++ /dev/null @@ -1,6 +0,0 @@ -unicode: "Sosa did fine.\u263A" -control: "\b1998\t1999\t2000\n" -hex esc: "\x0d\x0a is \r\n" -single: "Howdy! he cried.", -quoted: " # Not a ''comment''." -tie-fighter: '|\-*-/|' \ No newline at end of file diff --git a/src/test/resources/specification/example2_19.out.yaml b/src/test/resources/yaml/spec/2_19Integers.out.yaml similarity index 67% rename from src/test/resources/specification/example2_19.out.yaml rename to src/test/resources/yaml/spec/2_19Integers.out.yaml index 7c00552fcd..d28c24a670 100644 --- a/src/test/resources/specification/example2_19.out.yaml +++ b/src/test/resources/yaml/spec/2_19Integers.out.yaml @@ -1,5 +1,5 @@ canonical: 12345 decimal: 12345 -sexagesimal: 03:25:45 +sexagesimal: !Time 03:25:45 octal: 12 hexadecimal: 12 diff --git a/src/test/resources/yaml/spec/2_19Integers.yaml b/src/test/resources/yaml/spec/2_19Integers.yaml index 15a6442de7..ba9ca78e8a 100644 --- a/src/test/resources/yaml/spec/2_19Integers.yaml +++ b/src/test/resources/yaml/spec/2_19Integers.yaml @@ -1,4 +1,5 @@ canonical: 12345 -decimal: +12345 +decimal: +12_345 +sexagesimal: 3:25:45 octal: 0o14 -hexadecimal: 0xC \ No newline at end of file +hexadecimal: 0xC diff --git a/src/test/resources/yaml/spec/2_1_SequenceOfScalars.yaml b/src/test/resources/yaml/spec/2_1_SequenceOfScalars.yaml index 12519fb48c..d12e67111b 100644 --- a/src/test/resources/yaml/spec/2_1_SequenceOfScalars.yaml +++ b/src/test/resources/yaml/spec/2_1_SequenceOfScalars.yaml @@ -1,3 +1,3 @@ - Mark McGwire - Sammy Sosa -- Ken Griffey \ No newline at end of file +- Ken Griffey diff --git a/src/test/resources/yaml/spec/2_20FloatingPoint.yaml b/src/test/resources/yaml/spec/2_20FloatingPoint.yaml index 3600215305..60bfc06814 100644 --- a/src/test/resources/yaml/spec/2_20FloatingPoint.yaml +++ b/src/test/resources/yaml/spec/2_20FloatingPoint.yaml @@ -1,5 +1,6 @@ canonical: 1.23015e+3 exponential: 12.3015e+02 -fixed: 1230.15 +sexagesimal: 20:30.15 +fixed: 1_230.15 negative infinity: -.inf -not a number: .NaN \ No newline at end of file +not a number: .NaN diff --git a/src/test/resources/specification/example2_21.out.yaml b/src/test/resources/yaml/spec/2_21MiscellaneousBis.out.yaml similarity index 100% rename from src/test/resources/specification/example2_21.out.yaml rename to src/test/resources/yaml/spec/2_21MiscellaneousBis.out.yaml diff --git a/src/test/resources/specification/example2_21.yaml b/src/test/resources/yaml/spec/2_21MiscellaneousBis.yaml similarity index 100% rename from src/test/resources/specification/example2_21.yaml rename to src/test/resources/yaml/spec/2_21MiscellaneousBis.yaml diff --git a/src/test/resources/yaml/spec/2_22Timestamps.yaml b/src/test/resources/yaml/spec/2_22Timestamps.yaml index f3b74b4f47..aaac185a98 100644 --- a/src/test/resources/yaml/spec/2_22Timestamps.yaml +++ b/src/test/resources/yaml/spec/2_22Timestamps.yaml @@ -1,4 +1,4 @@ canonical: 2001-12-15T02:59:43.1Z iso8601: 2001-12-14t21:59:43.10-05:00 spaced: 2001-12-14 21:59:43.10 -5 -date: 2002-12-14 \ No newline at end of file +date: 2002-12-14 diff --git a/src/test/resources/yaml/spec/2_24GlobalTags.yaml b/src/test/resources/yaml/spec/2_24GlobalTags.yaml index a1a0a49356..1180757d81 100644 --- a/src/test/resources/yaml/spec/2_24GlobalTags.yaml +++ b/src/test/resources/yaml/spec/2_24GlobalTags.yaml @@ -11,4 +11,4 @@ - !label start: *ORIGIN color: 0xFFEEBB - text: Pretty vector drawing. \ No newline at end of file + text: Pretty vector drawing. diff --git a/src/test/resources/yaml/spec/2_25UnorderedSets.yaml b/src/test/resources/yaml/spec/2_25UnorderedSets.yaml index 4b59314e75..cf4943a201 100644 --- a/src/test/resources/yaml/spec/2_25UnorderedSets.yaml +++ b/src/test/resources/yaml/spec/2_25UnorderedSets.yaml @@ -4,4 +4,4 @@ --- !!set ? Mark McGwire ? Sammy Sosa -? Ken Griff \ No newline at end of file +? Ken Griff diff --git a/src/test/resources/yaml/spec/2_26OrderedMappings.yaml b/src/test/resources/yaml/spec/2_26OrderedMappings.yaml index 714fc91475..3143763dd0 100644 --- a/src/test/resources/yaml/spec/2_26OrderedMappings.yaml +++ b/src/test/resources/yaml/spec/2_26OrderedMappings.yaml @@ -1,4 +1,7 @@ +# ordered maps are represented as +# a sequence of mappings, with +# each mapping having one key --- !!omap - Mark McGwire: 65 - Sammy Sosa: 63 -- Ken Griffy: 58 \ No newline at end of file +- Ken Griffy: 58 diff --git a/src/test/resources/yaml/spec/2_27Invoice.yaml b/src/test/resources/yaml/spec/2_27Invoice.yaml index 82c69d6280..4625739d79 100644 --- a/src/test/resources/yaml/spec/2_27Invoice.yaml +++ b/src/test/resources/yaml/spec/2_27Invoice.yaml @@ -26,4 +26,4 @@ total: 4443.52 comments: Late afternoon is best. Backup contact is Nancy - Billsmer @ 338-4338. \ No newline at end of file + Billsmer @ 338-4338. diff --git a/src/test/resources/specification/example2_2.out.yaml b/src/test/resources/yaml/spec/2_2_MappingScalarsToScalars.out.yaml similarity index 100% rename from src/test/resources/specification/example2_2.out.yaml rename to src/test/resources/yaml/spec/2_2_MappingScalarsToScalars.out.yaml diff --git a/src/test/resources/yaml/spec/2_2_MappingScalarsToScalars.yaml b/src/test/resources/yaml/spec/2_2_MappingScalarsToScalars.yaml index d56c5d6056..7b7ec948db 100644 --- a/src/test/resources/yaml/spec/2_2_MappingScalarsToScalars.yaml +++ b/src/test/resources/yaml/spec/2_2_MappingScalarsToScalars.yaml @@ -1,3 +1,3 @@ hr: 65 # Home runs avg: 0.278 # Batting average -rbi: 147 # Runs Batted In \ No newline at end of file +rbi: 147 # Runs Batted In diff --git a/src/test/resources/specification/example2_3.out.yaml b/src/test/resources/yaml/spec/2_3_MappingScalarsToSequences.out.yaml similarity index 96% rename from src/test/resources/specification/example2_3.out.yaml rename to src/test/resources/yaml/spec/2_3_MappingScalarsToSequences.out.yaml index 3f337f32dd..057c8a17d5 100644 --- a/src/test/resources/specification/example2_3.out.yaml +++ b/src/test/resources/yaml/spec/2_3_MappingScalarsToSequences.out.yaml @@ -2,9 +2,9 @@ american: [ Boston Red Sox, Detroit Tigers, New York Yankees -], +] national: [ New York Mets, Chicago Cubs, Atlanta Braves -] \ No newline at end of file +] diff --git a/src/test/resources/yaml/spec/2_4_SequenceOfMappings-fixed.yaml b/src/test/resources/yaml/spec/2_4_SequenceOfMappings-fixed.yaml deleted file mode 100644 index 460b8e7407..0000000000 --- a/src/test/resources/yaml/spec/2_4_SequenceOfMappings-fixed.yaml +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - name: Mark McGwire, - hr: 65, - avg: 0.278 - }, - { - name: Sammy Sosa, - hr: 63, - avg: 0.288 - } -] \ No newline at end of file diff --git a/src/test/resources/yaml/spec/2_4_SequenceOfMappings.out.yaml b/src/test/resources/yaml/spec/2_4_SequenceOfMappings.out.yaml new file mode 100644 index 0000000000..eeb2bcc2b5 --- /dev/null +++ b/src/test/resources/yaml/spec/2_4_SequenceOfMappings.out.yaml @@ -0,0 +1,10 @@ +- { + name: Mark McGwire, + hr: 65, + avg: 0.278 +} +- { + name: Sammy Sosa, + hr: 63, + avg: 0.288 +} diff --git a/src/test/resources/yaml/spec/2_4_SequenceOfMappings.yaml b/src/test/resources/yaml/spec/2_4_SequenceOfMappings.yaml index e60d8a9b3a..430f6b3dbe 100644 --- a/src/test/resources/yaml/spec/2_4_SequenceOfMappings.yaml +++ b/src/test/resources/yaml/spec/2_4_SequenceOfMappings.yaml @@ -5,4 +5,4 @@ - name: Sammy Sosa hr: 63 - avg: 0.288 \ No newline at end of file + avg: 0.288 diff --git a/src/test/resources/yaml/spec/2_5_SequenceOfSequences.out.yaml b/src/test/resources/yaml/spec/2_5_SequenceOfSequences.out.yaml new file mode 100644 index 0000000000..b70df88e01 --- /dev/null +++ b/src/test/resources/yaml/spec/2_5_SequenceOfSequences.out.yaml @@ -0,0 +1,15 @@ +- [ + name, + hr, + avg +] +- [ + Mark McGwire, + 65, + 0.278 +] +- [ + Sammy Sosa, + 63, + 0.288 +] diff --git a/src/test/resources/yaml/spec/2_5_SequenceOfSequences.yaml b/src/test/resources/yaml/spec/2_5_SequenceOfSequences.yaml index 8c5b80575e..cdd7770628 100644 --- a/src/test/resources/yaml/spec/2_5_SequenceOfSequences.yaml +++ b/src/test/resources/yaml/spec/2_5_SequenceOfSequences.yaml @@ -1,3 +1,3 @@ - [name , hr, avg ] - [Mark McGwire, 65, 0.278] -- [Sammy Sosa , 63, 0.288] \ No newline at end of file +- [Sammy Sosa , 63, 0.288] diff --git a/src/test/resources/yaml/spec/2_6_MappingOfMappings.out.yaml b/src/test/resources/yaml/spec/2_6_MappingOfMappings.out.yaml new file mode 100644 index 0000000000..d7eb87ea37 --- /dev/null +++ b/src/test/resources/yaml/spec/2_6_MappingOfMappings.out.yaml @@ -0,0 +1,8 @@ +Mark McGwire: { + hr: 65, + avg: 0.278 +} +Sammy Sosa: { + hr: 63, + avg: 0.288 +} diff --git a/src/test/resources/yaml/spec/2_6_MappingOfMappings.yaml b/src/test/resources/yaml/spec/2_6_MappingOfMappings.yaml index cc9e27962e..7a957b23a1 100644 --- a/src/test/resources/yaml/spec/2_6_MappingOfMappings.yaml +++ b/src/test/resources/yaml/spec/2_6_MappingOfMappings.yaml @@ -2,4 +2,4 @@ Mark McGwire: {hr: 65, avg: 0.278} Sammy Sosa: { hr: 63, avg: 0.288 - } \ No newline at end of file + } diff --git a/src/test/resources/specification/example2_1.yaml b/src/test/resources/yaml/spec/2_7_TwoDocumentsInAStream.out.yaml similarity index 100% rename from src/test/resources/specification/example2_1.yaml rename to src/test/resources/yaml/spec/2_7_TwoDocumentsInAStream.out.yaml diff --git a/src/test/resources/yaml/spec/2_7_TwoDocumentsInAStream.yaml b/src/test/resources/yaml/spec/2_7_TwoDocumentsInAStream.yaml index b93cbf3c17..bc711d547c 100644 --- a/src/test/resources/yaml/spec/2_7_TwoDocumentsInAStream.yaml +++ b/src/test/resources/yaml/spec/2_7_TwoDocumentsInAStream.yaml @@ -7,4 +7,4 @@ # Team ranking --- - Chicago Cubs -- St Louis Cardinals \ No newline at end of file +- St Louis Cardinals diff --git a/src/test/resources/yaml/spec/2_7_TwoDocumentsInAStreamFixed.yaml b/src/test/resources/yaml/spec/2_7_TwoDocumentsInAStreamFixed.yaml deleted file mode 100644 index c59cd0ee49..0000000000 --- a/src/test/resources/yaml/spec/2_7_TwoDocumentsInAStreamFixed.yaml +++ /dev/null @@ -1,10 +0,0 @@ -# Ranking of 1998 home runs -[ -- Mark McGwire -- Sammy Sosa -- Ken Griffey -, -# Team ranking -- Chicago Cubs -- St Louis Cardinals -] \ No newline at end of file diff --git a/src/test/resources/yaml/spec/2_8_PlayByPlayFeed.yaml b/src/test/resources/yaml/spec/2_8_PlayByPlayFeed.yaml index 7dd0cf7d80..05e102d8eb 100644 --- a/src/test/resources/yaml/spec/2_8_PlayByPlayFeed.yaml +++ b/src/test/resources/yaml/spec/2_8_PlayByPlayFeed.yaml @@ -7,4 +7,4 @@ action: strike (miss) time: 20:03:47 player: Sammy Sosa action: grand slam -... \ No newline at end of file +... diff --git a/src/test/resources/yaml/spec/2_8_PlayByPlayFeedFixed.yaml b/src/test/resources/yaml/spec/2_8_PlayByPlayFeedFixed.yaml deleted file mode 100644 index 8763593198..0000000000 --- a/src/test/resources/yaml/spec/2_8_PlayByPlayFeedFixed.yaml +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - time: 20:03:20 - player: Sammy Sosa - action: strike (miss) - }, - { - time: 20:03:47 - player: Sammy Sosa - action: grand slam - } -] \ No newline at end of file diff --git a/src/test/resources/specification/example2_10.out.yaml b/src/test/resources/yaml/spec/2_9_SingleDocumentWithTwoComments.out.yaml similarity index 60% rename from src/test/resources/specification/example2_10.out.yaml rename to src/test/resources/yaml/spec/2_9_SingleDocumentWithTwoComments.out.yaml index fa0fa2262b..45407f5aed 100644 --- a/src/test/resources/specification/example2_10.out.yaml +++ b/src/test/resources/yaml/spec/2_9_SingleDocumentWithTwoComments.out.yaml @@ -1,8 +1,8 @@ hr: [ Mark McGwire, - &SS Sammy Sosa + Sammy Sosa ] rbi: [ - *SS, + Sammy Sosa, Ken Griffey -] \ No newline at end of file +] diff --git a/src/test/resources/yaml/spec/2_9_SingleDocumentWithTwoComments.yaml b/src/test/resources/yaml/spec/2_9_SingleDocumentWithTwoComments.yaml index a3ef726c03..e264180539 100644 --- a/src/test/resources/yaml/spec/2_9_SingleDocumentWithTwoComments.yaml +++ b/src/test/resources/yaml/spec/2_9_SingleDocumentWithTwoComments.yaml @@ -5,4 +5,4 @@ hr: # 1998 hr ranking rbi: # 1998 rbi ranking - Sammy Sosa - - Ken Griffey \ No newline at end of file + - Ken Griffey diff --git a/src/test/resources/yaml/spec/2_9_SingleDocumentWithTwoCommentsFixed.yaml b/src/test/resources/yaml/spec/2_9_SingleDocumentWithTwoCommentsFixed.yaml deleted file mode 100644 index 19da64a9ed..0000000000 --- a/src/test/resources/yaml/spec/2_9_SingleDocumentWithTwoCommentsFixed.yaml +++ /dev/null @@ -1,8 +0,0 @@ - -hr: # 1998 hr ranking - - Mark McGwire - - Sammy Sosa -rbi: - # 1998 rbi ranking - - Sammy Sosa - - Ken Griffey diff --git a/src/test/resources/specification/types/map.yaml b/src/test/resources/yaml/spec/types/map.yaml similarity index 100% rename from src/test/resources/specification/types/map.yaml rename to src/test/resources/yaml/spec/types/map.yaml diff --git a/src/test/resources/specification/types/map_mixed_tags.yaml b/src/test/resources/yaml/spec/types/map_mixed_tags.yaml similarity index 100% rename from src/test/resources/specification/types/map_mixed_tags.yaml rename to src/test/resources/yaml/spec/types/map_mixed_tags.yaml diff --git a/src/test/resources/specification/types/merge.yaml b/src/test/resources/yaml/spec/types/merge.yaml similarity index 100% rename from src/test/resources/specification/types/merge.yaml rename to src/test/resources/yaml/spec/types/merge.yaml diff --git a/src/test/resources/specification/types/omap.yaml b/src/test/resources/yaml/spec/types/omap.yaml similarity index 100% rename from src/test/resources/specification/types/omap.yaml rename to src/test/resources/yaml/spec/types/omap.yaml diff --git a/src/test/resources/specification/types/pairs.yaml b/src/test/resources/yaml/spec/types/pairs.yaml similarity index 100% rename from src/test/resources/specification/types/pairs.yaml rename to src/test/resources/yaml/spec/types/pairs.yaml diff --git a/src/test/resources/specification/types/seq.yaml b/src/test/resources/yaml/spec/types/seq.yaml similarity index 100% rename from src/test/resources/specification/types/seq.yaml rename to src/test/resources/yaml/spec/types/seq.yaml diff --git a/src/test/resources/specification/types/set.yaml b/src/test/resources/yaml/spec/types/set.yaml similarity index 100% rename from src/test/resources/specification/types/set.yaml rename to src/test/resources/yaml/spec/types/set.yaml diff --git a/src/test/resources/specification/types/v.yaml b/src/test/resources/yaml/spec/types/v.yaml similarity index 100% rename from src/test/resources/specification/types/v.yaml rename to src/test/resources/yaml/spec/types/v.yaml diff --git a/src/test/resources/specification/types/value.yaml b/src/test/resources/yaml/spec/types/value.yaml similarity index 100% rename from src/test/resources/specification/types/value.yaml rename to src/test/resources/yaml/spec/types/value.yaml