Modified: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/RequestInjectionTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/RequestInjectionTest.java?rev=1619007&r1=1619006&r2=1619007&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/RequestInjectionTest.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/RequestInjectionTest.java
 Tue Aug 19 22:51:36 2014
@@ -33,6 +33,7 @@ import org.osgi.framework.BundleContext;
 import org.osgi.service.component.ComponentContext;
 
 @RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings("javadoc")
 public class RequestInjectionTest {
 
     @Mock
@@ -63,10 +64,18 @@ public class RequestInjectionTest {
     }
 
     @Test
-    public void testNamedInjection() {
+    public void testNamedInjectionField() {
         BindingsModel model = factory.getAdapter(request, BindingsModel.class);
         assertNotNull(model.getSling());
         assertEquals(sling, model.getSling());
     }
 
+    @Test
+    public void testNamedInjectionConstructor() {
+        
org.apache.sling.models.testmodels.classes.constructorinjection.BindingsModel 
model
+                = factory.getAdapter(request, 
org.apache.sling.models.testmodels.classes.constructorinjection.BindingsModel.class);
+        assertNotNull(model.getSling());
+        assertEquals(sling, model.getSling());
+    }
+
 }

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/SelfDependencyTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/SelfDependencyTest.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/SelfDependencyTest.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/SelfDependencyTest.java
 Tue Aug 19 22:51:36 2014
@@ -0,0 +1,95 @@
+/*
+ * 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.impl;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.when;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.impl.injectors.SelfInjector;
+import 
org.apache.sling.models.testmodels.classes.DirectCyclicSelfDependencyModel;
+import 
org.apache.sling.models.testmodels.classes.IndirectCyclicSelfDependencyModelA;
+import org.apache.sling.models.testmodels.classes.SelfDependencyModelA;
+import org.apache.sling.models.testmodels.classes.SelfDependencyModelB;
+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.service.component.ComponentContext;
+
+@RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings("javadoc")
+public class SelfDependencyTest {
+
+    @Mock
+    private ComponentContext componentCtx;
+
+    @Mock
+    private BundleContext bundleContext;
+
+    private ModelAdapterFactory factory;
+
+    @Mock
+    private SlingHttpServletRequest request;
+
+    @SuppressWarnings("unchecked")
+    @Before
+    public void setup() {
+        when(componentCtx.getBundleContext()).thenReturn(bundleContext);
+        when(request.adaptTo(any(Class.class))).then(new Answer<Object>() {
+            @Override
+            public Object answer(InvocationOnMock invocation) throws Throwable 
{
+                Class<?> clazz = (Class<?>) invocation.getArguments()[0];
+                return factory.getAdapter(request, clazz);
+            }
+        });
+
+        factory = new ModelAdapterFactory();
+        factory.activate(componentCtx);
+        factory.bindInjector(new SelfInjector(), new ServicePropertiesMap(1, 
1));
+    }
+
+    @Test
+    public void testChainedSelfDependency() {
+        SelfDependencyModelA objectA = factory.getAdapter(request, 
SelfDependencyModelA.class);
+        assertNotNull(objectA);
+        SelfDependencyModelB objectB = objectA.getDependencyB();
+        assertNotNull(objectB);
+        assertSame(request, objectB.getRequest());
+    }
+
+    @Test
+    public void testDirectCyclicSelfDependency() {
+        DirectCyclicSelfDependencyModel object = factory.getAdapter(request, 
DirectCyclicSelfDependencyModel.class);
+        assertNull(object);
+    }
+
+    @Test
+    public void testInddirectCyclicSelfDependency() {
+        IndirectCyclicSelfDependencyModelA object = factory.getAdapter(request,
+                IndirectCyclicSelfDependencyModelA.class);
+        assertNull(object);
+    }
+
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/BindingsInjectorTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/BindingsInjectorTest.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/BindingsInjectorTest.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/BindingsInjectorTest.java
 Tue Aug 19 22:51:36 2014
@@ -0,0 +1,98 @@
+/*
+ * 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.impl.injectors;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import javax.servlet.ServletRequest;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.scripting.SlingBindings;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings("javadoc")
+public class BindingsInjectorTest {
+
+    private BindingsInjector injector = new BindingsInjector();
+
+    @Mock
+    private ServletRequest request;
+    @Mock
+    private SlingBindings bindings;
+
+    private static final String STRING_PARAM = "param1";
+    private static final String INTEGER_PARAM = "param2";
+    private static final String CLASS_PARAM = "param3";
+    private static final String STRING_VALUE = "myValue";
+    private static final int INTEGER_VALUE = 42;
+    private static final ResourceResolver CLASS_INSTANCE = 
mock(ResourceResolver.class);
+
+    @Before
+    public void setUp() {
+        
when(request.getAttribute(SlingBindings.class.getName())).thenReturn(bindings);
+        when(bindings.get(STRING_PARAM)).thenReturn(STRING_VALUE);
+        when(bindings.get(INTEGER_PARAM)).thenReturn(INTEGER_VALUE);
+        when(bindings.get(CLASS_PARAM)).thenReturn(CLASS_INSTANCE);
+    }
+
+    @Test
+    public void testStringParam() {
+        Object result = injector.getValue(request, STRING_PARAM, String.class, 
null, null);
+        assertEquals(STRING_VALUE, result);
+    }
+
+    @Test
+    public void testIntegerParam() {
+        Object result = injector.getValue(request, INTEGER_PARAM, 
Integer.class, null, null);
+        assertEquals(INTEGER_VALUE, result);
+    }
+
+    @Test
+    public void testClassInstance() {
+        Object result = injector.getValue(request, CLASS_PARAM, 
ResourceResolver.class, null, null);
+        assertSame(CLASS_INSTANCE, result);
+    }
+
+    @Test
+    public void testNonMatchingClassInstance() {
+        Object result = injector.getValue(request, CLASS_PARAM, 
Resource.class, null, null);
+        assertNull(result);
+    }
+
+    @Test
+    public void testNonRequestAdaptable() {
+        Object result = injector.getValue(mock(ResourceResolver.class), 
STRING_PARAM, String.class, null, null);
+        assertNull(result);
+    }
+
+    @Test
+    public void testRequestThatDoesNotContainBindings() {
+        
when(request.getAttribute(SlingBindings.class.getName())).thenReturn(null);
+        Object result = injector.getValue(request, STRING_PARAM, String.class, 
null, null);
+        assertNull(result);
+    }
+
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/RequestAttributeInjectorTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/RequestAttributeInjectorTest.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/RequestAttributeInjectorTest.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/RequestAttributeInjectorTest.java
 Tue Aug 19 22:51:36 2014
@@ -0,0 +1,86 @@
+/*
+ * 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.impl.injectors;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import javax.servlet.ServletRequest;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings("javadoc")
+public class RequestAttributeInjectorTest {
+
+    private RequestAttributeInjector injector = new RequestAttributeInjector();
+    
+    @Mock
+    private ServletRequest request;
+    
+    private static final String STRING_PARAM = "param1";
+    private static final String INTEGER_PARAM = "param2";
+    private static final String CLASS_PARAM = "param3";
+    private static final String STRING_VALUE = "myValue";
+    private static final int INTEGER_VALUE = 42;
+    private static final ResourceResolver CLASS_INSTANCE = 
mock(ResourceResolver.class);
+    
+    @Before
+    public void setUp() {
+        when(request.getAttribute(STRING_PARAM)).thenReturn(STRING_VALUE);
+        when(request.getAttribute(INTEGER_PARAM)).thenReturn(INTEGER_VALUE);
+        when(request.getAttribute(CLASS_PARAM)).thenReturn(CLASS_INSTANCE);
+    }
+
+    @Test
+    public void testStringParam() {
+        Object result = injector.getValue(request, STRING_PARAM, String.class, 
null, null);
+        assertEquals(STRING_VALUE, result);
+    }
+
+    @Test
+    public void testIntegerParam() {
+        Object result = injector.getValue(request, INTEGER_PARAM, 
Integer.class, null, null);
+        assertEquals(INTEGER_VALUE, result);
+    }
+
+    @Test
+    public void testClassInstance() {
+        Object result = injector.getValue(request, CLASS_PARAM, 
ResourceResolver.class, null, null);
+        assertSame(CLASS_INSTANCE, result);
+    }
+
+    @Test
+    public void testNonMatchingClassInstance() {
+        Object result = injector.getValue(request, CLASS_PARAM, 
Resource.class, null, null);
+        assertNull(result);
+    }
+
+    @Test
+    public void testNonRequestAdaptable() {
+        Object result = injector.getValue(mock(ResourceResolver.class), 
STRING_PARAM, String.class, null, null);
+        assertNull(result);
+    }
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/SelfInjectorTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/SelfInjectorTest.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/SelfInjectorTest.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/SelfInjectorTest.java
 Tue Aug 19 22:51:36 2014
@@ -0,0 +1,86 @@
+/*
+ * 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.impl.injectors;
+
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.mockito.Mockito.*;
+
+import java.lang.reflect.AnnotatedElement;
+
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.models.annotations.injectorspecific.Self;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings("javadoc")
+public class SelfInjectorTest {
+
+    private SelfInjector injector = new SelfInjector();
+    
+    @Mock
+    private SlingHttpServletRequest request;
+    @Mock
+    private AnnotatedElement annotatedElement;
+
+    @Test
+    public void testMatchingClass() {
+        Object result = injector.getValue(request, "notRelevant", 
SlingHttpServletRequest.class, annotatedElement, null);
+        assertSame(request, result);
+    }
+
+    @Test
+    public void testMatchingSubClass() {
+        Object result = injector.getValue(request, "notRelevant", 
HttpServletRequest.class, annotatedElement, null);
+        assertSame(request, result);
+    }
+
+    @Test
+    public void testNotMatchingClass() {
+        Object result = injector.getValue(request, "notRelevant", 
ResourceResolver.class, annotatedElement, null);
+        assertNull(result);
+    }
+
+    @Test
+    public void testWithNullName() {
+        Object result = injector.getValue(request, null, 
SlingHttpServletRequest.class, annotatedElement, null);
+        assertSame(request, result);
+    }
+
+    @Test
+    public void testMatchingClassWithSelfAnnotation() {
+        
when(annotatedElement.isAnnotationPresent(Self.class)).thenReturn(true);
+        Object result = injector.getValue(request, "notRelevant", 
SlingHttpServletRequest.class, annotatedElement, null);
+        assertSame(request, result);
+    }
+
+    @Test
+    public void testNotMatchingClassWithSelfAnnotation() {
+        
when(annotatedElement.isAnnotationPresent(Self.class)).thenReturn(true);
+        Object result = injector.getValue(request, "notRelevant", 
ResourceResolver.class, annotatedElement, null);
+        assertSame(request, result);
+    }
+
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/ValueMapInjectorTest.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/ValueMapInjectorTest.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/ValueMapInjectorTest.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/impl/injectors/ValueMapInjectorTest.java
 Tue Aug 19 22:51:36 2014
@@ -0,0 +1,86 @@
+/*
+ * 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.impl.injectors;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ValueMap;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.runners.MockitoJUnitRunner;
+
+@RunWith(MockitoJUnitRunner.class)
+@SuppressWarnings("javadoc")
+public class ValueMapInjectorTest {
+
+    private ValueMapInjector injector = new ValueMapInjector();
+
+    @Mock
+    private ValueMap valueMap;
+
+    private static final String STRING_PARAM = "param1";
+    private static final String INTEGER_PARAM = "param2";
+    private static final String CLASS_PARAM = "param3";
+    private static final String STRING_VALUE = "myValue";
+    private static final int INTEGER_VALUE = 42;
+    private static final ResourceResolver CLASS_INSTANCE = 
mock(ResourceResolver.class);
+
+    @Before
+    public void setUp() {
+        when(valueMap.get(STRING_PARAM, 
String.class)).thenReturn(STRING_VALUE);
+        when(valueMap.get(INTEGER_PARAM, 
Integer.class)).thenReturn(INTEGER_VALUE);
+        when(valueMap.get(CLASS_PARAM, 
ResourceResolver.class)).thenReturn(CLASS_INSTANCE);
+    }
+
+    @Test
+    public void testStringParam() {
+        Object result = injector.getValue(valueMap, STRING_PARAM, 
String.class, null, null);
+        assertEquals(STRING_VALUE, result);
+    }
+
+    @Test
+    public void testIntegerParam() {
+        Object result = injector.getValue(valueMap, INTEGER_PARAM, 
Integer.class, null, null);
+        assertEquals(INTEGER_VALUE, result);
+    }
+
+    @Test
+    public void testClassInstance() {
+        Object result = injector.getValue(valueMap, CLASS_PARAM, 
ResourceResolver.class, null, null);
+        assertSame(CLASS_INSTANCE, result);
+    }
+
+    @Test
+    public void testNonMatchingClassInstance() {
+        Object result = injector.getValue(valueMap, CLASS_PARAM, 
Resource.class, null, null);
+        assertNull(result);
+    }
+
+    @Test
+    public void testNonValueMapAdaptable() {
+        Object result = injector.getValue(mock(ResourceResolver.class), 
STRING_PARAM, String.class, null, null);
+        assertNull(result);
+    }
+
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/DirectCyclicSelfDependencyModel.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/DirectCyclicSelfDependencyModel.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/DirectCyclicSelfDependencyModel.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/DirectCyclicSelfDependencyModel.java
 Tue Aug 19 22:51:36 2014
@@ -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 org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.injectorspecific.Self;
+
+@Model(adaptables=SlingHttpServletRequest.class)
+@SuppressWarnings("javadoc")
+public class DirectCyclicSelfDependencyModel {
+
+    @Self
+    private DirectCyclicSelfDependencyModel modelSelf;
+
+    public DirectCyclicSelfDependencyModel getModelSelf() {
+        return modelSelf;
+    }
+
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelA.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelA.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelA.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelA.java
 Tue Aug 19 22:51:36 2014
@@ -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 org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.injectorspecific.Self;
+
+@Model(adaptables=SlingHttpServletRequest.class)
+@SuppressWarnings("javadoc")
+public class IndirectCyclicSelfDependencyModelA {
+
+    @Self
+    private IndirectCyclicSelfDependencyModelB dependencyB;
+
+    public IndirectCyclicSelfDependencyModelB getDependencyB() {
+        return dependencyB;
+    }
+
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelB.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelB.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelB.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/IndirectCyclicSelfDependencyModelB.java
 Tue Aug 19 22:51:36 2014
@@ -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 org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.injectorspecific.Self;
+
+@Model(adaptables=SlingHttpServletRequest.class)
+@SuppressWarnings("javadoc")
+public class IndirectCyclicSelfDependencyModelB {
+
+    @Self
+    private IndirectCyclicSelfDependencyModelA dependencyA;
+
+    public IndirectCyclicSelfDependencyModelA getDependencyA() {
+        return dependencyA;
+    }
+
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelA.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelA.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelA.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelA.java
 Tue Aug 19 22:51:36 2014
@@ -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 org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.injectorspecific.Self;
+
+@Model(adaptables=SlingHttpServletRequest.class)
+@SuppressWarnings("javadoc")
+public class SelfDependencyModelA {
+
+    @Self
+    private SelfDependencyModelB dependencyB;
+
+    public SelfDependencyModelB getDependencyB() {
+        return dependencyB;
+    }
+
+}

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelB.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelB.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelB.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/SelfDependencyModelB.java
 Tue Aug 19 22:51:36 2014
@@ -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 org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.injectorspecific.Self;
+
+@Model(adaptables=SlingHttpServletRequest.class)
+@SuppressWarnings("javadoc")
+public class SelfDependencyModelB {
+
+    @Self
+    private SlingHttpServletRequest request;
+
+    public SlingHttpServletRequest getRequest() {
+        return request;
+    }
+
+}

Copied: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/BindingsModel.java
 (from r1618976, 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/BindingsModel.java?p2=sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/BindingsModel.java&p1=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java&r1=1618976&r2=1619007&rev=1619007&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/BindingsModel.java
 Tue Aug 19 22:51:36 2014
@@ -14,30 +14,28 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.models.it.models;
-
-import java.util.List;
+package org.apache.sling.models.testmodels.classes.constructorinjection;
 
 import javax.inject.Inject;
-import javax.servlet.Filter;
+import javax.inject.Named;
 
-import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.scripting.SlingScriptHelper;
 import org.apache.sling.models.annotations.Model;
 
-@Model(adaptables=Resource.class)
-public class TestModel {
+@Model(adaptables = SlingHttpServletRequest.class)
+@SuppressWarnings("javadoc")
+public class BindingsModel {
+
+    private final SlingScriptHelper sling;
 
     @Inject
-    private String testProperty;
-    
-    @Inject
-    private List<Filter> filters;
-    
-    public String getTestProperty() {
-        return testProperty;
+    public BindingsModel(@Named("sling") SlingScriptHelper sling) {
+        this.sling = sling;
     }
-    
-    public List<Filter> getFilters() {
-        return filters;
+
+    public SlingScriptHelper getSling() {
+        return sling;
     }
-}
+
+}
\ No newline at end of file

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultPrimitivesModel.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultPrimitivesModel.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultPrimitivesModel.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultPrimitivesModel.java
 Tue Aug 19 22:51:36 2014
@@ -0,0 +1,62 @@
+/*
+ * 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.constructorinjection;
+
+import javax.inject.Inject;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Default;
+import org.apache.sling.models.annotations.Model;
+
+@Model(adaptables = Resource.class)
+@SuppressWarnings("javadoc")
+public class DefaultPrimitivesModel {
+
+    private final boolean booleanProperty;
+    private final boolean[] booleanArrayProperty;
+    private final long longProperty;
+    private final long[] longArrayProperty;
+
+    @Inject
+    public DefaultPrimitivesModel(
+            @Default(booleanValues = true) boolean booleanProperty, 
+            @Default(booleanValues = { true, true }) boolean[] 
booleanArrayProperty,
+            @Default(longValues = 1L) long longProperty,
+            @Default(longValues = { 1L, 1L }) long[] longArrayProperty
+    ) {
+        this.booleanProperty = booleanProperty;
+        this.booleanArrayProperty = booleanArrayProperty;
+        this.longProperty = longProperty;
+        this.longArrayProperty = longArrayProperty;
+    }
+
+    public boolean getBooleanProperty() {
+        return booleanProperty;
+    }
+
+    public boolean[] getBooleanArrayProperty() {
+        return booleanArrayProperty;
+    }
+
+    public long getLongProperty() {
+        return longProperty;
+    }
+
+    public long[] getLongArrayProperty() {
+        return longArrayProperty;
+    }
+}
\ No newline at end of file

Copied: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultStringModel.java
 (from r1618976, 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultStringModel.java?p2=sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultStringModel.java&p1=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java&r1=1618976&r2=1619007&rev=1619007&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultStringModel.java
 Tue Aug 19 22:51:36 2014
@@ -14,30 +14,35 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.models.it.models;
-
-import java.util.List;
+package org.apache.sling.models.testmodels.classes.constructorinjection;
 
 import javax.inject.Inject;
-import javax.servlet.Filter;
 
 import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Default;
 import org.apache.sling.models.annotations.Model;
 
-@Model(adaptables=Resource.class)
-public class TestModel {
+@Model(adaptables = Resource.class)
+@SuppressWarnings("javadoc")
+public class DefaultStringModel {
+
+    private final String firstProperty;
+    private final String[] secondProperty;
 
     @Inject
-    private String testProperty;
-    
-    @Inject
-    private List<Filter> filters;
-    
-    public String getTestProperty() {
-        return testProperty;
+    public DefaultStringModel(
+            @Default(values = "firstDefault") String firstProperty,
+            @Default(values = { "firstDefault", "secondDefault" }) String[] 
secondProperty
+    ) {
+        this.firstProperty = firstProperty;
+        this.secondProperty = secondProperty;
     }
-    
-    public List<Filter> getFilters() {
-        return filters;
+
+    public String getFirstProperty() {
+        return firstProperty;
+    }
+
+    public String[] getSecondProperty() {
+        return secondProperty;
     }
-}
+}
\ No newline at end of file

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultWrappersModel.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultWrappersModel.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultWrappersModel.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/DefaultWrappersModel.java
 Tue Aug 19 22:51:36 2014
@@ -0,0 +1,63 @@
+/*
+ * 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.constructorinjection;
+
+import javax.inject.Inject;
+
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Default;
+import org.apache.sling.models.annotations.Model;
+
+@Model(adaptables = Resource.class)
+@SuppressWarnings("javadoc")
+public class DefaultWrappersModel {
+
+    private final Boolean booleanWrapperProperty;
+    private final Boolean[] booleanWrapperArrayProperty;
+    private final Long longWrapperProperty;
+    private final Long[] longWrapperArrayProperty;
+
+    @Inject
+    public DefaultWrappersModel(
+            @Default(booleanValues = true) Boolean booleanWrapperProperty,
+            @Default(booleanValues = { true, true }) Boolean[] 
booleanWrapperArrayProperty,
+            @Default(longValues = 1L) Long longWrapperProperty,
+            @Default(longValues = { 1L, 1L }) Long[] longWrapperArrayProperty
+    ) {
+        this.booleanWrapperProperty = booleanWrapperProperty;
+        this.booleanWrapperArrayProperty = booleanWrapperArrayProperty;
+        this.longWrapperProperty = longWrapperProperty;
+        this.longWrapperArrayProperty = longWrapperArrayProperty;
+    }
+
+    public Boolean getBooleanWrapperProperty() {
+        return booleanWrapperProperty;
+    }
+
+    public Boolean[] getBooleanWrapperArrayProperty() {
+        return booleanWrapperArrayProperty;
+    }
+
+    public Long getLongWrapperProperty() {
+        return longWrapperProperty;
+    }
+
+    public Long[] getLongWrapperArrayProperty() {
+        return longWrapperArrayProperty;
+    }
+
+}
\ No newline at end of file

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/InjectorSpecificAnnotationModel.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/InjectorSpecificAnnotationModel.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/InjectorSpecificAnnotationModel.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/InjectorSpecificAnnotationModel.java
 Tue Aug 19 22:51:36 2014
@@ -0,0 +1,91 @@
+/*
+ * 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.constructorinjection;
+
+import javax.inject.Inject;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.scripting.SlingScriptHelper;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.injectorspecific.ChildResource;
+import org.apache.sling.models.annotations.injectorspecific.OSGiService;
+import org.apache.sling.models.annotations.injectorspecific.RequestAttribute;
+import org.apache.sling.models.annotations.injectorspecific.ScriptVariable;
+import org.apache.sling.models.annotations.injectorspecific.ValueMapValue;
+import org.slf4j.Logger;
+
+@Model(adaptables = SlingHttpServletRequest.class)
+@SuppressWarnings("javadoc")
+public class InjectorSpecificAnnotationModel {
+
+    private final String first;
+    private final String secondWithOtherName;
+    private final Logger log;
+    private final SlingScriptHelper helper;
+    private final Object requestAttribute;
+    private final Logger service;
+    private final Resource childResource;
+
+    @Inject
+    public InjectorSpecificAnnotationModel(
+            @ValueMapValue(name = "first", optional = true) String first,
+            @ValueMapValue(name = "second", optional = true) String 
secondWithOtherName,
+            @ValueMapValue(name = "log", optional = true) Logger log,
+            @ScriptVariable(optional = true, name = "sling") SlingScriptHelper 
helper,
+            @RequestAttribute(optional = true, name = "attribute") Object 
requestAttribute,
+            @OSGiService(optional = true) Logger service,
+            @ChildResource(optional = true, name = "child1") Resource 
childResource
+    ) {
+        this.first = first;
+        this.secondWithOtherName = secondWithOtherName;
+        this.log = log;
+        this.helper = helper;
+        this.requestAttribute = requestAttribute;
+        this.service = service;
+        this.childResource = childResource;
+    }
+
+    public String getFirst() {
+        return first;
+    }
+
+    public String getSecond() {
+        return secondWithOtherName;
+    }
+
+    public Logger getLog() {
+        return log;
+    }
+
+    public Logger getService() {
+        return service;
+    }
+
+    public SlingScriptHelper getHelper() {
+        return helper;
+    }
+
+    public Object getRequestAttribute() {
+        return requestAttribute;
+    }
+
+    public Resource getChildResource() {
+        return childResource;
+    }
+
+}
\ No newline at end of file

Copied: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ListOSGiModel.java
 (from r1618976, 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ListOSGiModel.java?p2=sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ListOSGiModel.java&p1=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java&r1=1618976&r2=1619007&rev=1619007&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/ListOSGiModel.java
 Tue Aug 19 22:51:36 2014
@@ -14,30 +14,29 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.models.it.models;
+package org.apache.sling.models.testmodels.classes.constructorinjection;
 
 import java.util.List;
 
 import javax.inject.Inject;
-import javax.servlet.Filter;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.testmodels.interfaces.ServiceInterface;
 
-@Model(adaptables=Resource.class)
-public class TestModel {
+@Model(adaptables = Resource.class)
+@SuppressWarnings("javadoc")
+public class ListOSGiModel {
+
+    private final List<ServiceInterface> services;
 
     @Inject
-    private String testProperty;
-    
-    @Inject
-    private List<Filter> filters;
-    
-    public String getTestProperty() {
-        return testProperty;
+    public ListOSGiModel(List<ServiceInterface> services) {
+        this.services = services;
     }
-    
-    public List<Filter> getFilters() {
-        return filters;
+
+    public List<ServiceInterface> getServices() {
+        return services;
     }
-}
+
+}
\ No newline at end of file

Added: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/NoNameModel.java
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/NoNameModel.java?rev=1619007&view=auto
==============================================================================
--- 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/NoNameModel.java
 (added)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/NoNameModel.java
 Tue Aug 19 22:51:36 2014
@@ -0,0 +1,42 @@
+/*
+ * 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.constructorinjection;
+
+import javax.inject.Inject;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.scripting.SlingScriptHelper;
+import org.apache.sling.models.annotations.Model;
+
+@Model(adaptables = SlingHttpServletRequest.class)
+@SuppressWarnings("javadoc")
+public class NoNameModel {
+
+    private final SlingScriptHelper sling;
+
+    @Inject
+    public NoNameModel(SlingScriptHelper sling) {
+        this.sling = sling;
+    }
+
+    public SlingScriptHelper getSling() {
+        return sling;
+    }
+
+}
\ No newline at end of file

Copied: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/SimpleOSGiModel.java
 (from r1618976, 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/SimpleOSGiModel.java?p2=sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/SimpleOSGiModel.java&p1=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java&r1=1618976&r2=1619007&rev=1619007&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/SimpleOSGiModel.java
 Tue Aug 19 22:51:36 2014
@@ -14,30 +14,27 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.models.it.models;
-
-import java.util.List;
+package org.apache.sling.models.testmodels.classes.constructorinjection;
 
 import javax.inject.Inject;
-import javax.servlet.Filter;
 
 import org.apache.sling.api.resource.Resource;
 import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.testmodels.interfaces.ServiceInterface;
 
-@Model(adaptables=Resource.class)
-public class TestModel {
+@Model(adaptables = Resource.class)
+@SuppressWarnings("javadoc")
+public class SimpleOSGiModel {
+
+    private final ServiceInterface service;
 
     @Inject
-    private String testProperty;
-    
-    @Inject
-    private List<Filter> filters;
-    
-    public String getTestProperty() {
-        return testProperty;
+    public SimpleOSGiModel(ServiceInterface service) {
+        this.service = service;
     }
-    
-    public List<Filter> getFilters() {
-        return filters;
+
+    public ServiceInterface getService() {
+        return service;
     }
-}
+
+}
\ No newline at end of file

Copied: 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/WithThreeConstructorsOneInjectModel.java
 (from r1618976, 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/WithThreeConstructorsOneInjectModel.java?p2=sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/WithThreeConstructorsOneInjectModel.java&p1=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java&r1=1618976&r2=1619007&rev=1619007&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/impl/src/test/java/org/apache/sling/models/testmodels/classes/constructorinjection/WithThreeConstructorsOneInjectModel.java
 Tue Aug 19 22:51:36 2014
@@ -14,30 +14,46 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.sling.models.it.models;
-
-import java.util.List;
+package org.apache.sling.models.testmodels.classes.constructorinjection;
 
 import javax.inject.Inject;
-import javax.servlet.Filter;
+import javax.inject.Named;
 
-import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.SlingHttpServletRequest;
 import org.apache.sling.models.annotations.Model;
 
-@Model(adaptables=Resource.class)
-public class TestModel {
+@Model(adaptables = SlingHttpServletRequest.class)
+@SuppressWarnings("javadoc")
+public class WithThreeConstructorsOneInjectModel {
+
+    private SlingHttpServletRequest request;
 
     @Inject
-    private String testProperty;
-    
+    private int attribute;
+
+    private String attribute2;
+
+    public WithThreeConstructorsOneInjectModel(SlingHttpServletRequest 
request) {
+        this.request = request;
+    }
+
+    public WithThreeConstructorsOneInjectModel() {
+    }
+
     @Inject
-    private List<Filter> filters;
-    
-    public String getTestProperty() {
-        return testProperty;
-    }
-    
-    public List<Filter> getFilters() {
-        return filters;
+    public WithThreeConstructorsOneInjectModel(@Named("attribute2") String 
attribute2) {
+        this.attribute2 = attribute2;
+    }
+
+    public int getAttribute() {
+        return attribute;
+    }
+
+    public String getAttribute2() {
+        return attribute2;
+    }
+
+    public SlingHttpServletRequest getRequest() {
+        return request;
     }
-}
+}
\ No newline at end of file

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=1619007&r1=1619006&r2=1619007&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
 Tue Aug 19 22:51:36 2014
@@ -27,44 +27,78 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.api.resource.ResourceResolverFactory;
 import org.apache.sling.junit.annotations.SlingAnnotationsTestRunner;
 import org.apache.sling.junit.annotations.TestReference;
-import org.apache.sling.models.it.models.TestModel;
+import org.apache.sling.models.it.models.ConstructorInjectionTestModel;
+import org.apache.sling.models.it.models.InterfaceInjectionTestModel;
+import org.apache.sling.models.it.models.FieldInjectionTestModel;
+import org.junit.After;
+import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 
 @RunWith(SlingAnnotationsTestRunner.class)
+@SuppressWarnings("javadoc")
 public class SimpleTest {
 
     @TestReference
     private ResourceResolverFactory rrFactory;
+    
+    private String value;
+    private ResourceResolver resolver;
+    private Resource resource;
+    private Node createdNode;
+    
+    @Before
+    public void setUp() throws Exception {
+        value = RandomStringUtils.randomAlphanumeric(10);
+
+        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);
+        session.save();
 
-    @Test
-    public void test() throws Exception {
-        String value = RandomStringUtils.randomAlphanumeric(10);
+        resource = resolver.getResource(createdNode.getPath());
+    }
 
-        ResourceResolver resolver = null;
-        Node createdNode = null;
-        try {
-            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);
-            session.save();
-
-            Resource resource = resolver.getResource(createdNode.getPath());
-
-            TestModel model = resource.adaptTo(TestModel.class);
-
-            assertNotNull("Model is null", model);
-            assertEquals("Test Property is not set correctly", value, 
model.getTestProperty());
-            assertNotNull("Filters is null", model.getFilters());
-        } finally {
-            if (createdNode != null) {
-                createdNode.remove();
-            }
-            if (resolver != null) {
-                resolver.close();
-            }
+    @After
+    public void tearDown() throws Exception {
+        if (createdNode != null) {
+            createdNode.remove();
+        }
+        if (resolver != null) {
+            resolver.close();
         }
     }
+
+    @Test
+    public void testFieldInjection() {
+        FieldInjectionTestModel model = 
resource.adaptTo(FieldInjectionTestModel.class);
+    
+        assertNotNull("Model is null", model);
+        assertEquals("Test Property is not set correctly", value, 
model.getTestProperty());
+        assertNotNull("Filters is null", model.getFilters());
+        assertSame("Adaptable is not injected", resource, model.getResource());
+    }
+
+    @Test
+    public void testInterfaceInjection() {
+        InterfaceInjectionTestModel model = 
resource.adaptTo(InterfaceInjectionTestModel.class);
+    
+        assertNotNull("Model is null", model);
+        assertEquals("Test Property is not set correctly", value, 
model.getTestProperty());
+        assertNotNull("Filters is null", model.getFilters());
+        assertSame("Adaptable is not injected", resource, model.getResource());
+    }
+
+    @Test
+    public void testConstructorInjection() {
+        ConstructorInjectionTestModel model = 
resource.adaptTo(ConstructorInjectionTestModel.class);
+    
+        assertNotNull("Model is null", model);
+        assertEquals("Test Property is not set correctly", value, 
model.getTestProperty());
+        assertNotNull("Filters is null", model.getFilters());
+        assertSame("Adaptable is not injected", resource, model.getResource());
+    }
+
 }

Copied: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/ConstructorInjectionTestModel.java
 (from r1618976, 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/ConstructorInjectionTestModel.java?p2=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/ConstructorInjectionTestModel.java&p1=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java&r1=1618976&r2=1619007&rev=1619007&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/ConstructorInjectionTestModel.java
 Tue Aug 19 22:51:36 2014
@@ -19,25 +19,38 @@ 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.models.annotations.Model;
 
 @Model(adaptables=Resource.class)
-public class TestModel {
+@SuppressWarnings("javadoc")
+public class ConstructorInjectionTestModel {
 
-    @Inject
-    private String testProperty;
+    private final String testProperty;
+    private final List<Filter> filters;
+    private final Resource resource;
     
     @Inject
-    private List<Filter> filters;
+    public ConstructorInjectionTestModel(@Named("testProperty") String 
testProperty,
+            @Named("filters") List<Filter> filters, Resource resource) {
+        this.testProperty = testProperty;
+        this.filters = filters;
+        this.resource = resource;
+    }
     
     public String getTestProperty() {
         return testProperty;
     }
-    
+
     public List<Filter> getFilters() {
         return filters;
     }
+
+    public Resource getResource() {
+        return resource;
+    }
+
 }

Copied: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java
 (from r1618976, 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.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?p2=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java&p1=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java&r1=1618976&r2=1619007&rev=1619007&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java
 Tue Aug 19 22:51:36 2014
@@ -25,7 +25,8 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.models.annotations.Model;
 
 @Model(adaptables=Resource.class)
-public class TestModel {
+@SuppressWarnings("javadoc")
+public class FieldInjectionTestModel {
 
     @Inject
     private String testProperty;
@@ -33,6 +34,12 @@ public class TestModel {
     @Inject
     private List<Filter> filters;
     
+    private final Resource resource;
+    
+    public FieldInjectionTestModel(Resource pResource) {
+        this.resource = pResource;
+    }
+    
     public String getTestProperty() {
         return testProperty;
     }
@@ -40,4 +47,9 @@ public class TestModel {
     public List<Filter> getFilters() {
         return filters;
     }
+
+    public Resource getResource() {
+        return resource;
+    }
+
 }

Copied: 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/InterfaceInjectionTestModel.java
 (from r1618976, 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java)
URL: 
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/InterfaceInjectionTestModel.java?p2=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/InterfaceInjectionTestModel.java&p1=sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java&r1=1618976&r2=1619007&rev=1619007&view=diff
==============================================================================
--- 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/TestModel.java
 (original)
+++ 
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/InterfaceInjectionTestModel.java
 Tue Aug 19 22:51:36 2014
@@ -25,19 +25,16 @@ import org.apache.sling.api.resource.Res
 import org.apache.sling.models.annotations.Model;
 
 @Model(adaptables=Resource.class)
-public class TestModel {
+@SuppressWarnings("javadoc")
+public interface InterfaceInjectionTestModel {
 
     @Inject
-    private String testProperty;
+    String getTestProperty();
     
     @Inject
-    private List<Filter> filters;
-    
-    public String getTestProperty() {
-        return testProperty;
-    }
-    
-    public List<Filter> getFilters() {
-        return filters;
-    }
+    List<Filter> getFilters();
+
+    @Inject
+    Resource getResource();
+
 }


Reply via email to