/** * @param exception */ public void setException(Throwable e) { if(e instanceof TeiidException) { this.exception = (TeiidException)e; } else { this.exception = new TeiidException(e, e.getMessage()); } }
/** * @param exception */ public void setException(Throwable e) { if(e instanceof TeiidException) { this.exception = (TeiidException)e; } else { this.exception = new TeiidException(e, e.getMessage()); } }
@Override public void visit(UriInfoBatch info) { this.exceptions.add(new TeiidException("UriInfoBatch NotSupported")); }
@Override public void visit(UriResourceLambdaVariable info) { this.exceptions.add(new TeiidException("UriResourceLambdaVariable NotSupported")); }
@Override public void visit(UriResourceRoot info) { this.exceptions.add(new TeiidException("UriResourceRoot NotSupported")); }
@Override public void visit(UriResourceIt info) { this.exceptions.add(new TeiidException("UriResourceIt NotSupported")); }
@Override public void visit(UriResourceComplexProperty info) { this.exceptions.add(new TeiidException("UriResourceComplexProperty NotSupported")); }
public static byte[] convertToByteArray(final Object data) throws TeiidException, IOException { if (data instanceof InputStream) { return convertToByteArray((InputStream) data); } else if (data instanceof byte[]) { return (byte[]) data; } else if (data instanceof java.sql.Blob) { return convertBlobToByteArray((java.sql.Blob) data); } else if (data instanceof File) { return convertFileToByteArray((File)data); } final Object[] params = new Object[]{data.getClass().getName()}; throw new TeiidException(CorePlugin.Event.TEIID10032, CorePlugin.Util.gs(CorePlugin.Event.TEIID10032,params)); }
public static byte[] convertToByteArray(final Object data) throws TeiidException, IOException { if (data instanceof InputStream) { return convertToByteArray((InputStream) data); } else if (data instanceof byte[]) { return (byte[]) data; } else if (data instanceof java.sql.Blob) { return convertBlobToByteArray((java.sql.Blob) data); } else if (data instanceof File) { return convertFileToByteArray((File)data); } final Object[] params = new Object[]{data.getClass().getName()}; throw new TeiidException(CorePlugin.Event.TEIID10032, CorePlugin.Util.gs(CorePlugin.Event.TEIID10032,params)); }
@Test public void testMetaMatrixExceptionWithExceptionAndCodeAndMessage() { final TeiidException child = new TeiidException(Event.propertyValuePhrase, "Child"); //$NON-NLS-1$ final TeiidException err = new TeiidException(Event.Code,child, "Test"); //$NON-NLS-1$ assertEquals("Code", err.getCode()); //$NON-NLS-1$ assertEquals("Code Test", err.getMessage()); //$NON-NLS-1$ } }
@Test public void testMetaMatrixExceptionWithExceptionAndMessage() { final TeiidException child = new TeiidException(Event.propertyValuePhrase, "Child"); //$NON-NLS-1$ final TeiidException err = new TeiidException(child, "Test"); //$NON-NLS-1$ assertEquals("propertyValuePhrase", err.getCode()); //$NON-NLS-1$ assertEquals("propertyValuePhrase Test", err.getMessage()); //$NON-NLS-1$ }
@Test public void testSanitize() { TeiidException te = new TeiidException(JDBCPlugin.Event.TEIID20000, "you don't want to see this"); te.initCause(new Exception("or this")); Throwable t = ExceptionUtil.sanitize(te, true); assertTrue(t.getStackTrace().length != 0); assertNotNull(t.getCause()); assertEquals("TEIID20000", t.getMessage()); assertEquals("java.lang.Exception", t.getCause().getMessage()); t = ExceptionUtil.sanitize(te, false); assertEquals(0, t.getStackTrace().length); assertEquals("TEIID20000", t.getMessage()); }
@Test public void testFailMetaMatrixExceptionWithNullMessage() { Throwable e = null; try { new TeiidException((String)null); // should throw NPE fail("Should not get here"); //$NON-NLS-1$ } catch ( Throwable ex ) { e = ex; } assertNotNull(e); }
Criteria buildJoinCriteria(DocumentNode joinResource, EdmNavigationProperty property) throws TeiidException { KeyInfo keyInfo = joinFK(joinResource.getTable(), getTable(), property); if (keyInfo == null) { keyInfo = joinFK(getTable(), joinResource.getTable(), property); if (keyInfo == null) { throw new TeiidException("Fk not found"); } } return buildCriteria(keyInfo.reverse?joinResource:this, keyInfo.reverse?this:joinResource, keyInfo.fk); }
@Test public void testGetAndClearWarnings() { FakeProcessorPlan plan = new FakeProcessorPlan(Collections.emptyList(), Collections.emptyList()); CommandContext cc = new CommandContext(); plan.initialize(cc, null, null); TeiidException warning = new TeiidException("test"); //$NON-NLS-1$ plan.addWarning(warning); List<Exception> warnings = cc.getAndClearWarnings(); assertEquals("Did not get expected number of warnings", 1, warnings.size()); //$NON-NLS-1$ assertEquals("Did not get expected warning", warning, warnings.get(0)); //$NON-NLS-1$ assertNull("Did not clear warnings from plan", cc.getAndClearWarnings()); //$NON-NLS-1$ } }
@Test public void testCreateThrowable3() { TeiidSQLException e = testCreateThrowable( new TeiidException( new SocketTimeoutException( "A test MM Invalid Session Exception"), //$NON-NLS-1$ "Test MetaMatrixRuntimeException with a InvalidSessionException in it"), //$NON-NLS-1$ SQLStates.CONNECTION_EXCEPTION_STALE_CONNECTION); //test to ensure that wrapping mmsqlexceptions works TeiidSQLException e1 = TeiidSQLException.create(e, "new message"); //$NON-NLS-1$ assertEquals("new message", e1.getMessage()); //$NON-NLS-1$ testCreateThrowable(((TeiidSQLException)e1.getCause()).getCause(), SQLStates.CONNECTION_EXCEPTION_STALE_CONNECTION); }
@Test public void testMetaMatrixExceptionWithMessage() { final TeiidException err = new TeiidException("Test"); //$NON-NLS-1$ assertNull(err.getCode()); assertEquals("Test", err.getMessage()); //$NON-NLS-1$ } public static enum Event implements BundleUtil.Event {
@Test public void testMetaMatrixExceptionWithCodeAndMessage() { final TeiidException err = new TeiidException(Event.Code, "Test"); //$NON-NLS-1$ assertEquals("Code", err.getCode()); //$NON-NLS-1$ assertEquals("Code Test", err.getMessage()); //$NON-NLS-1$ }
@Test public void testMetaMatrixExceptionWithNullThrowable() { final TeiidException err = new TeiidException((Throwable)null); assertNull(err.getCode()); assertNull(err.getMessage()); }
@Test public void testCodeAsVendorCode() { TeiidException sqlexception = new TeiidException(Event.TEIID21, "foo"); //$NON-NLS-1$ String message = "top level message"; //$NON-NLS-1$ TeiidSQLException exception = TeiidSQLException.create(sqlexception, message); assertEquals(sqlexception.getCode(), exception.getTeiidCode()); assertEquals(21, exception.getErrorCode()); }