JIRA-2353: Config incorrectly handles Windows absolute pathnames

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@929520 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shai Erera 2010-03-31 13:06:13 +00:00
parent 04dc8c10fd
commit 76dd311c5c
3 changed files with 47 additions and 0 deletions

View File

@ -2,6 +2,10 @@ Lucene Benchmark Contrib Change Log
The Benchmark contrib package contains code for benchmarking Lucene in a variety of ways.
3/28/2010
LUCENE-2353: Fixed bug in Config where Windows absolute path property values
were incorrectly handled (Shai Erera via ?)
3/24/2010
LUCENE-2343: Added support for benchmarking collectors. (Grant Ingersoll, Shai Erera)

View File

@ -139,6 +139,10 @@ public class Config {
}
if (sval.indexOf(":") < 0) {
return sval;
} else if (sval.indexOf(":\\") >= 0 || sval.indexOf(":/") >= 0) {
// this previously messed up absolute path names on Windows. Assuming
// there is no real value that starts with \ or /
return sval;
}
// first time this prop is extracted by round
int k = sval.indexOf(":");

View File

@ -0,0 +1,39 @@
package org.apache.lucene.benchmark.byTask.utils;
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import static org.junit.Assert.*;
import java.util.Properties;
import org.apache.lucene.util.LuceneTestCaseJ4;
import org.junit.Test;
public class TestConfig extends LuceneTestCaseJ4 {
@Test
public void testAbsolutePathNamesWindows() throws Exception {
Properties props = new Properties();
props.setProperty("work.dir1", "c:\\temp");
props.setProperty("work.dir2", "c:/temp");
Config conf = new Config(props);
assertEquals("c:\\temp", conf.get("work.dir1", ""));
assertEquals("c:/temp", conf.get("work.dir2", ""));
}
}