/*
 * 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.
 */


package org.apache.oodt.cas.metadata.preconditions;

//JDK imports
import java.io.File;
import java.io.IOException;
import java.util.LinkedList;

//Spring imports
import org.springframework.beans.BeansException;
import org.springframework.context.support.FileSystemXmlApplicationContext;

//Junit imports
import junit.framework.TestCase;

/**
 * 
 * @author bfoster
 * @author mattmann
 * @version $Revision$
 * 
 * <p>
 * Test suite for the {@link PreCondEvalUtils} class
 * </p>.
 */
public class TestPreCondEvalUtils extends TestCase {

    LinkedList<String> preconditions;
    
    private PreCondEvalUtils evalUtils;
    

    public TestPreCondEvalUtils() throws ClassNotFoundException, InstantiationException,
            IllegalAccessException, BeansException, IOException {
        this.preconditions = new LinkedList<String>();
        this.preconditions.add("CheckThatDataFileSizeIsGreaterThanZero");
        this.preconditions.add("CheckThatDataFileExists");
        this.preconditions.add("CheckDataFileMimeType");
        File preCondFile = new File(getClass().getResource("met_extr_preconditions.xml").getFile());
        assertNotNull(preCondFile);
        this.evalUtils = new PreCondEvalUtils(new FileSystemXmlApplicationContext(preCondFile.toURL().toExternalForm()));
    }

    public void testEval(){
        File prodFile = null;
        try{
            prodFile = new File(getClass().getResource("met_extr_preconditions.xml").getFile());
            assertTrue(this.evalUtils.eval(this.preconditions, prodFile));
        }
        catch(Throwable e){
            e.printStackTrace();
            fail(e.getMessage());
        }
    }

}

@@ -850,16 +850,91 @@
 tions;%0A%0A
+// Metadata Imports%0Aimport org.apache.oodt.cas.metadata.MetadataTestCase;%0A%0A
 //JDK im
@@ -1400,16 +1400,24 @@
 extends 
+Metadata
 TestCase
@@ -1502,21 +1502,16 @@
 alUtils;
-%0A    
 %0A%0A    pu
@@ -1540,130 +1540,116 @@
 ils(
-) throws ClassNotFoundException, InstantiationException,%0A            IllegalAccessException, BeansException, IOException %7B
+String name) %7B%0A        super(name);%0A    %7D%0A%0A    public void setUp() throws Exception %7B%0A        super.setUp();
 %0A   
@@ -1921,115 +1921,52 @@
 e = 
-new File(getClass().getResource(%22met_extr_preconditions.xml%22).getFile());%0A        assertNotNull(preCondFile
+getTestDataFile(%22met_extr_preconditions.xml%22
 );%0A 
@@ -2123,52 +2123,87 @@
 al()
-%7B%0A        File prodFile = null;%0A        try%7B
+ throws Throwable %7B%0A        // Test file is also the config file we used, neat!
 %0A   
@@ -2207,19 +2207,20 @@
         
-   
+File
  prodFil
@@ -2227,38 +2227,22 @@
 e = 
-new File(getClass().getResourc
+getTestDataFil
 e(%22m
@@ -2272,25 +2272,10 @@
 ml%22)
-.getFile());%0A    
+;%0A
     
@@ -2349,124 +2349,8 @@
     
-    %7D%0A        catch(Throwable e)%7B%0A            e.printStackTrace();%0A            fail(e.getMessage());%0A        %7D%0A    %7D%0A
+%7D
 %0A%7D%0A

Use MetadataTestCase as a base in order to get test data files via 'getTestDataFile'