You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/11/07 09:54:53 UTC

[sling-org-apache-sling-models-impl] annotated tag org.apache.sling.models.impl-1.0.2 created (now 39db6b5)

This is an automated email from the ASF dual-hosted git repository.

rombert pushed a change to annotated tag org.apache.sling.models.impl-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git.


      at 39db6b5  (tag)
 tagging 9f537a4b3d127974239821b2b114e370a5e3212a (commit)
      by Justin Edelson
      on Sat Mar 15 14:53:15 2014 +0000

- Log -----------------------------------------------------------------
org.apache.sling.models.impl-1.0.2
-----------------------------------------------------------------------

This annotated tag includes the following new commits:

     new 58786a9  SLING-3313 - adding initial version of Sling Models (nee YAMF)
     new 45be0c6  set svn:ignore
     new d407d6f  SLING-3313 - actually use the seal() method to make the disposal callback list unmodifiable
     new 40ea6f5  SLING-3335 - add a models configuration printer to see the currently registered injectors
     new ae43b9e  SLING-3334 - explicitly rank injectors
     new e9a5ebd  SLING-3357 - allow a model class to have a single argument constructor which takes the adaptable as a parameter.
     new d193760  using release version
     new fe08a96  avoid the use of Integer.compare()
     new 5f168bc  [maven-release-plugin] prepare release org.apache.sling.models.impl-1.0.0
     new d951930  [maven-release-plugin] prepare for next development iteration
     new 41e7e3c  Using 1.0.0 breaks the build, reverting to SNAPSHOT, we might change back to 1.0.0 once it's out
     new 53a6c31  SLING-3429 - fix NPE in OSGiServiceInjector which impacted multi-valued properties
     new 3fda5d4  SLING-3430 - only embedding necessary parts of beanutils
     new 9fb2350  SLING-3340 - reverting change to restrict inclusion of beanutils. error prone.
     new 6d238d2  no need to depend upon SNAPSHOT version of API
     new 64ef324  adding test for array properties
     new f9c6619  SLING-3455 - fixing issue with injection adaption in classes
     new 392c1c6  [maven-release-plugin] prepare release org.apache.sling.models.impl-1.0.2
     new 9f537a4  [maven-release-plugin]  copy for tag org.apache.sling.models.impl-1.0.2

The 19 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


-- 
To stop receiving notification emails like this one, please contact
['"commits@sling.apache.org" <co...@sling.apache.org>'].

[sling-org-apache-sling-models-impl] 07/10: adding test for array properties

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.models.impl-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git

