incubator-aries-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From timothyjw...@apache.org
Subject svn commit: r916383 - in /incubator/aries/trunk/jpa/jpa-blueprint-aries: pom.xml src/main/java/org/apache/aries/jpa/blueprint/aries/impl/NSHandler.java src/test/java/org/apache/aries/jpa/blueprint/aries/test/NSHandlerTest.java
Date Thu, 25 Feb 2010 18:07:27 GMT
Author: timothyjward
Date: Thu Feb 25 18:07:27 2010
New Revision: 916383

URL: http://svn.apache.org/viewvc?rev=916383&view=rev
Log:
ARIES-202 : Separate the JPA blueprint integration from managed persistence contexts

Modified:
    incubator/aries/trunk/jpa/jpa-blueprint-aries/pom.xml
    incubator/aries/trunk/jpa/jpa-blueprint-aries/src/main/java/org/apache/aries/jpa/blueprint/aries/impl/NSHandler.java
    incubator/aries/trunk/jpa/jpa-blueprint-aries/src/test/java/org/apache/aries/jpa/blueprint/aries/test/NSHandlerTest.java

Modified: incubator/aries/trunk/jpa/jpa-blueprint-aries/pom.xml
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-blueprint-aries/pom.xml?rev=916383&r1=916382&r2=916383&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-blueprint-aries/pom.xml (original)
+++ incubator/aries/trunk/jpa/jpa-blueprint-aries/pom.xml Thu Feb 25 18:07:27 2010
@@ -80,6 +80,12 @@
       <artifactId>org.apache.aries.testsupport.unit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-simple</artifactId>
+      <version>1.5.6</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
        <resources>
@@ -92,9 +98,9 @@
                 </includes>
             </resource>
             <resource>
-              <targetPath>org/apache/aries/jpa/container/context/namespace</targetPath>
+              <targetPath>org/apache/aries/jpa/blueprint/namespace</targetPath>
               <filtering>false</filtering>
-              <directory>${basedir}/src/main/resources/org/apache/aries/jpa/container/context/namespace</directory>
+              <directory>${basedir}/src/main/resources/org/apache/aries/jpa/blueprint/namespace</directory>
               <includes>
                 <include>*.xsd</include>
               </includes>

Modified: incubator/aries/trunk/jpa/jpa-blueprint-aries/src/main/java/org/apache/aries/jpa/blueprint/aries/impl/NSHandler.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-blueprint-aries/src/main/java/org/apache/aries/jpa/blueprint/aries/impl/NSHandler.java?rev=916383&r1=916382&r2=916383&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-blueprint-aries/src/main/java/org/apache/aries/jpa/blueprint/aries/impl/NSHandler.java
(original)
+++ incubator/aries/trunk/jpa/jpa-blueprint-aries/src/main/java/org/apache/aries/jpa/blueprint/aries/impl/NSHandler.java
Thu Feb 25 18:07:27 2010
@@ -69,7 +69,7 @@
 public class NSHandler implements NamespaceHandler {
     /** Logger */
     private static final Logger _logger = LoggerFactory
-            .getLogger("org.apache.aries.jpa.container.context");
+            .getLogger("org.apache.aries.jpa.blueprint.aries");
 
     /** The JPA namespace */
     public static final String NS_URI = "http://aries.apache.org/xmlns/jpa/v1.0.0";
@@ -214,7 +214,11 @@
     }
 
     public URL getSchemaLocation(String namespace) {
-        return getClass().getResource("jpa.xsd");
+        if(NS_URI.equals(namespace))
+            return getClass().getResource(
+                "/org/apache/aries/jpa/blueprint/namespace/jpa.xsd");
+        else
+            return null;
     }
 
     public Metadata parse(Element element, ParserContext context) {

Modified: incubator/aries/trunk/jpa/jpa-blueprint-aries/src/test/java/org/apache/aries/jpa/blueprint/aries/test/NSHandlerTest.java
URL: http://svn.apache.org/viewvc/incubator/aries/trunk/jpa/jpa-blueprint-aries/src/test/java/org/apache/aries/jpa/blueprint/aries/test/NSHandlerTest.java?rev=916383&r1=916382&r2=916383&view=diff
==============================================================================
--- incubator/aries/trunk/jpa/jpa-blueprint-aries/src/test/java/org/apache/aries/jpa/blueprint/aries/test/NSHandlerTest.java
(original)
+++ incubator/aries/trunk/jpa/jpa-blueprint-aries/src/test/java/org/apache/aries/jpa/blueprint/aries/test/NSHandlerTest.java
Thu Feb 25 18:07:27 2010
@@ -19,6 +19,8 @@
 package org.apache.aries.jpa.blueprint.aries.test;
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.util.ArrayList;
@@ -79,6 +81,7 @@
     sut = new NSHandler();
     manager = Skeleton.newMock(PersistenceContextProvider.class);
     sut.setManager(manager);
+    sut.contextAvailable(null);
     
     clientBundle = Skeleton.newMock(Bundle.class);
         
@@ -207,6 +210,30 @@
   }
   
   @Test
+  public void testContextNoPersistenceContextProvider() {
+    
+    sut.contextUnavailable(null);
+    Element e = getTestElement("context");
+    BeanMetadata bean = 
+      (BeanMetadata) sut.decorate(e, Skeleton.newMock(BeanMetadata.class), parserCtx);
+    BeanMetadata innerBean = (BeanMetadata) ((BeanProperty) bean.getProperties().get(0)).getValue();
+
+    assertEquals("createEntityManager", innerBean.getFactoryMethod());
+    assertEquals("internalClose", innerBean.getDestroyMethod());
+
+    assertEquals(1, registeredComponents.size());
+    ReferenceMetadata reference = (ReferenceMetadata) registeredComponents.get(0);
+    
+    assertEquals(EntityManagerFactory.class.getName(), reference.getInterface());
+    assertEquals("(&(org.apache.aries.jpa.proxy.factory=*)(osgi.unit.name=myUnit))",
reference.getFilter());
+    
+    Map<String,Object> props = new HashMap<String, Object>();
+    props.put(PersistenceContextProvider.PERSISTENCE_CONTEXT_TYPE, PersistenceContextType.TRANSACTION);
+    Skeleton.getSkeleton(manager).assertNotCalled(
+        new MethodCall(PersistenceContextProvider.class, "registerContext", String.class,
Bundle.class, Map.class));
+  }
+  
+  @Test
   public void testContextWithProps() {
     Element e = getTestElement("contextWithProps");
     BeanMetadata bean = 
@@ -258,4 +285,11 @@
     
     return null;
   }
+  
+  @Test
+  public void testgetSchemaLocation()
+  {
+    assertNotNull("No schema found", sut.getSchemaLocation(NSHandler.NS_URI));
+    assertNull("No schema expected", sut.getSchemaLocation("http://maven.apache.org/POM/4.0.0"));
+  }
 }



Mime
View raw message