Package org.picocontainer

Examples of org.picocontainer.PicoException


            assertTrue(set.contains(Throwable.class));
        }
        pico = new DefaultPicoContainer();
        pico.registerComponentInstance(THROWABLE);
        try {
            final PicoException exception = (PicoException) componentAdapter.getComponentInstance(pico);
            assertSame(THROWABLE, exception.getCause());
        } catch (final UnsatisfiableDependenciesException ex) {
            final Set set = new HashSet();
            for (final Iterator iter = ex.getUnsatisfiableDependencies().iterator(); iter.hasNext();) {
                final List list = (List) iter.next();
                set.addAll(list);
            }
            assertTrue(set.contains(String.class));
        }
        pico.registerComponentInstance(MESSAGE);
        final PicoException exception = (PicoException) componentAdapter.getComponentInstance(pico);
        assertEquals(MESSAGE, exception.getMessage());
        assertSame(THROWABLE, exception.getCause());
    }
View Full Code Here


        assertSame(String.class, classes[1]);
        assertTrue(cdEx.getMessage().indexOf(getClass().getName()) >= 0);
    }

    public void testPrintStackTrace() throws IOException {
        PicoException nestedException = new PicoException("Outer", new Exception("Inner")) {
        };
        PicoException simpleException = new PicoException("Outer") {
        };
        ByteArrayOutputStream out = new ByteArrayOutputStream();
        PrintStream printStream = new PrintStream(out);
        nestedException.printStackTrace(printStream);
        simpleException.printStackTrace(printStream);
        out.close();
        assertTrue(out.toString().indexOf("Caused by:") > 0);
        out = new ByteArrayOutputStream();
        PrintWriter writer = new PrintWriter(out);
        nestedException.printStackTrace(writer);
        simpleException.printStackTrace(writer);
        writer.flush();
        out.close();
        assertTrue(out.toString().indexOf("Caused by:") > 0);
    }
View Full Code Here

        for (Iterator iter = invocations.iterator(); iter.hasNext();) {
            Invocation invocation = (Invocation) iter.next();
            try {
                invocation.invoke(target);
            } catch (IllegalAccessException e) {
                throw new PicoException(e) {
                };
            } catch (InvocationTargetException e) {
                throw new PicoException(e) {
                };
            }
        }
    }
View Full Code Here

TOP

Related Classes of org.picocontainer.PicoException

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.