public void testExceptionHandling() { final ComponentAdapter componentAdapter = new ThreadLocalizing.ThreadLocalized( new ConstructorInjection.ConstructorInjector( TargetInvocationExceptionTester.class, ThrowingComponent.class, null)); final TargetInvocationExceptionTester tester = (TargetInvocationExceptionTester) componentAdapter.getComponentInstance(null, ComponentAdapter.NOTHING.class); try { tester.throwsCheckedException(); fail("ClassNotFoundException expected"); } catch (final ClassNotFoundException e) { assertEquals("junit", e.getMessage()); } try { tester.throwsRuntimeException(); fail("RuntimeException expected"); } catch (final RuntimeException e) { assertEquals("junit", e.getMessage()); } try { tester.throwsError(); fail("Error expected"); } catch (final Error e) { assertEquals("junit", e.getMessage()); } }
/** Test of setRect method, of class com.sun.electric.database.geometry.ERectangle. */ @Test public void testSerialization() { try { ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); ObjectOutputStream out = new ObjectOutputStream(byteStream); out.writeObject(rect); out.close(); byte[] serializedRect = byteStream.toByteArray(); ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(serializedRect)); ERectangle r = (ERectangle) in.readObject(); in.close(); assertEquals(rect, r); } catch (IOException e) { fail(e.getMessage()); } catch (ClassNotFoundException e) { fail(e.getMessage()); } }