Examples of LogFactory


Examples of org.apache.commons.logging.LogFactory

     * Don't forget to set the context classloader to whatever it will be
     * when an instance of this class is actually created <i>before</i> calling
     * this method!
     */
    public static void setAllowFlawedContext(String state) {
        LogFactory f = LogFactory.getFactory();
        f.setAttribute(LogFactoryImpl.ALLOW_FLAWED_CONTEXT_PROPERTY, state);
    }
View Full Code Here

Examples of org.apache.commons.logging.LogFactory

     * TCCL, and we've use a commons-logging.properties that disables TCCL loading,
     * we should see the default LogFactoryImpl rather than the custom one.
     */
    public void testTcclLoading() throws Exception {
        try {
            LogFactory instance = LogFactory.getFactory();
            fail("Unexpectedly succeeded in loading custom factory, though TCCL disabled.");
        } catch(org.apache.commons.logging.LogConfigurationException ex) {
            // ok, custom MyLogFactoryImpl as specified in props_disable_tccl
            // could not be found.
            int index = ex.getMessage().indexOf(MY_LOG_FACTORY_IMPL);
View Full Code Here

Examples of org.apache.commons.logging.LogFactory

     * via the TCCL has NOT been loaded. Because this is only accessable via the
     * TCCL, and we've use a commons-logging.properties that disables TCCL loading,
     * we should see the default Log rather than the custom one.
     */
    public void testTcclLoading() throws Exception {
        LogFactory instance = LogFactory.getFactory();
        assertEquals(
                "Correct LogFactory loaded",
                "org.apache.commons.logging.impl.LogFactoryImpl",
                instance.getClass().getName());

        try {
            Log log = instance.getLog("test");
            fail("Unexpectedly succeeded in loading a custom Log class"
                + " that is only accessable via the tccl.");
        } catch(LogConfigurationException ex) {
            // ok, expected
            int index = ex.getMessage().indexOf(MY_LOG_IMPL);
View Full Code Here

Examples of org.apache.commons.logging.LogFactory

     * Verify that the custom LogFactory implementation which is only accessable
     * via the TCCL has successfully been loaded as specified in the config file.
     * This proves that the TCCL was used to load that class.
     */
    public void testTcclLoading() throws Exception {
        LogFactory instance = LogFactory.getFactory();
       
        assertEquals(
            "Correct LogFactory loaded",
            "org.apache.commons.logging.tccl.custom.MyLogFactoryImpl",
            instance.getClass().getName());
    }
View Full Code Here

Examples of org.apache.commons.logging.LogFactory

    /**
     * Test that a LogFactory gets created as expected.
     */
    public void testCreateFactory() {
        LogFactory factory = LogFactory.getFactory();
        assertNotNull("LogFactory exists", factory);
        assertEquals("LogFactory class",
                     "org.apache.commons.logging.impl.LogFactoryImpl",
                     factory.getClass().getName());

        String names[] = factory.getAttributeNames();
        assertNotNull("Names exists", names);
        assertEquals("Names empty", 0, names.length);
    }
View Full Code Here

Examples of org.apache.commons.logging.LogFactory

     * Verify that the custom Log implementation which is only accessable
     * via the TCCL has successfully been loaded as specified in the config file.
     * This proves that the TCCL was used to load that class.
     */
    public void testTcclLoading() throws Exception {
        LogFactory instance = LogFactory.getFactory();
       
        assertEquals(
            "Correct LogFactory loaded",
            "org.apache.commons.logging.impl.LogFactoryImpl",
            instance.getClass().getName());

        Log log = instance.getLog("test");
        assertEquals(
            "Correct Log loaded",
            MY_LOG_IMPL,
            log.getClass().getName());
    }
View Full Code Here

Examples of org.apache.commons.logging.LogFactory

    /**
     * Verify that the config file being used is the one containing
     * the desired configId value.
     */
    public void testPriority() throws Exception {
        LogFactory instance = LogFactory.getFactory();
        String id = (String) instance.getAttribute("configId");
        assertEquals("Correct config file loaded", "priority20", id );
    }
View Full Code Here

Examples of org.apache.commons.logging.LogFactory

    /**
     * Verify that the config file being used is the one containing
     * the desired configId value.
     */
    public void testPriority() throws Exception {
        LogFactory instance = LogFactory.getFactory();
        String id = (String) instance.getAttribute("configId");
        assertEquals("Correct config file loaded", "priority20", id );
    }
View Full Code Here

Examples of org.apache.commons.logging.LogFactory

     * Verify that the custom LogFactory implementation which is only accessable
     * via the TCCL has successfully been loaded as specified in the config file.
     * This proves that the TCCL was used to load that class.
     */
    public void testTcclLoading() throws Exception {
        LogFactory instance = LogFactory.getFactory();
       
        assertEquals(
            "Correct LogFactory loaded",
            "org.apache.commons.logging.tccl.custom.MyLogFactoryImpl",
            instance.getClass().getName());
    }
View Full Code Here

Examples of org.apache.commons.logging.LogFactory

    /**
     * Verify that the config file being used is the one containing
     * the desired configId value.
     */
    public void testPriority() throws Exception {
        LogFactory instance = LogFactory.getFactory();

        ClassLoader thisClassLoader = this.getClass().getClassLoader();
        ClassLoader lfClassLoader = instance.getClass().getClassLoader();
        ClassLoader contextClassLoader = Thread.currentThread().getContextClassLoader();

        // context classloader should be thisClassLoader
        assertEquals(thisClassLoader, contextClassLoader);
       
        // lfClassLoader should be parent of this classloader
        assertEquals(lfClassLoader, thisClassLoader.getParent());
        assertEquals(PathableClassLoader.class.getName(),
                lfClassLoader.getClass().getName());

        String id = (String) instance.getAttribute("configId");
        assertEquals("Correct config file loaded", "priority20", id );
    }
View Full Code Here
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.