You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Joseph Chen (JIRA)" <ji...@apache.org> on 2005/12/02 02:44:32 UTC
[jira] Created: (JCR-285) Line-separator differences cause PredefinedNodeTypeTest to fail on different operating systems.
Line-separator differences cause PredefinedNodeTypeTest to fail on different operating systems.
-----------------------------------------------------------------------------------------------
Key: JCR-285
URL: http://issues.apache.org/jira/browse/JCR-285
Project: Jackrabbit
Type: Bug
Components: nodetype
Versions: 1.0
Reporter: Joseph Chen
Priority: Minor
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);
...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Updated: (JCR-285) Line-separator differences cause
PredefinedNodeTypeTest to fail on different operating systems.
Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/JCR-285?page=all ]
Jukka Zitting updated JCR-285:
------------------------------
Version: 0.9
1.0
> Line-separator differences cause PredefinedNodeTypeTest to fail on different operating systems.
> -----------------------------------------------------------------------------------------------
>
> Key: JCR-285
> URL: http://issues.apache.org/jira/browse/JCR-285
> Project: Jackrabbit
> Type: Bug
> Components: TCK
> Versions: 0.9, 1.0
> Reporter: Joseph Chen
> Priority: Minor
> Fix For: 1.1
> Attachments: PredefinedNodeTypeTest.java
>
> 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);
> ...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Updated: (JCR-285) Line-separator differences cause PredefinedNodeTypeTest to fail on different operating systems.
Posted by "Joseph Chen (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/JCR-285?page=all ]
Joseph Chen updated JCR-285:
----------------------------
Attachment: PredefinedNodeTypeTest.java
Proposed fix for unit test.
> Line-separator differences cause PredefinedNodeTypeTest to fail on different operating systems.
> -----------------------------------------------------------------------------------------------
>
> Key: JCR-285
> URL: http://issues.apache.org/jira/browse/JCR-285
> Project: Jackrabbit
> Type: Bug
> Components: nodetype
> Versions: 1.0
> Reporter: Joseph Chen
> Priority: Minor
> Attachments: PredefinedNodeTypeTest.java
>
> 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);
> ...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Updated: (JCR-285) Line-separator differences cause
PredefinedNodeTypeTest to fail on different operating systems.
Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/JCR-285?page=all ]
Jukka Zitting updated JCR-285:
------------------------------
Fix Version: 1.0
Version: (was: 1.0)
Tagged for 1.0
> Line-separator differences cause PredefinedNodeTypeTest to fail on different operating systems.
> -----------------------------------------------------------------------------------------------
>
> Key: JCR-285
> URL: http://issues.apache.org/jira/browse/JCR-285
> Project: Jackrabbit
> Type: Bug
> Components: TCK
> Reporter: Joseph Chen
> Priority: Minor
> Fix For: 1.0
> Attachments: PredefinedNodeTypeTest.java
>
> 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);
> ...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Updated: (JCR-285) Line-separator differences cause PredefinedNodeTypeTest to fail on different operating systems.
Posted by "Stefan Guggisberg (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/JCR-285?page=all ]
Stefan Guggisberg updated JCR-285:
----------------------------------
Component: TCK
(was: nodetype)
> Line-separator differences cause PredefinedNodeTypeTest to fail on different operating systems.
> -----------------------------------------------------------------------------------------------
>
> Key: JCR-285
> URL: http://issues.apache.org/jira/browse/JCR-285
> Project: Jackrabbit
> Type: Bug
> Components: TCK
> Versions: 1.0
> Reporter: Joseph Chen
> Priority: Minor
> Attachments: PredefinedNodeTypeTest.java
>
> 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);
> ...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira
[jira] Updated: (JCR-285) Line-separator differences cause
PredefinedNodeTypeTest to fail on different operating systems.
Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
[ http://issues.apache.org/jira/browse/JCR-285?page=all ]
Jukka Zitting updated JCR-285:
------------------------------
Fix Version: 1.1
(was: 1.0)
> Line-separator differences cause PredefinedNodeTypeTest to fail on different operating systems.
> -----------------------------------------------------------------------------------------------
>
> Key: JCR-285
> URL: http://issues.apache.org/jira/browse/JCR-285
> Project: Jackrabbit
> Type: Bug
> Components: TCK
> Reporter: Joseph Chen
> Priority: Minor
> Fix For: 1.1
> Attachments: PredefinedNodeTypeTest.java
>
> 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);
> ...
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
http://www.atlassian.com/software/jira