[jira] [Commented] (HDFS-10635) expected/actual parameters inverted in TestGlobPaths assertEquals

2016-07-18 Thread Chen Liang (JIRA)

[ 
https://issues.apache.org/jira/browse/HDFS-10635?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15382644#comment-15382644
 ] 

Chen Liang commented on HDFS-10635:
---

Thanks Steve, I'll keep an eye on that for now then.

> expected/actual parameters inverted in TestGlobPaths assertEquals
> -
>
> Key: HDFS-10635
> URL: https://issues.apache.org/jira/browse/HDFS-10635
> Project: Hadoop HDFS
>  Issue Type: Bug
>  Components: test
>Affects Versions: 2.8.0
>Reporter: Steve Loughran
>Assignee: Chen Liang
>Priority: Minor
>
> Pretty much all the assertEquals clauses in {{TestGlobPaths}} place the 
> actual value first, expected second. That's the wrong order and will lead to 
> misleading messages.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org



[jira] [Commented] (HDFS-10635) expected/actual parameters inverted in TestGlobPaths assertEquals

2016-07-18 Thread Steve Loughran (JIRA)

[ 
https://issues.apache.org/jira/browse/HDFS-10635?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15382633#comment-15382633
 ] 

Steve Loughran commented on HDFS-10635:
---

Chen, before you start this, wait until HADOOP-13371 is done, or at least have 
a patch up. There's enough common code that you can cut out all the equals 
checks from every test, leaving something much more minimal where you just 
provide the pattern, the files and the lists of indexes in the matchedPath 
values:

{code}
  @Test
  public void testNestedCurlyBracket() throws Throwable {
String[] files = {
userDir + "/a.abcxx",
userDir + "/a.abdxy",
userDir + "/a.hlp",
userDir + "/a.jhyy"
};
assertMatchOperation(userDir + "/a.{ab{c,d},jh}??", files, 0, 1, 3);
  }

  public Path[] assertMatchOperation(String pattern,
  String[] files,
  int... matchIndices)
  throws IOException {
Path[] matchedPaths = prepareTesting(pattern, files);
int expectedLength = matchIndices.length;
StringBuilder builder = new StringBuilder(
expectedLength * 128);
builder.append("Expected Paths\n");
for (int index : matchIndices) {
  if (index < path.length) {
builder.append(
String.format("  [%d] %s\n", index, path[index]));
  }
}
Joiner j = Joiner.on("\n  ");
builder.append("\nMatched paths:\n  ");
j.appendTo(builder, matchedPaths);
assertEquals(builder.toString(), expectedLength, matchedPaths.length);
for (int i = 0; i < matchedPaths.length; i++) {
  int expectedIndex = matchIndices[i];
  Path expectedPath = path[expectedIndex];
  assertEquals(String.format("Element %d: in %s", i, builder.toString()),
  expectedPath, matchedPaths[i]);
}
return matchedPaths;
  }
{code}


> expected/actual parameters inverted in TestGlobPaths assertEquals
> -
>
> Key: HDFS-10635
> URL: https://issues.apache.org/jira/browse/HDFS-10635
> Project: Hadoop HDFS
>  Issue Type: Bug
>  Components: test
>Affects Versions: 2.8.0
>Reporter: Steve Loughran
>Assignee: Chen Liang
>Priority: Minor
>
> Pretty much all the assertEquals clauses in {{TestGlobPaths}} place the 
> actual value first, expected second. That's the wrong order and will lead to 
> misleading messages.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

-
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org