You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by di...@apache.org on 2022/01/19 10:26:00 UTC

[sling-org-apache-sling-models-integration-tests] 01/01: SLING-11073: add integration tests for via OrigianlResource

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

diru pushed a commit to branch issue/SLING-11073
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-models-integration-tests.git

commit 6cebcf432c5d703f4b4731d401dcce443f4744f5
Author: Dirk Rudolph <dr...@adobe.com>
AuthorDate: Wed Jan 19 11:25:47 2022 +0100

    SLING-11073: add integration tests for via OrigianlResource
---
 pom.xml                                            |   6 +-
 .../models/it/delegate/viaoriginalresource/A.java  |  20 ++++
 .../models/it/delegate/viaoriginalresource/A1.java |  20 ++++
 .../models/it/delegate/viaoriginalresource/B.java  |  20 ++++
 .../models/it/delegate/viaoriginalresource/B1.java |  20 ++++
 .../viaoriginalresource/models/A1Impl.java         |  43 +++++++
 .../delegate/viaoriginalresource/models/AImpl.java |  39 ++++++
 .../viaoriginalresource/models/B1Impl.java         |  39 ++++++
 .../delegate/viaoriginalresource/models/BImpl.java |  30 +++++
 .../viaoriginalresource/models/package-info.java   |  21 ++++
 .../delegate/viaoriginalresource/package-info.java |  21 ++++
 .../ViaOriginalResourceDelegationIT.java           | 133 +++++++++++++++++++++
 12 files changed, 410 insertions(+), 2 deletions(-)

diff --git a/pom.xml b/pom.xml
index 00f7f7a..8c06a65 100644
--- a/pom.xml
+++ b/pom.xml
@@ -42,6 +42,7 @@
         <!-- start with -DkeepITServerRunning=true to allow to rerun ITs or inspect the server after the ITs have been executed there -->
         <keepITServerRunning>false</keepITServerRunning>
         <project.build.outputTimestamp>2021-12-01T00:00:00Z</project.build.outputTimestamp>
+        <sling.vm.options></sling.vm.options>
     </properties>
 
     <build>
@@ -147,6 +148,7 @@
                     <!-- this configuration only applies to 'prepare-package' and 'package' -->
                     <disableExtendingMavenClasspath>true</disableExtendingMavenClasspath>
                     <usePomDependencies>true</usePomDependencies>
+                    <keepLaunchpadRunning>${keepITServerRunning}</keepLaunchpadRunning>
                 </configuration>
             </plugin>
             <plugin>
@@ -334,13 +336,13 @@
         <profile>
             <id>debug-remote-process</id>
             <properties>
-                <jar.executor.vm.options>-Xmx512m -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=38080,suspend=n</jar.executor.vm.options>
+                <sling.vm.options>-Xmx512m -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=38080,suspend=n</sling.vm.options>
             </properties>
         </profile>
         <profile>
             <id>debug-remote-process-suspend</id>
             <properties>
-                <jar.executor.vm.options>-Xmx512m -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=38080,suspend=n</jar.executor.vm.options>
+                <sling.vm.options>-Xmx512m -Xdebug -Xrunjdwp:server=y,transport=dt_socket,address=38080,suspend=y</sling.vm.options>
             </properties>
         </profile>
     </profiles>
