summaryrefslogtreecommitdiffstats
path: root/proxy/src
diff options
context:
space:
mode:
Diffstat (limited to 'proxy/src')
-rw-r--r--proxy/src/main/java/org/fedoraproject/candlepin/util/EntityManagerUtil.java2
-rw-r--r--proxy/src/main/resources/WEB-INF/web.xml45
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTest.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/model/ConsumerTest.java)5
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTypeTest.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/model/ConsumerTypeTest.java)16
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/ObjectFactoryTest.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/model/ObjectFactoryTest.java)2
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/OwnerTest.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/model/OwnerTest.java)2
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/ProductTest.java64
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/model/test/TestUtil.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/model/TestUtil.java)2
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/ApiTest.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/resource/ApiTest.java)2
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/ConsumerResourceTest.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/resource/ConsumerResourceTest.java)4
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementMatcherTest.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/resource/EntitlementMatcherTest.java)4
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementResourceTest.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/resource/EntitlementResourceTest.java)4
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/TestResourceTest.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/resource/TestResourceTest.java)2
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/UserResourceTest.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/resource/UserResourceTest.java)2
-rw-r--r--proxy/src/test/java/org/fedoraproject/candlepin/resource/test/cert/test/CertTest.java (renamed from proxy/src/test/java/org/fedoraproject/candlepin/resource/cert/CertTest.java)2
15 files changed, 134 insertions, 24 deletions
diff --git a/proxy/src/main/java/org/fedoraproject/candlepin/util/EntityManagerUtil.java b/proxy/src/main/java/org/fedoraproject/candlepin/util/EntityManagerUtil.java
index b17964e..97a4b48 100644
--- a/proxy/src/main/java/org/fedoraproject/candlepin/util/EntityManagerUtil.java
+++ b/proxy/src/main/java/org/fedoraproject/candlepin/util/EntityManagerUtil.java
@@ -6,7 +6,7 @@ import javax.persistence.Persistence;
public class EntityManagerUtil {
- public static final String DEFAULT_PERSISTENCE_UNIT = "production";
+ public static final String DEFAULT_PERSISTENCE_UNIT = "test";
public static final String PERSISTENCE_UNIT_PROPERTY = "persistenceUnit";
public static final EntityManagerFactory emf = buildEntityManagerFactory();
diff --git a/proxy/src/main/resources/WEB-INF/web.xml b/proxy/src/main/resources/WEB-INF/web.xml
new file mode 100644
index 0000000..ca517c4
--- /dev/null
+++ b/proxy/src/main/resources/WEB-INF/web.xml
@@ -0,0 +1,45 @@
+<web-app xmlns= "http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
+ version="2.4">
+ <!--
+ =======================================================================
+ FILTERS
+ =======================================================================
+ -->
+ <!--
+ =======================================================================
+ FILTER MAPPINGS
+ =======================================================================
+ -->
+ <!--
+ =======================================================================
+ LISTENERS
+ =======================================================================
+ -->
+ <!--
+ =======================================================================
+ SERVLETS
+ =======================================================================
+ -->
+ <servlet>
+ <servlet-name>Jersey Web Application</servlet-name>
+ <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class>
+ <init-param>
+ <!-- this is a semi-colon separated list of package names -->
+ <param-name>com.sun.jersey.config.property.packages</param-name>
+ <param-value>org.fedoraproject.candlepin.resource</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <!--
+ =======================================================================
+ SERVLET MAPPINGS
+ =======================================================================
+ -->
+ <servlet-mapping>
+ <servlet-name>Jersey Web Application</servlet-name>
+ <url-pattern>/*</url-pattern>
+ </servlet-mapping>
+</web-app>
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/ConsumerTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTest.java
index f7b9506..ec057bb 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/model/ConsumerTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTest.java
@@ -12,7 +12,9 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
-package org.fedoraproject.candlepin.model;
+package org.fedoraproject.candlepin.model.test;
+
+import static org.junit.Assert.assertEquals;
import org.fedoraproject.candlepin.model.BaseModel;
import org.fedoraproject.candlepin.model.Consumer;
@@ -20,7 +22,6 @@ import org.fedoraproject.candlepin.model.Owner;
import org.fedoraproject.candlepin.model.Product;
import org.junit.Test;
-import static org.junit.Assert.*;
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/ConsumerTypeTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTypeTest.java
index 79bedcb..229644e 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/model/ConsumerTypeTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ConsumerTypeTest.java
@@ -1,16 +1,16 @@
-package org.fedoraproject.candlepin.model;
+package org.fedoraproject.candlepin.model.test;
-import java.util.List;
-
-import javax.persistence.EntityManager;
-import javax.persistence.EntityManagerFactory;
-import javax.persistence.EntityTransaction;
-import javax.persistence.Persistence;
+import static org.junit.Assert.assertEquals;
import org.fedoraproject.candlepin.model.ConsumerType;
import org.fedoraproject.candlepin.util.EntityManagerUtil;
+
import org.junit.Test;
-import static org.junit.Assert.*;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
public class ConsumerTypeTest {
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/ObjectFactoryTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ObjectFactoryTest.java
index a015dc1..8bd66f1 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/model/ObjectFactoryTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ObjectFactoryTest.java
@@ -12,7 +12,7 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
-package org.fedoraproject.candlepin.model;
+package org.fedoraproject.candlepin.model.test;
import org.fedoraproject.candlepin.model.BaseModel;
import org.fedoraproject.candlepin.model.ObjectFactory;
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/OwnerTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/OwnerTest.java
index 02874b1..abfce82 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/model/OwnerTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/OwnerTest.java
@@ -12,7 +12,7 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
-package org.fedoraproject.candlepin.model;
+package org.fedoraproject.candlepin.model.test;
import org.fedoraproject.candlepin.model.BaseModel;
import org.fedoraproject.candlepin.model.Consumer;
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ProductTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ProductTest.java
new file mode 100644
index 0000000..318ea49
--- /dev/null
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/ProductTest.java
@@ -0,0 +1,64 @@
+package org.fedoraproject.candlepin.model.test;
+
+import static org.junit.Assert.assertEquals;
+
+import org.fedoraproject.candlepin.model.Product;
+import org.fedoraproject.candlepin.util.EntityManagerUtil;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+
+import javax.persistence.EntityManager;
+import javax.persistence.EntityTransaction;
+import javax.persistence.PersistenceException;
+
+public class ProductTest {
+
+ private EntityManager em;
+
+ @Before
+ public void setUp() {
+ em = EntityManagerUtil.createEntityManager();
+ }
+
+ @Test
+ public void normalCreate() {
+
+ Product prod = new Product("myproductlabel", "My Product");
+ storeObject(prod);
+
+ List<Product> results = em.createQuery("select p from Product as p")
+ .getResultList();
+ assertEquals(1, results.size());
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void nameRequired() {
+
+ Product prod = new Product();
+ prod.setLabel("someproductlabel");
+ storeObject(prod);
+
+ }
+
+ @Test(expected = PersistenceException.class)
+ public void labelRequired() {
+
+ Product prod = new Product();
+ prod.setName("My Product Name");
+ storeObject(prod);
+
+ }
+
+ public void storeObject(Object storeMe) {
+ EntityTransaction tx = null;
+ tx = em.getTransaction();
+ tx.begin();
+
+ em.persist(storeMe);
+ tx.commit();
+ }
+
+}
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/model/TestUtil.java b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/TestUtil.java
index 443d4f8..b2e2ad3 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/model/TestUtil.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/model/test/TestUtil.java
@@ -12,7 +12,7 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
-package org.fedoraproject.candlepin.model;
+package org.fedoraproject.candlepin.model.test;
import org.fedoraproject.candlepin.model.BaseModel;
import org.fedoraproject.candlepin.model.Consumer;
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/ApiTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/ApiTest.java
index ed57600..5b5b4e9 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/resource/ApiTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/ApiTest.java
@@ -12,7 +12,7 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
-package org.fedoraproject.candlepin.resource;
+package org.fedoraproject.candlepin.resource.test;
import org.fedoraproject.candlepin.model.BaseModel;
import org.fedoraproject.candlepin.model.ObjectFactory;
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/ConsumerResourceTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/ConsumerResourceTest.java
index 07b09b9..3c78078 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/resource/ConsumerResourceTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/ConsumerResourceTest.java
@@ -12,13 +12,13 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
-package org.fedoraproject.candlepin.resource;
+package org.fedoraproject.candlepin.resource.test;
import org.fedoraproject.candlepin.model.Consumer;
import org.fedoraproject.candlepin.model.ConsumerInfo;
import org.fedoraproject.candlepin.model.ConsumerType;
import org.fedoraproject.candlepin.model.ObjectFactory;
-import org.fedoraproject.candlepin.model.TestUtil;
+import org.fedoraproject.candlepin.model.test.TestUtil;
import org.fedoraproject.candlepin.resource.ConsumerResource;
import com.sun.jersey.api.client.Client;
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/EntitlementMatcherTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementMatcherTest.java
index 2948302..910eee0 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/resource/EntitlementMatcherTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementMatcherTest.java
@@ -12,14 +12,14 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
-package org.fedoraproject.candlepin.resource;
+package org.fedoraproject.candlepin.resource.test;
import org.fedoraproject.candlepin.model.Consumer;
import org.fedoraproject.candlepin.model.ConsumerType;
import org.fedoraproject.candlepin.model.ObjectFactory;
import org.fedoraproject.candlepin.model.Product;
import org.fedoraproject.candlepin.model.ProductFactory;
-import org.fedoraproject.candlepin.model.TestUtil;
+import org.fedoraproject.candlepin.model.test.TestUtil;
import org.fedoraproject.candlepin.resource.EntitlementMatcher;
import java.util.List;
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/EntitlementResourceTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementResourceTest.java
index 92493d9..7d75d05 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/resource/EntitlementResourceTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/EntitlementResourceTest.java
@@ -12,14 +12,14 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
-package org.fedoraproject.candlepin.resource;
+package org.fedoraproject.candlepin.resource.test;
import org.fedoraproject.candlepin.model.Consumer;
import org.fedoraproject.candlepin.model.ConsumerType;
import org.fedoraproject.candlepin.model.EntitlementPool;
import org.fedoraproject.candlepin.model.ObjectFactory;
import org.fedoraproject.candlepin.model.Product;
-import org.fedoraproject.candlepin.model.TestUtil;
+import org.fedoraproject.candlepin.model.test.TestUtil;
import org.fedoraproject.candlepin.resource.EntitlementResource;
import com.sun.jersey.api.client.Client;
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/TestResourceTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/TestResourceTest.java
index 7943cce..7fc3648 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/resource/TestResourceTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/TestResourceTest.java
@@ -12,7 +12,7 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
-package org.fedoraproject.candlepin.resource;
+package org.fedoraproject.candlepin.resource.test;
import org.fedoraproject.candlepin.model.ConsumerType;
import org.fedoraproject.candlepin.model.JsonTestObject;
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/UserResourceTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/UserResourceTest.java
index 1b2b8fa..7ada16c 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/resource/UserResourceTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/UserResourceTest.java
@@ -12,7 +12,7 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
-package org.fedoraproject.candlepin.resource;
+package org.fedoraproject.candlepin.resource.test;
import org.fedoraproject.candlepin.model.User;
import org.fedoraproject.candlepin.resource.UserResource;
diff --git a/proxy/src/test/java/org/fedoraproject/candlepin/resource/cert/CertTest.java b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/cert/test/CertTest.java
index 5dea0a4..ff94fa9 100644
--- a/proxy/src/test/java/org/fedoraproject/candlepin/resource/cert/CertTest.java
+++ b/proxy/src/test/java/org/fedoraproject/candlepin/resource/test/cert/test/CertTest.java
@@ -12,7 +12,7 @@
* granted to use or replicate Red Hat trademarks that are incorporated
* in this software or its documentation.
*/
-package org.fedoraproject.candlepin.resource.cert;
+package org.fedoraproject.candlepin.resource.test.cert.test;
import org.fedoraproject.candlepin.resource.cert.CertGenerator;