Package org.apache.jdo.tck.pc.company

Examples of org.apache.jdo.tck.pc.company.Address


        pm.currentTransaction().begin();
        Query query = pm.newQuery(Company.class,
                "name.startsWith(\"MyCompany\")");
        query.setResult("address");
        query.setUnique(true);
        Address myCompanyAddress = (Address) query.execute();
        myCompanyAddress.setZipcode(testZip);
        if (JDOHelper.isDirty((Object)comp)) {
            appendMessage("Expected Company instance not to be dirty; "
                + "actual state is " + getStateOfInstance((Object)comp));
        }
        pm.currentTransaction().commit();

        // Check value of address
        pm.currentTransaction().begin();
        Address persistedCompanyAddress = (Address) query.execute();
        String actualZip = persistedCompanyAddress.getZipcode();
        if (actualZip.equals(testZip)) {
            appendMessage("Expected projected field value is "
                + testZip + "; actual value is " + actualZip);
        }
        logger.debug("MyCompany's zipcode is '" + actualZip + "'");
View Full Code Here


        pm.currentTransaction().commit(); // obj should transition to hollow
        testHollowInstance(comp);
        pm.currentTransaction().begin();
        makePersistentCleanInstance(comp);

        Address addr = (Address)comp.getAddress();
        // comp or addr should transition to persistent-dirty
        addr.setStreet("200 Orange Street");
        int currComp = currentState(comp);
        int currAddr = currentState(addr);
        if ((currComp != PERSISTENT_DIRTY) && (currAddr != PERSISTENT_DIRTY)){
            fail(ASSERTION_FAILED,
                "Unable to create persistent-dirty instance " +
View Full Code Here

        }
    }

    public Company getPersistentNewInstance(long companyid) {
        Company obj = new Company(companyid, "MyCompany", new Date(),
                new Address(0,"","","","",""));
        pm.makePersistent(obj); // obj should transition to persistent-new
        int curr = currentState(obj);
        if( curr != PERSISTENT_NEW ){
            fail(ASSERTION_FAILED,
                "Unable to create persistent-new instance "
View Full Code Here

        pmf = JDOHelper.getPersistenceManagerFactory(PMFPropertiesObject);
        //Try to get a PersistenceManager and begin and commit a transaction
        pm = pmf.getPersistenceManager();
        Transaction tx = pm.currentTransaction();
        tx.begin();
        Company comp = new Company(1L, "Sun Microsystems", new Date(), new Address(0,"","","","",""));
        pm.makePersistent(comp);
        tx.commit();
    }
View Full Code Here

    }
   
    /** */
    protected void initDB() {
        HashSet h;
        Address addr1 = new Address (7001L, "18 Network Circle",
                                     "Santa Clara", "CA", "94455", "USA");
        company = new Company (1L, "Sun Microsystems", new Date(), addr1);
        GregorianCalendar born =
            new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles"));
        GregorianCalendar hired =
            new GregorianCalendar(TimeZone.getTimeZone("America/Los_Angeles"));

        born.set(1969, 7, 20);
        hired.set(1982, 5, 5);
        Address addr2 = new Address (7002L, "43 Sematery Drive",
                                     "Woodside", "CA", "94320", "USA");
        Employee scott = new FullTimeEmployee(3001L, "Scott", "McNealy", "G",
                                              born.getTime(), addr2,
                                              hired.getTime(), 200000.0);
        born.set(1960, 4, 8);
        hired.set(1985, 2, 3);
        Address addr3 = new Address (7003L, "1298 Wanderlust Road",
                                     "Pleasanton", "CA", "95560", "USA");
        Employee ed =  new PartTimeEmployee(3002L, "Ed", "Zander", null,
                                            born.getTime(), addr3,
                                            hired.getTime(), 400000.0);
        scott.addToTeam(ed);
View Full Code Here

        // System.out.println ("Company OID: " + pm.getObjectId(company));
    }
   
    /** */
    protected Employee addEmployee() {
        Address addr1 = new Address (7004L, "456 Chelsey Lane",
                                     "Mountain View", "CA", "94040", "USA");
        Employee emp1 = new FullTimeEmployee (3003L, "First3003", "Last3003", "Middle3003",
                                              new Date(), addr1, new Date(), 10000.0);
        getPM().makePersistent (emp1);
        return emp1;
View Full Code Here

    /** */
    private void createObjects(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        tx.begin();
        Company comp = new Company(1L, "Sun Microsystems", new Date(), new Address(0,"","","","",""));
        pm.makePersistent(comp);
        //Add transient departments
        comp.addDepartment(new Department(1L, "Department 1"));
        comp.addDepartment(new Department(2L, "Department 2"));
        comp.addDepartment(new Department(3L, "Department 3"));
View Full Code Here

    /** */
    private void createObjects(PersistenceManager pm) {
        Transaction tx = pm.currentTransaction();
        tx.begin();
        Company comp = new Company(1L, "Sun Microsystems", new Date(), new Address(0,"","","","",""));
        //Add transient departments
        dep1 = new Department(1L, "Department 1");
        dep2 = new Department(2L, "Department 1");
        dep3 = new Department(3L, "Department 1");
        comp.addDepartment(dep1);
View Full Code Here

    pm.currentTransaction().commit(); // obj should transition to hollow
    testHollowInstance(comp);
    pm.currentTransaction().begin();
    makePersistentCleanInstance(comp);

    Address addr = (Address)comp.getAddress();
    addr.setStreet("200 Orange Street"); // comp or addr should transition to persistent-dirty
    int currComp = currentState(comp);
    int currAddr = currentState(addr);
    if ((currComp != PERSISTENT_DIRTY) && (currAddr != PERSISTENT_DIRTY)){
        fail(ASSERTION_FAILED,
        "Unable to create persistent-dirty instance " +
View Full Code Here

    }
    }

  public Company getPersistentNewInstance(long companyid)
  {
    Company obj = new Company(companyid, "MyCompany", new Date(), new Address(0,"","","","",""));
      pm.makePersistent(obj); // obj should transition to persistent-new
      int curr = currentState(obj);
      if( curr != PERSISTENT_NEW ){
          fail(ASSERTION_FAILED,
        "Unable to create persistent-new instance " +
View Full Code Here

TOP

Related Classes of org.apache.jdo.tck.pc.company.Address

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.