public void test() {
   EmployeeProject project = new EmployeeProject();
   ((DatasourceLogin) project.getDatasourceLogin())
       .usePlatform(OracleDBPlatformHelper.getInstance().getOracle9Platform());
   XMLProjectWriter.write("employee_project.xml", project);
   XMLProjectReader.read("employee_project.xml", getClass().getClassLoader());
 }
  public void addDescriptors(DatabaseSession session) {
    if (project == null) {
      project =
          XMLProjectReader.read(
              "org/eclipse/persistence/testing/models/employee/eis/xmlfile/employee-ns-project.xml",
              getClass().getClassLoader());
    }

    session.addDescriptors(project);
  }
  public EmployeeNSSystem() {

    /**
     * Use the EmployeeNSProject which is the basic EmployeeProject but with namespace qualified
     * elements.
     */
    project =
        XMLProjectReader.read(
            "org/eclipse/persistence/testing/models/employee/eis/xmlfile/employee-ns-project.xml",
            getClass().getClassLoader());
  }
  public void testDeploymentXmlConversion() {
    XMLProjectReader reader = new XMLProjectReader();
    XMLPlatform xmlPlatform = XMLPlatformFactory.getInstance().getXMLPlatform();
    XMLParser parser = xmlPlatform.newXMLParser();
    InputStream stream =
        ClassLoader.getSystemResourceAsStream(
            "org/eclipse/persistence/testing/oxm/deploymentxml/db-adapter-toplink-mapping-file.xml");
    Project proj = reader.read(new InputStreamReader(stream));

    StringWriter writer = new StringWriter();
    new XMLProjectWriter().write(proj, writer);

    parser.setNamespaceAware(true);
    parser.setWhitespacePreserving(false);
    String schema = XMLProjectReader.SCHEMA_DIR + XMLProjectReader.ECLIPSELINK_SCHEMA;
    parser.setValidationMode(XMLParser.SCHEMA_VALIDATION);
    URL eclipselinkSchemaURL = getClass().getClassLoader().getResource(schema);
    parser.setEntityResolver(
        new EntityResolver() {

          public InputSource resolveEntity(String publicId, String systemId)
              throws SAXException, IOException {
            if (XMLProjectReader.OPM_SCHEMA.equals(systemId)) {
              URL url =
                  getClass()
                      .getClassLoader()
                      .getResource(XMLProjectReader.SCHEMA_DIR + XMLProjectReader.OPM_SCHEMA);
              if (null == url) {
                return null;
              }
              return new InputSource(url.openStream());
            }
            return null;
          }
        });
    parser.setXMLSchema(eclipselinkSchemaURL);
    parser.parse(new StringReader(writer.toString()));
  }
  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);
  }
 public InheritanceSystem() {
   project =
       XMLProjectReader.read(
           "org/eclipse/persistence/testing/models/inheritance/inheritance-project.xml",
           getClass().getClassLoader());
 }
 public void test() {
   XMLProjectWriter.write(FILENAME, project);
   project = XMLProjectReader.read(FILENAME, getClass().getClassLoader());
 }
 /**
  * This method used to reset a project in a session. All connected clients will get errors.
  * project must be of the xml type. This attribute will not be stored on a save.
  *
  * @param projectFilePath the filename of the project xml file to build the new project from.
  */
 public void refreshProject(String projectFilePath) {
   ((DatabaseSessionImpl) getSession()).logout();
   getSession().setProject(XMLProjectReader.read(projectFilePath));
   ((DatabaseSessionImpl) getSession()).login();
 }
 /** For the given project, generate the project xml and read it back in. */
 public static Project buildProjectXML(Project project, String filename, ClassLoader loader) {
   XMLProjectWriter.write(filename + ".xml", project);
   return XMLProjectReader.read(filename + ".xml", loader);
 }