sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jus...@apache.org
Subject svn commit: r1745233 - in /sling/trunk/bundles/extensions/models/integration-tests: pom.xml src/main/java/org/apache/sling/models/it/SimpleTest.java src/main/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java
Date Mon, 23 May 2016 16:22:13 GMT
Author: justin
Date: Mon May 23 16:22:12 2016
New Revision: 1745233

URL: http://svn.apache.org/viewvc?rev=1745233&view=rev
Log:
adding integration test showing child property injection

Modified:
    sling/trunk/bundles/extensions/models/integration-tests/pom.xml
    sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/SimpleTest.java
    sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java

Modified: sling/trunk/bundles/extensions/models/integration-tests/pom.xml
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/pom.xml?rev=1745233&r1=1745232&r2=1745233&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/models/integration-tests/pom.xml (original)
+++ sling/trunk/bundles/extensions/models/integration-tests/pom.xml Mon May 23 16:22:12 2016
@@ -280,13 +280,13 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.models.api</artifactId>
-            <version>1.2.3-SNAPSHOT</version>
+            <version>1.2.2</version>
             <scope>provided</scope>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.models.impl</artifactId>
-            <version>1.2.7-SNAPSHOT</version>
+            <version>1.2.8</version>
             <scope>provided</scope>
         </dependency>
         <!-- not part of launchpad 7 (see SLING-4710) -->

Modified: sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/SimpleTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/SimpleTest.java?rev=1745233&r1=1745232&r2=1745233&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/SimpleTest.java
(original)
+++ sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/SimpleTest.java
Mon May 23 16:22:12 2016
@@ -42,6 +42,7 @@ public class SimpleTest {
     private ResourceResolverFactory rrFactory;
     
     private String value;
+    private String childValue;
     private ResourceResolver resolver;
     private Resource resource;
     private Node createdNode;
@@ -49,12 +50,15 @@ public class SimpleTest {
     @Before
     public void setUp() throws Exception {
         value = RandomStringUtils.randomAlphanumeric(10);
+        childValue = RandomStringUtils.randomAlphanumeric(10);
 
-        resolver = rrFactory.getAdministrativeResourceResolver(null);     
+        resolver = rrFactory.getAdministrativeResourceResolver(null);
         Session session = resolver.adaptTo(Session.class);
         Node rootNode = session.getRootNode();
         createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10));
         createdNode.setProperty("testProperty", value);
+        Node child = createdNode.addNode("child");
+        child.setProperty("childProperty", childValue);
         session.save();
 
         resource = resolver.getResource(createdNode.getPath());
@@ -76,6 +80,7 @@ public class SimpleTest {
     
         assertNotNull("Model is null", model);
         assertEquals("Test Property is not set correctly", value, model.getTestProperty());
+        assertEquals("Child Test Property is not set correctly", childValue, model.getChildProperty());
         assertNotNull("Filters is null", model.getFilters());
         assertSame("Adaptable is not injected", resource, model.getResource());
     }

Modified: sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java
URL: http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java?rev=1745233&r1=1745232&r2=1745233&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java
(original)
+++ sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java
Mon May 23 16:22:12 2016
@@ -19,10 +19,13 @@ package org.apache.sling.models.it.model
 import java.util.List;
 
 import javax.inject.Inject;
+import javax.inject.Named;
 import javax.servlet.Filter;
 
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Optional;
 
 @Model(adaptables=Resource.class)
 public class FieldInjectionTestModel {
@@ -30,6 +33,10 @@ public class FieldInjectionTestModel {
     @Inject
     private String testProperty;
     
+    @Inject @Optional
+    @Named("child/childProperty")
+    private String childProperty;
+
     @Inject
     private List<Filter> filters;
     
@@ -43,6 +50,8 @@ public class FieldInjectionTestModel {
         return testProperty;
     }
     
+    public String getChildProperty() { return childProperty; }
+
     public List<Filter> getFilters() {
         return filters;
     }



Mime
View raw message