Return-Path: Delivered-To: apmail-jackrabbit-dev-archive@www.apache.org Received: (qmail 62422 invoked from network); 3 Apr 2006 13:29:36 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 3 Apr 2006 13:29:36 -0000 Received: (qmail 42321 invoked by uid 500); 3 Apr 2006 13:29:26 -0000 Delivered-To: apmail-jackrabbit-dev-archive@jackrabbit.apache.org Received: (qmail 42257 invoked by uid 500); 3 Apr 2006 13:29:26 -0000 Mailing-List: contact dev-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@jackrabbit.apache.org Delivered-To: mailing list dev@jackrabbit.apache.org Received: (qmail 42226 invoked by uid 99); 3 Apr 2006 13:29:25 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Apr 2006 06:29:25 -0700 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; Mon, 03 Apr 2006 06:29:25 -0700 Received: from ajax (localhost.localdomain [127.0.0.1]) by ajax.apache.org (Postfix) with ESMTP id 07D046ACB1 for ; Mon, 3 Apr 2006 14:29:04 +0100 (BST) Message-ID: <1475307228.1144070944028.JavaMail.jira@ajax> Date: Mon, 3 Apr 2006 14:29:04 +0100 (BST) From: "Stefan Guggisberg (JIRA)" To: dev@jackrabbit.apache.org Subject: [jira] Resolved: (JCR-285) Line-separator differences cause PredefinedNodeTypeTest to fail on different operating systems. 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 resolved JCR-285: ----------------------------------- Fix Version: 1.0.1 (was: 1.1) Resolution: Fixed fixed as suggested (svn r391041). thanks for reporting this issue! > 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: test > Versions: 0.9, 1.0 > Reporter: Joseph Chen > Assignee: Stefan Guggisberg > Priority: Minor > Fix For: 1.0.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