From 0f17904f1e7b52810522a265553b4fa4f1f46faf Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Fri, 27 Mar 2009 08:44:33 +0000 Subject: [PATCH] remove slow download host; only download zip file once for all tests git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@759061 13f79535-47bb-0310-9956-ffa450edef68 --- .../compound/TestCompoundWordTokenFilter.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/contrib/analyzers/src/test/org/apache/lucene/analysis/compound/TestCompoundWordTokenFilter.java b/contrib/analyzers/src/test/org/apache/lucene/analysis/compound/TestCompoundWordTokenFilter.java index 394955be18a..581d47ebf52 100644 --- a/contrib/analyzers/src/test/org/apache/lucene/analysis/compound/TestCompoundWordTokenFilter.java +++ b/contrib/analyzers/src/test/org/apache/lucene/analysis/compound/TestCompoundWordTokenFilter.java @@ -46,7 +46,9 @@ public class TestCompoundWordTokenFilter extends TestCase { "http://dfn.dl.sourceforge.net/sourceforge/offo/offo-hyphenation.zip", "http://surfnet.dl.sourceforge.net/sourceforge/offo/offo-hyphenation.zip", "http://superb-west.dl.sourceforge.net/sourceforge/offo/offo-hyphenation.zip", - "http://superb-east.dl.sourceforge.net/sourceforge/offo/offo-hyphenation.zip"}; + "http://voxel.dl.sourceforge.net/sourceforge/offo/offo-hyphenation.zip"}; + // too slow: + //"http://superb-east.dl.sourceforge.net/sourceforge/offo/offo-hyphenation.zip"}; private byte[] patternsFileContent; @@ -166,23 +168,25 @@ public class TestCompoundWordTokenFilter extends TestCase { } private void getHyphenationPatternFileContents() { - try { - List urls = new LinkedList(Arrays.asList(locations)); - Collections.shuffle(urls); - URL url = new URL((String)urls.get(0)); - InputStream in = url.openStream(); - byte[] buffer = new byte[1024]; - ByteArrayOutputStream out = new ByteArrayOutputStream(); - int count; + if (patternsFileContent == null) { + try { + List urls = new LinkedList(Arrays.asList(locations)); + Collections.shuffle(urls); + URL url = new URL((String)urls.get(0)); + InputStream in = url.openStream(); + byte[] buffer = new byte[1024]; + ByteArrayOutputStream out = new ByteArrayOutputStream(); + int count; - while ((count = in.read(buffer)) != -1) { - out.write(buffer, 0, count); + while ((count = in.read(buffer)) != -1) { + out.write(buffer, 0, count); + } + in.close(); + out.close(); + patternsFileContent = out.toByteArray(); + } catch (IOException e) { + // we swallow all exceptions - the user might have no internet connection } - in.close(); - out.close(); - patternsFileContent = out.toByteArray(); - } catch (IOException e) { - // we swallow all exceptions - the user might have no internet connection } }