Java 8 ErrorManager - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 ErrorManager class.

This code example shows how to use the following methods:error
        System.setErr(err);
        super.tearDown(); 
    } 
 
    public void test_errorStringStringint() { 
        ErrorManager em = new ErrorManager();
        em.error(null, new NullPointerException(), ErrorManager.GENERIC_FAILURE);
        em.error("An error message.", null, ErrorManager.GENERIC_FAILURE);
        em.error(null, null, ErrorManager.GENERIC_FAILURE);
    } 
 
    public void test_constants() { 
        assertEquals(3, ErrorManager.CLOSE_FAILURE);
        assertEquals(2, ErrorManager.FLUSH_FAILURE);
        assertEquals(5, ErrorManager.FORMAT_FAILURE);
        assertEquals(0, ErrorManager.GENERIC_FAILURE);
        assertEquals(4, ErrorManager.OPEN_FAILURE);
        assertEquals(1, ErrorManager.WRITE_FAILURE);
    } 
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:error
        System.setOut(out);
        super.tearDown(); 
    } 
 
    public void test_errorCheck() { 
        ErrorManager em = new ErrorManager();
        MockStream aos = new MockStream();
        PrintStream st = new PrintStream(aos);
        System.setErr(st);
        System.setOut(st);
        em.error("supertest", null, ErrorManager.GENERIC_FAILURE);
        st.flush();
        assertTrue("message appears (supertest)", aos.getWrittenData().indexOf("supertest") != -1);
    } 
 
    public class MockStream extends ByteArrayOutputStream {
 
        private StringBuffer linesWritten = new StringBuffer();
 
        public void flush() {} 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:error
        System.setOut(out);
        super.tearDown(); 
    } 
 
    public void test_errorCheck() { 
        ErrorManager em = new ErrorManager();
        MockStream aos = new MockStream();
        PrintStream st = new PrintStream(aos);
        System.setErr(st);
        System.setOut(st);
        em.error("supertest", null, ErrorManager.GENERIC_FAILURE);
        st.flush();
        assertTrue("message appears (supertest)", aos.getWrittenData().indexOf("supertest") != -1);
    } 
 
    public class MockStream extends ByteArrayOutputStream {
 
        private StringBuffer linesWritten = new StringBuffer();
 
        public void flush() {} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        } else { 
            setFormatter(new SimpleFormatter());
        } 
         
        // Set error manager 
        setErrorManager(new ErrorManager());
         
    } 
 
     
    private String getProperty(String name, String defaultValue) {
        String value = LogManager.getLogManager().getProperty(name);
        if (value == null) {
            value = defaultValue;
        } else { 
            value = value.trim();
        } 
        return value;
    } 
     
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        } else { 
            setFormatter(new SimpleFormatter());
        } 
         
        // Set error manager 
        setErrorManager(new ErrorManager());
         
    } 
 
     
    private String getProperty(String name, String defaultValue) {
        String value = LogManager.getLogManager().getProperty(name);
        if (value == null) {
            value = defaultValue;
        } else { 
            value = value.trim();
        } 
        return value;
    } 
     
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
		} catch (NullPointerException e) {
		} 
 
		// test reset null 
		try { 
			h.setErrorManager(new ErrorManager());
			h.setErrorManager(null);
			fail("Should throw NullPointerException!");
		} catch (NullPointerException e) {
		} 
	} 
 
	/* 
	 * Test getFilter & setFilter methods with non-null value. 
	 */ 
	public void testGetSetFilter_Normal() throws Exception { 
		MockHandler h = new MockHandler();
		Filter f = new MockFilter();
		h.setFilter(f);
		assertSame(f, h.getFilter());
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
		} catch (NullPointerException e) {
		} 
 
		// test reset null 
		try { 
			h.setErrorManager(new ErrorManager());
			h.setErrorManager(null);
			fail("Should throw NullPointerException!");
		} catch (NullPointerException e) {
		} 
	} 
 
	/* 
	 * Test getErrorManager with insufficient privilege. 
	 */ 
	public void testGetErrorManager_InsufficientPrivilege() throws Exception { 
		MockHandler h = new MockHandler();
		SecurityManager oldMan = System.getSecurityManager();
		System.setSecurityManager(new MockSecurityManager());
 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
        } else { 
            setFormatter(new SimpleFormatter());
        } 
 
        // Set error manager 
        setErrorManager(new ErrorManager());
 
    } 
 
 
    private String getProperty(final String name, final String defaultValue) {
        String value = LogManager.getLogManager().getProperty(name);
        if (value == null) {
            value = defaultValue;
        } else { 
            value = value.trim();
        } 
        return value;
    } 
 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 ErrorManager Methods: