protected static void afterAddDescriptors(Session session, TestSystem aTestSystem) { if (aTestSystem instanceof InheritanceSystem) { // For using read all subclasses views. org.eclipse.persistence.internal.databaseaccess.DatabasePlatform platform = session.getLogin().getPlatform(); if (platform.isOracle() || platform.isSybase() || platform.isSQLAnywhere()) { ClassDescriptor computerDescriptor = session.getClassDescriptor(Computer.class); ClassDescriptor vehicleDescriptor = session.getClassDescriptor(Vehicle.class); if (computerDescriptor.getInheritancePolicy().requiresMultipleTableSubclassRead()) { computerDescriptor.getInheritancePolicy().setReadAllSubclassesViewName("AllComputers"); } if (vehicleDescriptor.getInheritancePolicy().requiresMultipleTableSubclassRead()) { vehicleDescriptor.getInheritancePolicy().setReadAllSubclassesViewName("AllVehicles"); } } } }
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); }
/** Drop table constraints */ public void dropTableConstraints(Session session) { if (!SchemaManager.FAST_TABLE_CREATOR) { if (session.getLogin().getPlatform().isOracle()) { try { session.executeNonSelectingCall(new SQLCall("drop table BUS CASCADE CONSTRAINTS")); } catch (Exception e) { } try { session.executeNonSelectingCall(new SQLCall("drop table CAR CASCADE CONSTRAINTS")); } catch (Exception e) { } try { session.executeNonSelectingCall(new SQLCall("drop table COMPANY CASCADE CONSTRAINTS")); } catch (Exception e) { } try { session.executeNonSelectingCall(new SQLCall("drop table FUEL_VEH CASCADE CONSTRAINTS")); } catch (Exception e) { } try { session.executeNonSelectingCall(new SQLCall("drop table NH_COMP CASCADE CONSTRAINTS")); } catch (Exception e) { } try { session.executeNonSelectingCall(new SQLCall("drop table INH_MF CASCADE CONSTRAINTS")); } catch (Exception e) { } try { session.executeNonSelectingCall( new SQLCall("drop table KING_DEVELOPER CASCADE CONSTRAINTS")); } catch (Exception e) { } try { session.executeNonSelectingCall( new SQLCall("drop table KING_PERSONG CASCADE CONSTRAINTS")); } catch (Exception e) { } try { session.executeNonSelectingCall(new SQLCall("drop table PARTNUMS CASCADE CONSTRAINTS")); } catch (Exception e) { } try { session.executeNonSelectingCall(new SQLCall("drop table VEHICLE CASCADE CONSTRAINTS")); } catch (Exception e) { } } // Drop old constraints. try { if (session.getPlatform().supportsUniqueKeyConstraints() && !session.getPlatform().requiresUniqueConstraintCreationOnTableCreate()) { session.executeNonSelectingSQL( "Alter TABLE PROJECT_WORKER_BATCH DROP CONSTRAINT PROJECT_WORKER_BATCH_HD"); session.executeNonSelectingSQL( "Alter TABLE PROJECT_BATCH DROP CONSTRAINT PROJECT_WORKER_BATCH_FK"); session.executeNonSelectingSQL( "Alter TABLE ALLIGATOR DROP CONSTRAINT FK_ALLIGATOR_VICTIM_ID"); session.executeNonSelectingSQL( "Alter TABLE PERSON2 DROP CONSTRAINT PERSON2_PERSON2_FRND"); session.executeNonSelectingSQL("Alter TABLE PERSON2 DROP CONSTRAINT PERSON2_PERSON2_REP"); session.executeNonSelectingSQL("Alter TABLE PERSON2 DROP CONSTRAINT PERSON2_PERSON2_BS"); } } catch (Exception ignore) { } } }
public boolean hasSameUser(Session otherSession) { return this.login.equals(otherSession.getLogin()); }