Package com.cedarsolutions.shared.domain

Examples of com.cedarsolutions.shared.domain.LocalizableMessage


    }

    /** Test assertSummary(). */
    @Test public void testAssertSummary() {
        ValidationErrors details1 = new ValidationErrors();
        details1.setSummary(new LocalizableMessage("key1", null, null));
        InvalidDataException e1 = new InvalidDataException("message1", details1);

        ValidationErrors details2 = new ValidationErrors();
        details2.setSummary(new LocalizableMessage("key2", "context2", null));
        InvalidDataException e2 = new InvalidDataException("message2", details2);

        assertSummary(e1, "key1");
        assertSummary(e1, "key1", null);
        assertSummary(e2, "key2", "context2");
View Full Code Here


    /** Test createServiceException. */
    @Test public void testCreateServiceException() {
        Throwable nested = new IllegalAccessException("nested");
        Throwable cause1 = new Exception("cause1");
        Throwable cause2 = new Exception("cause2", nested);
        LocalizableMessage message = new LocalizableMessage("whatever");

        try {
            throw ServiceExceptionUtils.createServiceException();
        } catch (ServiceException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(null, e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), (String) null);
            assertNull(e.getCause());
            assertNotNull(e.getContext());
            assertNull(e.getContext().getRootCause());
        }

        try {
            throw ServiceExceptionUtils.createServiceException("error");
        } catch (ServiceException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertNull(e.getCause());
            assertNotNull(e.getContext());
            assertNull(e.getContext().getRootCause());
        }

        try {
            throw ServiceExceptionUtils.createServiceException(message);
        } catch (ServiceException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertNull(e.getCause());
            assertNotNull(e.getContext());
            assertNull(e.getContext().getRootCause());
        }

        try {
            throw ServiceExceptionUtils.createServiceException("error", cause1);
        } catch (ServiceException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertSame(cause1, e.getCause());
            assertNotNull(e.getContext());
            assertNotNull(e.getContext().getRootCause());
        }

        try {
            throw ServiceExceptionUtils.createServiceException(message, cause1);
        } catch (ServiceException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertSame(cause1, e.getCause());
            assertNotNull(e.getContext());
            assertNotNull(e.getContext().getRootCause());
        }

        try {
            throw ServiceExceptionUtils.createServiceException("error", cause2);
        } catch (ServiceException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertSame(cause2, e.getCause());
            assertNotNull(e.getContext());
            assertNotNull(e.getContext().getRootCause());
        }

        try {
            throw ServiceExceptionUtils.createServiceException(message, cause2);
        } catch (ServiceException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertSame(cause2, e.getCause());
            assertNotNull(e.getContext());
            assertNotNull(e.getContext().getRootCause());
        }
View Full Code Here

    public CedarRuntimeException(String message) {
        this(message, null);
    }

    public CedarRuntimeException(String message, Throwable cause) {
        this(new LocalizableMessage(message), cause);
    }
View Full Code Here

    public CedarException(String message) {
        this(message, null);
    }

    public CedarException(String message, Throwable cause) {
        this(new LocalizableMessage(message), cause);
    }
View Full Code Here

    }

    /** Test DaoException. */
    @Test public void testDaoException() {
        Throwable cause = new Exception("cause");
        LocalizableMessage message = new LocalizableMessage("whatever");

        try {
            throw new DaoException();
        } catch (CedarRuntimeException e) {
            assertEquals(null, e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), (String) null);
            assertNull(e.getCause());
        }

        try {
            throw new DaoException("error");
        } catch (CedarRuntimeException e) {
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertNull(e.getCause());
        }

        try {
            throw new DaoException(message);
        } catch (CedarRuntimeException e) {
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertNull(e.getCause());
        }

        try {
            throw new DaoException("error", cause);
        } catch (CedarRuntimeException e) {
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertSame(cause, e.getCause());
        }

        try {
            throw new DaoException(message, cause);
        } catch (CedarRuntimeException e) {
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertSame(cause, e.getCause());
        }
    }
