<%@ page import="java.util.*,
                 org.jboss.ejb3.embedded.EJB3StandaloneBootstrap,
                 java.sql.ResultSet,
                 java.sql.Statement,
                 org.apache.log4j.BasicConfigurator,
                 org.apache.log4j.PatternLayout,
                 org.apache.log4j.ConsoleAppender,
                 org.apache.log4j.Priority,
                 org.apache.log4j.FileAppender,
                 org.jboss.logging.Logger,
                 javax.naming.InitialContext,
                 org.jboss.ejb3.embedded.EJB3StandaloneDeployer,
                 org.jboss.ejb3.test.standalone.CustomerDAO,
                 org.jboss.ejb3.test.standalone.Customer,
                 javax.sql.DataSource,
                 javax.transaction.TransactionManager,
                 java.sql.Connection" %>
<%@ page import="org.jboss.ejb3.embedded.EJB3StandaloneDeployer"%>
<%@ page import="javax.naming.NamingException"%>
<%@ page import="org.jboss.ejb3.test.standalone.ShoppingCart"%>
<%@ page import="javax.ejb.EJBNoSuchObjectException"%>

<%!

   private void executeEJBs(InitialContext ctx)
           throws NamingException
   {
      String output = "";
      CustomerDAO local = (CustomerDAO)ctx.lookup(CustomerDAO.class.getName());
      long id = local.createCustomer();
      Customer cust = local.findCustomer(id);

      if (!"Bill".equals(cust.getName())) throw new RuntimeException("FAILURE");

      ShoppingCart cart = (ShoppingCart)ctx.lookup(ShoppingCart.class.getName());
      cart.getCart().add("beer");
      cart.getCart().add("wine");
      if (2 != cart.getCart().size()) throw new RuntimeException("FAILURE");

      cart.checkout();

      boolean exceptionThrown = false;
      try
      {
         cart.getCart();
      }
      catch (EJBNoSuchObjectException e)
      {
         exceptionThrown = true;
      }
   }


%>

<html>
<body>
<%
   Hashtable properties = new Hashtable();
   properties.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
   properties.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
   executeEJBs(new InitialContext(properties));
%>
DONE!
</body>
</html>