Package com.alibaba.json.bvt

Examples of com.alibaba.json.bvt.Issue213Test$Product


  @Test
  public void singleModuleTransactional() {
    assertNull( productRepository.getProductWithId( 1 ) );

    Product product = new Product( 1, "product 1" );
    productRepository.save( product );

    closeSession();
    openSession();

    Product other = productRepository.getProductWithId( 1 );
    assertNotNull( other );
    assertEquals( product, other );
  }
View Full Code Here


    assertEquals( user, other );
  }

  @Test
  public void combinedSave() {
    Product product = new Product( 2, "product 2" );
    User user = new User( 2, "user 2" );

    userRepository.save( user, product );

    closeSession();
    openSession();

    User otherUser = userRepository.getUserWithId( 2 );
    assertNotNull( otherUser );
    assertEquals( user, otherUser );

    Product otherProduct = productRepository.getProductWithId( 2 );
    assertNotNull( otherProduct );
    assertEquals( product, otherProduct );
  }
View Full Code Here

    assertEquals( product, otherProduct );
  }

  @Test
  public void combinedRollback() {
    Product product = new Product( 3, "product 3" );

    boolean failed = false;

    try {
      userRepository.save( null, product );
    }
    catch ( Exception e ) {
      failed = true;
    }

    assertTrue( failed );

    closeSession();
    openSession();

    Product otherProduct = productRepository.getProductWithId( 3 );
    assertNull( otherProduct );
  }
View Full Code Here

public class ListUser
{
    public static void main(String[] args) {
        Lista<Product> shoppingList = new ShoppingList();
       
        Product milk = new Product();
        milk.setDescription("A bottle of milk.");
       
        shoppingList.add(milk);
       
        printFirstItem(shoppingList);
       
View Full Code Here

        writer.println("<tr><td><b>ID</b></td> <td><b>NAME</b></td> <td><b>PRICE</b></td> <td><b>STOCK</b></td></tr>");
        if (products != null)
        {
            for (Iterator it = products.iterator(); it.hasNext();)
            {
               Product a = (Product)it.next();
   
                writer.println("<tr><td>" + a.getId() + "</td> <td>" + a.getName() + "</td> <td>" + a.getPrice()+ "</td> <td>" + a.getStock() + "</td></tr>");  
            }
        }
        writer.println("</table>");
       
    }
View Full Code Here

        // We don't have a reference to the selected Product.
        // So first we have to lookup the object,
        // we do this by a query by example (QBE):
        // 1. build an example object with matching primary key values:
        Product example = new Product();
        example.setId(id);

        // 2. build a QueryByIdentity from this sample instance:
        Query query = new QueryByIdentity(example);
        try
        {
            // 3. start broker transaction
            broker.beginTransaction();

            // 4. lookup the product specified by the QBE
            Product toBeEdited = (Product) broker.getObjectByQuery(query);

            // 5. edit the existing entry
            System.out.println("please edit the product entry");
            in = readLineWithMessage("enter name (was " + toBeEdited.getName() + "):");
            toBeEdited.setName(in);
            in = readLineWithMessage("enter price (was " + toBeEdited.getPrice() + "):");
            toBeEdited.setPrice(Double.parseDouble(in));
            in = readLineWithMessage("enter available stock (was " + toBeEdited.getStock() + "):");
            toBeEdited.setStock(Integer.parseInt(in));



            // 6. now ask broker to store the edited object
            broker.store(toBeEdited);
View Full Code Here

        // We don't have a reference to the selected Product.
        // So first we have to lookup the object,
        // we do this by a query by example (QBE):
        // 1. build an example object with matching primary key values:
        Product example = new Product();
        example.setId(id);
        // 2. build a QueryByIdentity from this sample instance:
        Query query = new QueryByIdentity(example);
        try
        {
            // start broker transaction
            broker.beginTransaction();
            // lookup the product specified by the QBE
            Product toBeDeleted = (Product) broker.getObjectByQuery(query);
            // now ask broker to delete the object
            broker.delete(toBeDeleted);
            // commit transaction
            broker.commitTransaction();
        }
View Full Code Here

    /** perform this use case*/
    public void apply()
    {
        // this will be our new object
        Product newProduct = new Product();
       
        // thma: attention, no sequence numbers yet for ojb/prevalyer       
        newProduct.setId((int)System.currentTimeMillis());
       
        // now read in all relevant information and fill the new object:
        System.out.println("please enter a new product");
        String in = readLineWithMessage("enter name:");
        newProduct.setName(in);
        in = readLineWithMessage("enter price:");
        newProduct.setPrice(Double.parseDouble(in));
        in = readLineWithMessage("enter available stock:");
        newProduct.setStock(Integer.parseInt(in));

        // now perform persistence operations
        try
        {
            // 1. open transaction
View Full Code Here

        writer.println("<tr><td><b>ID</b></td> <td><b>NAME</b></td> <td><b>PRICE</b></td> <td><b>STOCK</b></td></tr>");
        if (products != null)
        {
            for (Iterator it = products.iterator(); it.hasNext();)
            {
               Product a = (Product)it.next();
   
                writer.println("<tr><td>" + a.getId() + "</td> <td>" + a.getName() + "</td> <td>" + a.getPrice()+ "</td> <td>" + a.getStock() + "</td></tr>");  
            }
        }
        writer.println("</table>");
       
    }
View Full Code Here

        // We don't have a reference to the selected Product.
        // So first we have to lookup the object,
        // we do this by a query by example (QBE):
        // 1. build an example object with matching primary key values:
        Product example = new Product();
        example.setId(id);

        // 2. build a QueryByIdentity from this sample instance:
        Query query = new QueryByIdentity(example);
        try
        {
            // 3. start broker transaction
            broker.beginTransaction();

            // 4. lookup the product specified by the QBE
            Product toBeEdited = (Product) broker.getObjectByQuery(query);

            // 5. edit the existing entry
            System.out.println("please edit the product entry");
            in = readLineWithMessage("enter name (was " + toBeEdited.getName() + "):");
            toBeEdited.setName(in);
            in = readLineWithMessage("enter price (was " + toBeEdited.getPrice() + "):");
            toBeEdited.setPrice(Double.parseDouble(in));
            in = readLineWithMessage("enter available stock (was " + toBeEdited.getStock() + "):");
            toBeEdited.setStock(Integer.parseInt(in));



            // 6. now ask broker to store the edited object
            broker.store(toBeEdited);
View Full Code Here

TOP

Related Classes of com.alibaba.json.bvt.Issue213Test$Product

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.