Examples of HandleException


Examples of org.apache.onami.test.reflection.HandleException

            {
                Method method = providedClass.getMethod( annotation.providedBy() );

                if ( !element.getType().isAssignableFrom( method.getReturnType() ) )
                {
                    throw new HandleException( "Impossible to mock %s due to compatibility type, method provider %s#%s returns %s",
                                               element.getDeclaringClass().getName(),
                                               providedClass.getName(),
                                               annotation.providedBy(),
                                               method.getReturnType().getName() );
                }
                try
                {
                    Object mocked = getMockProviderForType( element.getType(), method, type );
                    mockedObjects.put( element, mocked );
                }
                catch ( Throwable t )
                {
                    throw new HandleException( "Impossible to mock %s, method provider %s#%s raised an error: %s",
                                               element.getDeclaringClass().getName(),
                                               providedClass.getName(),
                                               annotation.providedBy(),
                                               t );
                }
            }
            catch ( SecurityException e )
            {
                throw new HandleException( "Impossible to mock %s, impossible to access to method provider %s#%s: %s",
                                           element.getDeclaringClass().getName(),
                                           providedClass.getName(),
                                           annotation.providedBy(),
                                           e );
            }
            catch ( NoSuchMethodException e )
            {
                throw new HandleException( "Impossible to mock %s, the method provider %s#%s doesn't exist.",
                                           element.getDeclaringClass().getName(),
                                           providedClass.getName(),
                                           annotation.providedBy() );
            }
        }
View Full Code Here

Examples of org.apache.onami.test.reflection.HandleException

                {
                    LOGGER.finer( "        ...invoke Provider method for Mock: " + method.getName() );
                }
                if ( !Modifier.isPublic( method.getModifiers() ) || !Modifier.isStatic( method.getModifiers() ) )
                {
                    throw new HandleException( "Impossible to invoke method %s#%s. The method shuld be 'static public %s %s()",
                                               cls.getName(),
                                               method.getName(),
                                               method.getReturnType().getName(),
                                               method.getName() );
                }

                return (T) method.invoke( cls );
            }
            catch ( Exception e )
            {
                throw new RuntimeException( e );
            }
        }
        throw new HandleException( "The method: %s should return type %s", method, t );
    }
View Full Code Here

Examples of org.apache.onami.test.reflection.HandleException

    public void handle( MockFramework annotation, Class<?> element )
        throws HandleException
    {
        if ( mockType != null && mockType != annotation.value() )
        {
            throw new HandleException( "Inconsistent mock framework found. " + "Mock framework already set [set: "
                + mockType + " now found: " + annotation.value() + "]" );
        }

        if ( LOGGER.isLoggable( Level.FINER ) )
        {
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.