JDO -> Integration (#1752)

* JDOIntegration

* JDOIntegration
This commit is contained in:
Grzegorz Piwowarek 2017-04-29 20:10:52 +02:00 committed by GitHub
parent 68190482b4
commit 0f300ece2e
1 changed files with 12 additions and 14 deletions

View File

@ -1,21 +1,20 @@
package com.baeldung.jdo; package com.baeldung.jdo;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import java.util.Iterator;
import java.util.List;
import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
import javax.jdo.Transaction;
import org.datanucleus.api.jdo.JDOPersistenceManagerFactory; import org.datanucleus.api.jdo.JDOPersistenceManagerFactory;
import org.datanucleus.metadata.PersistenceUnitMetaData; import org.datanucleus.metadata.PersistenceUnitMetaData;
import org.junit.Test; import org.junit.Test;
public class GuideToJDOTest { import javax.jdo.PersistenceManager;
import javax.jdo.PersistenceManagerFactory;
import javax.jdo.Query;
import javax.jdo.Transaction;
import java.util.Iterator;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
public class GuideToJDOIntegrationTest {
@Test @Test
public void givenProduct_WhenNewThenPerformTransaction() { public void givenProduct_WhenNewThenPerformTransaction() {
PersistenceUnitMetaData pumd = new PersistenceUnitMetaData("dynamic-unit", "RESOURCE_LOCAL", null); PersistenceUnitMetaData pumd = new PersistenceUnitMetaData("dynamic-unit", "RESOURCE_LOCAL", null);
@ -34,8 +33,7 @@ public class GuideToJDOTest {
tx.begin(); tx.begin();
for (int i = 0; i < 100; i++){ for (int i = 0; i < 100; i++){
String nam = "Product-" + i; String nam = "Product-" + i;
double price = i; Product productx = new Product(nam, (double) i);
Product productx = new Product(nam, price);
pm.makePersistent(productx); pm.makePersistent(productx);
} }
tx.commit(); tx.commit();