
|
If you were logged in you would be able to see more operations.
|
|
|
| Resolution Date: |
03/Apr/06 09:27 PM
|
|
In testPredefinedNodeType(), the test reads in a test file from the file system and then performs a string comparison, which may fail due to line-separator differences:
private void testPredefinedNodeType(String name)
throws NotExecutableException {
try {
StringBuffer spec = new StringBuffer();
String resource =
"org/apache/jackrabbit/test/api/nodetype/spec/"
+ name.replace(':', '-') + ".txt";
Reader reader = new InputStreamReader(
getClass().getClassLoader().getResourceAsStream(resource));
for (int ch = reader.read(); ch != -1; ch = reader.read()) {
spec.append((char) ch);
}
NodeType type = manager.getNodeType(name);
assertEquals(
"Predefined node type " + name,
spec.toString(),
getNodeTypeSpec(type));
...
The above works when the file being read in has line-separators that match the operating system the test is being run on. However, if there is a mismatch, the string comparison will fail.
The fix is to replace line-separators in both strings being compared:
Helper method to replace line separators
/** Standardize line separators around "\n". */
public String replaceLineSeparators(String stringValue) {
// Replace "\r\n" (Windows format) with "\n" (Unix format)
stringValue = stringValue.replaceAll("\r\n", "\n");
// Replace "\r" (Mac format) with "\n" (Unix format)
stringValue = stringValue.replaceAll("\r", "\n");
return stringValue;
}
Updated test method:
private void testPredefinedNodeType(String name)
throws NotExecutableException {
try {
StringBuffer spec = new StringBuffer();
String resource =
"org/apache/jackrabbit/test/api/nodetype/spec/"
+ name.replace(':', '-') + ".txt";
Reader reader = new InputStreamReader(
getClass().getClassLoader().getResourceAsStream(resource));
for (int ch = reader.read(); ch != -1; ch = reader.read()) {
spec.append((char) ch);
}
NodeType type = manager.getNodeType(name);
String nodeTypeSpecValue = replaceLineSeparators(getNodeTypeSpec(type));
String specValue = replaceLineSeparators(spec.toString());
assertEquals(
"Predefined node type " + name,
specValue,
nodeTypeSpecValue);
...
|
|
Description
|
In testPredefinedNodeType(), the test reads in a test file from the file system and then performs a string comparison, which may fail due to line-separator differences:
private void testPredefinedNodeType(String name)
throws NotExecutableException {
try {
StringBuffer spec = new StringBuffer();
String resource =
"org/apache/jackrabbit/test/api/nodetype/spec/"
+ name.replace(':', '-') + ".txt";
Reader reader = new InputStreamReader(
getClass().getClassLoader().getResourceAsStream(resource));
for (int ch = reader.read(); ch != -1; ch = reader.read()) {
spec.append((char) ch);
}
NodeType type = manager.getNodeType(name);
assertEquals(
"Predefined node type " + name,
spec.toString(),
getNodeTypeSpec(type));
...
The above works when the file being read in has line-separators that match the operating system the test is being run on. However, if there is a mismatch, the string comparison will fail.
The fix is to replace line-separators in both strings being compared:
Helper method to replace line separators
/** Standardize line separators around "\n". */
public String replaceLineSeparators(String stringValue) {
// Replace "\r\n" (Windows format) with "\n" (Unix format)
stringValue = stringValue.replaceAll("\r\n", "\n");
// Replace "\r" (Mac format) with "\n" (Unix format)
stringValue = stringValue.replaceAll("\r", "\n");
return stringValue;
}
Updated test method:
private void testPredefinedNodeType(String name)
throws NotExecutableException {
try {
StringBuffer spec = new StringBuffer();
String resource =
"org/apache/jackrabbit/test/api/nodetype/spec/"
+ name.replace(':', '-') + ".txt";
Reader reader = new InputStreamReader(
getClass().getClassLoader().getResourceAsStream(resource));
for (int ch = reader.read(); ch != -1; ch = reader.read()) {
spec.append((char) ch);
}
NodeType type = manager.getNodeType(name);
String nodeTypeSpecValue = replaceLineSeparators(getNodeTypeSpec(type));
String specValue = replaceLineSeparators(spec.toString());
assertEquals(
"Predefined node type " + name,
specValue,
nodeTypeSpecValue);
... |
Show » |
made changes - 02/Dec/05 07:08 PM
|
Component/s
|
nodetype
[ 11614
]
|
|
|
Component/s
|
|
TCK
[ 11645
]
|
made changes - 11/Jan/06 06:13 PM
|
Affects Version/s
|
1.0
[ 12310154
]
|
|
|
Fix Version/s
|
|
1.0
[ 12310154
]
|
made changes - 07/Mar/06 03:32 PM
|
Fix Version/s
|
|
1.1
[ 12310346
]
|
|
Fix Version/s
|
1.0
[ 12310154
]
|
|
made changes - 21/Mar/06 06:24 AM
|
Affects Version/s
|
|
0.9
[ 12310719
]
|
|
Affects Version/s
|
|
1.0
[ 12310154
]
|
made changes - 03/Apr/06 08:56 PM
|
Assignee
|
|
Stefan Guggisberg
[ stefan@jira
]
|
made changes - 03/Apr/06 09:27 PM
|
Resolution
|
|
Fixed
[ 1
]
|
|
Fix Version/s
|
1.1
[ 12310346
]
|
|
|
Fix Version/s
|
|
1.0.1
[ 12310345
]
|
|
Status
|
Open
[ 1
]
|
Resolved
[ 5
]
|
made changes - 13/Oct/06 04:08 PM
|
Status
|
Resolved
[ 5
]
|
Closed
[ 6
]
|
made changes - 07/Jul/09 01:04 PM
|
Workflow
|
jira
[ 12344349
]
|
no-reopen-closed, patch-avail
[ 12469533
]
|
|