Permalink
Browse files

Fixed some build issue

  • Loading branch information...
1 parent e06e8c3 commit a1ca123f516156c200134667c49ce5acd7f0ef64 @kkmishra kkmishra committed Dec 18, 2012
@@ -195,11 +195,11 @@ public static void dropKeySpace(String keyspaceName)
try
{
client.system_drop_keyspace(keyspaceName);
- deleteCassandraFolders("/var/lib/cassandra/data/");
- deleteCassandraFolders("/var/lib/cassandra/data/system/");
- deleteCassandraFolders("/var/lib/cassandra/commitlog/");
- deleteCassandraFolders("/var/lib/cassandra/saved_caches/");
- deleteCassandraFolders("/var/log/cassandra/");
+// deleteCassandraFolders("/var/lib/cassandra/data/");
+// deleteCassandraFolders("/var/lib/cassandra/data/system/");
+// deleteCassandraFolders("/var/lib/cassandra/commitlog/");
+// deleteCassandraFolders("/var/lib/cassandra/saved_caches/");
+// deleteCassandraFolders("/var/log/cassandra/");
}
catch (InvalidRequestException e)
{
@@ -60,9 +60,7 @@
<property name="kundera.port" value="9160" />
<property name="kundera.keyspace" value="KunderaCounterColumn" />
<property name="kundera.dialect" value="cassandra" />
-
<!-- <property name="kundera.ddl.auto.prepare" value="create" /> -->
-
<property name="kundera.client.lookup.class"
value="com.impetus.client.cassandra.thrift.ThriftClientFactory" />
<property name="kundera.cache.provider.class"
@@ -1,4 +1,4 @@
-log4j.rootLogger=INFO, DRFA, CONSOLE
+log4j.rootLogger=WARN, DRFA, CONSOLE
### direct log messages to stdout ###
log4j.appender.DRFA=org.apache.log4j.DailyRollingFileAppender
@@ -40,99 +40,106 @@
* @author vivek.mishra
*
*/
-public class MongoBatchProcessorTest {
-
- /**
- * persistence unit.
- */
- private static final String PERSISTENCE_UNIT = "MongoBatchTest";
-
- /** The emf. */
- private static EntityManagerFactory emf;
-
- /** The em. */
- private static EntityManager em;
-
- private List<PersonBatchMongoEntity> rows;
-
- /**
- * @throws java.lang.Exception
- */
- @Before
- public void setUp() throws Exception {
- emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT);
- em = emf.createEntityManager();
- }
-
- /**
- * Test case for batch operation.
- */
- @Test
- public void onBatch() {
- int counter = 0;
- rows = prepareData(10);
- for (PersonBatchMongoEntity entity : rows) {
- em.persist(entity);
-
- // check for implicit flush.
- if (++counter == 5) {
- Map<String, Client> clients = (Map<String, Client>) em
- .getDelegate();
-
- Batcher client = (Batcher) clients.get(PERSISTENCE_UNIT);
- Assert.assertEquals(5, client.getBatchSize());
- em.clear();
- for (int i = 0; i < 5; i++) {
-
- // assert on each batch size record
- Assert.assertNotNull(em.find(PersonBatchMongoEntity.class,
- rows.get(i).getPersonId()));
-
- // as batch size is 5.
- Assert.assertNull(em.find(PersonBatchMongoEntity.class,
- rows.get(6).getPersonId()));
- }
- // means implicit flush must happen
- }
- }
-
- // flush all on close.
- // explicit flush on close
- em.clear();
- em.flush();
-
- String sql = " Select p from PersonBatchMongoEntity p";
- Query query = em.createQuery(sql);
- List<PersonBatchMongoEntity> results = query.getResultList();
- Assert.assertNotNull(results);
- Assert.assertEquals(10, results.size());
- }
-
- /**
- * @throws java.lang.Exception
- */
- @After
- public void tearDown() throws Exception {
- for (PersonBatchMongoEntity o : rows) {
- em.remove(o);
- }
-
- MongoUtils.dropDatabase(emf, PERSISTENCE_UNIT);
- em.close();
- emf.close();
- }
-
- private List<PersonBatchMongoEntity> prepareData(Integer noOfRecords) {
- List<PersonBatchMongoEntity> persons = new ArrayList<PersonBatchMongoEntity>();
- for (int i = 1; i <= noOfRecords; i++) {
- PersonBatchMongoEntity o = new PersonBatchMongoEntity();
- o.setPersonId(i + "");
- o.setPersonName("vivek" + i);
- o.setAge(10);
- persons.add(o);
- }
-
- return persons;
- }
+public class MongoBatchProcessorTest
+{
+
+ /**
+ * persistence unit.
+ */
+ private static final String PERSISTENCE_UNIT = "MongoBatchTest";
+
+ /** The emf. */
+ private static EntityManagerFactory emf;
+
+ /** The em. */
+ private static EntityManager em;
+
+ private List<PersonBatchMongoEntity> rows;
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @Before
+ public void setUp() throws Exception
+ {
+ emf = Persistence.createEntityManagerFactory(PERSISTENCE_UNIT);
+ em = emf.createEntityManager();
+ }
+
+ /**
+ * Test case for batch operation.
+ */
+ @Test
+ public void onBatch()
+ {
+ int counter = 0;
+ rows = prepareData(10);
+ for (PersonBatchMongoEntity entity : rows)
+ {
+ em.persist(entity);
+
+ // check for implicit flush.
+ if (++counter == 5)
+ {
+ Map<String, Client> clients = (Map<String, Client>) em.getDelegate();
+
+ Batcher client = (Batcher) clients.get(PERSISTENCE_UNIT);
+ Assert.assertEquals(5, client.getBatchSize());
+ em.clear();
+ for (int i = 0; i < 5; i++)
+ {
+
+ // assert on each batch size record
+ Assert.assertNotNull(em.find(PersonBatchMongoEntity.class, rows.get(i).getPersonId()));
+
+ // as batch size is 5.
+ Assert.assertNull(em.find(PersonBatchMongoEntity.class, rows.get(6).getPersonId()));
+ }
+ // means implicit flush must happen
+ }
+ }
+
+ // flush all on close.
+ // explicit flush on close
+ em.clear();
+ em.flush();
+
+ String sql = " Select p from PersonBatchMongoEntity p";
+ Query query = em.createQuery(sql);
+ List<PersonBatchMongoEntity> results = query.getResultList();
+ Assert.assertNotNull(results);
+ Assert.assertEquals(10, results.size());
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ @After
+ public void tearDown() throws Exception
+ {
+ for (PersonBatchMongoEntity o : rows)
+ {
+ em.remove(o);
+ }
+
+ MongoUtils.dropDatabase(emf, PERSISTENCE_UNIT);
+ em.close();
+ emf.close();
+ }
+
+ private List<PersonBatchMongoEntity> prepareData(Integer noOfRecords)
+ {
+ List<PersonBatchMongoEntity> persons = new ArrayList<PersonBatchMongoEntity>();
+ for (int i = 1; i <= noOfRecords; i++)
+ {
+ PersonBatchMongoEntity o = new PersonBatchMongoEntity();
+ o.setPersonId(i + "");
+ o.setPersonName("vivek" + i);
+ o.setAge(10);
+ persons.add(o);
+ }
+
+ return persons;
+ }
}
@@ -206,5 +206,6 @@ public void tearDown() throws Exception
em.remove(val);
}
MongoUtils.dropDatabase(emf, _PU);
+ emf.close();
}
}
Oops, something went wrong.

0 comments on commit a1ca123

Please sign in to comment.