View Full Code Here

    }

    /** Test EnumException. */
    @Test public void testEnumException() {
        Throwable cause = new Exception("cause");
        LocalizableMessage message = new LocalizableMessage("whatever");

        try {
            throw new EnumException();
        } catch (EnumException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(null, e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), (String) null);
            assertNull(e.getCause());
        }

        try {
            throw new EnumException("error");
        } catch (EnumException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertNull(e.getCause());
        }

        try {
            throw new EnumException(message);
        } catch (EnumException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertNull(e.getCause());
        }

        try {
            throw new EnumException("error", cause);
        } catch (EnumException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertSame(cause, e.getCause());
        }

        try {
            throw new EnumException(message, cause);
        } catch (EnumException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertSame(cause, e.getCause());
        }
    }
View Full Code Here

    }

    /** Test NotConfiguredException. */
    @Test public void testNotConfiguredException() {
        Throwable cause = new Exception("cause");
        LocalizableMessage message = new LocalizableMessage("whatever");

        try {
            throw new NotConfiguredException();
        } catch (NotConfiguredException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(null, e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), (String) null);
            assertNull(e.getCause());
        }

        try {
            throw new NotConfiguredException("error");
        } catch (NotConfiguredException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertNull(e.getCause());
        }

        try {
            throw new NotConfiguredException(message);
        } catch (NotConfiguredException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertNull(e.getCause());
        }

        try {
            throw new NotConfiguredException("error", cause);
        } catch (NotConfiguredException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertSame(cause, e.getCause());
        }

        try {
            throw new NotConfiguredException(message, cause);
        } catch (NotConfiguredException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertSame(cause, e.getCause());
        }
    }
View Full Code Here

    }

    /** Test NotFoundException. */
    @Test public void testNotFoundException() {
        Throwable cause = new Exception("cause");
        LocalizableMessage message = new LocalizableMessage("whatever");

        try {
            throw new NotFoundException();
        } catch (NotFoundException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(null, e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), (String) null);
            assertNull(e.getCause());
        }

        try {
            throw new NotFoundException("error");
        } catch (NotFoundException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertNull(e.getCause());
        }

        try {
            throw new NotFoundException(message);
        } catch (NotFoundException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertNull(e.getCause());
        }

        try {
            throw new NotFoundException("error", cause);
        } catch (NotFoundException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertSame(cause, e.getCause());
        }

        try {
            throw new NotFoundException(message, cause);
        } catch (NotFoundException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertSame(cause, e.getCause());
        }
    }
View Full Code Here

    }

    /** Test NotImplementedException. */
    @Test public void testNotImplementedException() {
        Throwable cause = new Exception("cause");
        LocalizableMessage message = new LocalizableMessage("whatever");

        try {
            throw new NotImplementedException();
        } catch (NotImplementedException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(null, e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), (String) null);
            assertNull(e.getCause());
        }

        try {
            throw new NotImplementedException("error");
        } catch (NotImplementedException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertNull(e.getCause());
        }

        try {
            throw new NotImplementedException(message);
        } catch (NotImplementedException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertNull(e.getCause());
        }

        try {
            throw new NotImplementedException("error", cause);
        } catch (NotImplementedException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertSame(cause, e.getCause());
        }

        try {
            throw new NotImplementedException(message, cause);
        } catch (NotImplementedException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertSame(cause, e.getCause());
        }
    }
View Full Code Here

    }

    /** Test NotSupportedException. */
    @Test public void testNotSupportedException() {
        Throwable cause = new Exception("cause");
        LocalizableMessage message = new LocalizableMessage("whatever");

        try {
            throw new NotSupportedException();
        } catch (NotSupportedException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(null, e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), (String) null);
            assertNull(e.getCause());
        }

        try {
            throw new NotSupportedException("error");
        } catch (NotSupportedException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertNull(e.getCause());
        }

        try {
            throw new NotSupportedException(message);
        } catch (NotSupportedException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertNull(e.getCause());
        }

        try {
            throw new NotSupportedException("error", cause);
        } catch (NotSupportedException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals("error", e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), "error");
            assertSame(cause, e.getCause());
        }

        try {
            throw new NotSupportedException(message, cause);
        } catch (NotSupportedException e) {
            assertTrue(e instanceof CedarRuntimeException);
            assertEquals(message.getText(), e.getMessage());
            assertMessageValues(e.getLocalizableMessage(), message);
            assertSame(cause, e.getCause());
        }
    }
View Full Code Here

TOP

Related Classes of com.cedarsolutions.shared.domain.LocalizableMessage

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.