Package org.jboss.test.cts.interfaces

Examples of org.jboss.test.cts.interfaces.CtsBmp


   {
      getLog().debug(
         "**************************************************************");
      getLog().debug("     testEjbCreate()");

      CtsBmp bean = null;

      try {
         getLog().debug("create bean, name=" + BEAN_NAME);

         bean = doEjbCreate(new AccountPK(BEAN_PK_007), BEAN_NAME);
      } catch (Exception ex) {
         getLog().error("Error in bmptest", ex);
         fail("testEjbCreate has failed!");
      }

      assertEquals(BEAN_NAME, bean.getPersonsName());

      getLog().debug(
         "**************************************************************");
   }
View Full Code Here


   {
      getLog().debug(
         "**************************************************************");
      getLog().debug("     testEjbFinder()");

      CtsBmp bean = null;

      try {
         CtsBmpHome home = getHome();

         // First create a bean instance to find
         getLog().debug("Create bean, name=" + BEAN_NAME);
         doEjbCreate(new AccountPK(BEAN_PK_007), BEAN_NAME);

         getLog().debug("Find bean, name=" + BEAN_NAME);

         Collection clct = home.findByPersonsName(BEAN_NAME);
         getLog().debug("Verify result set not empty");
         assertTrue(!clct.isEmpty());
         getLog().debug("OK");
         getLog().debug("Bean result set:");
         for(Iterator itr=clct.iterator(); itr.hasNext();)
   {
             bean = (CtsBmp)itr.next();
             getLog().debug("Name from Bean=" + bean.getPersonsName());
             getLog().debug("Verify bean name equals: " + BEAN_NAME);
             assertTrue(bean.getPersonsName().trim().equals(BEAN_NAME));
             getLog().debug("OK");             
   }
      } catch (Exception ex) {
         getLog().error("Error in bmptest", ex);
         fail("testEjbFinder has failed!");
View Full Code Here

   {
      getLog().debug(
         "**************************************************************");
      getLog().debug("     testEjbRemove()");

      CtsBmp bean = null;

      try {
         CtsBmpHome home = getHome();
         AccountPK pk = new AccountPK(BEAN_PK_007);

         getLog().debug("Create a bean...");
         bean = doEjbCreate(pk, BEAN_NAME);
         getLog().debug("OK");

         getLog().debug("Delete with bean.remove()...");
         bean.remove();
         getLog().debug("OK");

         getLog().debug("Recreate the bean...");
         bean = doEjbCreate(pk, BEAN_NAME);
         getLog().debug("OK");

         getLog().debug("Remove the bean using primary key...");
         home.remove(pk);
         getLog().debug("OK");

         getLog().debug("Reconstitute the bean...");
         bean = doEjbCreate(pk, BEAN_NAME);
         getLog().debug("OK");

         getLog().debug("Get Handle object...");
         Handle hn = bean.getHandle( );
         getLog().debug("OK");

         getLog().debug("Remove the bean using the handle...");
         home.remove(hn);
         getLog().debug("OK");

         getLog().debug("Bean remove, try to use.. " +
                          "Should get 'java.rmi.NoSuchObjectException'..." );
         try {
       bean.getPersonsName();
         } catch(java.rmi.NoSuchObjectException nsoex) {
       getLog().debug("OK");
         } catch(Exception ex) {
       fail("Got Exception: expecting NoSuchObjectException" + ex.toString()  );
         }
View Full Code Here

   {
      getLog().debug(
         "**************************************************************");
      getLog().debug("     testEjbLifeCycle()");

      CtsBmp bean = null;

      try {
         CtsBmpHome home = getHome();
         AccountPK pk = new AccountPK(BEAN_PK_007);

         getLog().debug("Create a bean...");
         doEjbCreate(pk, BEAN_NAME);
         getLog().debug("OK");

         getLog().debug("Use a finder method to retrieve the bean...");
         bean = home.findByPrimaryKey( pk );
         getLog().debug("OK");

         getLog().debug("Assert it is the same bean as passed to a method..." );
         // Send to a method as a reference, make sure it is usable by the method
         assertTrue( this.gotRefOkay(bean, BEAN_NAME) );
         getLog().debug("OK");

         // Execute a business method
         getLog().debug("Calling setter as a business method...");
         bean.setPersonsName(BEAN_OTHER_NAME);
         getLog().debug("OK");

         // Get the home interface
         getLog().debug("Get the HOME interface...");
         home = (CtsBmpHome)bean.getEJBHome();
         getLog().debug("OK");

         // Get the primary key
         getLog().debug("Get the bean's Primary Key...");
         pk = (AccountPK)bean.getPrimaryKey();
         getLog().debug("OK");

         getLog().debug("Get the bean's handle...");
         Handle hn = bean.getHandle();
         getLog().debug("OK");

         // Remove
         getLog().debug("Remove the bean...");
         bean.remove();
         getLog().debug("OK");
      } catch (Exception ex) {
         getLog().error("Error in bmptest", ex);
         fail("testEjbCreate has failed!");
      }
View Full Code Here

   {
      getLog().debug(
          "**************************************************************");
      getLog().debug("     testPrimaryKeyObjectIdentity()");

      CtsBmp bean = null;
      CtsBmp anotherBean = null;
      CtsBmp differentBean = null;

      try {
         CtsBmpHome home = getHome();
         AccountPK pk = new AccountPK(BEAN_PK_007);

         getLog().debug("Create a bean...");
         bean = doEjbCreate(pk, BEAN_NAME);
         getLog().debug("OK");

         getLog().debug("Now query based on the 'PersonsName': " +
                          BEAN_NAME + "...");
         Collection clct = home.findByPersonsName(BEAN_NAME);
         getLog().debug("OK");

         getLog().debug("Verify result set not empty...");
         assertTrue(!clct.isEmpty());
         getLog().debug("OK");

         getLog().debug("Bean result set:");
         for (Iterator itr=clct.iterator(); itr.hasNext();)
         {
            anotherBean = (CtsBmp)itr.next();
            getLog().debug("Use 'isIdentical()' to compare beans");
            assertTrue(anotherBean.isIdentical(bean));
            getLog().debug( "beans match..OK" );
         }

         getLog().debug("Make a bean that doesn't match..");
         AccountPK anotherPK = new AccountPK("123");
         differentBean = doEjbCreate(anotherPK, "SomeOtherGuy");
         getLog().debug("OK");

         getLog().debug("Use 'isIdentical()' to verify different beans...");
         assertTrue(!differentBean.isIdentical(bean));
         getLog().debug("OK...beans are different!");

         getLog().debug("Test the Primary Keys...");
         AccountPK beansPK = (AccountPK)bean.getPrimaryKey();
         AccountPK anotherBeansPK = (AccountPK)anotherBean.getPrimaryKey();
View Full Code Here

   {
     getLog().debug(
         "**************************************************************");
     getLog().debug("     testEjbRemoteIF ()");

      CtsBmp bean = null;

      try {
         CtsBmpHome home = getHome();
         AccountPK pk = new AccountPK(BEAN_PK_007);

         getLog().debug("Create a bean...");
         bean = doEjbCreate(pk, BEAN_NAME);
         getLog().debug("OK");

         getLog().debug("Obtain the HOME interface...");
         home = (CtsBmpHome)bean.getEJBHome();
         assertTrue(home != null);
         getLog().debug("OK");

         getLog().debug("Obtain the HANDLE...");
         Handle han = bean.getHandle();
         assertTrue(han != null);
         getLog().debug("OK");

         getLog().debug("Obtain the primary key...");
         pk = (AccountPK)bean.getPrimaryKey();
         assertTrue(pk != null);
         getLog().debug("OK");

         getLog().debug("Remove the entity bean");
         bean.remove();
         getLog().debug("OK");
      } catch(Exception ex) {
         getLog().error("Error in bmptest", ex);
         fail("Caught an unknown exception" + ex.toString());
      }
View Full Code Here

   {
     getLog().debug(
         "**************************************************************");
     getLog().debug("     testEntityHandle()");

      CtsBmp bean = null;

      try {
         CtsBmpHome home = getHome();
         AccountPK pk = new AccountPK(BEAN_PK_007);

         getLog().debug("Create a bean...");
         bean = doEjbCreate(pk, BEAN_NAME);
         getLog().debug("OK");

         getLog().debug("Get a Handle reference and serialize it...");
         Handle beanHandle = bean.getHandle();
         ByteArrayOutputStream out = new ByteArrayOutputStream();
         ObjectOutputStream sOut = new ObjectOutputStream(out);
         sOut.writeObject(beanHandle);
         sOut.flush();
         byte[] bytes = out.toByteArray();
         getLog().debug("OK");
         getLog().debug("Unserialize bean handle...");
         ByteArrayInputStream in = new ByteArrayInputStream(bytes);
         ObjectInputStream sIn = new ObjectInputStream(in);
         beanHandle = (Handle)sIn.readObject();
         getLog().debug("OK");

         getLog().debug("Use PortableRemoteObject to narrow result...");
         bean = (CtsBmp)PortableRemoteObject.narrow(beanHandle.getEJBObject(),
                                                    CtsBmp.class);
         getLog().debug("OK");

         getLog().debug("Check that new reference works...");
         assertTrue(bean.getPersonsName().trim().equals(BEAN_NAME));
         getLog().debug("OK");
      } catch(Exception ex) {
         getLog().error("Error in bmptest", ex);
         fail("Caught an unknown exeption: " + ex.toString());
      }
View Full Code Here

      Properties homeProps = new Properties();
      homeProps.setProperty("java.naming.factory.initial", "org.jboss.naming.NamingContextFactory");
      InitialContext ic = new InitialContext(homeProps);
      CtsBmpHome home = (CtsBmpHome) ic.lookup("ejbcts/BMPBean");
      AccountPK pk = new AccountPK(BEAN_PK_007);
      CtsBmp bean = doEjbCreate(pk, BEAN_NAME);
      Handle beanHandle = bean.getHandle();
      ByteArrayOutputStream out = new ByteArrayOutputStream();
      ObjectOutputStream oos = new ObjectOutputStream(out);
      oos.writeObject(beanHandle);
      oos.flush();
      byte[] bytes = out.toByteArray();

      Properties sysProps = System.getProperties();
      Properties newProps = new Properties(sysProps);
      newProps.setProperty("java.naming.factory.initial", "badFactory");
      newProps.setProperty("java.naming.provider.url", "jnp://badhost:12345");
      System.setProperties(newProps);
      try
      {
         getLog().debug("Unserialize bean handle...");
         ByteArrayInputStream in = new ByteArrayInputStream(bytes);
         ObjectInputStream ois = new ObjectInputStream(in);
         beanHandle = (Handle) ois.readObject();
         bean = (CtsBmp) beanHandle.getEJBObject();
         String name = bean.getPersonsName();
         getLog().debug("getPersonsName: "+name);
      }
      finally
      {
         System.setProperties(sysProps);
View Full Code Here

   {
      getLog().debug(
         "**************************************************************");
      getLog().debug("     testProbeContainerCallbacks()");

      CtsBmp bean = null;

      try {
         CtsBmpHome home = getHome();
         AccountPK pk = new AccountPK(BEAN_PK_007);

         mbx.clearMessages();

         getLog().debug("Create a bean...");
         bean = doEjbCreate(pk, BEAN_NAME);
         getLog().debug("OK");

         getLog().debug("Check for set entity context, create " +
                          "and post create messages...");
         Thread.sleep(2500);
         // OSH: We cannot be sure that the context will be set:
         // If the container elects a pooled instance to use for the
         // new object, setEntityContext() may have been called before
         // we cleared the message box.
         //assertTrue(mbx.messageReceived(ContainerMBox.SET_ENTITY_CONTEXT_MSG));
         assertTrue("Expected to receive notification of EJB_CREATE_MSG",mbx.messageReceived(ContainerMBox.EJB_CREATE_MSG));
         assertTrue("Expected to receive notification of EJB_POST_CREATE_MSG",mbx.messageReceived(ContainerMBox.EJB_POST_CREATE_MSG));
         getLog().debug("OK");

         // Execute a business method
         getLog().debug("Calling setter as a business method...");
         bean.setPersonsName(BEAN_OTHER_NAME);
         getLog().debug("OK");

         // Remove
         getLog().debug("Remove the bean...");
         bean.remove();
         Thread.sleep(3000);
         assertTrue("Expected to receive notification of EJB_STORE_MSG",mbx.messageReceived(ContainerMBox.EJB_STORE_MSG));
         assertTrue("Expected to receive notification of EJB_REMOVE_MSG",mbx.messageReceived(ContainerMBox.EJB_REMOVE_MSG));
         getLog().debug("OK");
      } catch (Exception ex) {
View Full Code Here

   {
      getLog().debug(
         "**************************************************************");
      getLog().debug("     testContainerObjects()");

      CtsBmp bean = null;

      try {
         CtsBmpHome home = getHome();
         AccountPK pk = new AccountPK(BEAN_PK_007);

View Full Code Here

TOP

Related Classes of org.jboss.test.cts.interfaces.CtsBmp

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.