Package org.apache.james.jspf.core

Examples of org.apache.james.jspf.core.Logger


    }

    private void verifyResult(String testName, SPFResult res) {
        String resultSPF = res.getResult();
        HashMap currentTest = (HashMap) data.getTests().get(testName);
        Logger testLogger = log.getChildLogger(testName+"-verify");
        if (currentTest.get("result") instanceof String) {
            assertEquals("Test "+testName+" ("+currentTest.get("description")+") failed. Returned: "+resultSPF+" Expected: "+currentTest.get("result")+" [["+resultSPF+"||"+res.getHeaderText()+"]]", currentTest.get("result"), resultSPF);
        } else {
            ArrayList results = (ArrayList) currentTest.get("result");
            boolean match = false;
            for (int i = 0; i < results.size(); i++) {
                if (results.get(i).equals(resultSPF)) match = true;
                // testLogger.debug("checking "+resultSPF+" against allowed result "+results.get(i));
            }
            assertTrue("Test "+testName+" ("+currentTest.get("description")+") failed. Returned: "+resultSPF+" Expected: "+results, match);
        }
       
        if (currentTest.get("explanation") != null) {
           
            // Check for our default explanation!
            if (currentTest.get("explanation").equals("DEFAULT")) {
                assertTrue(res.getExplanation().startsWith("http://www.openspf.org/why.html?sender="));
            } else if (currentTest.get("explanation").equals("cafe:babe::1 is queried as 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.E.B.A.B.E.F.A.C.ip6.arpa")) {
                // See http://java.sun.com/j2se/1.4.2/docs/api/java/net/Inet6Address.html   
                // For methods that return a textual representation as output value, the full form is used.
                // Inet6Address will return the full form because it is unambiguous when used in combination with other textual data.
                assertTrue(res.getExplanation().equals("cafe:babe:0:0:0:0:0:1 is queried as 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.E.B.A.B.E.F.A.C.ip6.arpa"));
            } else {
                assertEquals(currentTest.get("explanation"),res.getExplanation());
            }
   
        }
   
        testLogger.info("PASSED. Result="+resultSPF+" Explanation="+res.getExplanation()+" Header="+res.getHeaderText());
    }
View Full Code Here


     *
     * @param args
     * @throws Throwable
     */
    public static void main(String[] args) throws Throwable {
        Logger l = new Log4JLogger(org.apache.log4j.Logger.getLogger("ROOT"));

        List tests = SPFYamlTestDescriptor.loadTests(YAMLFILE2);
        Iterator i = tests.iterator();
        while (i.hasNext()) {
            SPFYamlTestDescriptor o = (SPFYamlTestDescriptor) i.next();
View Full Code Here

     *
     * @param args
     * @throws Throwable
     */
    public static void main(String[] args) throws Throwable {
        Logger l = new Log4JLogger(org.apache.log4j.Logger.getLogger("ROOT"));

        List tests = SPFYamlTestDescriptor.loadTests(YAMLFILE2);
        Iterator i = tests.iterator();
        while (i.hasNext()) {
            SPFYamlTestDescriptor o = (SPFYamlTestDescriptor) i.next();
View Full Code Here

     *
     * @param args
     * @throws Throwable
     */
    public static void main(String[] args) throws Throwable {
        Logger l = new Log4JLogger(org.apache.log4j.Logger.getLogger("ROOT"));

        List tests = loadTests(YAMLFILE2);
        Iterator i = tests.iterator();
        while (i.hasNext()) {
            SPFYamlTestSuite o = (SPFYamlTestSuite) i.next();
View Full Code Here

     *
     * @param args
     * @throws Throwable
     */
    public static void main(String[] args) throws Throwable {
        Logger l = new Log4JLogger(org.apache.log4j.Logger.getLogger("ROOT"));

        List tests = loadTests(YAMLFILE2);
        Iterator i = tests.iterator();
        while (i.hasNext()) {
            SPFYamlTestSuite o = (SPFYamlTestSuite) i.next();
View Full Code Here

       
    }

    private SPFResult runSingleTest(String testName) {
        HashMap currentTest = (HashMap) data.getTests().get(testName);
        Logger testLogger = log.getChildLogger(testName);
        testLogger.info("TESTING "+testName+": "+currentTest.get("description"));

        String ip = null;
        String sender = null;
        String helo = null;
   
View Full Code Here

    }

    private void verifyResult(String testName, SPFResult res) {
        String resultSPF = res.getResult();
        HashMap currentTest = (HashMap) data.getTests().get(testName);
        Logger testLogger = log.getChildLogger(testName+"-verify");
        if (currentTest.get("result") instanceof String) {
            assertEquals("Test "+testName+" ("+currentTest.get("description")+") failed. Returned: "+res.getResult()+" Expected: "+currentTest.get("result")+" [["+res.getResult()+"||"+res.getHeaderText()+"]]", currentTest.get("result"), res.getResult());
        } else {
            ArrayList results = (ArrayList) currentTest.get("result");
            boolean match = false;
            for (int i = 0; i < results.size(); i++) {
                if (results.get(i).equals(resultSPF)) match = true;
                // testLogger.debug("checking "+resultSPF+" against allowed result "+results.get(i));
            }
            assertTrue(match);
        }
       
        if (currentTest.get("explanation") != null) {
           
            // Check for our default explanation!
            if (currentTest.get("explanation").equals("DEFAULT") || currentTest.get("explanation").equals("postmaster") ) {
                assertTrue(res.getExplanation().startsWith("http://www.openspf.org/why.html?sender="));
            } else if (currentTest.get("explanation").equals("cafe:babe::1 is queried as 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.E.B.A.B.E.F.A.C.ip6.arpa")) {
                // See http://java.sun.com/j2se/1.4.2/docs/api/java/net/Inet6Address.html   
                // For methods that return a textual representation as output value, the full form is used.
                // Inet6Address will return the full form because it is unambiguous when used in combination with other textual data.
                assertTrue(res.getExplanation().equals("cafe:babe:0:0:0:0:0:1 is queried as 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.E.B.A.B.E.F.A.C.ip6.arpa"));
            } else {
                assertEquals(currentTest.get("explanation"),res.getExplanation());
            }
   
        }
   
        testLogger.info("PASSED. Result="+res.getResult()+" Explanation="+res.getExplanation()+" Header="+res.getHeaderText());
    }
View Full Code Here

TOP

Related Classes of org.apache.james.jspf.core.Logger

Copyright © 2018 www.massapicom. 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.