public List<Exception> getAndClearWarnings() { return this.context.getAndClearWarnings(); }
public List<Exception> getAndClearWarnings() { return this.context.getAndClearWarnings(); }
public List<Exception> getAndClearWarnings() { return this.context.getAndClearWarnings(); }
@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 testPartialResults() throws Exception { DataTierTupleSource info = helpSetup(1); connectorManager.throwExceptionOnExecute = true; for (int i = 0; i < 10; i++) { try { assertNull(info.nextTuple()); SourceWarning warning = (SourceWarning) context.getAndClearWarnings().get(0); assertTrue(warning.isPartialResultsError()); return; } catch (BlockedException e) { Thread.sleep(50); } } fail(); }
@Test public void testExceptionHandling() throws Exception { String ddl = "create virtual procedure vproc (x integer) returns integer as begin " + "raise sqlexception 'hello world' sqlstate 'abc', 1;" + "exception e " + "raise sqlwarning sqlexception 'caught' chain e.exception; " + "\"return\" = 1;"+ "end;"; TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl); String sql = "call vproc(1)"; //$NON-NLS-1$ ProcessorPlan plan = getProcedurePlan(sql, tm); HardcodedDataManager dataManager = new HardcodedDataManager(tm); helpTestProcess(plan, new List[] {Arrays.asList(1)}, dataManager, tm); TeiidSQLException tse = (TeiidSQLException)plan.getContext().getAndClearWarnings().get(0); assertEquals("caught", tse.getMessage()); assertEquals("hello world", tse.getCause().getMessage()); }
@Test public void testDataTierTupleSourceWarnings() throws Exception { DataTierTupleSource info = helpSetup(1); connectorManager.addWarning = true; assertEquals(10, pullTuples(info, 10)); assertNotNull(workItem.getConnectorRequest(info.getAtomicRequestMessage().getAtomicRequestID())); assertNull(info.nextTuple()); List<Exception> warnings = context.getAndClearWarnings(); assertEquals(1, warnings.size()); SourceWarning warning = (SourceWarning) warnings.get(0); assertFalse(warning.isPartialResultsError()); info.closeSource(); assertNull(workItem.getConnectorRequest(info.getAtomicRequestMessage().getAtomicRequestID())); }
@Test public void testExceptionAndWarning() throws Exception { String ddl = "create virtual procedure vproc (x integer) returns integer as begin declare exception e = sqlexception 'hello'; raise sqlwarning e; raise sqlexception 'hello world' sqlstate 'abc', 1 chain e; end;"; TransformationMetadata tm = TestProcedureResolving.createMetadata(ddl); String sql = "call vproc(1)"; //$NON-NLS-1$ ProcessorPlan plan = getProcedurePlan(sql, tm); HardcodedDataManager dataManager = new HardcodedDataManager(tm); try { helpTestProcess(plan, null, dataManager, tm); fail(); } catch (TeiidProcessingException e) { TeiidSQLException tsw = (TeiidSQLException) plan.getContext().getAndClearWarnings().get(0); assertEquals("hello", tsw.getMessage()); assertEquals(e.getCause().getCause(), tsw); TeiidSQLException tse = (TeiidSQLException)e.getCause(); assertEquals("hello world", tse.getMessage()); assertEquals("abc", tse.getSQLState()); assertEquals(1, tse.getErrorCode()); } }