/* LanguageTool, a natural language style checker 
 * Copyright (C) 2005 Daniel Naber (http://www.danielnaber.de)
 * 
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */
package org.languagetool;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import junit.framework.TestCase;

public class VersionNumberTest extends TestCase {

  public void testVersionNumber() throws IOException {
    String buildFile = load("build.properties");
    Pattern p1 = Pattern.compile("version = ([0-9\\.]+(-dev)?)");
    Matcher m1 = p1.matcher(buildFile);
    m1.find();
    String javaFile = load("src/java/org/languagetool/JLanguageTool.java");
    Pattern p2 = Pattern.compile("VERSION = \"(.*?)\"");
    Matcher m2 = p2.matcher(javaFile);
    m2.find();
    assertEquals(m1.group(1), m2.group(1));
    //System.out.println(m1.group(1));
  }

  private String load(String filename) throws IOException {
    FileReader fr = new FileReader(filename);
    BufferedReader br = new BufferedReader(fr);
    StringBuffer sb = new StringBuffer();
    String line;    
    while ((line = br.readLine()) != null) {      
        sb.append(line);                
    }
    br.close();
    fr.close();
    return sb.toString();
  }

}

@@ -893,30 +893,76 @@
 rt j
-ava.io.BufferedReader;
+unit.framework.TestCase;%0Aimport org.languagetool.tools.StringTools;%0A
 %0Aimp
@@ -977,22 +977,27 @@
 .io.File
-Reader
+InputStream
 ;%0Aimport
@@ -1087,42 +1087,8 @@
 n;%0A%0A
-import junit.framework.TestCase;%0A%0A
 publ
@@ -1212,20 +1212,56 @@
 dFile = 
-load
+StringTools.readFile(new FileInputStream
 (%22build.
@@ -1272,16 +1272,17 @@
 erties%22)
+)
 ;%0A    Pa
@@ -1418,20 +1418,56 @@
 aFile = 
-load
+StringTools.readFile(new FileInputStream
 (%22src/ja
@@ -1506,16 +1506,17 @@
 l.java%22)
+)
 ;%0A    Pa
@@ -1668,425 +1668,8 @@
 ));%0A
-    //System.out.println(m1.group(1));%0A  %7D%0A%0A  private String load(String filename) throws IOException %7B%0A    FileReader fr = new FileReader(filename);%0A    BufferedReader br = new BufferedReader(fr);%0A    StringBuffer sb = new StringBuffer();%0A    String line;    %0A    while ((line = br.readLine()) != null) %7B      %0A        sb.append(line);                %0A    %7D%0A    br.close();%0A    fr.close();%0A    return sb.toString();%0A
   %7D%0A

simplify code