commit 64ef324ccf9bd80cca8222ec7a179a1bc8b912ea
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Fri Mar 14 13:10:33 2014 +0000

    adding test for array properties
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl@1577514 13f79535-47bb-0310-9956-ffa450edef68
---
 .../org/apache/sling/models/impl/ResourceModelClassesTest.java    | 8 +++++++-
 .../sling/models/testmodels/classes/SimplePropertyModel.java      | 7 +++++++
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java b/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java
index 46e825a..552f142 100644
--- a/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java
@@ -75,6 +75,7 @@ public class ResourceModelClassesTest {
         map.put("first", "first-value");
         map.put("third", "third-value");
         map.put("intProperty", new Integer(3));
+        map.put("arrayProperty", new String[] { "three", "four" });
         ValueMap vm = new ValueMapDecorator(map);
 
         Resource res = mock(Resource.class);
@@ -86,6 +87,11 @@ public class ResourceModelClassesTest {
         assertNull(model.getSecond());
         assertEquals("third-value", model.getThirdProperty());
         assertEquals(3, model.getIntProperty());
+
+        String[] array = model.getArrayProperty();
+        assertEquals(2, array.length);
+        assertEquals("three", array[0]);
+
         assertTrue(model.isPostConstructCalled());
     }
 
@@ -154,7 +160,7 @@ public class ResourceModelClassesTest {
 
         ParentModel model = factory.getAdapter(res, ParentModel.class);
         assertNotNull(model);
-        
+
         ChildModel childModel = model.getFirstChild();
         assertNotNull(childModel);
         assertEquals(value, childModel.getProperty());
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/SimplePropertyModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/SimplePropertyModel.java
index ddd3b2f..1c9c05f 100644
--- a/src/test/java/org/apache/sling/models/testmodels/classes/SimplePropertyModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/SimplePropertyModel.java
@@ -41,6 +41,9 @@ public class SimplePropertyModel {
     @Inject
     private int intProperty;
 
+    @Inject
+    private String[] arrayProperty;
+
     private boolean postConstructCalled;
 
     public int getIntProperty() {
@@ -59,6 +62,10 @@ public class SimplePropertyModel {
         return thirdProperty;
     }
 
+    public String[] getArrayProperty() {
+        return arrayProperty;
+    }
+
     @PostConstruct
     protected void postConstruct() {
         postConstructCalled = true;

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-models-impl] 02/10: Using 1.0.0 breaks the build, reverting to SNAPSHOT, we might change back to 1.0.0 once it's out

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.models.impl-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git

commit 41e7e3ccc3e705e751dbd00c5d4e3699ded418c2
Author: Bertrand Delacretaz <bd...@apache.org>
AuthorDate: Fri Jan 31 10:12:04 2014 +0000

    Using 1.0.0 breaks the build, reverting to SNAPSHOT, we might change back to 1.0.0 once it's out
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl@1563100 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 557979f..12899fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,7 +63,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.models.api</artifactId>
-            <version>1.0.0</version>
+            <version>1.0.1-SNAPSHOT</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-models-impl] 09/10: [maven-release-plugin] prepare release org.apache.sling.models.impl-1.0.2

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.models.impl-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git

commit 392c1c6fe06e51a94f3beb8db3b9fd77eafd44ad
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Sat Mar 15 14:53:13 2014 +0000

    [maven-release-plugin] prepare release org.apache.sling.models.impl-1.0.2
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl@1577869 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 557979f..fb3053a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.models.impl</artifactId>
     <packaging>bundle</packaging>
-    <version>1.0.1-SNAPSHOT</version>
+    <version>1.0.2</version>
     <name>Sling Models Implementation</name>
     <description>Sling Models Implementation</description>
     <properties>
         <sling.java.version>6</sling.java.version>
     </properties>
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl</connection>
-        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.models.impl-1.0.2</connection>
+        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.models.impl-1.0.2</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.models.impl-1.0.2</url>
     </scm>
     <build>
         <plugins>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-models-impl] 05/10: SLING-3340 - reverting change to restrict inclusion of beanutils. error prone.

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.models.impl-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git

commit 9fb2350b80f3705040e8b53ad41dab72297c733e
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Tue Mar 4 11:57:55 2014 +0000

    SLING-3340 - reverting change to restrict inclusion of beanutils. error prone.
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl@1574050 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index bc65ea6..12899fe 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,7 @@
                 <configuration>
                     <instructions>
                         <Embed-Dependency>
-                            commons-beanutils;inline="org/apache/commons/beanutils/PropertyUtils.class|org/apache/commons/beanutils/PropertyUtilsBean.class|org/apache/commons/beanutils/DynaProperty.class|org/apache/commons/beanutils/expression/*.class",
+                            *;scope=compile,
                             org.osgi.compendium;inline="org/osgi/util/tracker/*"</Embed-Dependency>
                     </instructions>
                 </configuration>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-models-impl] 10/10: [maven-release-plugin] copy for tag org.apache.sling.models.impl-1.0.2

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.models.impl-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git

commit 9f537a4b3d127974239821b2b114e370a5e3212a
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Sat Mar 15 14:53:15 2014 +0000

    [maven-release-plugin]  copy for tag org.apache.sling.models.impl-1.0.2
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.models.impl-1.0.2@1577870 13f79535-47bb-0310-9956-ffa450edef68

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-models-impl] 01/10: [maven-release-plugin] prepare for next development iteration

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.models.impl-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git

commit d95193071e651713b745058f01e33bcc20ca0ca9
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Fri Jan 31 04:30:07 2014 +0000

    [maven-release-plugin] prepare for next development iteration
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl@1563059 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pom.xml b/pom.xml
index 1e99449..557979f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -28,16 +28,16 @@
     <groupId>org.apache.sling</groupId>
     <artifactId>org.apache.sling.models.impl</artifactId>
     <packaging>bundle</packaging>
-    <version>1.0.0</version>
+    <version>1.0.1-SNAPSHOT</version>
     <name>Sling Models Implementation</name>
     <description>Sling Models Implementation</description>
     <properties>
         <sling.java.version>6</sling.java.version>
     </properties>
     <scm>