diff --git a/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/A.java b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/A.java
new file mode 100644
index 0000000..cf4e22e
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/A.java
@@ -0,0 +1,20 @@
+/*
+ * 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.it.delegate.viaoriginalresource;
+
+public interface A {
+}
diff --git a/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/A1.java b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/A1.java
new file mode 100644
index 0000000..ac28d3b
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/A1.java
@@ -0,0 +1,20 @@
+/*
+ * 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.it.delegate.viaoriginalresource;
+
+public interface A1 extends A {
+}
diff --git a/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/B.java b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/B.java
new file mode 100644
index 0000000..8e53719
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/B.java
@@ -0,0 +1,20 @@
+/*
+ * 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.it.delegate.viaoriginalresource;
+
+public interface B {
+}
diff --git a/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/B1.java b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/B1.java
new file mode 100644
index 0000000..084de18
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/B1.java
@@ -0,0 +1,20 @@
+/*
+ * 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.it.delegate.viaoriginalresource;
+
+public interface B1 extends B {
+}
diff --git a/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/A1Impl.java b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/A1Impl.java
new file mode 100644
index 0000000..559329d
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/A1Impl.java
@@ -0,0 +1,43 @@
+/*
+ * 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.it.delegate.viaoriginalresource.models;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Via;
+import org.apache.sling.models.annotations.injectorspecific.Self;
+import org.apache.sling.models.annotations.via.ResourceSuperType;
+import org.apache.sling.models.it.delegate.viaoriginalresource.A;
+import org.apache.sling.models.it.delegate.viaoriginalresource.A1;
+import org.apache.sling.models.it.delegate.viaoriginalresource.B1;
+
+@Model(
+    adaptables = { SlingHttpServletRequest.class, Resource.class },
+    adapters = { A1.class, A.class },
+    resourceType = "delegate/nestedrtbound/specific"
+)
+public class A1Impl implements A1 {
+
+    @Self
+    @Via(type = ResourceSuperType.class)
+    public A delegate;
+
+    @Self
+    public B1 other;
+
+}
diff --git a/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/AImpl.java b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/AImpl.java
new file mode 100644
index 0000000..31e8794
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/AImpl.java
@@ -0,0 +1,39 @@
+/*
+ * 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.it.delegate.viaoriginalresource.models;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Via;
+import org.apache.sling.models.annotations.injectorspecific.Self;
+import org.apache.sling.models.annotations.via.OriginalResource;
+import org.apache.sling.models.it.delegate.viaoriginalresource.A;
+import org.apache.sling.models.it.delegate.viaoriginalresource.B;
+
+@Model(
+    adaptables = { SlingHttpServletRequest.class, Resource.class },
+    adapters = { A.class },
+    resourceType = "delegate/nestedrtbound/generic"
+)
+public class AImpl implements A {
+
+    @Self
+    @Via(type = OriginalResource.class)
+    public B other;
+
+}
diff --git a/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/B1Impl.java b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/B1Impl.java
new file mode 100644
index 0000000..a0a6637
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/B1Impl.java
@@ -0,0 +1,39 @@
+/*
+ * 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.it.delegate.viaoriginalresource.models;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.annotations.Via;
+import org.apache.sling.models.annotations.injectorspecific.Self;
+import org.apache.sling.models.annotations.via.ResourceSuperType;
+import org.apache.sling.models.it.delegate.viaoriginalresource.B;
+import org.apache.sling.models.it.delegate.viaoriginalresource.B1;
+
+@Model(
+    adaptables = { SlingHttpServletRequest.class, Resource.class },
+    adapters = { B1.class, B.class },
+    resourceType = "delegate/nestedrtbound/specific"
+)
+public class B1Impl implements B1 {
+
+    @Self
+    @Via(type = ResourceSuperType.class)
+    public B delegate;
+
+}
diff --git a/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/BImpl.java b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/BImpl.java
new file mode 100644
index 0000000..c807d6b
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/BImpl.java
@@ -0,0 +1,30 @@
+/*
+ * 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.it.delegate.viaoriginalresource.models;
+
+import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.models.annotations.Model;
+import org.apache.sling.models.it.delegate.viaoriginalresource.B;
+
+@Model(
+    adaptables = { SlingHttpServletRequest.class, Resource.class },
+    adapters = { B.class },
+    resourceType = "delegate/nestedrtbound/generic"
+)
+public class BImpl implements B {
+}
diff --git a/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/package-info.java b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/package-info.java
new file mode 100644
index 0000000..88f82b0
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+@Version("1.0")
+package org.apache.sling.models.it.delegate.viaoriginalresource.models;
+
+import org.osgi.annotation.versioning.Version;
diff --git a/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/package-info.java b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/package-info.java
new file mode 100644
index 0000000..fa049a5
--- /dev/null
+++ b/src/main/java/org/apache/sling/models/it/delegate/viaoriginalresource/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+@Version("1.0")
+package org.apache.sling.models.it.delegate.viaoriginalresource;
+
+import org.osgi.annotation.versioning.Version;
diff --git a/src/test/java/org/apache/sling/models/testing/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java b/src/test/java/org/apache/sling/models/testing/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java
new file mode 100644
index 0000000..1b59672
--- /dev/null
+++ b/src/test/java/org/apache/sling/models/testing/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java
@@ -0,0 +1,133 @@
+/*
+ * 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.testing.delegate.viaoriginalresource;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.sling.api.resource.LoginException;
+import org.apache.sling.api.resource.PersistenceException;
+import org.apache.sling.api.resource.Resource;
+import org.apache.sling.api.resource.ResourceResolver;
+import org.apache.sling.api.resource.ResourceResolverFactory;
+import org.apache.sling.api.resource.ResourceUtil;
+import org.apache.sling.junit.rules.TeleporterRule;
+import org.apache.sling.models.factory.ModelFactory;
+import org.apache.sling.models.it.delegate.viaoriginalresource.A;
+import org.apache.sling.models.it.delegate.viaoriginalresource.models.A1Impl;
+import org.apache.sling.models.it.delegate.viaoriginalresource.models.AImpl;
+import org.apache.sling.models.it.delegate.viaoriginalresource.models.B1Impl;
+import org.apache.sling.models.it.delegate.viaoriginalresource.models.BImpl;
+import org.apache.sling.models.testing.rtbound.FakeRequest;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
+public class ViaOriginalResourceDelegationIT {
+
+    @Rule
+    public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter");
+
+    private ResourceResolverFactory rrFactory;
+
+    private ModelFactory modelFactory;
+
+    private final String genericComponent = "/apps/delegate/nestedrtbound/generic";
+    private final String specificComponent = "/apps/delegate/nestedrtbound/specific";
+    private final String genericContent = "/content/delegate/nestedrtbound/generic";
+    private final String specificContent = "/content/delegate/nestedrtbound/specific";
+
+    @Before
+    @SuppressWarnings("null")
+    public void setup() throws LoginException, PersistenceException {
+        rrFactory = teleporter.getService(ResourceResolverFactory.class);
+        modelFactory = teleporter.getService(ModelFactory.class);
+        try (ResourceResolver adminResolver = rrFactory.getServiceResourceResolver(null);) {
+
+            Map<String, Object> properties = new HashMap<String, Object>();
+            ResourceUtil.getOrCreateResource(adminResolver, genericComponent, properties, null, false);
+            properties.clear();
+
+            properties.put("sling:resourceSuperType", "delegate/nestedrtbound/generic");
+            ResourceUtil.getOrCreateResource(adminResolver, specificComponent, properties, null, false);
+            properties.clear();
+
+            properties.put("sling:resourceType", "delegate/nestedrtbound/generic");
+            ResourceUtil.getOrCreateResource(adminResolver, genericContent, properties, null, false);
+            properties.clear();
+
+            properties.put("sling:resourceType", "delegate/nestedrtbound/specific");
+            ResourceUtil.getOrCreateResource(adminResolver, specificContent, properties, null, false);
+            properties.clear();
+
+            adminResolver.commit();
+        }
+    }
+
+    @Test
+    public void testGenericModelFromRequest() throws LoginException {
+        try (ResourceResolver resolver = rrFactory.getServiceResourceResolver(null);) {
+            final Resource content = resolver.getResource(genericContent);
+            final FakeRequest baseRequest = new FakeRequest(content);
+
+            final A model = modelFactory.createModel(baseRequest, A.class);
+            assertTrue(model instanceof AImpl);
+            assertTrue(((AImpl) model).other instanceof BImpl);
+        }
+    }
+
+    @Test
+    public void testSpecificModelFromRequest() throws LoginException {
+        try (ResourceResolver resolver = rrFactory.getServiceResourceResolver(null);) {
+            final Resource content = resolver.getResource(specificContent);
+            final FakeRequest baseRequest = new FakeRequest(content);
+
+            final A model = modelFactory.createModel(baseRequest, A.class);
+            assertTrue(model instanceof A1Impl);
+            assertTrue(((A1Impl) model).other instanceof B1Impl);
+            assertTrue(((A1Impl) model).delegate instanceof AImpl);
+            assertTrue(((AImpl) ((A1Impl) model).delegate).other instanceof B1Impl);
+        }
+    }
+
+    @Test
+    public void testGenericModelFromResource() throws LoginException {
+        try (ResourceResolver resolver = rrFactory.getServiceResourceResolver(null);) {
+            final Resource content = resolver.getResource(genericContent);
+
+            final A model = modelFactory.createModel(content, A.class);
+            assertTrue(model instanceof AImpl);
+            assertTrue(((AImpl) model).other instanceof BImpl);
+        }
+    }
+
+    @Test
+    public void testSpecificModelFromResource() throws LoginException {
+        try (ResourceResolver resolver = rrFactory.getServiceResourceResolver(null);) {
+            final Resource content = resolver.getResource(specificContent);
+
+            final A model = modelFactory.createModel(content, A.class);
+            assertTrue(model instanceof A1Impl);
+            assertTrue(((A1Impl) model).other instanceof B1Impl);
+            assertTrue(((A1Impl) model).delegate instanceof AImpl);
+            assertTrue(((AImpl) ((A1Impl) model).delegate).other instanceof B1Impl);
+        }
+    }
+}