Skip to content

Commit

Permalink
Fixed build failure.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vivs committed May 28, 2012
1 parent 2f33d6c commit a0421a7
Showing 1 changed file with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@
public class NativeQueryTest
{

/** The schema. */
private final String schema = "test";
// /** The schema. */
private final String schema = "KunderaExamples";

/**
* Sets the up.
Expand All @@ -66,7 +66,7 @@ public class NativeQueryTest
public void setUp() throws Exception
{
CassandraCli.cassandraSetUp();
CassandraCli.createKeySpace("KunderaExamples");
CassandraCli.createKeySpace(schema);
}

/**
Expand All @@ -91,16 +91,16 @@ public void testCreateNativeQuery()
public void testExecutNativeQuery()
{
EntityManagerFactoryImpl emf = getEntityManagerFactory();
String nativeSql = "CREATE KEYSPACE " + schema
+ " with strategy_class = 'SimpleStrategy' and strategy_options:replication_factor=1";
String useNativeSql = "USE test";
// String nativeSql = "CREATE KEYSPACE " + schema
// + " with strategy_class = 'SimpleStrategy' and strategy_options:replication_factor=1";
String useNativeSql = "USE " + schema;

EntityManager em = new EntityManagerImpl(emf, PersistenceUnitTransactionType.RESOURCE_LOCAL,
PersistenceContextType.EXTENDED);
Query q = em.createNativeQuery(nativeSql, CassandraEntitySample.class);
// q.getResultList();
q.executeUpdate();
q = em.createNativeQuery(useNativeSql, CassandraEntitySample.class);
// Query q = em.createNativeQuery(nativeSql, CassandraEntitySample.class);
// // q.getResultList();
// q.executeUpdate();
Query q = em.createNativeQuery(useNativeSql, CassandraEntitySample.class);
// q.getResultList();
q.executeUpdate();
Assert.assertTrue(CassandraCli.keyspaceExist(schema));
Expand All @@ -114,21 +114,22 @@ public void testExecutNativeQuery()
@Test
public void testReleasesNativeQueryConnection() {
EntityManagerFactoryImpl emf = getEntityManagerFactory();
String nativeSql = "CREATE KEYSPACE "
+ schema
+ " with strategy_class = 'SimpleStrategy' and strategy_options:replication_factor=1";
String useNativeSql = "USE test";
// String nativeSql = "CREATE KEYSPACE "
// + schema
// + " with strategy_class = 'SimpleStrategy' and strategy_options:replication_factor=1";
// String useNativeSql = "USE test";
String useNativeSql = "USE " + schema;

EntityManager em = new EntityManagerImpl(emf,
PersistenceUnitTransactionType.RESOURCE_LOCAL,
PersistenceContextType.EXTENDED);
Query q = em.createNativeQuery(nativeSql, CassandraEntitySample.class);
// q.getResultList();
q.executeUpdate();
// Query q = em.createNativeQuery(nativeSql, CassandraEntitySample.class);
// // q.getResultList();
// q.executeUpdate();

// won't be able to loop if connections are leaked
for (int i = 0; i < 30; i++) {
q = em.createNativeQuery(useNativeSql, CassandraEntitySample.class);
Query q = em.createNativeQuery(useNativeSql, CassandraEntitySample.class);
// q.getResultList();
q.executeUpdate();
}
Expand All @@ -140,16 +141,17 @@ public void testReleasesNativeQueryConnection() {
@Test
public void testCreateInsertColumnFamilyQuery()
{
String nativeSql = "CREATE KEYSPACE " + schema
+ " with strategy_class = 'SimpleStrategy' and strategy_options:replication_factor=1";
String useNativeSql = "USE test";
// String nativeSql = "CREATE KEYSPACE " + schema
// + " with strategy_class = 'SimpleStrategy' and strategy_options:replication_factor=1";
// String useNativeSql = "USE test";
String useNativeSql = "USE " + schema;
EntityManagerFactoryImpl emf = getEntityManagerFactory();
EntityManager em = new EntityManagerImpl(emf, PersistenceUnitTransactionType.RESOURCE_LOCAL,
PersistenceContextType.EXTENDED);
Query q = em.createNativeQuery(nativeSql, CassandraEntitySample.class);
// q.getResultList();
q.executeUpdate();
q = em.createNativeQuery(useNativeSql, CassandraEntitySample.class);
// Query q = em.createNativeQuery(nativeSql, CassandraEntitySample.class);
// // q.getResultList();
// q.executeUpdate();
Query q = em.createNativeQuery(useNativeSql, CassandraEntitySample.class);
// q.getResultList();
q.executeUpdate();
// create column family
Expand Down Expand Up @@ -259,7 +261,7 @@ private EntityManagerFactoryImpl getEntityManagerFactory()
@After
public void tearDown() throws Exception
{
CassandraCli.dropKeySpace("KunderaExamples");
// CassandraCli.dropKeySpace("KunderaExamples");
CassandraCli.dropKeySpace(schema);
}

Expand Down

0 comments on commit a0421a7

Please sign in to comment.