From c5aa1d6962ee16812d8d8c19b167b1b256e8002f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Mej=C3=ADa?= Date: Tue, 4 Dec 2018 14:05:30 +0100 Subject: [PATCH] AVRO-1939: Add missing Apache license header (#399) Add missing Apache license header and fix failing test case for schema normalization tool --- .../java/org/apache/avro/tool/CatTool.java | 2 +- .../avro/tool/SchemaNormalizationTool.java | 22 ++++++++++++++++++- .../java/org/apache/avro/tool/TestMain.java | 20 ++++++++++++++++- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/lang/java/tools/src/main/java/org/apache/avro/tool/CatTool.java b/lang/java/tools/src/main/java/org/apache/avro/tool/CatTool.java index 642b5637120..2574b11a27f 100644 --- a/lang/java/tools/src/main/java/org/apache/avro/tool/CatTool.java +++ b/lang/java/tools/src/main/java/org/apache/avro/tool/CatTool.java @@ -210,7 +210,7 @@ public String getName() { @Override public String getShortDescription() { - return "extracts samples from files"; + return "Extracts samples from files"; } } diff --git a/lang/java/tools/src/main/java/org/apache/avro/tool/SchemaNormalizationTool.java b/lang/java/tools/src/main/java/org/apache/avro/tool/SchemaNormalizationTool.java index 1cd63c71085..28fb74b8984 100644 --- a/lang/java/tools/src/main/java/org/apache/avro/tool/SchemaNormalizationTool.java +++ b/lang/java/tools/src/main/java/org/apache/avro/tool/SchemaNormalizationTool.java @@ -1,3 +1,20 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.avro.tool; import java.io.BufferedInputStream; @@ -12,9 +29,12 @@ import org.apache.avro.Schema; import org.apache.avro.SchemaNormalization; +/** + * Utility to convert an Avro @{Schema} to its canonical form. + */ public class SchemaNormalizationTool implements Tool { @Override - public String getName() { return "schemacanonical"; } + public String getName() { return "canonical"; } @Override public String getShortDescription() { return "Converts an Avro Schema to its canonical form"; } diff --git a/lang/java/tools/src/test/java/org/apache/avro/tool/TestMain.java b/lang/java/tools/src/test/java/org/apache/avro/tool/TestMain.java index 5a2acc008e2..f4ee46d96ca 100644 --- a/lang/java/tools/src/test/java/org/apache/avro/tool/TestMain.java +++ b/lang/java/tools/src/test/java/org/apache/avro/tool/TestMain.java @@ -22,8 +22,8 @@ import org.junit.Test; public class TestMain { - @Test /** Make sure that tool descriptions fit in 80 characters. */ + @Test public void testToolDescriptionLength() { Main m = new Main(); for (Tool t : m.tools.values()) { @@ -32,4 +32,22 @@ public void testToolDescriptionLength() { } } } + + /** + * Make sure that the tool name is not too long, otherwise space for + * description is too short because they are rebalanced in the CLI. + */ + @Test + public void testToolNameLength() { + // 13 chosen for backwards compatibility + final int MAX_NAME_LENGTH = 13; + + Main m = new Main(); + for (Tool t : m.tools.values()) { + if (t.getName().length() > MAX_NAME_LENGTH) { + fail("Tool name too long (" + t.getName().length() + "): " + + t.getName() + ". Max length is: " + MAX_NAME_LENGTH); + } + } + } }