ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan.Mate...@rzf.fin-nrw.de
Subject Class.forName() in test environment
Date Thu, 08 Jul 2004 12:43:47 GMT
I´ve added the capability to specify a class which the <modified> selector
should load as cache|algorithm|comparator. Test passed.

BUT

I have to add "-lib build\testcases" for running the tests, otherwise
the selector wont find a mock class which resides in the test package.

A first view into the build.xml seems to add the test classes (and sources)
to the classpath, but it doesnt ...

Has someone an idea?


Jan



src/main/.../selectors/modfiedselector
    ModifiedSelector.java:   Object rv =
Class.forName(classname).newInstance();

src/testcases/.../selectors/
    ModifiedSelectorTest.java: 
        String algo =
getAlgoName("org.apache.tools.ant.types.selectors.MockAlgorithm");
        ...
        private String getAlgoName(String classname) {
            ModifiedSelector sel = new ModifiedSelector();
            sel.setAlgorithmClass(classname);
            // let the selector do its checks
            sel.validate();
            String s1 = sel.toString();
            int posStart = s1.indexOf("algorithm=") + 10;
            int posEnd   = s1.indexOf(" comparator=");
            String algo  = s1.substring(posStart, posEnd);
            ...
            return algo;
        }

    MockAlgorithm.java
    MockCache.java
    MockComparator.java

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message