Micheal,
I did, and was just trying to see some symptoms for my own knowledge base,
or is that lack there of??
thanks
-mez
----- Original Message -----
From: "Michael Brailsford" <[EMAIL PROTECTED]>
To: "Ant Users List" <[EMAIL PROTECTED]>
Sent: Thursday, December 27, 2001 3:32 PM
Subject: Re: ant/junit & files
> There are currently problems with the <junit> task when you set fork=no,
> try setting fork to yes on you junit task, and see if that doesn't solve
> the problem.
>
> -Michael
>
> On Thu, Dec 27, 2001 at 01:34:22PM -0800, Marcus wrote:
> > Erik,
> >
> > build.xml snippet:
> > <!-- RUN ALL THE TESTS IN THIS SECTTION maybe put this in an other
> > run_tests.xml file?? -->
> > <target name="run_tests" depends="deploy_tests, deploy_debug"
> > description="Execute Unit Tests">
> > <junit printsummary="yes" fork="no" haltonfailure="no">
> > <sysproperty key="mdb.properties.file" value="mdb.properties"/>
> > <classpath>
> > <fileset dir="${java_deploy_dir}/lib">
> > <include name="*.jar"/>
> > </fileset>
> > <fileset dir="${JLIB}">
> > <include name="*.jar"/>
> > </fileset>
> > </classpath>
> > <formatter type="xml" />
> > <test name="cp_test.system.TestMiniMetanet" />
> > </junit>
> >
> > <java classname="cp_test.system.TestMiniMetanet" fork="yes" >
> > <classpath>
> > <pathelement path="${CLASSPATH}"/>
> > </classpath>
> > <jvmarg
> >
value="-Dmdb.properties.file=p:\cpdev\main\src\html\prototype\Web-Inf\mdb.pr
> > operties"/>
> > </java>
> >
> >
> > unit test:
> > package cp_test.system;
> >
> > import junit.framework.Assert;
> > import junit.framework.Test;
> > import junit.framework.TestCase;
> > import junit.framework.TestSuite;
> >
> > import criticalpoint.db.DomainConnection;
> > import criticalpoint.db.DomainManager;
> > import criticalpoint.db.ParserDBServices;
> >
> > import criticalpoint.util.TimeMeasurements;
> > import criticalpoint.util.SystemProperties;
> >
> > import criticalpoint.command.query.*;
> >
> > import java.util.Iterator;
> > import java.util.ArrayList;
> > import java.util.Hashtable;
> >
> > import java.io.File;
> > import java.io.IOException;
> >
> >
> > public class TestMiniMetanet extends MultiThreadedTestCase
> > implements TestConstants
> > {
> > ////////////////////////////////////////////////////////////////
> > // CONSTANTS
> > ////////////////////////////////////////////////////////////////
> >
> > ////////////////////////////////////////////////////////////////
> > // INSTANCE DATA
> > ////////////////////////////////////////////////////////////////
> >
> > //useful when no answer file exists to compare against
> > private boolean m_generateBenchmark = false;
> >
> > private ArrayList m_questionList = new ArrayList(500);
> >
> > private int m_numThreads;
> >
> > private String m_postfix1;
> > private String m_postfix2;
> >
> > private String m_benchmarkFileName = null;
> > private String m_outputFileNames = null;
> > private String m_diffFileNames = null;
> > private String m_questionFileName = null;
> > private String m_answerFileName = null;
> >
> > public TimeMeasurements[] timers;
> >
> > private String m_dbName;
> >
> > public static final String REQUIRYSTRING = "requiry".intern();
> >
> > ////////////////////////////////////////////////////////////////
> > // CONSTRUCTOR
> > ////////////////////////////////////////////////////////////////
> > public TestMiniMetanet( String name )
> > {
> >
> > super( name );
> > m_postfix1 = "." + name;
> >
> > SystemProperties.setProperty( SystemProperties.ADD_HEADING,
"true" );
> > }
> >
> > ////////////////////////////////////////////////////////////////
> > // OTHER PUBLIC METHODS
> > ////////////////////////////////////////////////////////////////
> > public void setNumberThreads( int n )
> > {
> > m_numThreads = n;
> > }
> >
> > public void setDbName( String dbName )
> > {
> > m_dbName = dbName;
> > }
> >
> > public void setQuestionFileName( String questionFileName )
> > {
> > m_questionFileName = questionFileName;
> > try {File thisfile=new File("");
> > System.out.println( "THis is the file questionFileName:
> > "+questionFileName );
> > } catch (Exception e){}
> > }
> >
> > public void setAnswerFileName( String answerFileName )
> > {
> > m_benchmarkFileName = answerFileName;
> > }
> >
> > ////////////////////////////////////////////////////////////////
> > // FIXTURE
> > ////////////////////////////////////////////////////////////////
> > protected void setUp() throws IOException
> > {
> > File tempDir = new File( OUTPUTDIRNAME );
> > if( !tempDir.exists() )
> > {
> > tempDir.mkdir();
> > }
> >
> > //m_benchmarkFileName = BENCHMARK + m_postfix1;
> > m_outputFileNames = OUTPUT + m_postfix1;
> > m_diffFileNames = DIFF + m_postfix1;
> > try {File thisfile=new File("");
> > System.out.println( "THis is the file m_questionFileName:
> > "+m_questionFileName );
> > } catch (Exception e){}
> >
> > m_questionList = FileUtil.getListFromFile( m_questionFileName );
> >
> > if( m_questionList.size() == 0 || m_questionList == null )
> > {
> > throw new RuntimeException( "empty question list" );
> > }
> > }
> >
> > protected void tearDown()
> > {
> > if( m_questionList != null )
> > {
> > m_questionList.clear();
> > }
> > }
> >
> > //////////////////////////////////////////////////////////////
> > // INNER CLASS
> > //////////////////////////////////////////////////////////////
> >
> > public void testSubmitQueryMThread()
> > {
> > TestCaseRunnable threads[] = new TestCaseRunnable[ m_numThreads ];
> >
> > TimeMeasurements timers[] = new TimeMeasurements[ m_numThreads ];
> > TimeMeasurements timer = new TimeMeasurements();
> >
> > for ( int i = 0; i < threads.length; i++ )
> > {
> > threads[i] = new SubmitQueryThread();
> > timers[i] = ( (SubmitQueryThread) threads[i]).getTimer();
> > }
> >
> > runTestCaseRunnables(threads);
> >
> > for ( int i = 0; i < threads.length; i++ )
> > {
> > timer.add( timers[i] );
> > System.out.println("THREAD-" + i + ": " + timers[i].toString() );
> > }
> >
> > System.out.println("ALL THREADS: " + timer.toString() );
> >
> > }
> >
> > ////////////////////////////////////////////////////////////////
> > // INDUCTION
> > ////////////////////////////////////////////////////////////////
> >
> > public static void main( String[] args )
> > {
> > /*
> > if( args.length != 4 )
> > {
> > System.out.println( "Usage: DbName, questionfile name,
> > benchmarkfilename and Number of threads" );
> > System.out.println
> > ( "Example: runj cp_test.system.TestMiniMetanet");
> > System.out.print( " minitest QUESTIONFILE_minimetanet
> > ANSWERFILE_minimetanet 1\n");
> >
> > System.exit(0);
> > }
> > */
> > try {File thisfile=new File("");
> > System.out.println( "Trying to get the damn file:
> > "+thisfile.getCanonicalPath() );
> > } catch (Exception e){}
> >
> > TestMiniMetanet test =
> > new TestMiniMetanet("testSubmitQueryMThread");
> >
> > test.setNumberThreads( 1 );
> > test.setDbName( "minitest" );
> > test.setQuestionFileName( "QUESTIONFILE_minimetanet" );
> > test.setAnswerFileName( "ANSWER_minimetanet" );
> >
> > try
> > {
> > junit.textui.TestRunner.run( test );
> > }
> > catch( Throwable t )
> > {
> > System.exit(0);
> > }
> > }
> >
> > //////////////////////////////////////////////////////////////
> > // INNER CLASS
> > //////////////////////////////////////////////////////////////
> > public class SubmitQueryThread extends TestCaseRunnable
> > {
> > private TimeMeasurements m_threadTimer = new TimeMeasurements();
> > private String m_postfix2;
> > private ArrayList m_resultList = new ArrayList(500);
> >
> > public TimeMeasurements getTimer()
> > {
> > return m_threadTimer;
> > }
> >
> > public void runTestCase()
> > throws Exception
> > {
> > m_postfix2 = "." + Thread.currentThread().getName();
> >
> > File file = new File( m_outputFileNames + m_postfix2 );
> > if( file.exists() )
> > {
> > file.delete();
> > }
> > file = new File( m_diffFileNames + m_postfix2 );
> > if( file.exists() )
> > {
> > file.delete();
> > }
> >
> > if( m_resultList != null )
> > {
> > m_resultList.clear();
> > }
> >
> > m_threadTimer.reset();
> >
> > // start generating and submitting queries
> > Iterator it = m_questionList.iterator();
> >
> > DomainConnection connection = null;
> > ParserDBServices dbs = null;
> > StringBuffer buf = new StringBuffer();
> >
> > //sigle out the first query which takes long initialization time
> > boolean isFirstQuery = true;
> >
> > //test whether a time measurement has been ended, so that
> > //when error occurs the timer can be ended in the final block
> > Hashtable timingEnded = new Hashtable();
> > Query oldQuery = null;
> > boolean isRequiry = false;
> > Query query = null;
> >
> > while( it.hasNext() )
> > {
> > connection = DomainManager.connect( m_dbName );
> > dbs = connection.parserDbServices();
> >
> > String question = (String) ( it.next() );
> >
> > int reIndex = 0;
> >
> > if( (reIndex = question.indexOf( REQUIRYSTRING )) >= 0 )
> > {
> > question = question.substring(
reIndex+REQUIRYSTRING.length()+1 );
> > if( oldQuery == null )
> > {
> > throw new RuntimeException("Error: trying to requiry an null
old
> > query"
> > + " for " + question );
> > }
> >
> > isRequiry = true;
> > }
> >
> > buf.append( "<question question=\"" + question + "\"/>\n");
> > if( isRequiry )
> > {
> > buf.append( "<requiry oldSummary=" +
oldQuery.getQuerySummary()
> > + "\"/>\n");
> > }
> >
> > timingEnded.clear();
> >
> > try
> > {
> > timingEnded.put( isFirstQuery?
"createFirstQuery":"createQuery",
> > Boolean.FALSE );
> >
> > m_threadTimer.startMeasurement( (isFirstQuery?
> >
> >
"createFirstQuery":"createQuery") );
> > if( !isRequiry )
> > {
> > query = QueryFunctions.createQuery( connection, question );
> > }
> > else
> > {
> > query = QueryFunctions.refineQuery( connection, oldQuery,
> > question);
> > }
> >
> > m_threadTimer.endMeasurement( (isFirstQuery?
> >
> >
"createFirstQuery":"createQuery") );
> > timingEnded.put( isFirstQuery?
"createFirstQuery":"createQuery",
> > Boolean.TRUE );
> >
> > timingEnded.put( "executeQuery", Boolean.FALSE );
> > m_threadTimer.startMeasurement( "executeQuery" );
> > Iterator results = QueryFunctions.executeQuery( connection,
> > query );
> >
> > if( results.hasNext() )
> > {
> > AppendResultUtil.appendSuccessInfo( buf, query, results );
> > }
> > else
> > {
> > AlternateQuery[] alts = null;
> > if( query.isUsefulSearch(dbs) )
> > {
> > alts = QueryFunctions.generateAlternates( connection,
query );
> > }
> > if( alts == null || alts.length == 0 )
> > {
> > AppendResultUtil.appendFailureInfo( buf );
> > }
> > else if( alts.length == 1 )
> > {
> > AppendResultUtil.appendOneAlternateInfo( buf, alts );
> > }
> > else
> > {
> > AppendResultUtil.appendAlternatesInfo( buf, alts );
> > }
> > }
> >
> > DomainManager.disconnect( connection );
> >
> > m_resultList.add( buf.toString() );
> > m_threadTimer.endMeasurement( "executeQuery" );
> > timingEnded.put( "executeQuery", Boolean.TRUE );
> >
> > oldQuery = query;
> > isRequiry = false;
> > }
> > catch( Exception e )
> > {
> > m_resultList.add( buf.toString() );
> > m_resultList.add( (e.toString()).trim() );
> > }
> > finally
> > {
> > FileUtil.saveListToFile(m_resultList,
> > m_outputFileNames+m_postfix2);
> >
> > int b = buf.length();
> > buf.delete( 0, buf.length() ); //clear stringbuffer for reuse
> >
> > Object o = timingEnded.get(isFirstQuery?
> > "createFirstQuery":"createQuery");
> > if( o != null && !((Boolean)o).booleanValue() )
> > {
> > m_threadTimer.endMeasurement( (isFirstQuery?
> >
"createFirstQuery":"createQuery") );
> > }
> > isFirstQuery = false;
> >
> > o = timingEnded.get("executeQuery");
> > if( o != null && !((Boolean)o).booleanValue() )
> > {
> > m_threadTimer.endMeasurement( "executeQuery" );
> > }
> > }
> > }
> >
> > // start testing
> > assert("\n ERROR in TestMiniMetanet: Diffs are saved in file " +
> > m_diffFileNames,
> > DiffUtil.diffFiles( m_outputFileNames + m_postfix2,
> > m_benchmarkFileName,
> > m_diffFileNames + m_postfix2 ) );
> >
> > System.out.println( m_threadTimer.toString() );
> > }
> > }
> > }
> > ----- Original Message -----
> > From: "Erik Hatcher" <[EMAIL PROTECTED]>
> > To: "Ant Users List" <[EMAIL PROTECTED]>
> > Sent: Thursday, December 27, 2001 1:14 PM
> > Subject: Re: ant/junit & files
> >
> >
> > > Marcus,
> > >
> > > The only way for us to help you is for you to post your test case
code,
> > and
> > > your build.xml snippet that is calling the tests.
> > >
> > > Are you referencing files by full path? Or by relative path? Are
they in
> > > the classpath?
> > >
> > > Erik
> > >
> > > ----- Original Message -----
> > > From: "Marcus" <[EMAIL PROTECTED]>
> > > To: "Ant Users List" <[EMAIL PROTECTED]>
> > > Sent: Thursday, December 27, 2001 4:18 PM
> > > Subject: ant/junit & files
> > >
> > >
> > > Please excuse my ignorance, but I am new to ant and junit.
> > >
> > > My unit test reads a file and outputs a file. my problem is as long as
my
> > > unit tests do not read in or spit out a file
> > > the test unit runs fine. what i get as an error when running with in
ant
> > and
> > > using junit it can't find the file
> > > even thought:
> > > 1) the file is there
> > > 2) i run with java, from line command, and it runs just fine
> > > 3) i run ant.java and it runs fine
> > >
> > > Does anyone know why it can't find the file when using ant/junit but
> > > ant/java works fine?
> > >
> > > Thanks in advance.
> > > -mez
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> > > For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:
<mailto:[EMAIL PROTECTED]>
> > For additional commands, e-mail:
<mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
>
>
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>