Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ private synchronized void update(
int i = 0;
final List<String> names = Pair.left(map);
for (String s : names) {
if (s.compareToIgnoreCase(testCaseName) <= 0) {
if (s.compareTo(testCaseName) <= 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as here lexicographical order with respect of case is used

// Make sure that there are no duplicate test cases, and count how many
// tests are out of order.
final SortedMap<String, Node> testCases = new TreeMap<>();

++i;
}
}
Expand All @@ -598,13 +598,13 @@ private synchronized void update(
// will end up in exactly the right position, and if the list is not sorted,
// the new item will end up in approximately the right position.
while (i < map.size()
&& names.get(i).compareToIgnoreCase(testCaseName) < 0) {
&& names.get(i).compareTo(testCaseName) < 0) {
++i;
}
if (i >= map.size() - 1) {
if (i > map.size() - 1) {
return null;
}
while (i >= 0 && names.get(i).compareToIgnoreCase(testCaseName) > 0) {
while (i >= 0 && names.get(i).compareTo(testCaseName) > 0) {
--i;
}
return map.get(i + 1).right;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
* 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.calcite.test;

import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.endsWith;

/**
* Tests checking generated actual XML version.
*
* <p>Test case for
* <a href="https://issues.apache.org/jira/browse/CALCITE-7261">[CALCITE-7261]
* DiffRepository generation xml doesn't respect alphabetical order</a>.
*/
public class DiffRepositoryGeneratedFileTest {
private static final DiffRepository REPO =
DiffRepository.lookup(DiffRepositoryGeneratedFileTest.class);

@AfterAll
static void tearDown() throws IOException {
final String fileContent =
String.join("\n", Files.readAllLines(Paths.get(REPO.logFilePath())));
assertThat(
fileContent, endsWith(
"<Root>\n"
+ " <TestCase name=\"testDiff\">\n"
+ " <Resource name=\"resource\">\n"
+ " <![CDATA[diff]]>\n"
+ " </Resource>\n"
+ " </TestCase>\n"
+ " <TestCase name=\"testNull\">\n"
+ " <Resource name=\"resource\">\n"
+ " <![CDATA[null]]>\n"
+ " </Resource>\n"
+ " </TestCase>\n"
+ " <TestCase name=\"testmulti\">\n"
+ " <Resource name=\"resource\">\n"
+ " <![CDATA[multi]]>\n"
+ " </Resource>\n"
+ " </TestCase>\n"
+ "</Root>"));
}

@Test void testDiff() {
REPO.set("resource", "diff");
}

// Here method name was intentionally written in lower case to highlight
// discrepancy between checking logic and generated logic
@Test void testmulti() {
REPO.set("resource", "multi");
}

@Test void testNull() {
REPO.set("resource", "null");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" ?>
<!--
~ 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.
-->
<Root></Root>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dummy xml in order to generate and test actual

Loading