Search in sources :

Example 66 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class TestExceptionUtil method testSanitize.

@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());
}
Also used : TeiidException(org.teiid.core.TeiidException) TeiidException(org.teiid.core.TeiidException) Test(org.junit.Test)

Example 67 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class TestProcessor method sampleDataBQT2.

private void sampleDataBQT2(FakeDataManager dataMgr) {
    QueryMetadataInterface metadata = RealMetadataFactory.exampleBQTCached();
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    String[] groups = new String[] { "bqt1.smalla", "bqt2.smalla", "bqt3.smalla" };
    try {
        for (int i = 0; i < groups.length; i++) {
            String groupName = groups[i];
            List[] tuples = new List[30];
            for (int row = 0; row < tuples.length; row++) {
                tuples[row] = new ArrayList(17);
                tuples[row].add(new Integer(row));
                for (int col = 0; col < 16; col++) {
                    tuples[row].add(null);
                }
            }
            dataMgr.registerTuples(metadata, groupName, tuples);
        }
    } catch (TeiidException e) {
        throw new RuntimeException(e);
    }
}
Also used : BigInteger(java.math.BigInteger) TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) TeiidException(org.teiid.core.TeiidException)

Example 68 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class TestBaseProcessorPlan method testGetAndClearWarnings.

@Test
public void testGetAndClearWarnings() {
    FakeProcessorPlan plan = new FakeProcessorPlan(Collections.emptyList(), Collections.emptyList());
    CommandContext cc = new CommandContext();
    plan.initialize(cc, null, null);
    // $NON-NLS-1$
    TeiidException warning = new TeiidException("test");
    plan.addWarning(warning);
    List<Exception> warnings = cc.getAndClearWarnings();
    // $NON-NLS-1$
    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());
}
Also used : CommandContext(org.teiid.query.util.CommandContext) TeiidException(org.teiid.core.TeiidException) TeiidException(org.teiid.core.TeiidException) Test(org.junit.Test)

Example 69 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class TestQueryRewriter method parseCriteria.

// ################################## TEST HELPERS ################################
private Criteria parseCriteria(String critStr, QueryMetadataInterface metadata) {
    try {
        Criteria crit = QueryParser.getQueryParser().parseCriteria(critStr);
        // resolve against metadata
        QueryResolver.resolveCriteria(crit, metadata);
        return crit;
    } catch (TeiidException e) {
        throw new RuntimeException(e);
    }
}
Also used : TeiidRuntimeException(org.teiid.core.TeiidRuntimeException) TeiidException(org.teiid.core.TeiidException)

Example 70 with TeiidException

use of org.teiid.core.TeiidException in project teiid by teiid.

the class TestQueryRewriter method testRewriteFunctionThrowsEvaluationError.

@Test
public void testRewriteFunctionThrowsEvaluationError() {
    QueryMetadataInterface metadata = RealMetadataFactory.example1Cached();
    // $NON-NLS-1$
    Criteria origCrit = parseCriteria("5 / 0 = 5", metadata);
    // rewrite
    try {
        QueryRewriter.rewriteCriteria(origCrit, null, metadata);
        // $NON-NLS-1$
        fail("Expected QueryValidatorException due to divide by 0");
    } catch (TeiidException e) {
        // looks like message is being wrapped with another exception with same message
        // $NON-NLS-1$
        assertEquals("TEIID30328 Unable to evaluate (5 / 0): TEIID30384 Error while evaluating function /", e.getMessage());
    }
}
Also used : QueryMetadataInterface(org.teiid.query.metadata.QueryMetadataInterface) TeiidException(org.teiid.core.TeiidException) Test(org.junit.Test)

Aggregations

TeiidException (org.teiid.core.TeiidException)85 TeiidRuntimeException (org.teiid.core.TeiidRuntimeException)26 ArrayList (java.util.ArrayList)14 Test (org.junit.Test)13 QueryMetadataInterface (org.teiid.query.metadata.QueryMetadataInterface)10 SQLException (java.sql.SQLException)9 GroupSymbol (org.teiid.query.sql.symbol.GroupSymbol)8 BigInteger (java.math.BigInteger)6 Column (org.teiid.metadata.Column)6 Command (org.teiid.query.sql.lang.Command)6 TranslatorException (org.teiid.translator.TranslatorException)6 IOException (java.io.IOException)5 TeiidProcessingException (org.teiid.core.TeiidProcessingException)5 List (java.util.List)4 EdmEntityType (org.apache.olingo.commons.api.edm.EdmEntityType)4 ODataApplicationException (org.apache.olingo.server.api.ODataApplicationException)4 TeiidComponentException (org.teiid.core.TeiidComponentException)4 UpdateResponse (org.teiid.odata.api.UpdateResponse)4 Update (org.teiid.query.sql.lang.Update)4 SocketTimeoutException (java.net.SocketTimeoutException)3