Esempio n. 1
0
  public String doTest() {
    stat.addDescription("This is to test connector 1.5 " + "contracts.");

    String res = "NOT RUN";
    debug("doTest() ENTER...");
    boolean pass = false;
    try {

      try {
        InitialContext ic = new InitialContext();
        System.out.println(
            "appclient lookup of java:app/jdbc/app-level-ds : "
                + ic.lookup("java:app/jdbc/app-level-ds"));
      } catch (Exception e) {
        e.printStackTrace();
      }
      res = "ALL TESTS PASSED";
      int testCount = 1;
      while (!done()) {

        notifyAndWait();
        if (!done()) {
          debug("Running...");
          pass = checkResults(expectedResults());
          debug("Got expected results = " + pass);

          // do not continue if one test failed
          if (!pass) {
            res = "SOME TESTS FAILED";
            stat.addStatus("ID Connector 1.6 test - " + testCount, stat.FAIL);
          } else {
            stat.addStatus("ID Connector 1.6 test - " + testCount, stat.PASS);
          }
        } else {
          break;
        }
        testCount++;
      }

    } catch (Exception ex) {
      System.out.println("Importing transaction test failed.");
      ex.printStackTrace();
      res = "TEST FAILED";
    }
    stat.printSummary("connector1.6ID");

    debug("EXITING... STATUS = " + res);
    return res;
  }
Esempio n. 2
0
 @Before
 public void setUp() {
   try {
     hello = (Hello) ic.lookup("HelloBean/remote");
   } catch (NamingException e) {
     e.printStackTrace();
   }
 }
  public static void main(String[] args) throws Exception {

    SimpleReporterAdapter stat = new SimpleReporterAdapter();
    String testSuite = "StatementWrapper ";

    InitialContext ic = new InitialContext();
    Object objRef = ic.lookup("java:comp/env/ejb/SimpleBMPHome");
    SimpleBMPHome simpleBMPHome =
        (SimpleBMPHome) javax.rmi.PortableRemoteObject.narrow(objRef, SimpleBMPHome.class);

    SimpleBMP simpleBMP = simpleBMPHome.create();
    stat.addDescription("JDBC Statement Wrapper Tests");

    if (simpleBMP.statementTest()) {
      stat.addStatus(testSuite + " statementTest : ", stat.PASS);
    } else {
      stat.addStatus(testSuite + " statementTest : ", stat.FAIL);
    }

    if (simpleBMP.preparedStatementTest()) {
      stat.addStatus(testSuite + " preparedStatementTest : ", stat.PASS);
    } else {
      stat.addStatus(testSuite + " preparedStatementTest : ", stat.FAIL);
    }

    if (simpleBMP.callableStatementTest()) {
      stat.addStatus(testSuite + " callableStatementTest : ", stat.PASS);
    } else {
      stat.addStatus(testSuite + " callableStatementTest : ", stat.FAIL);
    }

    if (simpleBMP.metaDataTest()) {
      stat.addStatus(testSuite + " metaDataTest : ", stat.PASS);
    } else {
      stat.addStatus(testSuite + " metaDataTest : ", stat.FAIL);
    }

    if (simpleBMP.resultSetTest()) {
      stat.addStatus(testSuite + " resultSetTest : ", stat.PASS);
    } else {
      stat.addStatus(testSuite + " resultSetTest : ", stat.FAIL);
    }

    stat.printSummary();
  }
