log.setValue( logProperties.toURL().toString() );
URI logPropertiesURI = logProperties.toURI(); String logPropertiesSpec = logPropertiesURI.toString(); log.setValue( logPropertiesSpec );
    private void executeUnitTests( final File src, final Path classpath, File working )    {        final Project project = getProject();        log( "Test classpath: " + classpath, Project.MSG_VERBOSE );        final FileSet fileset = createFileSet( src );        final JUnitTask junit = (JUnitTask) project.createTask( "junit" );        junit.setTaskName( getTaskName() );                final JUnitTask.SummaryAttribute summary = getSummaryAttribute();        junit.setPrintsummary( summary );                junit.setShowOutput( true );        junit.setTempdir( working );        junit.setReloading( true );        junit.setFiltertrace( true );                junit.createClasspath().add( classpath );                Context context = getContext();        String verbose = getVerboseArgument();        if( null != verbose )        {            Commandline.Argument arg = junit.createJvmarg();            arg.setValue( "-verbose:" + verbose );        }                    final File reports = getContext().getTargetReportsTestDirectory();        mkDir( reports );        final BatchTest batch = junit.createBatchTest();        batch.addFileSet( fileset );        batch.setTodir( reports );        final FormatterElement plain = newConfiguredFormatter( "plain" );        junit.addFormatter( plain );                final FormatterElement xml = newConfiguredFormatter( "xml" );        junit.addFormatter( xml );                final Environment.Variable work = new Environment.Variable();        work.setKey( WORK_DIR_KEY );        work.setValue( working.toString() );        junit.addConfiguredSysproperty( work );        final Environment.Variable testBaseDir = new Environment.Variable();        testBaseDir.setKey( "project.test.dir" );        testBaseDir.setValue( working.toString() );        junit.addConfiguredSysproperty( testBaseDir );                final Environment.Variable targetDir = new Environment.Variable();        targetDir.setKey( "project.target.dir" );        targetDir.setValue( getContext().getTargetDirectory().toString() );        junit.addConfiguredSysproperty( targetDir );        final Environment.Variable deliverablesDir = new Environment.Variable();        deliverablesDir.setKey( "project.target.deliverables.dir" );        deliverablesDir.setValue( getContext().getTargetDeliverablesDirectory().toString() );        junit.addConfiguredSysproperty( deliverablesDir );        final Environment.Variable basedir = new Environment.Variable();        basedir.setKey( "basedir" );        basedir.setValue( project.getBaseDir().toString() );        junit.addConfiguredSysproperty( basedir );        final Environment.Variable basedir2 = new Environment.Variable();        basedir2.setKey( "project.basedir" );        basedir2.setValue( project.getBaseDir().toString() );        junit.addConfiguredSysproperty( basedir2 );        final Environment.Variable cache = new Environment.Variable();        cache.setKey( CACHE_PATH_KEY );        cache.setValue( getCachePath() );        junit.addConfiguredSysproperty( cache );        final File policy = new File( working, "security.policy" );        if( policy.exists() )        {            final Environment.Variable security = new Environment.Variable();            security.setKey( "java.security.policy" );            security.setValue( policy.toString() );            junit.addConfiguredSysproperty( security );        }        setupTestProperties( junit, project );                final File logProperties = new File( working, "logging.properties" );        if( logProperties.exists() )        {            final Environment.Variable log = new Environment.Variable();            log.setKey( "dpml.logging.config" );            try            {                log.setValue( logProperties.toURL().toString() );            }            catch( IOException e )            {                final String error =                   "Unexpected file to url error."                  + "\nFile: " + logProperties;                throw new BuildException( error, e );            }            junit.addConfiguredSysproperty( log );        }                String formatter = getResource().getProperty( "java.util.logging.config.class" );        if( null != formatter )        {            final Environment.Variable logging = new Environment.Variable();            logging.setKey( "java.util.logging.config.class" );            if( "dpml".equals( formatter ) )            {                logging.setValue( "net.dpml.util.ConfigurationHandler" );            }            else            {                logging.setValue( formatter );            }            junit.addConfiguredSysproperty( logging );        }                final Environment.Variable endorsed = new Environment.Variable();        endorsed.setKey( "java.endorsed.dirs" );        endorsed.setValue( new File( Transit.DPML_SYSTEM, "lib/endorsed" ).getAbsolutePath() );        junit.addConfiguredSysproperty( endorsed );                configureDeliverableSysProperties( junit );        configureForExecution( junit );                junit.setErrorProperty( ERROR_KEY );        junit.setFailureProperty( FAILURE_KEY );        final boolean haltOnErrorPolicy = getHaltOnErrorPolicy();        if( haltOnErrorPolicy )        {            junit.setHaltonerror( true );        }        final boolean haltOnFailurePolicy = getHaltOnFailurePolicy();        if( haltOnFailurePolicy )        {            junit.setHaltonfailure( true );        }                junit.init();        junit.execute();    }