use of org.teiid.translator.ExecutionContext in project teiid by teiid.
the class TestOracleTranslator method testOracleCommentPayload.
/**
* Case 3744. Test that an Oracle-specific db hint, delivered as a String via command
* payload, is added to the translated SQL.
*
* @since 4.3
*/
@Test
public void testOracleCommentPayload() throws Exception {
// $NON-NLS-1$
String input = "SELECT part_name, rownum FROM parts";
// $NON-NLS-1$
String output = "SELECT /*+ ALL_ROWS */ PARTS.PART_NAME, ROWNUM FROM PARTS";
// $NON-NLS-1$
String hint = "/*+ ALL_ROWS */";
// $NON-NLS-1$
ExecutionContext context = new ExecutionContextImpl(null, 1, hint, null, "", 1, null, null);
helpTestVisitor(getTestVDB(), input, context, null, output, false);
}
use of org.teiid.translator.ExecutionContext in project teiid by teiid.
the class TestOracleTranslator method testOracleCommentPayload1.
@Test
public void testOracleCommentPayload1() throws Exception {
// $NON-NLS-1$
String input = "SELECT part_name, rownum FROM parts";
// $NON-NLS-1$
String output = "SELECT PARTS.PART_NAME, ROWNUM FROM PARTS";
// $NON-NLS-1$
String hint = "/*+ ALL_ROWS */ something else";
// $NON-NLS-1$
ExecutionContext context = new ExecutionContextImpl(null, 1, hint, null, "", 1, null, null);
helpTestVisitor(getTestVDB(), input, context, null, output, false);
}
use of org.teiid.translator.ExecutionContext in project teiid by teiid.
the class TestLDAPDirectQueryExecution method testDelete.
@Test
public void testDelete() throws Exception {
String input = "exec native('delete;uid=doe,ou=people,o=teiid.org')";
TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
Command command = util.parseCommand(input);
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
LdapContext connection = Mockito.mock(LdapContext.class);
LdapContext ctx = Mockito.mock(LdapContext.class);
Mockito.stub(connection.lookup("")).toReturn(ctx);
LDAPDirectCreateUpdateDeleteQueryExecution execution = (LDAPDirectCreateUpdateDeleteQueryExecution) TRANSLATOR.createExecution(command, ec, rm, connection);
execution.execute();
Mockito.verify(ctx, Mockito.times(1)).destroySubcontext("uid=doe,ou=people,o=teiid.org");
}
use of org.teiid.translator.ExecutionContext in project teiid by teiid.
the class TestLDAPDirectQueryExecution method testCreateFail.
@Test(expected = TranslatorException.class)
public void testCreateFail() throws Exception {
String input = "exec native('create;uid=doe,ou=people,o=teiid.org;attributes=one,two,three', 'one')";
TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
Command command = util.parseCommand(input);
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
LdapContext connection = Mockito.mock(LdapContext.class);
LdapContext ctx = Mockito.mock(LdapContext.class);
Mockito.stub(connection.lookup("")).toReturn(ctx);
LDAPDirectCreateUpdateDeleteQueryExecution execution = (LDAPDirectCreateUpdateDeleteQueryExecution) TRANSLATOR.createExecution(command, ec, rm, connection);
execution.execute();
}
use of org.teiid.translator.ExecutionContext in project teiid by teiid.
the class TestLDAPDirectQueryExecution method testSearch.
@Test
public void testSearch() throws Exception {
String input = "exec native('search;context-name=corporate;filter=(objectClass=*);count-limit=5;timeout=6;search-scope=ONELEVEL_SCOPE;attributes=uid,cn')";
TranslationUtility util = FakeTranslationFactory.getInstance().getExampleTranslationUtility();
Command command = util.parseCommand(input);
ExecutionContext ec = Mockito.mock(ExecutionContext.class);
RuntimeMetadata rm = Mockito.mock(RuntimeMetadata.class);
LdapContext connection = Mockito.mock(LdapContext.class);
LdapContext ctx = Mockito.mock(LdapContext.class);
Mockito.stub(connection.lookup("corporate")).toReturn(ctx);
LDAPDirectSearchQueryExecution execution = (LDAPDirectSearchQueryExecution) TRANSLATOR.createExecution(command, ec, rm, connection);
execution.execute();
LDAPSearchDetails details = execution.getDelegate().getSearchDetails();
assertEquals("corporate", details.getContextName());
assertEquals("(objectClass=*)", details.getContextFilter());
assertEquals(5, details.getCountLimit());
assertEquals(6, details.getTimeLimit());
assertEquals(1, details.getSearchScope());
assertEquals(2, details.getElementList().size());
assertEquals("uid", details.getElementList().get(0).getName());
assertEquals("cn", details.getElementList().get(1).getName());
}
Aggregations