Esempio n. 4
0
  public static void main(String[] argv) throws Exception {
    SimpleReporterAdapter stat = new SimpleReporterAdapter();
    String testSuite = "ReconfigMaxPoolSize ";

    InitialContext ic = new InitialContext();
    Object objRef = ic.lookup("java:comp/env/ejb/SimpleBMPHome");
    SimpleBMPHome simpleBMPHome =
        (SimpleBMPHome) javax.rmi.PortableRemoteObject.narrow(objRef, SimpleBMPHome.class);

    SimpleBMP simpleBMP = simpleBMPHome.create();
    stat.addDescription("Reconfig MaxPoolSize tests");
    /*
     * Tests 1,2 use non-xa pool - so the 3rd param "useXA" is false
     * Tests 3,4 use xa pool - so the 3rd param "useXA" is true
     */
    if ("1".equals(argv[0])) {
      if (simpleBMP.test1(10, true, false)) {
        stat.addStatus(testSuite + " test1 : ", stat.PASS);
      } else {
        stat.addStatus(testSuite + " test1 : ", stat.FAIL);
      }
    } else if ("2".equals(argv[0])) {
      if (simpleBMP.test1(19, false, false)) {
        stat.addStatus(testSuite + " test2 : ", stat.PASS);
      } else {
        stat.addStatus(testSuite + " test2 : ", stat.FAIL);
      }
    } else if ("3".equals(argv[0])) {
      if (simpleBMP.test1(10, false, true)) {
        stat.addStatus(testSuite + " test3 : ", stat.PASS);
      } else {
        stat.addStatus(testSuite + " test3 : ", stat.FAIL);
      }
    } else if ("4".equals(argv[0])) {
      if (simpleBMP.test1(19, false, true)) {
        stat.addStatus(testSuite + " test4 : ", stat.PASS);
      } else {
        stat.addStatus(testSuite + " test4 : ", stat.FAIL);
      }
    }

    System.out.println("jdbc reconfig-maxpoolsize status: ");
    stat.printSummary();
  }
Esempio n. 5
0
  public static void main(String[] args) throws Exception {

    SimpleReporterAdapter stat = new SimpleReporterAdapter();
    String testSuite = "notxconn";

    InitialContext ic = new InitialContext();
    Object objRef = ic.lookup("java:comp/env/ejb/SimpleSessionHome");
    SimpleSessionHome simpleSessionHome =
        (SimpleSessionHome) javax.rmi.PortableRemoteObject.narrow(objRef, SimpleSessionHome.class);

    stat.addDescription("Running notxops testSuite2 ");
    SimpleSession simpleSession = simpleSessionHome.create();
    if (simpleSession.test1()) {
      stat.addStatus(testSuite + " test1 : ", stat.PASS);
    } else {
      stat.addStatus(testSuite + " test1 : ", stat.FAIL);
    }

    stat.printSummary();
  }
  public void deleteAdminObject(String jndiName) throws ConnectorRuntimeException {

    try {
      InitialContext ic = new InitialContext();
      ic.unbind(jndiName);
    } catch (NamingException ne) {
      ResourcesUtil resutil = ResourcesUtil.createInstance();
      if (resutil.adminObjectBelongsToSystemRar(jndiName)) {
        return;
      }
      if (ne instanceof NameNotFoundException) {
        _logger.log(Level.FINE, "rardeployment.admin_object_delete_failure", jndiName);
        _logger.log(Level.FINE, "", ne);
        return;
      }
      ConnectorRuntimeException cre =
          new ConnectorRuntimeException("Failed to delete admin object from jndi");
      cre.initCause(ne);
      _logger.log(Level.SEVERE, "rardeployment.admin_object_delete_failure", jndiName);
      _logger.log(Level.SEVERE, "", cre);
      throw cre;
    }
  }
