Return-Path: Delivered-To: apmail-incubator-jackrabbit-dev-archive@www.apache.org Received: (qmail 40419 invoked from network); 2 Dec 2005 10:09:56 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 2 Dec 2005 10:09:56 -0000 Received: (qmail 21493 invoked by uid 500); 2 Dec 2005 10:09:55 -0000 Mailing-List: contact jackrabbit-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: jackrabbit-dev@incubator.apache.org Delivered-To: mailing list jackrabbit-dev@incubator.apache.org Received: (qmail 21482 invoked by uid 99); 2 Dec 2005 10:09:55 -0000 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received: from [192.87.106.226] (HELO ajax.apache.org) (192.87.106.226) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 02 Dec 2005 02:09:53 -0800 Received: from ajax.apache.org (ajax.apache.org [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id EC752CB for ; Fri, 2 Dec 2005 11:09:31 +0100 (CET) Message-ID: <110212761.1133518171966.JavaMail.jira@ajax.apache.org> Date: Fri, 2 Dec 2005 11:09:31 +0100 (CET) From: "Stefan Guggisberg (JIRA)" To: jackrabbit-dev@incubator.apache.org Subject: [jira] Updated: (JCR-285) Line-separator differences cause PredefinedNodeTypeTest to fail on different operating systems. In-Reply-To: <1533201440.1133487872317.JavaMail.jira@ajax.apache.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N [ 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