List of usage examples for java.lang.reflect InvocationTargetException getCause
public Throwable getCause()
From source file:com.cloudera.dataflow.hadoop.WritableCoder.java
@Override public T decode(InputStream inStream, Context context) throws IOException { try {/*w ww.j a v a2s .co m*/ T t = type.getConstructor().newInstance(); t.readFields(new DataInputStream(inStream)); return t; } catch (NoSuchMethodException | InstantiationException | IllegalAccessException e) { throw new CoderException("unable to deserialize record", e); } catch (InvocationTargetException ite) { throw new CoderException("unable to deserialize record", ite.getCause()); } }
From source file:org.pentaho.proxy.creators.userdatailsservice.ProxyUserDetailsServiceTest.java
@Test public void testNoUserDetailsProxyWrapper() { Object wrappedObject = new ProxyUserDetailsService(mockUserDetailsService); Assert.assertNotNull(wrappedObject); Method loadUserByUsernameMethod = ReflectionUtils.findMethod(wrappedObject.getClass(), "loadUserByUsername", String.class); try {// w ww . j av a2 s. c o m loadUserByUsernameMethod.invoke(wrappedObject, MOCK_USERNAME_NOT_EXISTS); Assert.fail(); } catch (InvocationTargetException e) { Assert.assertTrue(e.getCause() instanceof UsernameNotFoundException); } catch (Throwable t) { logger.error(t.getMessage(), t); Assert.fail(); } try { loadUserByUsernameMethod.invoke(wrappedObject, MOCK_USERNAME_NOT_EXISTS_RETURNS_NULL); Assert.fail(); } catch (InvocationTargetException e) { Assert.assertTrue(e.getCause() instanceof UsernameNotFoundException); } catch (Throwable t) { logger.error(t.getMessage(), t); Assert.fail(); } }
From source file:com.puppycrawl.tools.checkstyle.checks.NewlineAtEndOfFileCheckTest.java
@Test public void testWrongSeparatorLength() throws Exception { NewlineAtEndOfFileCheck check = new NewlineAtEndOfFileCheck(); final DefaultConfiguration checkConfig = createCheckConfig(NewlineAtEndOfFileCheck.class); check.configure(checkConfig);// ww w . jav a 2 s.c o m Method method = NewlineAtEndOfFileCheck.class.getDeclaredMethod("endsWithNewline", RandomAccessFile.class); method.setAccessible(true); RandomAccessFile file = mock(RandomAccessFile.class); when(file.length()).thenReturn(2000000L); try { method.invoke(new NewlineAtEndOfFileCheck(), file); } catch (InvocationTargetException ex) { assertTrue(ex.getCause() instanceof IOException); if (System.getProperty("os.name").toLowerCase(ENGLISH).startsWith("windows")) { assertEquals("Unable to read 2 bytes, got 0", ex.getCause().getMessage()); } else { assertEquals("Unable to read 1 bytes, got 0", ex.getCause().getMessage()); } } }
From source file:libepg.common.descriptor.Descriptors.java
public Descriptor getSERVICE_DESCRIPTOR() { try {/*w w w. ja v a 2s .c o m*/ return init(this.SERVICE_DESCRIPTOR_BYTE); } catch (InvocationTargetException ex) { LOG.fatal(ex.getCause()); } return null; }
From source file:libepg.common.descriptor.Descriptors.java
public Descriptor getSHORT_EVENT_DESCRIPTOR() { try {/*from w w w . j a v a2s . com*/ return init(this.SERVICE_DESCRIPTOR_BYTE); } catch (InvocationTargetException ex) { LOG.fatal(ex.getCause()); } return null; }
From source file:libepg.common.descriptor.Descriptors.java
public Descriptor getEXTENDED_EVENT_DESCRIPTOR() { try {/*from ww w . ja v a 2 s .c o m*/ return init(this.EXTENDED_EVENT_DESCRIPTOR_BYTE); } catch (InvocationTargetException ex) { LOG.fatal(ex.getCause()); } return null; }
From source file:libepg.common.descriptor.Descriptors.java
public Descriptor getDIGITAL_COPY_CONTROL_DESCRIPTOR() { try {// w w w.j av a 2s . c o m return init(this.DIGITAL_COPY_CONTROL_DESCRIPTOR_BYTE); } catch (InvocationTargetException ex) { LOG.fatal(ex.getCause()); } return null; }
From source file:libepg.common.descriptor.Descriptors.java
public Descriptor getLOGO_TRANSMISSION_DESCRIPTOR() { try {/*from w ww. j a v a 2 s .c o m*/ return init(this.LOGO_TRANSMISSION_DESCRIPTOR_BYTE); } catch (InvocationTargetException ex) { LOG.fatal(ex.getCause()); } return null; }
From source file:libepg.common.descriptor.Descriptors.java
public Descriptor getCONTENT_DESCRIPTOR() { try {//from ww w. j a v a 2 s . c o m return init(this.CONTENT_DESCRIPTOR_BYTE); } catch (InvocationTargetException ex) { LOG.fatal(ex.getCause()); } return null; }
From source file:org.apache.camel.component.bean.BeanInvocation.java
/** * This causes us to invoke the endpoint Pojo using reflection. * * @param pojo the bean on which to perform this invocation * @param exchange the exchange carrying the method invocation *///from w ww . j av a 2 s . c o m public void invoke(Object pojo, Exchange exchange) { try { if (LOG.isTraceEnabled()) { LOG.trace("Invoking method: " + getMethod() + " with args: " + getArgs()); } Object response = getMethod().invoke(pojo, getArgs()); if (LOG.isTraceEnabled()) { LOG.trace("Got response: " + response); } exchange.getOut().setBody(response); } catch (InvocationTargetException e) { exchange.setException(ObjectHelper.wrapRuntimeCamelException(e.getCause())); } catch (Exception e) { throw ObjectHelper.wrapRuntimeCamelException(e); } }