Package org.jostraca.util.test

Source Code of org.jostraca.util.test.BuildResourceTest

/*
* Name:    BuildResourceTest
* Author:  Richard Rodger
*
* Copyright (c) 2002-2003 Richard Rodger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*
*/


// package
package org.jostraca.util.test;


// import
import org.jostraca.util.RootBuildResource;
import org.jostraca.util.FileBuildResource;

import junit.framework.TestCase;
import junit.framework.TestSuite;
import junit.textui.TestRunner;

import java.io.File;


/** Test cases for BuildResource
*/
public class BuildResourceTest extends TestCase {

  // test framework

  public BuildResourceTest( String pName ) {
    super( pName );
  }

  public static TestSuite suite() {
    return new TestSuite( BuildResourceTest.class );
  }

  public static void main( String[] pArgs ) {
    TestRunner.run( suite() );
  }




  // public methods

  public void testToString() throws Exception {
   
    RootBuildResource root = new RootBuildResource();
    System.out.println( root.toString() );
    System.out.println( "\n-1--\n" );
   
    RootBuildResource subroot = new RootBuildResource();
    root.add( subroot );
    System.out.println( root.toString() );
    System.out.println( "\n-2--\n" );

    FileBuildResource fbr01 = new FileBuildResource( new File("a"), new File("b") );
    System.out.println( fbr01 );
    System.out.println( "\n-3--\n" );

    root.add( fbr01 );
    root.add( fbr01 );
    System.out.println( root.toString() );
    System.out.println( "\n-4--\n" );

    FileBuildResource fbr02 = new FileBuildResource( new File("c"), new File("d") );
    subroot.add( fbr02 );
    System.out.println( root.toString() );
    System.out.println( "\n-5--\n" );

  }



  public void testUptodate() throws Exception {
   
    RootBuildResource root = new RootBuildResource();
    assertTrue( root.uptodate() );
    System.out.println( root.toStringStatus() );   
    System.out.println( "\n---\n" );

    RootBuildResource subroot = new RootBuildResource();
    root.add( subroot );
    assertTrue( root.uptodate() );
    System.out.println( root.toStringStatus() );   
    System.out.println( "\n---\n" );

    RootBuildResource br01 = new RootBuildResource( true );
    root.add( br01 );
    assertTrue( root.uptodate() );
    System.out.println( root.toStringStatus() );   
    System.out.println( "\n---\n" );

    RootBuildResource br02 = new RootBuildResource( false );
    subroot.add( br02 );
    assertTrue( !root.uptodate() );
    System.out.println( root.toStringStatus() );   
    System.out.println( "\n---\n" );

    System.out.println( root.toStringStatus() );
  }


  public void testFileBuildResource() throws Exception {

    File a = File.createTempFile( "jostraca-test-", ".tmp" );
    try { Thread.sleep( 2000 ); } catch( Exception e ) {}
    File b = File.createTempFile( "jostraca-test-", ".tmp" );
    File c = new File( "this-file-does-not-exist" );

    FileBuildResource fbr = new FileBuildResource( a, b );
    assertTrue( fbr.uptodate() );

    fbr = new FileBuildResource( b, a );
    assertTrue( !fbr.uptodate() );

    fbr = new FileBuildResource( a, c );
    assertTrue( !fbr.uptodate() );

    fbr = new FileBuildResource( c, a );
    assertTrue( !fbr.uptodate() );

    fbr = new FileBuildResource( c, c );
    assertTrue( !fbr.uptodate() );
  }


  /* Public Methods >> */

}
 
TOP

Related Classes of org.jostraca.util.test.BuildResourceTest

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.