-        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/tags/org.apache.sling.models.impl-1.0.0</connection>
-        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/tags/org.apache.sling.models.impl-1.0.0</developerConnection>
-        <url>http://svn.apache.org/viewvc/sling/tags/org.apache.sling.models.impl-1.0.0</url>
+        <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl</connection>
+        <developerConnection> scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl</developerConnection>
+        <url>http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl</url>
     </scm>
     <build>
         <plugins>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-models-impl] 06/10: no need to depend upon SNAPSHOT version of API

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.models.impl-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git

commit 6d238d2bd50311bac7b880316301728b37714563
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Fri Mar 14 13:10:31 2014 +0000

    no need to depend upon SNAPSHOT version of API
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl@1577513 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 12899fe..557979f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -63,7 +63,7 @@
         <dependency>
             <groupId>org.apache.sling</groupId>
             <artifactId>org.apache.sling.models.api</artifactId>
-            <version>1.0.1-SNAPSHOT</version>
+            <version>1.0.0</version>
             <scope>provided</scope>
         </dependency>
         <dependency>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-models-impl] 08/10: SLING-3455 - fixing issue with injection adaption in classes

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.models.impl-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git

commit f9c661982d80203d06f9a64bb5cfe7612612116d
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Fri Mar 14 13:54:27 2014 +0000

    SLING-3455 - fixing issue with injection adaption in classes
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl@1577534 13f79535-47bb-0310-9956-ffa450edef68
---
 .../sling/models/impl/ModelAdapterFactory.java     |  4 +-
 .../models/impl/ResourceModelClassesTest.java      |  6 +-
 .../models/impl/ResourceModelInterfacesTest.java   | 68 +++++++++++++++++++++-
 .../ChildResourceModel.java}                       | 12 ++--
 .../ChildValueMapModel.java}                       | 13 +++--
 .../{interfaces => classes}/ParentModel.java       | 11 ++--
 .../{ParentModel.java => ChildModel.java}          |  5 +-
 .../models/testmodels/interfaces/ParentModel.java  |  1 -
 8 files changed, 98 insertions(+), 22 deletions(-)

diff --git a/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java b/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
index caf88a6..6fe7868 100644
--- a/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
+++ b/src/main/java/org/apache/sling/models/impl/ModelAdapterFactory.java
@@ -571,8 +571,8 @@ public class ModelAdapterFactory implements AdapterFactory, Runnable {
 
     private boolean setField(Field field, Object createdObject, Object value) {
         if (value != null) {
-            if (!isAcceptableType(field.getClass(), value) && value instanceof Adaptable) {
-                value = ((Adaptable) value).adaptTo(field.getClass());
+            if (!isAcceptableType(field.getType(), value) && value instanceof Adaptable) {
+                value = ((Adaptable) value).adaptTo(field.getType());
                 if (value == null) {
                     return false;
                 }
diff --git a/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java b/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java
index 552f142..8f6aaf7 100644
--- a/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ResourceModelClassesTest.java
@@ -30,11 +30,11 @@ import org.apache.sling.api.wrappers.ValueMapDecorator;
 import org.apache.sling.models.impl.injectors.ChildResourceInjector;
 import org.apache.sling.models.impl.injectors.ValueMapInjector;
 import org.apache.sling.models.testmodels.classes.ChildModel;
+import org.apache.sling.models.testmodels.classes.ChildResourceModel;
+import org.apache.sling.models.testmodels.classes.ChildValueMapModel;
+import org.apache.sling.models.testmodels.classes.ParentModel;
 import org.apache.sling.models.testmodels.classes.ResourceModelWithRequiredField;
 import org.apache.sling.models.testmodels.classes.SimplePropertyModel;
-import org.apache.sling.models.testmodels.interfaces.ChildResourceModel;
-import org.apache.sling.models.testmodels.interfaces.ChildValueMapModel;
-import org.apache.sling.models.testmodels.interfaces.ParentModel;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
diff --git a/src/test/java/org/apache/sling/models/impl/ResourceModelInterfacesTest.java b/src/test/java/org/apache/sling/models/impl/ResourceModelInterfacesTest.java
index 6d1b0c8..663d653 100644
--- a/src/test/java/org/apache/sling/models/impl/ResourceModelInterfacesTest.java
+++ b/src/test/java/org/apache/sling/models/impl/ResourceModelInterfacesTest.java
@@ -16,24 +16,32 @@
  */
 package org.apache.sling.models.impl;
 
-import static org.mockito.Mockito.*;
 import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
 
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 
+import org.apache.commons.lang.RandomStringUtils;
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.api.resource.ValueMap;
 import org.apache.sling.api.wrappers.ValueMapDecorator;
+import org.apache.sling.models.impl.injectors.ChildResourceInjector;
 import org.apache.sling.models.impl.injectors.ValueMapInjector;
 import org.apache.sling.models.testmodels.classes.ResourceModelWithRequiredField;
+import org.apache.sling.models.testmodels.interfaces.ChildModel;
+import org.apache.sling.models.testmodels.interfaces.ChildResourceModel;
+import org.apache.sling.models.testmodels.interfaces.ChildValueMapModel;
+import org.apache.sling.models.testmodels.interfaces.ParentModel;
 import org.apache.sling.models.testmodels.interfaces.SimplePropertyModel;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.Mock;
+import org.mockito.invocation.InvocationOnMock;
 import org.mockito.runners.MockitoJUnitRunner;
+import org.mockito.stubbing.Answer;
 import org.osgi.framework.BundleContext;
 import org.osgi.framework.Constants;
 import org.osgi.service.component.ComponentContext;
@@ -55,6 +63,8 @@ public class ResourceModelInterfacesTest {
         factory = new ModelAdapterFactory();
         factory.activate(componentCtx);
         factory.bindInjector(new ValueMapInjector(),
+                Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 1L));
+        factory.bindInjector(new ChildResourceInjector(),
                 Collections.<String, Object> singletonMap(Constants.SERVICE_ID, 0L));
     }
 
@@ -92,5 +102,61 @@ public class ResourceModelInterfacesTest {
 
         verify(vm).get("required", String.class);
     }
+    
+    @Test
+    public void testChildResource() {
+        Resource child = mock(Resource.class);
+
+        Resource res = mock(Resource.class);
+        when(res.getChild("firstChild")).thenReturn(child);
+
+        ChildResourceModel model = factory.getAdapter(res, ChildResourceModel.class);
+        assertNotNull(model);
+        assertEquals(child, model.getFirstChild());
+    }
+
+    @Test
+    public void testChildValueMap() {
+        ValueMap map = ValueMapDecorator.EMPTY;
+
+        Resource child = mock(Resource.class);
+        when(child.adaptTo(ValueMap.class)).thenReturn(map);
+
+        Resource res = mock(Resource.class);
+        when(res.getChild("firstChild")).thenReturn(child);
+
+        ChildValueMapModel model = factory.getAdapter(res, ChildValueMapModel.class);
+        assertNotNull(model);
+        assertEquals(map, model.getFirstChild());
+    }
+
+    @Test
+    public void testChildModel() {
+        Object value = RandomStringUtils.randomAlphabetic(10);
+        Map<String, Object> props = Collections.singletonMap("property", value);
+        ValueMap map = new ValueMapDecorator(props);
+
+        final Resource child = mock(Resource.class);
+        when(child.adaptTo(ValueMap.class)).thenReturn(map);
+        when(child.adaptTo(ChildModel.class)).thenAnswer(new Answer<ChildModel>() {
+
+            @Override
+            public ChildModel answer(InvocationOnMock invocation) throws Throwable {
+                return factory.getAdapter(child, ChildModel.class);
+            }
+
+        });
+
+        Resource res = mock(Resource.class);
+        when(res.getChild("firstChild")).thenReturn(child);
+
+        ParentModel model = factory.getAdapter(res, ParentModel.class);
+        assertNotNull(model);
+
+        ChildModel childModel = model.getFirstChild();
+        assertNotNull(childModel);
+        assertEquals(value, childModel.getProperty());
+    }
+
 
 }
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceModel.java
similarity index 83%
copy from src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
copy to src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceModel.java
index e0ec29d..0bca5ec 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ChildResourceModel.java
@@ -14,17 +14,21 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.models.testmodels.interfaces;
+package org.apache.sling.models.testmodels.classes;
 
 import javax.inject.Inject;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.models.annotations.Model;
-import org.apache.sling.models.testmodels.classes.ChildModel;
 
 @Model(adaptables = Resource.class)
-public interface ParentModel {
+public class ChildResourceModel {
 
     @Inject
-    public ChildModel getFirstChild();
+    private Resource firstChild;
+    
+    public Resource getFirstChild() {
+        return firstChild;
+    }
+
 }
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ChildValueMapModel.java
similarity index 80%
copy from src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
copy to src/test/java/org/apache/sling/models/testmodels/classes/ChildValueMapModel.java
index e0ec29d..01d1aea 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ChildValueMapModel.java
@@ -14,17 +14,22 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.models.testmodels.interfaces;
+package org.apache.sling.models.testmodels.classes;
 
 import javax.inject.Inject;
 
 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.testmodels.classes.ChildModel;
 
 @Model(adaptables = Resource.class)
-public interface ParentModel {
+public class ChildValueMapModel {
 
     @Inject
-    public ChildModel getFirstChild();
+    private ValueMap firstChild;
+    
+    public ValueMap getFirstChild() {
+        return firstChild;
+    }
+
 }
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/ParentModel.java
similarity index 83%
copy from src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
copy to src/test/java/org/apache/sling/models/testmodels/classes/ParentModel.java
index e0ec29d..c0da400 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/ParentModel.java
@@ -14,17 +14,20 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.models.testmodels.interfaces;
+package org.apache.sling.models.testmodels.classes;
 
 import javax.inject.Inject;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.models.annotations.Model;
-import org.apache.sling.models.testmodels.classes.ChildModel;
 
 @Model(adaptables = Resource.class)
-public interface ParentModel {
+public class ParentModel {
 
     @Inject
-    public ChildModel getFirstChild();
+    private ChildModel firstChild;
+
+    public ChildModel getFirstChild() {
+        return firstChild;
+    }
 }
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildModel.java
similarity index 88%
copy from src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
copy to src/test/java/org/apache/sling/models/testmodels/interfaces/ChildModel.java
index e0ec29d..d74d550 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/ChildModel.java
@@ -20,11 +20,10 @@ import javax.inject.Inject;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.models.annotations.Model;
-import org.apache.sling.models.testmodels.classes.ChildModel;
 
 @Model(adaptables = Resource.class)
-public interface ParentModel {
+public interface ChildModel {
 
     @Inject
-    public ChildModel getFirstChild();
+    public String getProperty();
 }
diff --git a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java b/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
index e0ec29d..5dceeb5 100644
--- a/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
+++ b/src/test/java/org/apache/sling/models/testmodels/interfaces/ParentModel.java
@@ -20,7 +20,6 @@ import javax.inject.Inject;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.models.annotations.Model;
-import org.apache.sling.models.testmodels.classes.ChildModel;
 
 @Model(adaptables = Resource.class)
 public interface ParentModel {

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-models-impl] 03/10: SLING-3429 - fix NPE in OSGiServiceInjector which impacted multi-valued properties

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.models.impl-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git

commit 53a6c314c6b9595f8776360164f0fa2b5b22d3d6
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Mon Mar 3 17:58:16 2014 +0000

    SLING-3429 - fix NPE in OSGiServiceInjector which impacted multi-valued properties
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl@1573637 13f79535-47bb-0310-9956-ffa450edef68
---
 .../models/impl/injectors/OSGiServiceInjector.java |  6 ++++
 .../sling/models/impl/OSGiInjectionTest.java       | 25 ++++++++++++++
 .../testmodels/classes/OptionalArrayOSGiModel.java | 36 ++++++++++++++++++++
 .../testmodels/classes/OptionalListOSGiModel.java  | 38 ++++++++++++++++++++++
 4 files changed, 105 insertions(+)

diff --git a/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java b/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
index 78a73bb..59a9636 100644
--- a/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
+++ b/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java
@@ -148,6 +148,9 @@ public class OSGiServiceInjector implements Injector {
             Class<?> injectedClass = (Class<?>) type;
             if (injectedClass.isArray()) {
                 Object[] services = getServices(adaptable, injectedClass.getComponentType(), filterString, callbackRegistry);
+                if (services == null) {
+                    return null;
+                }
                 Object arr = Array.newInstance(injectedClass.getComponentType(), services.length);
                 for (int i = 0; i < services.length; i++) {
                     Array.set(arr, i, services[i]);
@@ -168,6 +171,9 @@ public class OSGiServiceInjector implements Injector {
 
             Class<?> serviceType = (Class<?>) ptype.getActualTypeArguments()[0];
             Object[] services = getServices(adaptable, serviceType, filterString, callbackRegistry);
+            if (services == null) {
+                return null;
+            }
             return Arrays.asList(services);
         } else {
             log.warn("Cannot handle type {}", type);
diff --git a/src/test/java/org/apache/sling/models/impl/OSGiInjectionTest.java b/src/test/java/org/apache/sling/models/impl/OSGiInjectionTest.java
index b26eb13..9812003 100644
--- a/src/test/java/org/apache/sling/models/impl/OSGiInjectionTest.java
+++ b/src/test/java/org/apache/sling/models/impl/OSGiInjectionTest.java
@@ -30,6 +30,8 @@ import org.apache.sling.models.impl.injectors.OSGiServiceInjector;
 import org.apache.sling.models.testmodels.classes.ArrayOSGiModel;
 import org.apache.sling.models.testmodels.classes.CollectionOSGiModel;
 import org.apache.sling.models.testmodels.classes.ListOSGiModel;
+import org.apache.sling.models.testmodels.classes.OptionalArrayOSGiModel;
+import org.apache.sling.models.testmodels.classes.OptionalListOSGiModel;
 import org.apache.sling.models.testmodels.classes.RequestOSGiModel;
 import org.apache.sling.models.testmodels.classes.SetOSGiModel;
 import org.apache.sling.models.testmodels.classes.SimpleOSGiModel;
@@ -161,6 +163,29 @@ public class OSGiInjectionTest {
     }
 
     @Test
+    public void testOptionalArrayOSGiModel() throws Exception {
+
+        Resource res = mock(Resource.class);
+
+        OptionalArrayOSGiModel model = factory.getAdapter(res, OptionalArrayOSGiModel.class);
+        assertNotNull(model);
+        assertNull(model.getServices());
+
+        verifyNoMoreInteractions(res);
+    }
+
+    @Test
+    public void testOptionalListOSGiModel() throws Exception {
+        Resource res = mock(Resource.class);
+
+        OptionalListOSGiModel model = factory.getAdapter(res, OptionalListOSGiModel.class);
+        assertNotNull(model);
+        assertNull(model.getServices());
+
+        verifyNoMoreInteractions(res);
+    }
+
+    @Test
     public void testCollectionOSGiModel() throws Exception {
         ServiceReference ref1 = mock(ServiceReference.class);
         ServiceInterface service1 = mock(ServiceInterface.class);
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/OptionalArrayOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalArrayOSGiModel.java
new file mode 100644
index 0000000..84aac68
--- /dev/null
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalArrayOSGiModel.java
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.testmodels.classes;
+
+import javax.inject.Inject;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Optional;
+import org.apache.sling.models.testmodels.interfaces.ServiceInterface;
+
+@Model(adaptables = Resource.class)
+public class OptionalArrayOSGiModel {
+    
+    @Inject @Optional
+    private ServiceInterface[] services;
+    
+    public ServiceInterface[] getServices() {
+        return services;
+    }
+
+}
diff --git a/src/test/java/org/apache/sling/models/testmodels/classes/OptionalListOSGiModel.java b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalListOSGiModel.java
new file mode 100644
index 0000000..b8a2146
--- /dev/null
+++ b/src/test/java/org/apache/sling/models/testmodels/classes/OptionalListOSGiModel.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sling.models.testmodels.classes;
+
+import java.util.List;
+
+import javax.inject.Inject;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Optional;
+import org.apache.sling.models.testmodels.interfaces.ServiceInterface;
+
+@Model(adaptables = Resource.class)
+public class OptionalListOSGiModel {
+    
+    @Inject @Optional
+    private List<ServiceInterface> services;
+    
+    public List<ServiceInterface> getServices() {
+        return services;
+    }
+
+}

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.

[sling-org-apache-sling-models-impl] 04/10: SLING-3430 - only embedding necessary parts of beanutils

Posted by ro...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rombert pushed a commit to annotated tag org.apache.sling.models.impl-1.0.2
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-impl.git

commit 3fda5d4b75e96ee68ac6d51c4d1f535b94bfb4ea
Author: Justin Edelson <ju...@apache.org>
AuthorDate: Mon Mar 3 17:58:20 2014 +0000

    SLING-3430 - only embedding necessary parts of beanutils
    
    git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/extensions/models/impl@1573638 13f79535-47bb-0310-9956-ffa450edef68
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index 12899fe..bc65ea6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,7 @@
                 <configuration>
                     <instructions>
                         <Embed-Dependency>
-                            *;scope=compile,
+                            commons-beanutils;inline="org/apache/commons/beanutils/PropertyUtils.class|org/apache/commons/beanutils/PropertyUtilsBean.class|org/apache/commons/beanutils/DynaProperty.class|org/apache/commons/beanutils/expression/*.class",
                             org.osgi.compendium;inline="org/osgi/util/tracker/*"</Embed-Dependency>
                     </instructions>
                 </configuration>

-- 
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.