Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2011
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.42 KB | None | 0 0
  1. /*
  2.  * JBoss, Home of Professional Open Source.
  3.  * Copyright 2011, Red Hat, Inc., and individual contributors
  4.  * as indicated by the @author tags. See the copyright.txt file in the
  5.  * distribution for a full listing of individual contributors.
  6.  *
  7.  * This is free software; you can redistribute it and/or modify it
  8.  * under the terms of the GNU Lesser General Public License as
  9.  * published by the Free Software Foundation; either version 2.1 of
  10.  * the License, or (at your option) any later version.
  11.  *
  12.  * This software is distributed in the hope that it will be useful,
  13.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15.  * Lesser General Public License for more details.
  16.  *
  17.  * You should have received a copy of the GNU Lesser General Public
  18.  * License along with this software; if not, write to the Free
  19.  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20.  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  21.  */
  22.  
  23. package org.jboss.as.testsuite.integration.jpa.multiRow;
  24.  
  25. import org.jboss.arquillian.container.test.api.Deployment;
  26. import org.jboss.arquillian.junit.Arquillian;
  27. import org.jboss.arquillian.test.api.ArquillianResource;
  28. import org.jboss.shrinkwrap.api.Archive;
  29. import org.jboss.shrinkwrap.api.ShrinkWrap;
  30. import org.jboss.shrinkwrap.api.asset.StringAsset;
  31. import org.jboss.shrinkwrap.api.spec.JavaArchive;
  32. import org.junit.Test;
  33. import org.junit.runner.RunWith;
  34.  
  35. import javax.naming.InitialContext;
  36. import javax.naming.NamingException;
  37.  
  38. /**
  39.  * Transaction tests
  40.  *
  41.  * @author Scott Marlow
  42.  */
  43. @RunWith(Arquillian.class)
  44. //@Ignore
  45. public class InsertMultipleRowsTestCase {
  46.  
  47.     private static final String ARCHIVE_NAME = "jpa_InsertMultipleRowsTestCase";
  48.  
  49.     private static final String persistence_xml =
  50.         "<?xml version=\"1.0\" encoding=\"UTF-8\"?> " +
  51.             "<persistence xmlns=\"http://java.sun.com/xml/ns/persistence\" version=\"1.0\">" +
  52.             "  <persistence-unit name=\"mypc\">" +
  53.             "    <description>Persistence Unit." +
  54.             "    </description>" +
  55.             "  <jta-data-source>java:jboss/datasources/ExampleDS</jta-data-source>" +
  56.             "<properties> <property name=\"hibernate.hbm2ddl.auto\" value=\"create-drop\"/>" +
  57.             "</properties>" +
  58.             "  </persistence-unit>" +
  59.             "</persistence>";
  60.  
  61.     @ArquillianResource
  62.     private static InitialContext iniCtx;
  63.  
  64.     @Deployment
  65.     public static Archive<?> deploy() {
  66.  
  67.         JavaArchive jar = ShrinkWrap.create(JavaArchive.class, ARCHIVE_NAME + ".jar");
  68.         jar.addClasses(InsertMultipleRowsTestCase.class,
  69.             Employee.class,Employee2.class,Employee3.class,Employee4.class,Employee5.class,
  70.             SFSB1.class
  71.         );
  72.  
  73.         jar.addAsResource(new StringAsset(persistence_xml), "META-INF/persistence.xml");
  74.         return jar;
  75.     }
  76.  
  77.     protected static <T> T lookup(String beanName, Class<T> interfaceType) throws NamingException {
  78.         return interfaceType.cast(iniCtx.lookup("java:global/" + ARCHIVE_NAME + "/" + beanName + "!" + interfaceType.getName()));
  79.     }
  80.  
  81.     @Test
  82.     public void testCreateBunchOfEntities() throws Exception {
  83.         SFSB1 sfsb1 = lookup("SFSB1", SFSB1.class);
  84.         sfsb1.createEmployee("Sally", "1 home street", 1, 200);
  85.         sfsb1.createEmployee("Sally", "1 home street", 201, 500);
  86.  
  87.     }
  88.  
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement