public void test() { Vector sessions = new Vector(); try { for (int i = 0; i < stressLevel; i++) { Session session = new Project(getSession().getDatasourceLogin().clone()).createDatabaseSession(); ((DatabaseSession) session).login(); sessions.addElement(session); } getSession().readObject(Address.class); } finally { for (Enumeration sessionEnum = sessions.elements(); sessionEnum.hasMoreElements(); ) { ((DatabaseSession) sessionEnum.nextElement()).logout(); } } getSession().readObject(Address.class); }
public void test() { EmployeeProjectForIntegrityChecker project = new EmployeeProjectForIntegrityChecker(); project.setDatasourceLogin(getSession().getDatasourceLogin()); DatabaseSession session = new Project(getSession().getDatasourceLogin()).createDatabaseSession(); session.dontLogMessages(); boolean caughtError = false; try { session.login(); session.setIntegrityChecker(new IntegrityChecker()); session.getIntegrityChecker().dontCatchExceptions(); session.addDescriptors(project); } catch (DescriptorException exception) { caughtError = true; } finally { session.logout(); } if (!caughtError) { throw new TestErrorException("Test is Failed, no exception was thrown"); } }
public void setup() { oldSession = getSession(); DatabaseLogin login = (DatabaseLogin) oldSession.getLogin().clone(); if (login.getConnector() instanceof JNDIConnector) { login.setConnector(new JNDIConnector("jdbc/OracleCoreAQ")); } else { login.setUserName("aquser"); login.setPassword("aquser"); } DatabaseSession session = new Project(login).createDatabaseSession(); session.setSessionLog(getSession().getSessionLog()); try { session.login(); } catch (Exception exception) { throw new TestProblemException( "Database needs to be setup for AQ, with the aquser", exception); } /** * to setup aquser, need to execute, 1 - login as sys (default password is password) - login as * scott tiger connect sys/password@james as sysdba * * <p>2 - might need to install aq procesures? - in sqlplus * - @@<orahome>\ora92\rdbms\admin\catproc.sql * * <p>3 - create a aq user (i.e aquser) grant connect, resource , aq_administrator_role to * aquser identified by aquser grant execute on dbms_aq to aquser grant execute on dbms_aqadm to * aquser grant execute on dbms_lock to aquser connect aquser/aquser */ try { session.executeNonSelectingCall( new SQLCall("begin DBMS_AQADM.STOP_QUEUE (queue_name => 'order_queue'); end;")); } catch (Exception notThere) { } try { session.executeNonSelectingCall( new SQLCall("begin DBMS_AQADM.DROP_QUEUE (queue_name => 'order_queue'); end;")); } catch (Exception notThere) { } try { session.executeNonSelectingCall( new SQLCall( "begin DBMS_AQADM.DROP_QUEUE_TABLE (queue_table => 'order_queue_table'); end;")); } catch (Exception notThere) { } try { session.executeNonSelectingCall( new SQLCall("begin DBMS_AQADM.STOP_QUEUE (queue_name => 'order_topic'); end;")); } catch (Exception notThere) { } try { session.executeNonSelectingCall( new SQLCall("begin DBMS_AQADM.DROP_QUEUE (queue_name => 'order_topic'); end;")); } catch (Exception notThere) { } try { session.executeNonSelectingCall( new SQLCall( "begin DBMS_AQADM.DROP_QUEUE_TABLE (queue_table => 'order_topic_table'); end;")); } catch (Exception notThere) { } try { session.executeNonSelectingCall( new SQLCall("begin DBMS_AQADM.STOP_QUEUE (queue_name => 'raw_order_queue'); end;")); } catch (Exception notThere) { } try { session.executeNonSelectingCall( new SQLCall("begin DBMS_AQADM.DROP_QUEUE (queue_name => 'raw_order_queue'); end;")); } catch (Exception notThere) { } try { session.executeNonSelectingCall( new SQLCall( "begin DBMS_AQADM.DROP_QUEUE_TABLE (queue_table => 'raw_order_queue_table'); end;")); } catch (Exception notThere) { } session.executeNonSelectingCall( new SQLCall( "begin DBMS_AQADM.CREATE_QUEUE_TABLE (queue_table => 'order_queue_table', multiple_consumers => FALSE, queue_payload_type => 'SYS.AQ$_JMS_TEXT_MESSAGE'); end;")); session.executeNonSelectingCall( new SQLCall( "begin DBMS_AQADM.CREATE_QUEUE (queue_name => 'order_queue', queue_table => 'order_queue_table'); end;")); session.executeNonSelectingCall( new SQLCall("begin DBMS_AQADM.START_QUEUE (queue_name => 'order_queue'); end;")); session.executeNonSelectingCall( new SQLCall( "begin DBMS_AQADM.CREATE_QUEUE_TABLE (queue_table => 'order_topic_table', multiple_consumers => TRUE, queue_payload_type => 'SYS.AQ$_JMS_TEXT_MESSAGE'); end;")); session.executeNonSelectingCall( new SQLCall( "begin DBMS_AQADM.CREATE_QUEUE (queue_name => 'order_topic', queue_table => 'order_topic_table'); end;")); session.executeNonSelectingCall( new SQLCall("begin DBMS_AQADM.START_QUEUE (queue_name => 'order_topic'); end;")); session.executeNonSelectingCall( new SQLCall( "begin DBMS_AQADM.CREATE_QUEUE_TABLE (queue_table => 'raw_order_queue_table', multiple_consumers => FALSE, queue_payload_type => 'RAW'); end;")); session.executeNonSelectingCall( new SQLCall( "begin DBMS_AQADM.CREATE_QUEUE (queue_name => 'raw_order_queue', queue_table => 'raw_order_queue_table'); end;")); session.executeNonSelectingCall( new SQLCall("begin DBMS_AQADM.START_QUEUE (queue_name => 'raw_order_queue'); end;")); session = XMLProjectReader.read( "org/eclipse/persistence/testing/models/order/eis/aq/order-project.xml", getClass().getClassLoader()) .createDatabaseSession(); session.setSessionLog(getSession().getSessionLog()); // String url = oldSession.getLogin().getConnectionString(); String url; try { url = ((AbstractSession) getSession()).getAccessor().getConnection().getMetaData().getURL(); } catch (java.sql.SQLException se) { se.printStackTrace(); throw new TestErrorException("There is SQLException"); } EISLogin eisLogin = (EISLogin) session.getDatasourceLogin(); eisLogin.setConnectionSpec(new AQEISConnectionSpec()); eisLogin.setProperty(AQEISConnectionSpec.URL, url); eisLogin.setUserName("aquser"); eisLogin.setPassword("aquser"); session.login(); getExecutor().setSession(session); }