Esempio n. 7
0
  public static void main(String[] args) {
    try {
      Properties p = new Properties();

      p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
      p.put(Context.PROVIDER_URL, "10.10.10.13:1100,10.10.10.14:1100");
      // p.put(Context.PROVIDER_URL, "localhost:1100");
      p.put(Context.URL_PKG_PREFIXES, "org.jboss.naming:org.jnp.interfaces");
      InitialContext ctx = new InitialContext(p);

      StatelessSessionHome statelessSessionHome =
          (StatelessSessionHome) ctx.lookup("nextgen.StatelessSession");
      EnterpriseEntityHome cmpHome = (EnterpriseEntityHome) ctx.lookup("nextgen.EnterpriseEntity");
      StatelessSession statelessSession = statelessSessionHome.create();
      EnterpriseEntity cmp = null;
      try {
        cmp = cmpHome.findByPrimaryKey("bill");
      } catch (Exception ex) {
        cmp = cmpHome.create("bill");
      }
      int count = 0;
      while (true) {
        System.out.println(statelessSession.callBusinessMethodB());
        try {
          cmp.setOtherField(count++);
        } catch (Exception ex) {
          System.out.println("exception, trying to create it: " + ex);
          cmp = cmpHome.create("bill");
          cmp.setOtherField(count++);
        }
        System.out.println("Entity: " + cmp.getOtherField());
        Thread.sleep(2000);
      }
    } catch (NamingException nex) {
      if (nex.getRootCause() != null) {
        nex.getRootCause().printStackTrace();
      }
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
Esempio n. 8
0
 @AfterClass
 public static void tearDownClass() throws Exception {
   ic.close();
 }
Esempio n. 9
0
  public static void main(String[] args) throws Exception {

    SimpleReporterAdapter stat = new SimpleReporterAdapter();
    String testSuite = "CustomValidation ";
    InitialContext ic = new InitialContext();
    Object objRef = ic.lookup("java:comp/env/ejb/SimpleBMPHome");
    SimpleBMPHome convalBMPHome =
        (SimpleBMPHome) javax.rmi.PortableRemoteObject.narrow(objRef, SimpleBMPHome.class);

    SimpleBMP convalBMP = convalBMPHome.create();
    stat.addDescription("Custom Validation Tests");

    if (args != null && args.length > 0) {
      String param = args[0];

      switch (Integer.parseInt(param)) {
        case 1:
          {
            if (convalBMP.test1()) {
              stat.addStatus(testSuite + "test-1 ", stat.PASS);
            } else {
              stat.addStatus(testSuite + "test-1 ", stat.FAIL);
            }
            break;
          }
        case 3:
          {
            if (convalBMP.test1()) {
              stat.addStatus(testSuite + "test-3 ", stat.PASS);
              System.out.println("test-3 returned true as validation is enabled ");
            } else {
              stat.addStatus(testSuite + "test-3 ", stat.FAIL);
            }
            break;
          }
        case 4:
          {
            if (convalBMP.test1()) {
              stat.addStatus(testSuite + "test-4 ", stat.PASS);
              System.out.println("test-4 returned true as validation is enabled ");
            } else {
              stat.addStatus(testSuite + "test-4 ", stat.FAIL);
            }
            break;
          }

        case 2:
          {
            try {
              if (convalBMP.test1()) {
                stat.addStatus(testSuite + "test-2 ", stat.FAIL);
              } else {
                stat.addStatus(testSuite + "test-2 ", stat.PASS);
                System.out.println("test-2 returned false as validation is not enabled ");
              }
            } catch (Exception e) {
              stat.addStatus(testSuite + "test1 ", stat.PASS);
            }
            break;
          }
      }
      stat.printSummary();
    }
  }
  /**
   * See <a href="http://e-docs.bea.com/wls/docs100/javadocs/weblogic/common/T3StartupDef.html">
   * http://e-docs.bea.com/wls/docs100/javadocs/weblogic/common/T3StartupDef.html</a> for more
   * information.
   *
   * @param str Virtual name by which the class is registered as a {@code startupClass} in the
   *     {@code config.xml} file
   * @param params A hashtable that is made up of the name-value pairs supplied from the {@code
   *     startupArgs} property
   * @return Result string (log message).
   * @throws Exception Thrown if error occurred.
   */
  @SuppressWarnings({"unchecked", "CatchGenericClass"})
  @Override
  public String startup(String str, Hashtable params) throws Exception {
    GridLogger log = new GridJavaLogger(LoggingHelper.getServerLogger());

    cfgFile = (String) params.get(cfgFilePathParam);

    if (cfgFile == null) {
      throw new IllegalArgumentException("Failed to read property: " + cfgFilePathParam);
    }

    String workMgrName = (String) params.get(workMgrParam);

    URL cfgUrl = U.resolveGridGainUrl(cfgFile);

    if (cfgUrl == null)
      throw new ServerLifecycleException(
          "Failed to find Spring configuration file (path provided should be "
              + "either absolute, relative to GRIDGAIN_HOME, or relative to META-INF folder): "
              + cfgFile);

    GenericApplicationContext springCtx;

    try {
      springCtx = new GenericApplicationContext();

      XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(springCtx);

      xmlReader.loadBeanDefinitions(new UrlResource(cfgUrl));

      springCtx.refresh();
    } catch (BeansException e) {
      throw new ServerLifecycleException(
          "Failed to instantiate Spring XML application context: " + e.getMessage(), e);
    }

    Map cfgMap;

    try {
      // Note: Spring is not generics-friendly.
      cfgMap = springCtx.getBeansOfType(GridConfiguration.class);
    } catch (BeansException e) {
      throw new ServerLifecycleException(
          "Failed to instantiate bean [type="
              + GridConfiguration.class
              + ", err="
              + e.getMessage()
              + ']',
          e);
    }

    if (cfgMap == null)
      throw new ServerLifecycleException(
          "Failed to find a single grid factory configuration in: " + cfgUrl);

    if (cfgMap.isEmpty())
      throw new ServerLifecycleException("Can't find grid factory configuration in: " + cfgUrl);

    try {
      ExecutorService execSvc = null;

      MBeanServer mbeanSrv = null;

      for (GridConfiguration cfg : (Collection<GridConfiguration>) cfgMap.values()) {
        assert cfg != null;

        GridConfigurationAdapter adapter = new GridConfigurationAdapter(cfg);

        // Set logger.
        if (cfg.getGridLogger() == null) adapter.setGridLogger(log);

        if (cfg.getExecutorService() == null) {
          if (execSvc == null)
            execSvc =
                workMgrName != null
                    ? new GridThreadWorkManagerExecutor(workMgrName)
                    : new GridThreadWorkManagerExecutor(J2EEWorkManager.getDefault());

          adapter.setExecutorService(execSvc);
        }

        if (cfg.getMBeanServer() == null) {
          if (mbeanSrv == null) {
            InitialContext ctx = null;

            try {
              ctx = new InitialContext();

              mbeanSrv = (MBeanServer) ctx.lookup("java:comp/jmx/runtime");
            } catch (Exception e) {
              throw new IllegalArgumentException(
                  "MBean server was not provided and failed to obtain " + "Weblogic MBean server.",
                  e);
            } finally {
              if (ctx != null) ctx.close();
            }
          }

          adapter.setMBeanServer(mbeanSrv);
        }

        Grid grid = G.start(adapter, springCtx);

        // Test if grid is not null - started properly.
        if (grid != null) gridNames.add(grid.name());
      }

      return getClass().getSimpleName() + " started successfully.";
    } catch (GridException e) {
      // Stop started grids only.
      for (String name : gridNames) G.stop(name, true);

      throw new ServerLifecycleException("Failed to start GridGain.", e);
    }
  }
Esempio n. 11
0
  public void _jspService(HttpServletRequest request, HttpServletResponse response)
      throws java.io.IOException, ServletException {

    PageContext pageContext = null;
    HttpSession session = null;
    ServletContext application = null;
    ServletConfig config = null;
    JspWriter out = null;
    Object page = this;
    JspWriter _jspx_out = null;
    PageContext _jspx_page_context = null;

    try {
      response.setContentType("text/html;charset=UTF-8");
      pageContext = _jspxFactory.getPageContext(this, request, response, null, true, 8192, true);
      _jspx_page_context = pageContext;
      application = pageContext.getServletContext();
      config = pageContext.getServletConfig();
      session = pageContext.getSession();
      out = pageContext.getOut();
      _jspx_out = out;
      _jspx_resourceInjector =
          (org.apache.jasper.runtime.ResourceInjector)
              application.getAttribute("com.sun.appserv.jsp.resource.injector");

      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write("\n");
      out.write(" ");

      DataSource ds = null;
      Connection con = null;
      PreparedStatement ps = null;
      InitialContext ic;
      try {
        ic = new InitialContext();
        ds = (DataSource) ic.lookup("java:/jdbc/AVMS");
        // ds = (DataSource)ic.lookup( "java:/jboss" );
        con = ds.getConnection();
        ps = con.prepareStatement("SELECT * FROM dbo.ROLE");
        // pr = con.prepareStatement("SELECT * FROM dbo.JMS_USERS");
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
          out.println("<br> " + rs.getString("role_name") + " | " + rs.getString("role_desc"));
          // out.println("<br> " +rs.getString("USERID") + " | " +rs.getString("PASSWD"));
        }
        rs.close();
        ps.close();
      } catch (Exception e) {
        out.println("Exception thrown :: " + e);
      } finally {
        if (con != null) {
          con.close();
        }
      }
      out.write('\n');
      out.write('\n');
    } catch (Throwable t) {
      if (!(t instanceof SkipPageException)) {
        out = _jspx_out;
        if (out != null && out.getBufferSize() != 0) out.clearBuffer();
        if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
      }
    } finally {
      _jspxFactory.releasePageContext(_jspx_page_context);
    }
  }