Sophie

Sophie

distrib > Mageia > 2 > i586 > by-pkgid > 3690ad4682dcf5f350914c33ff2c3da4 > files > 2

ccl-util-manual-32.69-1.mga2.noarch.rpm

<html>
    <head>
        <title>InitTest</title>
    </head>
    <body>
        <br>&nbsp;</br>
        <CENTER>
            <H1>InitTest</H1>
        </CENTER>
        <BR>
        <CENTER>
            <B>
                <FONT FACE="Arial,Helvetica">Chr. Clemens Lee</FONT>
            </B>
            <br>&nbsp;</br>
            <B>2000-11-21</B>
        </CENTER>
        <P>
        </P>
        <BR>
        <h2>Abstract</h2>

    This document contains the documentation and source code
    of the ccl java class
    <a href="../src/ccl/util/test/InitTest.java">ccl.util.test.InitTest</a>.
  
        <a name="toc"></a><h2>Table of Contents</h2>
            <a href="#section1">1&nbsp;&nbsp;&nbsp;InitTest</a><br />
&nbsp;&nbsp;&nbsp;&nbsp;<a href="#subsection1_1">1.1&nbsp;&nbsp;&nbsp;Test for project under classes directory</a><br />
<a href="#links">Links</a>
        <br><a name="section1"></a><a href="#toc"><h2>1&nbsp;&nbsp;&nbsp;InitTest</h2></a>

    


    <a name="subsection1_1"></a><a href="#toc"><h3>1.1&nbsp;&nbsp;&nbsp;Test for project under classes directory</h3></a>

      We want to setup a test where we can check if projects
      installed under directories with name "classes" are
      working.<p>

      For this we need to create a classes directory inside
      a temporary directory and inside of this a "inittest"
      directory. When the test has been finished all temporary
      directories will be removed together with the files
      underneath these directories.

      <p>In this temporary directory we copy over the ccl.jar
      file to classes/ccl9.26/lib/ccl.jar. We also need to
      be able to alter the classpath so that this jar file
      is the first item in the classpath init uses.

      <p>The output we expect from Init.getApplicationPath()
      is the path to the
      temporary file (.../classes/ccl9.26/). The question is
      what input we have to provide for this test.

      <div style="border:1px black solid; margin:10px; padding:10px">
            <pre>
    private void _testGetApplicationPath( String sRCSHeader_ ) 
        throws IOException
    {
        String sTempDir = FileUtil.createTempDir();
        String sAppDir = FileUtil.concatPath( sTempDir
                                              , "classes"
                                                + File.separator
                                                + "ccl9.26"      );
        String sTempJar = FileUtil.concatPath( sAppDir
                                               , "lib"  );
        FileUtil.md( sTempJar );

        // locate and copy ccl.jar
        String sOrigJar = _init.getApplicationPath();
        sOrigJar = FileUtil.concatPath( sOrigJar
                                        , "lib"
                                          + File.separator
                                          + "ccl.jar"      );
        sTempJar = sTempJar + File.separator + "inittest.jar";
        FileUtil.copy( sOrigJar, sTempJar );

        // alter classpath temporarily
        String sOrigClasspath = System.getProperty( "java.class.path" );
        String sTempClasspath = sTempJar + File.pathSeparator + sOrigClasspath;
        System.setProperty( "java.class.path", sTempClasspath );

        // create new Init object
        Init init = new Init( this, null, sRCSHeader_ );
        assert( init.getApplicationName().equals( "InitTest" )
                , "Application name should be 'Inittest' but is '" + init.getApplicationName() + "'!" );
        assert( FileUtil.equalsPath( init.getApplicationPath()
                                      , sAppDir               )
                , "Application path should be '" + sAppDir + "' but is '" + init.getApplicationPath() + "'!" );

        System.setProperty( "java.class.path", sOrigClasspath );

        FileUtil.deleteRecursively( sTempDir );
    }
</pre>
        </div>

    

  <a name="links"></a>
        <h2>Links</h2>
        <table>
            <tr>
                <td>ccl.util.test.InitTest: &nbsp;</td><td><a href="../src/ccl/util/test/InitTest.java">../src/ccl/util/test/InitTest.java</a></td>
            </tr>
            <tr>
                <td>Clemens' Java Page: &nbsp;</td><td><a href="http://www.kclee.com/clemens/">http://www.kclee.com/clemens/java/</a></td>
            </tr>
            <tr>
                <td>Clemens' Home Page: &nbsp;</td><td><a href="http://www.kclee.com/clemens/">http://www.kclee.com/clemens/</a></td>
            </tr>
        </table>
        <p>
        </p>
        <hr>
        <i><a href="mailto:clemens@kclee.com">clemens@kclee.com</a></i>,&nbsp;&nbsp;&nbsp;&nbsp;last revised: &nbsp;&nbsp;$date: $</body>
</html>