From 1535b26177c3fe5ab548d223ba3dfba4d334cade Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 23 Jan 2026 10:12:09 +0100 Subject: [PATCH 01/17] SLING-13068 Update to Parent 65 also update testing dependencies --- pom.xml | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 07a2857..0794a4d 100644 --- a/pom.xml +++ b/pom.xml @@ -22,7 +22,7 @@ org.apache.sling sling-bundle-parent - 62 + 65 org.apache.sling.models.impl @@ -88,13 +88,11 @@ javax.servlet javax.servlet-api - 4.0.1 provided jakarta.servlet jakarta.servlet-api - 6.0.0 provided @@ -165,22 +163,32 @@ junit-jupiter-api test + + org.junit.platform + junit-platform-engine + test + + + org.junit.platform + junit-platform-launcher + test + org.mockito mockito-junit-jupiter - 4.4.0 + 5.21.0 test org.apache.sling org.apache.sling.testing.osgi-mock.junit4 - 3.5.2 + 3.5.4 test org.mockito mockito-core - 4.4.0 + 5.21.0 test From 7ad9b4a141fe9374cd870ce347142637623a3d29 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 23 Jan 2026 10:14:06 +0100 Subject: [PATCH 02/17] SLING-13068 update testing dependencies --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 0794a4d..e2668d8 100644 --- a/pom.xml +++ b/pom.xml @@ -219,7 +219,7 @@ org.springframework spring-context - 5.3.39 + 7.0.3 test From 868609481ae57774be3dc2611dbb796818421e7c Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 23 Jan 2026 10:58:13 +0100 Subject: [PATCH 03/17] SLING-13050 define models versions --- pom.xml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e2668d8..7440647 100644 --- a/pom.xml +++ b/pom.xml @@ -36,16 +36,18 @@ org.apache.sling.models.impl-1.7.2 https://github.com/apache/sling-org-apache-sling-models-impl.git + 2025-08-27T03:14:05Z 17 + 2.0.0 org.apache.sling org.apache.sling.models.api - 2.0.0 + ${models.api.version} provided From 94a43647da4db32a22b21f56daa723698f3f8855 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 23 Jan 2026 11:02:46 +0100 Subject: [PATCH 04/17] SLING-13050 add IT test models --- pom.xml | 23 +++++-- .../delegate/request/DelegateBaseModel.java | 50 ++++++++++++++ .../request/DelegateExtendedModel.java | 46 +++++++++++++ .../delegate/request/DelegateInterface.java | 26 ++++++++ .../it/delegate/request/package-info.java | 21 ++++++ .../delegate/resource/DelegateBaseModel.java | 44 +++++++++++++ .../resource/DelegateExtendedModel.java | 43 ++++++++++++ .../delegate/resource/DelegateInterface.java | 26 ++++++++ .../it/delegate/resource/package-info.java | 21 ++++++ .../it/delegate/viaoriginalresource/A.java | 21 ++++++ .../it/delegate/viaoriginalresource/A1.java | 21 ++++++ .../it/delegate/viaoriginalresource/B.java | 21 ++++++ .../it/delegate/viaoriginalresource/B1.java | 21 ++++++ .../viaoriginalresource/models/A1Impl.java | 43 ++++++++++++ .../viaoriginalresource/models/AImpl.java | 39 +++++++++++ .../viaoriginalresource/models/B1Impl.java | 40 +++++++++++ .../viaoriginalresource/models/BImpl.java | 31 +++++++++ .../models/package-info.java | 21 ++++++ .../viaoriginalresource/package-info.java | 21 ++++++ .../CustomLastImplementationPicker.java | 44 +++++++++++++ .../models/it/implpicker/package-info.java | 21 ++++++ .../models/ConstructorInjectionTestModel.java | 59 +++++++++++++++++ .../it/models/FieldInjectionTestModel.java | 66 +++++++++++++++++++ .../models/InterfaceInjectionTestModel.java | 41 ++++++++++++ .../it/models/JakartaRequestSelfModel.java | 26 ++++++++ .../models/JakartaRequestSelfModelImpl.java | 34 ++++++++++ .../it/models/ModelWithOptionalImport.java | 32 +++++++++ .../models/it/models/RequestSelfModel.java | 26 ++++++++ .../it/models/RequestSelfModelImpl.java | 34 ++++++++++ .../sling/models/it/models/SelfModel.java | 34 ++++++++++ .../it/models/ServiceInjectionTestModel.java | 49 ++++++++++++++ .../SlingPropertyAnnotationTestModel.java | 34 ++++++++++ .../sling/models/it/models/SourceObject.java | 34 ++++++++++ .../sling/models/it/models/ViaModel.java | 36 ++++++++++ .../implextend/ExtendsClassPropertyModel.java | 37 +++++++++++ .../ImplementsInterfacePropertyModel.java | 53 +++++++++++++++ .../ImplementsInterfacePropertyModel2.java | 52 +++++++++++++++ ...validImplementsInterfacePropertyModel.java | 52 +++++++++++++++ .../InvalidSampleServiceInterface.java | 30 +++++++++ .../implextend/SampleServiceInterface.java | 30 +++++++++ .../implextend/SimplePropertyModel.java | 47 +++++++++++++ .../it/models/implextend/package-info.java | 21 ++++++ .../sling/models/it/models/package-info.java | 21 ++++++ .../models/it/rtbound/BaseComponent.java | 51 ++++++++++++++ .../models/it/rtbound/ExtendedComponent.java | 48 ++++++++++++++ .../it/rtbound/FromRequestComponent.java | 27 ++++++++ .../sling/models/it/rtbound/package-info.java | 21 ++++++ .../it/rtboundpicker/BaseComponent.java | 31 +++++++++ .../it/rtboundpicker/SubRTComponent.java | 31 +++++++++ .../it/rtboundpicker/TestComponent.java | 24 +++++++ .../models/it/rtboundpicker/package-info.java | 21 ++++++ .../AnotherTestBindingsValuesProvider.java | 36 ++++++++++ .../models/it/services/SimpleService.java | 23 +++++++ .../SimpleServiceWithCustomRanking.java | 32 +++++++++ .../services/TestBindingsValuesProvider.java | 36 ++++++++++ .../it/services/TestResourceDecorator.java | 66 +++++++++++++++++++ .../models/it/services/package-info.java | 21 ++++++ .../it/servlets/PathBoundJakartaServlet.java | 46 +++++++++++++ .../models/it/servlets/PathBoundServlet.java | 46 +++++++++++++ .../apache/sling/models/it/noclasses/foo.txt | 1 + 60 files changed, 2048 insertions(+), 5 deletions(-) create mode 100644 src/test/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/request/package-info.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/resource/package-info.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A1.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B1.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/A1Impl.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/AImpl.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/B1Impl.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/BImpl.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/package-info.java create mode 100644 src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/package-info.java create mode 100644 src/test/java/org/apache/sling/models/it/implpicker/CustomLastImplementationPicker.java create mode 100644 src/test/java/org/apache/sling/models/it/implpicker/package-info.java create mode 100644 src/test/java/org/apache/sling/models/it/models/ConstructorInjectionTestModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/InterfaceInjectionTestModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModelImpl.java create mode 100644 src/test/java/org/apache/sling/models/it/models/ModelWithOptionalImport.java create mode 100644 src/test/java/org/apache/sling/models/it/models/RequestSelfModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/RequestSelfModelImpl.java create mode 100644 src/test/java/org/apache/sling/models/it/models/SelfModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/ServiceInjectionTestModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/SlingPropertyAnnotationTestModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/SourceObject.java create mode 100644 src/test/java/org/apache/sling/models/it/models/ViaModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/implextend/ExtendsClassPropertyModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel2.java create mode 100644 src/test/java/org/apache/sling/models/it/models/implextend/InvalidImplementsInterfacePropertyModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/implextend/InvalidSampleServiceInterface.java create mode 100644 src/test/java/org/apache/sling/models/it/models/implextend/SampleServiceInterface.java create mode 100644 src/test/java/org/apache/sling/models/it/models/implextend/SimplePropertyModel.java create mode 100644 src/test/java/org/apache/sling/models/it/models/implextend/package-info.java create mode 100644 src/test/java/org/apache/sling/models/it/models/package-info.java create mode 100644 src/test/java/org/apache/sling/models/it/rtbound/BaseComponent.java create mode 100644 src/test/java/org/apache/sling/models/it/rtbound/ExtendedComponent.java create mode 100644 src/test/java/org/apache/sling/models/it/rtbound/FromRequestComponent.java create mode 100644 src/test/java/org/apache/sling/models/it/rtbound/package-info.java create mode 100644 src/test/java/org/apache/sling/models/it/rtboundpicker/BaseComponent.java create mode 100644 src/test/java/org/apache/sling/models/it/rtboundpicker/SubRTComponent.java create mode 100644 src/test/java/org/apache/sling/models/it/rtboundpicker/TestComponent.java create mode 100644 src/test/java/org/apache/sling/models/it/rtboundpicker/package-info.java create mode 100644 src/test/java/org/apache/sling/models/it/services/AnotherTestBindingsValuesProvider.java create mode 100644 src/test/java/org/apache/sling/models/it/services/SimpleService.java create mode 100644 src/test/java/org/apache/sling/models/it/services/SimpleServiceWithCustomRanking.java create mode 100644 src/test/java/org/apache/sling/models/it/services/TestBindingsValuesProvider.java create mode 100644 src/test/java/org/apache/sling/models/it/services/TestResourceDecorator.java create mode 100644 src/test/java/org/apache/sling/models/it/services/package-info.java create mode 100644 src/test/java/org/apache/sling/models/it/servlets/PathBoundJakartaServlet.java create mode 100644 src/test/java/org/apache/sling/models/it/servlets/PathBoundServlet.java create mode 100644 src/test/resources/org/apache/sling/models/it/noclasses/foo.txt diff --git a/pom.xml b/pom.xml index 7440647..e5d0f43 100644 --- a/pom.xml +++ b/pom.xml @@ -97,6 +97,12 @@ jakarta.servlet-api provided + + javax.annotation + javax.annotation-api + 1.3.2 + provided + org.apache.felix org.apache.felix.http.wrappers @@ -210,7 +216,7 @@ 2.0.0 test - + org.apache.commons commons-collections4 @@ -225,10 +231,16 @@ test - javax.annotation - javax.annotation-api - 1.3.2 - provided + org.apache.sling + org.apache.sling.servlets.annotations + test + + + + commons-beanutils + commons-beanutils + 1.9.4 + test @@ -290,6 +302,7 @@ dependency-reduced-pom.xml + src/test/resources/org/apache/sling/models/it/noclasses/foo.txt diff --git a/src/test/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java b/src/test/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java new file mode 100644 index 0000000..1e4369e --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java @@ -0,0 +1,50 @@ +/* + * 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.request; + +import javax.inject.Inject; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.Via; + +@Model( + adaptables = SlingHttpServletRequest.class, + adapters = DelegateInterface.class, + resourceType = "sling/delegate/base") +public class DelegateBaseModel implements DelegateInterface { + + @Inject + @Via("resource") + private String text; + + @Inject + @Via("resource") + private String other; + + @Override + public String getText() { + return text; + } + + @Override + public String getOther() { + return other; + } +} diff --git a/src/test/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java b/src/test/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java new file mode 100644 index 0000000..c2a01a7 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java @@ -0,0 +1,46 @@ +/* + * 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.request; + +import org.apache.sling.api.SlingHttpServletRequest; +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; + +@Model( + adaptables = SlingHttpServletRequest.class, + adapters = DelegateInterface.class, + resourceType = "sling/delegate/extended") +public class DelegateExtendedModel implements DelegateInterface { + + @Self + @Via(type = ResourceSuperType.class) + private DelegateInterface delegate; + + @Override + public String getOther() { + return delegate.getOther(); + } + + @Override + public String getText() { + return delegate.getText().toUpperCase(); + } +} diff --git a/src/test/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java b/src/test/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java new file mode 100644 index 0000000..9826052 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java @@ -0,0 +1,26 @@ +/* + * 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.request; + +public interface DelegateInterface { + + String getText(); + + String getOther(); +} diff --git a/src/test/java/org/apache/sling/models/it/delegate/request/package-info.java b/src/test/java/org/apache/sling/models/it/delegate/request/package-info.java new file mode 100644 index 0000000..3e7e701 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/request/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.request; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java b/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java new file mode 100644 index 0000000..0b2031b --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java @@ -0,0 +1,44 @@ +/* + * 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.resource; + +import javax.inject.Inject; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; + +@Model(adaptables = Resource.class, adapters = DelegateInterface.class, resourceType = "sling/delegate/base") +public class DelegateBaseModel implements DelegateInterface { + + @Inject + private String text; + + @Inject + private String other; + + @Override + public String getText() { + return text; + } + + @Override + public String getOther() { + return other; + } +} diff --git a/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.java b/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.java new file mode 100644 index 0000000..df901f5 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.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.resource; + +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; + +@Model(adaptables = Resource.class, adapters = DelegateInterface.class, resourceType = "sling/delegate/extended") +public class DelegateExtendedModel implements DelegateInterface { + + @Self + @Via(type = ResourceSuperType.class) + private DelegateInterface delegate; + + @Override + public String getOther() { + return delegate.getOther(); + } + + @Override + public String getText() { + return delegate.getText().toUpperCase(); + } +} diff --git a/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java b/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java new file mode 100644 index 0000000..2b208e2 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java @@ -0,0 +1,26 @@ +/* + * 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.resource; + +public interface DelegateInterface { + + String getText(); + + String getOther(); +} diff --git a/src/test/java/org/apache/sling/models/it/delegate/resource/package-info.java b/src/test/java/org/apache/sling/models/it/delegate/resource/package-info.java new file mode 100644 index 0000000..a0f5c5b --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/resource/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.resource; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A.java b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A.java new file mode 100644 index 0000000..7581fea --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A.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. + */ +package org.apache.sling.models.it.delegate.viaoriginalresource; + +public interface A {} diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A1.java b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A1.java new file mode 100644 index 0000000..6d3048b --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A1.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. + */ +package org.apache.sling.models.it.delegate.viaoriginalresource; + +public interface A1 extends A {} diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B.java b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B.java new file mode 100644 index 0000000..8fbbdab --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B.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. + */ +package org.apache.sling.models.it.delegate.viaoriginalresource; + +public interface B {} diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B1.java b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B1.java new file mode 100644 index 0000000..50fb27c --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B1.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. + */ +package org.apache.sling.models.it.delegate.viaoriginalresource; + +public interface B1 extends B {} diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/A1Impl.java b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/A1Impl.java new file mode 100644 index 0000000..62e4b63 --- /dev/null +++ b/src/test/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/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/AImpl.java b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/AImpl.java new file mode 100644 index 0000000..9622bdb --- /dev/null +++ b/src/test/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.OriginalResourceType; +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 = OriginalResourceType.class) + public B other; +} diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/B1Impl.java b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/B1Impl.java new file mode 100644 index 0000000..85e744f --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/B1Impl.java @@ -0,0 +1,40 @@ +/* + * 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", + cache = true) +public class B1Impl implements B1 { + + @Self + @Via(type = ResourceSuperType.class) + public B delegate; +} diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/BImpl.java b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/BImpl.java new file mode 100644 index 0000000..e3b8569 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/BImpl.java @@ -0,0 +1,31 @@ +/* + * 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", + cache = true) +public class BImpl implements B {} diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/package-info.java b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/package-info.java new file mode 100644 index 0000000..88f82b0 --- /dev/null +++ b/src/test/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/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/package-info.java b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/package-info.java new file mode 100644 index 0000000..fa049a5 --- /dev/null +++ b/src/test/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/it/implpicker/CustomLastImplementationPicker.java b/src/test/java/org/apache/sling/models/it/implpicker/CustomLastImplementationPicker.java new file mode 100644 index 0000000..5979847 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/implpicker/CustomLastImplementationPicker.java @@ -0,0 +1,44 @@ +/* + * 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.implpicker; + +import org.apache.commons.lang3.StringUtils; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.spi.ImplementationPicker; +import org.jetbrains.annotations.NotNull; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.propertytypes.ServiceRanking; + +/** + * This is a curious {@link ImplementationPicker} implementation for integration test + * that picks the last implementation if the resource has the name "custom"; + */ +@Component(service = ImplementationPicker.class) +@ServiceRanking(100) +public class CustomLastImplementationPicker implements ImplementationPicker { + + public static final String CUSTOM_NAME = "custom"; + + public Class pick(@NotNull Class adapterType, Class[] implementationsTypes, @NotNull Object adaptable) { + if (adaptable instanceof Resource && StringUtils.equals(((Resource) adaptable).getName(), CUSTOM_NAME)) { + return implementationsTypes[implementationsTypes.length - 1]; + } + return null; + } +} diff --git a/src/test/java/org/apache/sling/models/it/implpicker/package-info.java b/src/test/java/org/apache/sling/models/it/implpicker/package-info.java new file mode 100644 index 0000000..c8a5b3e --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/implpicker/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.implpicker; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/models/ConstructorInjectionTestModel.java b/src/test/java/org/apache/sling/models/it/models/ConstructorInjectionTestModel.java new file mode 100644 index 0000000..c80b1c5 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/ConstructorInjectionTestModel.java @@ -0,0 +1,59 @@ +/* + * 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.models; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.servlet.Filter; + +import java.util.List; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.Self; + +@Model(adaptables = Resource.class) +public class ConstructorInjectionTestModel { + + private final String testProperty; + private final List filters; + private final Resource resource; + + @Inject + public ConstructorInjectionTestModel( + @Named("testProperty") String testProperty, + @Named("filters") List filters, + @Self Resource resource) { + this.testProperty = testProperty; + this.filters = filters; + this.resource = resource; + } + + public String getTestProperty() { + return testProperty; + } + + public List getFilters() { + return filters; + } + + public Resource getResource() { + return resource; + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java b/src/test/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java new file mode 100644 index 0000000..f8ed3a8 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java @@ -0,0 +1,66 @@ +/* + * 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.models; + +import javax.inject.Inject; +import javax.inject.Named; +import javax.servlet.Filter; + +import java.util.List; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.Optional; + +@Model(adaptables = Resource.class) +public class FieldInjectionTestModel { + + @Inject + private String testProperty; + + @Inject + @Optional + @Named("child/childProperty") + private String childProperty; + + @Inject + private List filters; + + private final Resource resource; + + public FieldInjectionTestModel(Resource pResource) { + this.resource = pResource; + } + + public String getTestProperty() { + return testProperty; + } + + public String getChildProperty() { + return childProperty; + } + + public List getFilters() { + return filters; + } + + public Resource getResource() { + return resource; + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/InterfaceInjectionTestModel.java b/src/test/java/org/apache/sling/models/it/models/InterfaceInjectionTestModel.java new file mode 100644 index 0000000..52e2e40 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/InterfaceInjectionTestModel.java @@ -0,0 +1,41 @@ +/* + * 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.models; + +import javax.inject.Inject; +import javax.servlet.Filter; + +import java.util.List; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.Self; + +@Model(adaptables = Resource.class) +public interface InterfaceInjectionTestModel { + + @Inject + String getTestProperty(); + + @Inject + List getFilters(); + + @Self + Resource getResource(); +} diff --git a/src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModel.java b/src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModel.java new file mode 100644 index 0000000..24282af --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModel.java @@ -0,0 +1,26 @@ +/* + * 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.models; + +import org.apache.sling.api.SlingJakartaHttpServletRequest; + +public interface JakartaRequestSelfModel { + + SlingJakartaHttpServletRequest getRequest(); +} diff --git a/src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModelImpl.java b/src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModelImpl.java new file mode 100644 index 0000000..ab7261a --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModelImpl.java @@ -0,0 +1,34 @@ +/* + * 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.models; + +import org.apache.sling.api.SlingJakartaHttpServletRequest; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.Self; + +@Model(adaptables = SlingJakartaHttpServletRequest.class, adapters = RequestSelfModel.class) +public class JakartaRequestSelfModelImpl implements JakartaRequestSelfModel { + + @Self + private SlingJakartaHttpServletRequest request; + + public SlingJakartaHttpServletRequest getRequest() { + return request; + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/ModelWithOptionalImport.java b/src/test/java/org/apache/sling/models/it/models/ModelWithOptionalImport.java new file mode 100644 index 0000000..d33b05b --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/ModelWithOptionalImport.java @@ -0,0 +1,32 @@ +/* + * 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.models; + +import org.apache.commons.beanutils.BeanUtils; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; + +@Model(adaptables = Resource.class) +public class ModelWithOptionalImport { + + // this class is not available at runtime. The containing package has an optional import so the bundle + // still resolves + @SuppressWarnings("unused") + private BeanUtils beanUtils = new BeanUtils(); +} diff --git a/src/test/java/org/apache/sling/models/it/models/RequestSelfModel.java b/src/test/java/org/apache/sling/models/it/models/RequestSelfModel.java new file mode 100644 index 0000000..b711431 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/RequestSelfModel.java @@ -0,0 +1,26 @@ +/* + * 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.models; + +import org.apache.sling.api.SlingHttpServletRequest; + +public interface RequestSelfModel { + + SlingHttpServletRequest getRequest(); +} diff --git a/src/test/java/org/apache/sling/models/it/models/RequestSelfModelImpl.java b/src/test/java/org/apache/sling/models/it/models/RequestSelfModelImpl.java new file mode 100644 index 0000000..de9e83f --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/RequestSelfModelImpl.java @@ -0,0 +1,34 @@ +/* + * 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.models; + +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, adapters = RequestSelfModel.class) +public class RequestSelfModelImpl implements RequestSelfModel { + + @Self + private SlingHttpServletRequest request; + + public SlingHttpServletRequest getRequest() { + return request; + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/SelfModel.java b/src/test/java/org/apache/sling/models/it/models/SelfModel.java new file mode 100644 index 0000000..c635c4e --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/SelfModel.java @@ -0,0 +1,34 @@ +/* + * 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.models; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.Self; + +@Model(adaptables = Resource.class) +public class SelfModel { + + @Self + private Resource resource; + + public Resource getResource() { + return resource; + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/ServiceInjectionTestModel.java b/src/test/java/org/apache/sling/models/it/models/ServiceInjectionTestModel.java new file mode 100644 index 0000000..c9f2cf3 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/ServiceInjectionTestModel.java @@ -0,0 +1,49 @@ +/* + * 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.models; + +import java.util.ArrayList; +import java.util.List; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.OSGiService; +import org.apache.sling.models.it.services.SimpleService; + +@Model(adaptables = Resource.class) +public class ServiceInjectionTestModel { + + @OSGiService + private SimpleService simpleService; // must return the service impl with the highest ranking + + @OSGiService + private List simpleServices; + + public SimpleService getSimpleService() { + return simpleService; + } + + public Integer[] getSimpleServicesRankings() { + List serviceRankings = new ArrayList(); + for (SimpleService service : simpleServices) { + serviceRankings.add(service.getRanking()); + } + return serviceRankings.toArray(new Integer[serviceRankings.size()]); + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/SlingPropertyAnnotationTestModel.java b/src/test/java/org/apache/sling/models/it/models/SlingPropertyAnnotationTestModel.java new file mode 100644 index 0000000..abda77a --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/SlingPropertyAnnotationTestModel.java @@ -0,0 +1,34 @@ +/* + * 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.models; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.injectorspecific.ValueMapValue; + +@Model(adaptables = Resource.class) +public class SlingPropertyAnnotationTestModel { + + @ValueMapValue + private String testProperty; + + public String getTestProperty() { + return testProperty; + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/SourceObject.java b/src/test/java/org/apache/sling/models/it/models/SourceObject.java new file mode 100644 index 0000000..d31d57f --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/SourceObject.java @@ -0,0 +1,34 @@ +/* + * 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.models; + +import org.apache.sling.api.resource.Resource; + +public class SourceObject { + + public SourceObject(Resource resource) { + this.resource = resource; + } + + private Resource resource; + + public Resource getResource() { + return resource; + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/ViaModel.java b/src/test/java/org/apache/sling/models/it/models/ViaModel.java new file mode 100644 index 0000000..a33c24e --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/ViaModel.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.models.it.models; + +import javax.inject.Inject; + +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.Via; + +@Model(adaptables = SourceObject.class) +public class ViaModel { + + @Inject + @Via("resource") + private String testProperty; + + public String getTestProperty() { + return testProperty; + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/ExtendsClassPropertyModel.java b/src/test/java/org/apache/sling/models/it/models/implextend/ExtendsClassPropertyModel.java new file mode 100644 index 0000000..4dbb0dc --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/implextend/ExtendsClassPropertyModel.java @@ -0,0 +1,37 @@ +/* + * 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.models.implextend; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; + +/** + * This is an example for a model that can not be adapted itself, but only + * to a superclass it extends. This superclass is defined as "adapters". + */ +@Model( + adaptables = Resource.class, + adapters = {SimplePropertyModel.class}) +public class ExtendsClassPropertyModel extends SimplePropertyModel { + + @Override + public String getAllProperties() { + return "!" + super.getAllProperties() + "!"; + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel.java b/src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel.java new file mode 100644 index 0000000..033d184 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel.java @@ -0,0 +1,53 @@ +/* + * 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.models.implextend; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.Optional; + +/** + * This is an example for a model that can not be adapted itself, but only + * to an interface it implements. This interfaces is defined as "adapters". + */ +@Model( + adaptables = Resource.class, + adapters = {SampleServiceInterface.class}) +public class ImplementsInterfacePropertyModel implements SampleServiceInterface { + + @Inject + private String first; + + @Inject + @Optional + private String second; + + @Inject + @Named("third") + private String thirdProperty; + + public String getAllProperties() { + StringBuilder sb = new StringBuilder(); + sb.append(first).append("|").append(second).append("|").append(thirdProperty); + return sb.toString(); + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel2.java b/src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel2.java new file mode 100644 index 0000000..40d05ec --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel2.java @@ -0,0 +1,52 @@ +/* + * 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.models.implextend; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.Optional; + +/** + * Additional model class that implements the same interface as {@link ImplementsInterfacePropertyModel}. + */ +@Model( + adaptables = Resource.class, + adapters = {SampleServiceInterface.class}) +public class ImplementsInterfacePropertyModel2 implements SampleServiceInterface { + + @Inject + private String first; + + @Inject + @Optional + private String second; + + @Inject + @Named("third") + private String thirdProperty; + + public String getAllProperties() { + StringBuilder sb = new StringBuilder(); + sb.append(first).append("|").append(second).append("|").append(thirdProperty); + return sb.toString(); + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/InvalidImplementsInterfacePropertyModel.java b/src/test/java/org/apache/sling/models/it/models/implextend/InvalidImplementsInterfacePropertyModel.java new file mode 100644 index 0000000..6f0dfdf --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/implextend/InvalidImplementsInterfacePropertyModel.java @@ -0,0 +1,52 @@ +/* + * 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.models.implextend; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; +import org.apache.sling.models.annotations.Optional; + +/** + * This model defines an invalid adapters property containing an interface it does not implement. + */ +@Model( + adaptables = Resource.class, + adapters = {InvalidSampleServiceInterface.class}) +public class InvalidImplementsInterfacePropertyModel implements SampleServiceInterface { + + @Inject + private String first; + + @Inject + @Optional + private String second; + + @Inject + @Named("third") + private String thirdProperty; + + public String getAllProperties() { + StringBuilder sb = new StringBuilder(); + sb.append(first).append("|").append(second).append("|").append(thirdProperty); + return sb.toString(); + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/InvalidSampleServiceInterface.java b/src/test/java/org/apache/sling/models/it/models/implextend/InvalidSampleServiceInterface.java new file mode 100644 index 0000000..18f26cb --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/implextend/InvalidSampleServiceInterface.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.models.implextend; + +/** + * Example "service" interface to which sling models can adapt. + */ +public interface InvalidSampleServiceInterface { + + /** + * @return concanated string with all properties + */ + String getAllProperties(); +} diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/SampleServiceInterface.java b/src/test/java/org/apache/sling/models/it/models/implextend/SampleServiceInterface.java new file mode 100644 index 0000000..84f1155 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/implextend/SampleServiceInterface.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.models.implextend; + +/** + * Example "service" interface to which sling models can adapt. + */ +public interface SampleServiceInterface { + + /** + * @return concatenated string with all properties + */ + String getAllProperties(); +} diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/SimplePropertyModel.java b/src/test/java/org/apache/sling/models/it/models/implextend/SimplePropertyModel.java new file mode 100644 index 0000000..a942c08 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/implextend/SimplePropertyModel.java @@ -0,0 +1,47 @@ +/* + * 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.models.implextend; + +import javax.inject.Inject; +import javax.inject.Named; + +import org.apache.sling.models.annotations.Optional; + +/** + * Base class without @Model annotation. + */ +public class SimplePropertyModel { + + @Inject + private String first; + + @Inject + @Optional + private String second; + + @Inject + @Named("third") + private String thirdProperty; + + public String getAllProperties() { + StringBuilder sb = new StringBuilder(); + sb.append(first).append("|").append(second).append("|").append(thirdProperty); + return sb.toString(); + } +} diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/package-info.java b/src/test/java/org/apache/sling/models/it/models/implextend/package-info.java new file mode 100644 index 0000000..3d4840c --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/models/implextend/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.models.implextend; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/models/package-info.java b/src/test/java/org/apache/sling/models/it/models/package-info.java new file mode 100644 index 0000000..d387b59 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/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.models; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/rtbound/BaseComponent.java b/src/test/java/org/apache/sling/models/it/rtbound/BaseComponent.java new file mode 100644 index 0000000..b15f9f3 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/rtbound/BaseComponent.java @@ -0,0 +1,51 @@ +/* + * 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.rtbound; + +import javax.inject.Inject; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; + +@Model( + adaptables = {Resource.class}, + resourceType = "sling/rt/base") +public class BaseComponent { + + private final Resource resource; + + @Inject + private String sampleValue; + + public BaseComponent(Resource resource) { + this.resource = resource; + } + + public String getId() { + return this.resource.getPath(); + } + + public String getSampleValue() { + return sampleValue; + } + + public String getSampleValueToUpperCase() { + return sampleValue.toUpperCase(); + } +} diff --git a/src/test/java/org/apache/sling/models/it/rtbound/ExtendedComponent.java b/src/test/java/org/apache/sling/models/it/rtbound/ExtendedComponent.java new file mode 100644 index 0000000..43cbed7 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/rtbound/ExtendedComponent.java @@ -0,0 +1,48 @@ +/* + * 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.rtbound; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; + +@Model( + adaptables = {Resource.class}, + resourceType = "sling/rt/extended") +public class ExtendedComponent extends BaseComponent { + + private final Date d = new Date(); + + public ExtendedComponent(Resource resource) { + super(resource); + } + + public Calendar getDateByCalendar() { + Calendar cal = new GregorianCalendar(); + cal.setTime(d); + return cal; + } + + public Date getDate() { + return d; + } +} diff --git a/src/test/java/org/apache/sling/models/it/rtbound/FromRequestComponent.java b/src/test/java/org/apache/sling/models/it/rtbound/FromRequestComponent.java new file mode 100644 index 0000000..c39b754 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/rtbound/FromRequestComponent.java @@ -0,0 +1,27 @@ +/* + * 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.rtbound; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.models.annotations.Model; + +@Model( + adaptables = {SlingHttpServletRequest.class}, + resourceType = "sling/rt/fromRequest") +public class FromRequestComponent {} diff --git a/src/test/java/org/apache/sling/models/it/rtbound/package-info.java b/src/test/java/org/apache/sling/models/it/rtbound/package-info.java new file mode 100644 index 0000000..19332e3 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/rtbound/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.rtbound; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/rtboundpicker/BaseComponent.java b/src/test/java/org/apache/sling/models/it/rtboundpicker/BaseComponent.java new file mode 100644 index 0000000..292cef0 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/rtboundpicker/BaseComponent.java @@ -0,0 +1,31 @@ +/* + * 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.rtboundpicker; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; + +@Model(adaptables = Resource.class, adapters = TestComponent.class, resourceType = "sling/rtpicker/base") +public class BaseComponent implements TestComponent { + + @Override + public String getSampleValue() { + return "base"; + } +} diff --git a/src/test/java/org/apache/sling/models/it/rtboundpicker/SubRTComponent.java b/src/test/java/org/apache/sling/models/it/rtboundpicker/SubRTComponent.java new file mode 100644 index 0000000..32011b2 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/rtboundpicker/SubRTComponent.java @@ -0,0 +1,31 @@ +/* + * 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.rtboundpicker; + +import org.apache.sling.api.resource.Resource; +import org.apache.sling.models.annotations.Model; + +@Model(adaptables = Resource.class, adapters = TestComponent.class, resourceType = "sling/rtpicker/sub") +public class SubRTComponent implements TestComponent { + + @Override + public String getSampleValue() { + return "sub"; + } +} diff --git a/src/test/java/org/apache/sling/models/it/rtboundpicker/TestComponent.java b/src/test/java/org/apache/sling/models/it/rtboundpicker/TestComponent.java new file mode 100644 index 0000000..3d97aea --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/rtboundpicker/TestComponent.java @@ -0,0 +1,24 @@ +/* + * 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.rtboundpicker; + +public interface TestComponent { + + String getSampleValue(); +} diff --git a/src/test/java/org/apache/sling/models/it/rtboundpicker/package-info.java b/src/test/java/org/apache/sling/models/it/rtboundpicker/package-info.java new file mode 100644 index 0000000..950815c --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/rtboundpicker/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.rtboundpicker; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/services/AnotherTestBindingsValuesProvider.java b/src/test/java/org/apache/sling/models/it/services/AnotherTestBindingsValuesProvider.java new file mode 100644 index 0000000..9dcce31 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/services/AnotherTestBindingsValuesProvider.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.models.it.services; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.osgi.service.component.annotations.Component; + +@Component( + service = Map.class, + property = {"javax.script.name=sling-models-exporter"}) +public class AnotherTestBindingsValuesProvider extends HashMap { + private static final long serialVersionUID = 1L; + + public AnotherTestBindingsValuesProvider() { + super.put("testBindingsObject2", Collections.singletonMap("name2", "value2")); + } +} diff --git a/src/test/java/org/apache/sling/models/it/services/SimpleService.java b/src/test/java/org/apache/sling/models/it/services/SimpleService.java new file mode 100644 index 0000000..aeb4ee1 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/services/SimpleService.java @@ -0,0 +1,23 @@ +/* + * 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.services; + +public interface SimpleService { + int getRanking(); +} diff --git a/src/test/java/org/apache/sling/models/it/services/SimpleServiceWithCustomRanking.java b/src/test/java/org/apache/sling/models/it/services/SimpleServiceWithCustomRanking.java new file mode 100644 index 0000000..33a8068 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/services/SimpleServiceWithCustomRanking.java @@ -0,0 +1,32 @@ +/* + * 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.services; + +public class SimpleServiceWithCustomRanking implements SimpleService { + + private final int ranking; + + public SimpleServiceWithCustomRanking(int ranking) { + this.ranking = ranking; + } + + public int getRanking() { + return ranking; + } +} diff --git a/src/test/java/org/apache/sling/models/it/services/TestBindingsValuesProvider.java b/src/test/java/org/apache/sling/models/it/services/TestBindingsValuesProvider.java new file mode 100644 index 0000000..a7dcb68 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/services/TestBindingsValuesProvider.java @@ -0,0 +1,36 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.sling.models.it.services; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import org.osgi.service.component.annotations.Component; + +@Component( + service = Map.class, + property = {"javax.script.name=*"}) +public class TestBindingsValuesProvider extends HashMap { + private static final long serialVersionUID = -5029445376678233701L; + + public TestBindingsValuesProvider() { + super.put("testBindingsObject", Collections.singletonMap("name", "value")); + } +} diff --git a/src/test/java/org/apache/sling/models/it/services/TestResourceDecorator.java b/src/test/java/org/apache/sling/models/it/services/TestResourceDecorator.java new file mode 100644 index 0000000..8d2a0a1 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/services/TestResourceDecorator.java @@ -0,0 +1,66 @@ +/* + * 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.services; + +import javax.servlet.http.HttpServletRequest; + +import org.apache.sling.api.adapter.AdapterManager; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.ResourceDecorator; +import org.apache.sling.api.resource.ResourceWrapper; +import org.apache.sling.api.resource.ValueMap; +import org.jetbrains.annotations.NotNull; +import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; + +@Component(service = ResourceDecorator.class) +public class TestResourceDecorator implements ResourceDecorator { + + @Reference + private AdapterManager adapterManager; + + @Override + @SuppressWarnings("null") + public Resource decorate(@NotNull Resource resource) { + ValueMap map = resource.adaptTo(ValueMap.class); + if (map != null && map.containsKey("decorate")) { + if (map.get("decorate", "default").equals("customAdaptTo")) { + return new ResourceWrapper(resource) { + @Override + public AdapterType adaptTo(Class type) { + AdapterType adapter = adapterManager.getAdapter(this, type); + if (adapter != null) { + return adapter; + } else { + return super.adaptTo(type); + } + } + }; + } else { + return new ResourceWrapper(resource); + } + } + return null; + } + + @Override + public Resource decorate(@NotNull Resource resource, @NotNull HttpServletRequest request) { + return decorate(resource); + } +} diff --git a/src/test/java/org/apache/sling/models/it/services/package-info.java b/src/test/java/org/apache/sling/models/it/services/package-info.java new file mode 100644 index 0000000..1f5740a --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/services/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.services; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/servlets/PathBoundJakartaServlet.java b/src/test/java/org/apache/sling/models/it/servlets/PathBoundJakartaServlet.java new file mode 100644 index 0000000..4900f29 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/servlets/PathBoundJakartaServlet.java @@ -0,0 +1,46 @@ +/* + * 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.servlets; + +import java.io.IOException; + +import jakarta.servlet.Servlet; +import jakarta.servlet.ServletException; +import org.apache.sling.api.SlingJakartaHttpServletRequest; +import org.apache.sling.api.SlingJakartaHttpServletResponse; +import org.apache.sling.api.servlets.SlingJakartaSafeMethodsServlet; +import org.apache.sling.models.it.models.JakartaRequestSelfModel; +import org.apache.sling.servlets.annotations.SlingServletPaths; +import org.jetbrains.annotations.NotNull; +import org.osgi.service.component.annotations.Component; + +@Component(service = Servlet.class) +@SlingServletPaths("/apps/rtpickerrequest-jakarta") +public class PathBoundJakartaServlet extends SlingJakartaSafeMethodsServlet { + private static final long serialVersionUID = 1L; + + @Override + @SuppressWarnings("unused") + protected void doGet( + @NotNull SlingJakartaHttpServletRequest request, @NotNull SlingJakartaHttpServletResponse response) + throws ServletException, IOException { + JakartaRequestSelfModel model = request.adaptTo(JakartaRequestSelfModel.class); + response.setStatus(200); + } +} diff --git a/src/test/java/org/apache/sling/models/it/servlets/PathBoundServlet.java b/src/test/java/org/apache/sling/models/it/servlets/PathBoundServlet.java new file mode 100644 index 0000000..7657275 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/servlets/PathBoundServlet.java @@ -0,0 +1,46 @@ +/* + * 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.servlets; + +import javax.servlet.Servlet; +import javax.servlet.ServletException; + +import java.io.IOException; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.SlingHttpServletResponse; +import org.apache.sling.api.servlets.SlingSafeMethodsServlet; +import org.apache.sling.models.it.models.RequestSelfModel; +import org.apache.sling.servlets.annotations.SlingServletPaths; +import org.jetbrains.annotations.NotNull; +import org.osgi.service.component.annotations.Component; + +@Component(service = Servlet.class) +@SlingServletPaths("/apps/rtpickerrequest") +public class PathBoundServlet extends SlingSafeMethodsServlet { + private static final long serialVersionUID = 1L; + + @Override + @SuppressWarnings("unused") + protected void doGet(@NotNull SlingHttpServletRequest request, @NotNull SlingHttpServletResponse response) + throws ServletException, IOException { + RequestSelfModel model = request.adaptTo(RequestSelfModel.class); + response.setStatus(200); + } +} diff --git a/src/test/resources/org/apache/sling/models/it/noclasses/foo.txt b/src/test/resources/org/apache/sling/models/it/noclasses/foo.txt new file mode 100644 index 0000000..dd50685 --- /dev/null +++ b/src/test/resources/org/apache/sling/models/it/noclasses/foo.txt @@ -0,0 +1 @@ +text file to ensure the package gets created, but without class files \ No newline at end of file From d4f3dbf5a11125828ab61b28a538e8bf2f653a85 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 23 Jan 2026 11:21:37 +0100 Subject: [PATCH 05/17] SLING-13050 add sling launcher --- pom.xml | 192 ++++++++++++++++++++++++ src/test/features/launcher-repoinit.txt | 23 +++ src/test/features/launcher.json | 30 ++++ 3 files changed, 245 insertions(+) create mode 100644 src/test/features/launcher-repoinit.txt create mode 100644 src/test/features/launcher.json diff --git a/pom.xml b/pom.xml index e5d0f43..1f93553 100644 --- a/pom.xml +++ b/pom.xml @@ -41,6 +41,11 @@ 2025-08-27T03:14:05Z 17 2.0.0 + + 14-SNAPSHOT + 200 + 60 + info @@ -242,9 +247,54 @@ 1.9.4 test + + + org.apache.sling + org.apache.sling.junit.core + 1.2.0 + test + + + org.apache.sling + org.apache.sling.testing.rules + 2.0.2 + test + + + org.apache.sling + org.apache.sling.testing.clients + 3.1.0 + test + + + javax.servlet + servlet-api + + + + + org.apache.sling + org.apache.sling.junit.teleporter + 1.1.0 + test + + + org.apache.sling + org.apache.sling.commons.johnzon + 2.0.0 + test + + + org.apache.sling + org.apache.sling.engine + 3.0.0 + test + + + org.apache.maven.plugins maven-surefire-plugin @@ -261,6 +311,7 @@ + org.apache.maven.plugins maven-shade-plugin @@ -296,6 +347,7 @@ + org.apache.rat apache-rat-plugin @@ -306,6 +358,7 @@ + org.apache.maven.plugins maven-source-plugin @@ -313,6 +366,145 @@ false + + + org.codehaus.mojo + build-helper-maven-plugin + + + reserve-network-port + + reserve-network-port + + initialize + + + http.port + + + + + + + + org.apache.sling + slingfeature-maven-plugin + 1.9.2 + true + + + models.api.version,it.models.log.level + true + + + it-app + *.json + + ${http.port} + + + org.apache.sling:org.apache.sling.models.api:HIGHEST + org.apache.sling:org.apache.sling.models.impl:HIGHEST + + + org.apache.sling + org.apache.sling.starter + nosample_base + ${sling.starter.version} + slingosgifeature + + + org.apache.sling + org.apache.sling.starter + oak_persistence_sns + ${sling.starter.version} + slingosgifeature + + + org.apache.sling + org.apache.sling.starter + junit + ${sling.starter.version} + slingosgifeature + + + + + + it-app + + + + + + prepare-features + + aggregate-features + analyse-features + attach-features + + prepare-package + + + + + + org.apache.sling + feature-launcher-maven-plugin + 1.0.2 + + + + sling-starter-oak-tar + + org.apache.sling + org.apache.sling.models.impl + ${project.version} + it-app + slingosgifeature + + + + --add-opens java.base/java.lang=ALL-UNNAMED + + + ${http.port} + 5000000 + + + ${it.startTimeoutSeconds} + + + + + + launcher-start + + start + stop + + + + + + + + + + it-debug + + 8080 + true + debug + + + + diff --git a/src/test/features/launcher-repoinit.txt b/src/test/features/launcher-repoinit.txt new file mode 100644 index 0000000..7d36118 --- /dev/null +++ b/src/test/features/launcher-repoinit.txt @@ -0,0 +1,23 @@ +# +# 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. +# + +create service user models-it +set ACL for models-it + allow jcr:all on / +end \ No newline at end of file diff --git a/src/test/features/launcher.json b/src/test/features/launcher.json new file mode 100644 index 0000000..291d66e --- /dev/null +++ b/src/test/features/launcher.json @@ -0,0 +1,30 @@ +{ + "bundles": [ + { + "id": "org.apache.sling/org.apache.sling.models.api/${models.api.version}", + "start-order": 20 + }, + { + "id": "org.apache.sling/org.apache.sling.models.impl/${project.version}", + "start-order": 20 + }, + { + "id": "org.apache.sling/org.apache.sling.models.impl.it.test-models/${project.version}", + "start-order": 20 + } + ], + "configurations": { + "org.apache.sling.serviceusermapping.impl.ServiceUserMapperImpl.amended~integration-tests": { + "user.mapping": [ + "org.apache.sling.junit.core=models-it" + ] + }, + "org.apache.sling.commons.log.LogManager.factory.config~integration-tests": { + "org.apache.sling.commons.log.names": [ + "org.apache.sling.models" + ], + "org.apache.sling.commons.log.level": "${it.models.log.level}" + } + }, + "repoinit:TEXT|true": "@file" +} \ No newline at end of file From 32e378412e9cf193d9e6d93a5f05570ff82e4ce3 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 23 Jan 2026 11:32:26 +0100 Subject: [PATCH 06/17] SLING-13050 add ITs --- pom.xml | 24 +- .../launcher-repoinit.txt | 0 .../{features => it-features}/launcher.json | 0 .../customizers/SM_TeleporterCustomizer.java | 60 +++ .../sling/models/testing/DecoratedIT.java | 96 ++++ .../models/testing/ImplementsExtendsIT.java | 150 ++++++ .../testing/InjectorSpecificAnnotationIT.java | 72 +++ .../models/testing/ModelFactorySimpleIT.java | 130 +++++ .../models/testing/PathBoundServletIT.java | 66 +++ ...erviceInjectionWithDifferentRankingIT.java | 147 ++++++ .../apache/sling/models/testing/SimpleIT.java | 111 ++++ .../apache/sling/models/testing/ViaIT.java | 77 +++ .../testing/delegate/DelegateRequestIT.java | 114 ++++ .../testing/delegate/DelegateResourceIT.java | 105 ++++ .../ViaOriginalResourceDelegationIT.java | 139 +++++ .../models/testing/helper/FakeRequest.java | 400 ++++++++++++++ .../models/testing/helper/FakeResponse.java | 191 +++++++ .../models/testing/rtbound/FakeRequest.java | 498 ++++++++++++++++++ .../rtbound/ResourceTypeBindingIT.java | 146 +++++ .../rtboundpicker/ResourceTypePickerIT.java | 91 ++++ 20 files changed, 2616 insertions(+), 1 deletion(-) rename src/test/{features => it-features}/launcher-repoinit.txt (100%) rename src/test/{features => it-features}/launcher.json (100%) create mode 100644 src/test/java/org/apache/sling/junit/teleporter/customizers/SM_TeleporterCustomizer.java create mode 100644 src/test/java/org/apache/sling/models/testing/DecoratedIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/ImplementsExtendsIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/InjectorSpecificAnnotationIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/ModelFactorySimpleIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/PathBoundServletIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/ServiceInjectionWithDifferentRankingIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/SimpleIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/ViaIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/delegate/DelegateRequestIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/delegate/DelegateResourceIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/helper/FakeRequest.java create mode 100644 src/test/java/org/apache/sling/models/testing/helper/FakeResponse.java create mode 100644 src/test/java/org/apache/sling/models/testing/rtbound/FakeRequest.java create mode 100644 src/test/java/org/apache/sling/models/testing/rtbound/ResourceTypeBindingIT.java create mode 100644 src/test/java/org/apache/sling/models/testing/rtboundpicker/ResourceTypePickerIT.java diff --git a/pom.xml b/pom.xml index 1f93553..94116ec 100644 --- a/pom.xml +++ b/pom.xml @@ -391,8 +391,8 @@ slingfeature-maven-plugin 1.9.2 true - + src/test/it-features models.api.version,it.models.log.level true @@ -487,6 +487,28 @@ + + maven-failsafe-plugin + + + http://localhost:${http.port} + false:${http.port} + ${starter.min.bundles.count} + + /system/console/bundles, + + + + + integration-test + + integration-test + verify + + + + + diff --git a/src/test/features/launcher-repoinit.txt b/src/test/it-features/launcher-repoinit.txt similarity index 100% rename from src/test/features/launcher-repoinit.txt rename to src/test/it-features/launcher-repoinit.txt diff --git a/src/test/features/launcher.json b/src/test/it-features/launcher.json similarity index 100% rename from src/test/features/launcher.json rename to src/test/it-features/launcher.json diff --git a/src/test/java/org/apache/sling/junit/teleporter/customizers/SM_TeleporterCustomizer.java b/src/test/java/org/apache/sling/junit/teleporter/customizers/SM_TeleporterCustomizer.java new file mode 100644 index 0000000..ed04105 --- /dev/null +++ b/src/test/java/org/apache/sling/junit/teleporter/customizers/SM_TeleporterCustomizer.java @@ -0,0 +1,60 @@ +/* + * 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.junit.teleporter.customizers; + +import java.io.IOException; +import java.net.URI; +import java.util.concurrent.TimeoutException; + +import org.apache.sling.junit.rules.TeleporterRule; +import org.apache.sling.models.impl.ModelAdapterFactory; +import org.apache.sling.testing.clients.ClientException; +import org.apache.sling.testing.clients.osgi.OsgiConsoleClient; +import org.apache.sling.testing.serversetup.instance.SlingTestBase; +import org.apache.sling.testing.teleporter.client.ClientSideTeleporter; +import org.apache.sling.testing.timeouts.TimeoutsProvider; + +/** This is required by the TeleporterRule, to setup the client-side + * teleporter with (at least) the test server URL. + */ +public class SM_TeleporterCustomizer implements TeleporterRule.Customizer { + + private static final SlingTestBase S = new SlingTestBase(); + + private static final Class[] EXPECTED_COMPONENTS = new Class[] {ModelAdapterFactory.class}; + + @Override + public void customize(TeleporterRule t, String options) { + final ClientSideTeleporter cst = (ClientSideTeleporter) t; + cst.setBaseUrl(S.getServerBaseUrl()); + cst.setServerCredentials(S.getServerUsername(), S.getServerPassword()); + cst.setTestReadyTimeoutSeconds(TimeoutsProvider.getInstance().getTimeout(5)); + cst.includeDependencyPrefix("org.apache.sling.models.testing"); + + // additionally check for the registration of mandatory sling models components + try (OsgiConsoleClient osgiClient = + new OsgiConsoleClient(URI.create(S.getServerBaseUrl()), S.getServerUsername(), S.getServerPassword())) { + for (Class clazz : EXPECTED_COMPONENTS) { + osgiClient.waitComponentRegistered(clazz.getName(), 20000, 200); + } + } catch (ClientException | TimeoutException | InterruptedException | IOException ex) { + throw new RuntimeException("Error waiting for expected components.", ex); + } + } +} diff --git a/src/test/java/org/apache/sling/models/testing/DecoratedIT.java b/src/test/java/org/apache/sling/models/testing/DecoratedIT.java new file mode 100644 index 0000000..8c0a39b --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/DecoratedIT.java @@ -0,0 +1,96 @@ +/* + * 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; + +import javax.jcr.Node; +import javax.jcr.Session; + +import org.apache.commons.lang3.RandomStringUtils; +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.ResourceWrapper; +import org.apache.sling.junit.rules.TeleporterRule; +import org.apache.sling.models.factory.ModelFactory; +import org.apache.sling.models.it.models.SelfModel; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class DecoratedIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + private ModelFactory modelFactory; + + private ResourceResolver resolver; + private Resource resourceWithDefaultWrapperBehavior; + private Resource resourceWithCustomAdaptToWrapper; + + @Before + @SuppressWarnings("null") + public void setUp() throws Exception { + ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); + modelFactory = teleporter.getService(ModelFactory.class); + resolver = rrFactory.getServiceResourceResolver(null); + Session session = resolver.adaptTo(Session.class); + Node rootNode = session.getRootNode(); + Node createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + createdNode.setProperty("decorate", true); + session.save(); + + resourceWithDefaultWrapperBehavior = resolver.getResource(createdNode.getPath()); + + createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + createdNode.setProperty("decorate", "customAdaptTo"); + session.save(); + + resourceWithCustomAdaptToWrapper = resolver.getResource(createdNode.getPath()); + } + + @After + public void tearDown() throws Exception { + resolver.delete(resourceWithDefaultWrapperBehavior); + resolver.delete(resourceWithCustomAdaptToWrapper); + resolver.close(); + } + + @Test + public void testInjectDecoratedResourceUsingCreateModel() { + assertTrue("Resource is not wrapped", resourceWithDefaultWrapperBehavior instanceof ResourceWrapper); + SelfModel model = modelFactory.createModel(resourceWithDefaultWrapperBehavior, SelfModel.class); + + assertNotNull("Model is null", model); + assertTrue("Model is not wrapped", model.getResource() instanceof ResourceWrapper); + } + + @Test + public void testInjectDecoratedResourceUsingAdaptTo() { + assertTrue("Resource is not wrapped", resourceWithCustomAdaptToWrapper instanceof ResourceWrapper); + SelfModel model = resourceWithCustomAdaptToWrapper.adaptTo(SelfModel.class); + + assertNotNull("Model is null", model); + assertTrue("Model is not wrapped", model.getResource() instanceof ResourceWrapper); + } +} diff --git a/src/test/java/org/apache/sling/models/testing/ImplementsExtendsIT.java b/src/test/java/org/apache/sling/models/testing/ImplementsExtendsIT.java new file mode 100644 index 0000000..cc42661 --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/ImplementsExtendsIT.java @@ -0,0 +1,150 @@ +/* + * 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; + +import javax.jcr.Node; +import javax.jcr.RepositoryException; +import javax.jcr.Session; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.sling.api.adapter.AdapterManager; +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.junit.rules.TeleporterRule; +import org.apache.sling.models.it.implpicker.CustomLastImplementationPicker; +import org.apache.sling.models.it.models.implextend.ImplementsInterfacePropertyModel; +import org.apache.sling.models.it.models.implextend.ImplementsInterfacePropertyModel2; +import org.apache.sling.models.it.models.implextend.InvalidSampleServiceInterface; +import org.apache.sling.models.it.models.implextend.SampleServiceInterface; +import org.apache.sling.models.it.models.implextend.SimplePropertyModel; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +public class ImplementsExtendsIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + private AdapterManager adapterManager; + + private String firstValue; + private String secondValue; + private String thirdValue; + private ResourceResolver resolver; + private Resource resource; + private Node createdNode; + + @Before + @SuppressWarnings("null") + public void setUp() throws Exception { + ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); + adapterManager = teleporter.getService(AdapterManager.class); + firstValue = RandomStringUtils.randomAlphanumeric(10); + thirdValue = RandomStringUtils.randomAlphanumeric(10); + + resolver = rrFactory.getServiceResourceResolver(null); + Session session = resolver.adaptTo(Session.class); + Node rootNode = session.getRootNode(); + createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + createdNode.setProperty("first", firstValue); + createdNode.setProperty("third", thirdValue); + session.save(); + + resource = resolver.getResource(createdNode.getPath()); + } + + @After + public void after() throws Exception { + if (resolver != null) { + resolver.close(); + } + } + + /** + * Try to adapt to interface, with an different implementation class that has the @Model annotation + */ + @Test + public void testImplementsInterfaceModel() { + SampleServiceInterface model = adapterManager.getAdapter(resource, SampleServiceInterface.class); + assertNotNull(model); + assertEquals(ImplementsInterfacePropertyModel.class, model.getClass()); + assertEquals(firstValue + "|" + secondValue + "|" + thirdValue, model.getAllProperties()); + } + + /** + * Ensure that the implementation class itself can be adapted to, even if it is not part of the "adapter" property in the annotation. + */ + @Test + public void testImplementsInterfaceModel_ImplClassImplicitlyMapped() { + ImplementsInterfacePropertyModel model = + adapterManager.getAdapter(resource, ImplementsInterfacePropertyModel.class); + assertNotNull(model); + } + + /** + * Test implementation class with a mapping that is not valid (an interface that is not implemented). + */ + @Test + public void testInvalidImplementsInterfaceModel() { + InvalidSampleServiceInterface model = adapterManager.getAdapter(resource, InvalidSampleServiceInterface.class); + assertNull(model); + } + + /** + * Test to adapt to a superclass of the implementation class with the appropriate mapping in the @Model annotation. + */ + @Test + public void testExtendsClassModel() { + SimplePropertyModel model = adapterManager.getAdapter(resource, SimplePropertyModel.class); + assertNotNull(model); + assertEquals("!" + firstValue + "|" + secondValue + "|" + thirdValue + "!", model.getAllProperties()); + } + + /** + * Try to adapt to interface, with an different implementation class that has the @Model annotation + */ + @Test + @SuppressWarnings("null") + public void testImplementsInterfaceModelWithPickLastImplementationPicker() throws RepositoryException { + + Session session = resolver.adaptTo(Session.class); + Node node = resource.adaptTo(Node.class); + Node childNode = node.addNode(CustomLastImplementationPicker.CUSTOM_NAME); + childNode.setProperty("first", firstValue); + childNode.setProperty("third", thirdValue); + session.save(); + + Resource childResource = resolver.getResource(childNode.getPath()); + + SampleServiceInterface model = adapterManager.getAdapter(childResource, SampleServiceInterface.class); + assertNotNull(model); + assertEquals(ImplementsInterfacePropertyModel2.class, model.getClass()); + assertEquals(firstValue + "|" + secondValue + "|" + thirdValue, model.getAllProperties()); + + childNode.remove(); + session.save(); + } +} diff --git a/src/test/java/org/apache/sling/models/testing/InjectorSpecificAnnotationIT.java b/src/test/java/org/apache/sling/models/testing/InjectorSpecificAnnotationIT.java new file mode 100644 index 0000000..3764dbc --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/InjectorSpecificAnnotationIT.java @@ -0,0 +1,72 @@ +/* + * 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; + +import javax.jcr.Node; +import javax.jcr.Session; + +import org.apache.commons.lang3.RandomStringUtils; +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.junit.rules.TeleporterRule; +import org.apache.sling.models.it.models.SlingPropertyAnnotationTestModel; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class InjectorSpecificAnnotationIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + @Test + @SuppressWarnings("null") + public void test() throws Exception { + ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); + String value = RandomStringUtils.randomAlphanumeric(10); + + ResourceResolver resolver = null; + Node createdNode = null; + try { + resolver = rrFactory.getServiceResourceResolver(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()); + + SlingPropertyAnnotationTestModel model = resource.adaptTo(SlingPropertyAnnotationTestModel.class); + + assertNotNull("Model is null", model); + assertEquals("Test Property is not set correctly", value, model.getTestProperty()); + } finally { + if (createdNode != null) { + createdNode.remove(); + } + if (resolver != null) { + resolver.close(); + } + } + } +} diff --git a/src/test/java/org/apache/sling/models/testing/ModelFactorySimpleIT.java b/src/test/java/org/apache/sling/models/testing/ModelFactorySimpleIT.java new file mode 100644 index 0000000..5468113 --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/ModelFactorySimpleIT.java @@ -0,0 +1,130 @@ +/* + * 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; + +import javax.jcr.Node; +import javax.jcr.Session; + +import org.apache.commons.lang3.RandomStringUtils; +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.junit.rules.TeleporterRule; +import org.apache.sling.models.factory.ModelFactory; +import org.apache.sling.models.it.models.ConstructorInjectionTestModel; +import org.apache.sling.models.it.models.FieldInjectionTestModel; +import org.apache.sling.models.it.models.implextend.InvalidImplementsInterfacePropertyModel; +import org.apache.sling.models.it.models.implextend.SampleServiceInterface; +import org.junit.After; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +public class ModelFactorySimpleIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + private ModelFactory modelFactory; + + private String value; + private ResourceResolver resolver; + private Resource resource; + private Node createdNode; + + @Before + @SuppressWarnings("null") + public void setUp() throws Exception { + ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); + modelFactory = teleporter.getService(ModelFactory.class); + value = RandomStringUtils.randomAlphanumeric(10); + + resolver = rrFactory.getServiceResourceResolver(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 = resolver.getResource(createdNode.getPath()); + } + + @After + public void tearDown() throws Exception { + if (createdNode != null) { + createdNode.remove(); + } + if (resolver != null) { + resolver.close(); + } + } + + @Test + public void testCreateModel() { + FieldInjectionTestModel model = modelFactory.createModel(resource, 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()); + } + + @Ignore + private static final class DummyClass {} + + @Test + public void testIsModelClass() { + assertTrue("Model is not detected as such", modelFactory.isModelClass(ConstructorInjectionTestModel.class)); + assertFalse("Dummy class incorrectly detected as model class", modelFactory.isModelClass(DummyClass.class)); + assertFalse( + "Model with invalid adaptable incorrectly detected as model class", + modelFactory.isModelClass(InvalidImplementsInterfacePropertyModel.class)); + assertTrue( + "Model is not detected as such", + modelFactory.isModelClass(SampleServiceInterface.class)); // being provided by two adapters + } + + @Test + public void testCanCreateFromAdaptable() { + assertTrue( + "Model is not detected as such", + modelFactory.canCreateFromAdaptable(resource, ConstructorInjectionTestModel.class)); + assertTrue( + "Model is not detected as such", + modelFactory.canCreateFromAdaptable(resource, SampleServiceInterface.class)); + assertFalse( + "Model is incorrectly detected", + modelFactory.canCreateFromAdaptable( + new String(), ConstructorInjectionTestModel.class)); // invalid adaptable + } + + @Test() + public void testCanCreateFromAdaptableWithModelExceptin() { + assertFalse( + "Model is incorrectly detected", + modelFactory.canCreateFromAdaptable(resource, DummyClass.class)); // no model class + } +} diff --git a/src/test/java/org/apache/sling/models/testing/PathBoundServletIT.java b/src/test/java/org/apache/sling/models/testing/PathBoundServletIT.java new file mode 100644 index 0000000..bec53f8 --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/PathBoundServletIT.java @@ -0,0 +1,66 @@ +/* + * 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; + +import org.apache.sling.api.resource.ResourceResolver; +import org.apache.sling.api.resource.ResourceResolverFactory; +import org.apache.sling.engine.SlingRequestProcessor; +import org.apache.sling.junit.rules.TeleporterRule; +import org.apache.sling.models.testing.helper.FakeRequest; +import org.apache.sling.models.testing.helper.FakeResponse; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +public class PathBoundServletIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + private ResourceResolverFactory rrFactory; + private SlingRequestProcessor slingRequestProcessor; + + @Before + @SuppressWarnings("null") + public void setup() { + rrFactory = teleporter.getService(ResourceResolverFactory.class); + slingRequestProcessor = teleporter.getService(SlingRequestProcessor.class); + } + + @Test + public void testDoubledServlets() throws Exception { + try (ResourceResolver resolver = rrFactory.getServiceResourceResolver(null); ) { + FakeResponse response = new FakeResponse(); + slingRequestProcessor.processRequest(new FakeRequest("/apps/rtpickerrequest"), response, resolver); + + Assert.assertEquals(200, response.getStatus()); + } + } + + @Test + public void testDoubledServletsJakarta() throws Exception { + try (ResourceResolver resolver = rrFactory.getServiceResourceResolver(null); ) { + FakeResponse response = new FakeResponse(); + slingRequestProcessor.processRequest(new FakeRequest("/apps/rtpickerrequest-jakarta"), response, resolver); + + Assert.assertEquals(200, response.getStatus()); + } + } +} diff --git a/src/test/java/org/apache/sling/models/testing/ServiceInjectionWithDifferentRankingIT.java b/src/test/java/org/apache/sling/models/testing/ServiceInjectionWithDifferentRankingIT.java new file mode 100644 index 0000000..7a9b1a0 --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/ServiceInjectionWithDifferentRankingIT.java @@ -0,0 +1,147 @@ +/* + * 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; + +import javax.jcr.Node; +import javax.jcr.Session; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Dictionary; +import java.util.Hashtable; + +import org.apache.commons.lang3.RandomStringUtils; +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.junit.Activator; +import org.apache.sling.junit.rules.TeleporterRule; +import org.apache.sling.models.factory.ModelFactory; +import org.apache.sling.models.it.models.ServiceInjectionTestModel; +import org.apache.sling.models.it.services.SimpleService; +import org.apache.sling.models.it.services.SimpleServiceWithCustomRanking; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.osgi.framework.BundleContext; +import org.osgi.framework.Constants; +import org.osgi.framework.ServiceRegistration; + +import static org.junit.Assert.assertArrayEquals; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class ServiceInjectionWithDifferentRankingIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + private ModelFactory modelFactory; + + private String value; + private ResourceResolver resolver; + private Resource resource; + private Node createdNode; + private BundleContext bundleContext; + private Collection serviceRegistrations; + + @Before + @SuppressWarnings("null") + public void setUp() throws Exception { + ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); + modelFactory = teleporter.getService(ModelFactory.class); + value = RandomStringUtils.randomAlphanumeric(10); + + resolver = rrFactory.getServiceResourceResolver(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 = resolver.getResource(createdNode.getPath()); + + bundleContext = Activator.getBundleContext(); + serviceRegistrations = new ArrayList(); + } + + @After + public void tearDown() throws Exception { + if (createdNode != null) { + createdNode.remove(); + } + if (resolver != null) { + resolver.close(); + } + + for (ServiceRegistration serviceRegistration : serviceRegistrations) { + serviceRegistration.unregister(); + } + } + + @SuppressWarnings("unchecked") + private void registerSimpleService(int ranking) { + @SuppressWarnings("rawtypes") + Dictionary serviceProps = new Hashtable(); + serviceProps.put(Constants.SERVICE_RANKING, new Integer(ranking)); + ServiceRegistration serviceRegistration = bundleContext.registerService( + SimpleService.class.getName(), new SimpleServiceWithCustomRanking(ranking), serviceProps); + serviceRegistrations.add(serviceRegistration); + } + + @Test + public void testServiceInjectionConsideringRankingWithResource() throws IOException { + + registerSimpleService(0); + // cannot use adaptTo due to adaptersCache + ServiceInjectionTestModel model = modelFactory.createModel(resource, ServiceInjectionTestModel.class); + assertNotNull("Model is null", model); + // only the default service with ranking 0 is known + assertEquals( + "The service with the highest ranking was not returned", + 0, + model.getSimpleService().getRanking()); + assertArrayEquals("Order on injected services is wrong", model.getSimpleServicesRankings(), new Integer[] {0}); + + registerSimpleService(-1000); + model = modelFactory.createModel(resource, ServiceInjectionTestModel.class); + assertNotNull("Model is null", model); + // ranking 0 is still the highest one + assertEquals( + "The service with the highest ranking was not returned", + 0, + model.getSimpleService().getRanking()); + assertArrayEquals( + "Order on injected services is wrong", model.getSimpleServicesRankings(), new Integer[] {0, -1000}); + + registerSimpleService(1000); + model = modelFactory.createModel(resource, ServiceInjectionTestModel.class); + assertNotNull("Model is null", model); + // now ranking 1000 is the highest + assertEquals( + "The service with the highest ranking was not returned", + 1000, + model.getSimpleService().getRanking()); + assertArrayEquals( + "Order on injected services is wrong", model.getSimpleServicesRankings(), new Integer[] {1000, 0, -1000 + }); + } +} diff --git a/src/test/java/org/apache/sling/models/testing/SimpleIT.java b/src/test/java/org/apache/sling/models/testing/SimpleIT.java new file mode 100644 index 0000000..7ab3c7f --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/SimpleIT.java @@ -0,0 +1,111 @@ +/* + * 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; + +import javax.jcr.Node; +import javax.jcr.Session; + +import org.apache.commons.lang3.RandomStringUtils; +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.junit.rules.TeleporterRule; +import org.apache.sling.models.it.models.ConstructorInjectionTestModel; +import org.apache.sling.models.it.models.FieldInjectionTestModel; +import org.apache.sling.models.it.models.InterfaceInjectionTestModel; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; + +public class SimpleIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + private String value; + private String childValue; + private ResourceResolver resolver; + private Resource resource; + private Node createdNode; + + @Before + @SuppressWarnings("null") + public void setUp() throws Exception { + ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); + value = RandomStringUtils.randomAlphanumeric(10); + childValue = RandomStringUtils.randomAlphanumeric(10); + + resolver = rrFactory.getServiceResourceResolver(null); + Session session = resolver.adaptTo(Session.class); + Node rootNode = session.getRootNode(); + createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + createdNode.setProperty("testProperty", value); + Node child = createdNode.addNode("child"); + child.setProperty("childProperty", childValue); + session.save(); + + resource = resolver.getResource(createdNode.getPath()); + } + + @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()); + assertEquals("Child Test Property is not set correctly", childValue, model.getChildProperty()); + assertNotNull("Filters is null", model.getFilters()); + assertSame("Adaptable is not injected", resource, model.getResource()); + } + + @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()); + } +} diff --git a/src/test/java/org/apache/sling/models/testing/ViaIT.java b/src/test/java/org/apache/sling/models/testing/ViaIT.java new file mode 100644 index 0000000..07f973e --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/ViaIT.java @@ -0,0 +1,77 @@ +/* + * 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; + +import javax.jcr.Node; +import javax.jcr.Session; + +import org.apache.commons.lang3.RandomStringUtils; +import org.apache.sling.api.adapter.AdapterManager; +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.junit.rules.TeleporterRule; +import org.apache.sling.models.it.models.SourceObject; +import org.apache.sling.models.it.models.ViaModel; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + +public class ViaIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + @Test + @SuppressWarnings("null") + public void test() throws Exception { + ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); + AdapterManager adapterManager = teleporter.getService(AdapterManager.class); + + String value = RandomStringUtils.randomAlphanumeric(10); + + ResourceResolver resolver = null; + Node createdNode = null; + try { + resolver = rrFactory.getServiceResourceResolver(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()); + SourceObject obj = new SourceObject(resource); + + ViaModel model = adapterManager.getAdapter(obj, ViaModel.class); + + assertNotNull("Model is null", model); + assertEquals("Test Property is not set correctly", value, model.getTestProperty()); + } finally { + if (createdNode != null) { + createdNode.remove(); + } + if (resolver != null) { + resolver.close(); + } + } + } +} diff --git a/src/test/java/org/apache/sling/models/testing/delegate/DelegateRequestIT.java b/src/test/java/org/apache/sling/models/testing/delegate/DelegateRequestIT.java new file mode 100644 index 0000000..a6b494a --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/delegate/DelegateRequestIT.java @@ -0,0 +1,114 @@ +/* + * 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; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.sling.api.SlingConstants; +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.request.DelegateBaseModel; +import org.apache.sling.models.it.delegate.request.DelegateExtendedModel; +import org.apache.sling.models.it.delegate.request.DelegateInterface; +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.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class DelegateRequestIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + private ResourceResolverFactory rrFactory; + + private ModelFactory modelFactory; + + private final String baseComponentPath = "/content/delegate/baseComponent"; + private final String extendedComponentPath = "/content/delegate/extendedComponent"; + + @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 properties = new HashMap(); + properties.put("text", "baseTESTValue"); + properties.put("other", "baseOther"); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_TYPE, + "sling/delegate/base"); + ResourceUtil.getOrCreateResource(adminResolver, baseComponentPath, properties, null, false); + properties.clear(); + + properties.put("text", "extendedTESTValue"); + properties.put("other", "extendedOther"); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_TYPE, + "sling/delegate/extended"); + ResourceUtil.getOrCreateResource(adminResolver, extendedComponentPath, properties, null, false); + properties.clear(); + + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, + "sling/delegate/base"); + ResourceUtil.getOrCreateResource(adminResolver, "/apps/sling/delegate/extended", properties, null, false); + properties.clear(); + + adminResolver.commit(); + } + } + + @Test + public void testCreateDelegateModel() throws LoginException { + try (ResourceResolver resolver = rrFactory.getServiceResourceResolver(null); ) { + final Resource baseComponentResource = resolver.getResource(baseComponentPath); + assertNotNull(baseComponentResource); + final FakeRequest baseRequest = new FakeRequest(baseComponentResource); + final DelegateInterface modelFromBase = modelFactory.createModel(baseRequest, DelegateInterface.class); + assertNotNull("Base Model should not be null", modelFromBase); + assertTrue("Model should be DelegateBaseModel", modelFromBase instanceof DelegateBaseModel); + assertEquals("baseTESTValue", modelFromBase.getText()); + assertEquals("baseOther", modelFromBase.getOther()); + + final Resource extendedComponentResource = resolver.getResource(extendedComponentPath); + assertNotNull(extendedComponentResource); + final FakeRequest extendedRequest = new FakeRequest(extendedComponentResource); + final DelegateInterface modelFromExtended = + modelFactory.createModel(extendedRequest, DelegateInterface.class); + assertNotNull("Extended Model should not be null", modelFromExtended); + assertTrue("Model should be DelegateExtendedModel", modelFromExtended instanceof DelegateExtendedModel); + assertEquals("EXTENDEDTESTVALUE", modelFromExtended.getText()); + assertEquals("extendedOther", modelFromExtended.getOther()); + } + } +} diff --git a/src/test/java/org/apache/sling/models/testing/delegate/DelegateResourceIT.java b/src/test/java/org/apache/sling/models/testing/delegate/DelegateResourceIT.java new file mode 100644 index 0000000..97f8094 --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/delegate/DelegateResourceIT.java @@ -0,0 +1,105 @@ +/* + * 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; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.sling.api.SlingConstants; +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.it.delegate.resource.DelegateBaseModel; +import org.apache.sling.models.it.delegate.resource.DelegateExtendedModel; +import org.apache.sling.models.it.delegate.resource.DelegateInterface; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; + +public class DelegateResourceIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + private ResourceResolverFactory rrFactory; + + private final String baseComponentPath = "/content/delegate/baseComponent"; + private final String extendedComponentPath = "/content/delegate/extendedComponent"; + + @Before + @SuppressWarnings("null") + public void setup() throws LoginException, PersistenceException { + rrFactory = teleporter.getService(ResourceResolverFactory.class); + try (ResourceResolver adminResolver = rrFactory.getServiceResourceResolver(null); ) { + Map properties = new HashMap(); + properties.put("text", "baseTESTValue"); + properties.put("other", "baseOther"); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_TYPE, + "sling/delegate/base"); + ResourceUtil.getOrCreateResource(adminResolver, baseComponentPath, properties, null, false); + properties.clear(); + + properties.put("text", "extendedTESTValue"); + properties.put("other", "extendedOther"); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_TYPE, + "sling/delegate/extended"); + ResourceUtil.getOrCreateResource(adminResolver, extendedComponentPath, properties, null, false); + properties.clear(); + + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, + "sling/delegate/base"); + ResourceUtil.getOrCreateResource(adminResolver, "/apps/sling/delegate/extended", properties, null, false); + properties.clear(); + + adminResolver.commit(); + } + } + + @Test + public void testCreateDelegateModel() throws LoginException { + try (ResourceResolver resolver = rrFactory.getServiceResourceResolver(null); ) { + final Resource baseComponentResource = resolver.getResource(baseComponentPath); + assertNotNull(baseComponentResource); + final DelegateInterface modelFromBase = baseComponentResource.adaptTo(DelegateInterface.class); + assertNotNull("Model should not be null", modelFromBase); + assertTrue("Model should be DelegateBaseModel", modelFromBase instanceof DelegateBaseModel); + assertEquals("baseTESTValue", modelFromBase.getText()); + assertEquals("baseOther", modelFromBase.getOther()); + + final Resource extendedComponentResource = resolver.getResource(extendedComponentPath); + assertNotNull(extendedComponentResource); + final DelegateInterface modelFromExtended = extendedComponentResource.adaptTo(DelegateInterface.class); + assertNotNull("Model should not be null", modelFromExtended); + assertTrue("Model should be DelegateExtendedModel", modelFromExtended instanceof DelegateExtendedModel); + assertEquals("EXTENDEDTESTVALUE", modelFromExtended.getText()); + assertEquals("extendedOther", modelFromExtended.getOther()); + } + } +} 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..ee119b7 --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java @@ -0,0 +1,139 @@ +/* + * 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 properties = new HashMap(); + 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); + // Since SLING-11133 and cache = true + assertSame(((A1Impl) model).other, ((AImpl) ((A1Impl) model).delegate).other); + } + } + + @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); + // Since SLING-11133 and cache = true + assertSame(((A1Impl) model).other, ((AImpl) ((A1Impl) model).delegate).other); + } + } +} diff --git a/src/test/java/org/apache/sling/models/testing/helper/FakeRequest.java b/src/test/java/org/apache/sling/models/testing/helper/FakeRequest.java new file mode 100644 index 0000000..1290f8a --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/helper/FakeRequest.java @@ -0,0 +1,400 @@ +/* + * 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.helper; + +import javax.servlet.AsyncContext; +import javax.servlet.DispatcherType; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpUpgradeHandler; +import javax.servlet.http.Part; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.Principal; +import java.util.Collection; +import java.util.Collections; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; + +public class FakeRequest implements HttpServletRequest { + + private final String path; + + private final StringBuffer requestUrl; + + private final Map attributes = new HashMap(); + + public FakeRequest(String path) { + this.path = path; + this.requestUrl = new StringBuffer("http://notarealhost").append(path); + } + + @Override + public String getAuthType() { + return null; + } + + @Override + public Cookie[] getCookies() { + return new Cookie[0]; + } + + @Override + public long getDateHeader(String name) { + return 0; + } + + @Override + public String getHeader(String name) { + return null; + } + + @Override + public Enumeration getHeaders(String name) { + return null; + } + + @Override + public Enumeration getHeaderNames() { + return null; + } + + @Override + public int getIntHeader(String name) { + return 0; + } + + @Override + public String getMethod() { + return "GET"; + } + + @Override + public String getPathInfo() { + return path; + } + + @Override + public String getPathTranslated() { + return null; + } + + @Override + public String getContextPath() { + return null; + } + + @Override + public String getQueryString() { + return null; + } + + @Override + public String getRemoteUser() { + return null; + } + + @Override + public boolean isUserInRole(String role) { + return false; + } + + @Override + public Principal getUserPrincipal() { + return null; + } + + @Override + public String getRequestedSessionId() { + return null; + } + + @Override + public String getRequestURI() { + return null; + } + + @Override + public StringBuffer getRequestURL() { + return requestUrl; + } + + @Override + public String getServletPath() { + return ""; + } + + @Override + public HttpSession getSession(boolean create) { + return null; + } + + @Override + public HttpSession getSession() { + return null; + } + + @Override + public boolean isRequestedSessionIdValid() { + return false; + } + + @Override + public boolean isRequestedSessionIdFromCookie() { + return false; + } + + @Override + public boolean isRequestedSessionIdFromURL() { + return false; + } + + @Override + public boolean isRequestedSessionIdFromUrl() { + return false; + } + + @Override + public Object getAttribute(String name) { + return attributes.get(name); + } + + @Override + public Enumeration getAttributeNames() { + return null; + } + + @Override + public String getCharacterEncoding() { + return null; + } + + @Override + public void setCharacterEncoding(String env) throws UnsupportedEncodingException {} + + @Override + public int getContentLength() { + return 0; + } + + @Override + public String getContentType() { + return null; + } + + @Override + public ServletInputStream getInputStream() throws IOException { + return null; + } + + @Override + public String getParameter(String name) { + return null; + } + + @Override + public Enumeration getParameterNames() { + return null; + } + + @Override + public String[] getParameterValues(String name) { + return new String[0]; + } + + @Override + public Map getParameterMap() { + return Collections.emptyMap(); + } + + @Override + public String getProtocol() { + return null; + } + + @Override + public String getScheme() { + return null; + } + + @Override + public String getServerName() { + return null; + } + + @Override + public int getServerPort() { + return 0; + } + + @Override + public BufferedReader getReader() throws IOException { + return null; + } + + @Override + public String getRemoteAddr() { + return null; + } + + @Override + public String getRemoteHost() { + return null; + } + + @Override + public void setAttribute(String name, Object o) { + attributes.put(name, o); + } + + @Override + public void removeAttribute(String name) { + attributes.remove(name); + } + + @Override + public Locale getLocale() { + return null; + } + + @Override + public Enumeration getLocales() { + return Collections.emptyEnumeration(); + } + + @Override + public boolean isSecure() { + return false; + } + + @Override + public RequestDispatcher getRequestDispatcher(String path) { + return null; + } + + @Override + public String getRealPath(String path) { + return null; + } + + @Override + public int getRemotePort() { + return 0; + } + + @Override + public String getLocalName() { + return null; + } + + @Override + public String getLocalAddr() { + return null; + } + + @Override + public int getLocalPort() { + return 0; + } + + @Override + public long getContentLengthLong() { + return 0; + } + + @Override + public ServletContext getServletContext() { + return null; + } + + @Override + public AsyncContext startAsync() throws IllegalStateException { + return null; + } + + @Override + public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) + throws IllegalStateException { + return null; + } + + @Override + public boolean isAsyncStarted() { + return false; + } + + @Override + public boolean isAsyncSupported() { + return false; + } + + @Override + public AsyncContext getAsyncContext() { + return null; + } + + @Override + public DispatcherType getDispatcherType() { + return null; + } + + @Override + public String changeSessionId() { + return null; + } + + @Override + public boolean authenticate(HttpServletResponse response) throws IOException, ServletException { + return false; + } + + @Override + public void login(String username, String password) throws ServletException {} + + @Override + public void logout() throws ServletException {} + + @Override + public Collection getParts() throws IOException, ServletException { + return null; + } + + @Override + public Part getPart(String name) throws IOException, ServletException { + return null; + } + + @Override + @SuppressWarnings("null") + public T upgrade(Class handlerClass) throws IOException, ServletException { + return null; + } +} diff --git a/src/test/java/org/apache/sling/models/testing/helper/FakeResponse.java b/src/test/java/org/apache/sling/models/testing/helper/FakeResponse.java new file mode 100644 index 0000000..fa474aa --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/helper/FakeResponse.java @@ -0,0 +1,191 @@ +/* + * 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.helper; + +import javax.servlet.ServletOutputStream; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; + +import java.io.IOException; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.util.Collection; +import java.util.Locale; + +public class FakeResponse implements HttpServletResponse { + + private StringWriter stringWriter = new StringWriter(); + private String contentType = null; + private String characterEncoding = null; + private int status = -1; + + @Override + public void addCookie(Cookie cookie) {} + + @Override + public boolean containsHeader(String name) { + return false; + } + + @Override + public String encodeURL(String url) { + return null; + } + + @Override + public String encodeRedirectURL(String url) { + return null; + } + + @Override + public String encodeUrl(String url) { + return null; + } + + @Override + public String encodeRedirectUrl(String url) { + return null; + } + + @Override + public void sendError(int sc, String msg) throws IOException {} + + @Override + public void sendError(int sc) throws IOException {} + + @Override + public void sendRedirect(String location) throws IOException {} + + @Override + public void setDateHeader(String name, long date) {} + + @Override + public void addDateHeader(String name, long date) {} + + @Override + public void setHeader(String name, String value) {} + + @Override + public void addHeader(String name, String value) {} + + @Override + public void setIntHeader(String name, int value) {} + + @Override + public void addIntHeader(String name, int value) {} + + @Override + public void setStatus(int sc) { + this.status = sc; + } + + @Override + public void setStatus(int sc, String sm) { + setStatus(sc); + } + + @Override + public String getCharacterEncoding() { + return characterEncoding; + } + + @Override + public String getContentType() { + return contentType; + } + + @Override + public ServletOutputStream getOutputStream() throws IOException { + return null; + } + + @Override + public PrintWriter getWriter() throws IOException { + return new PrintWriter(stringWriter); + } + + @Override + public void setCharacterEncoding(String charset) { + this.characterEncoding = charset; + } + + @Override + public void setContentLength(int len) {} + + @Override + public void setContentType(String type) { + this.contentType = type; + } + + @Override + public void setBufferSize(int size) {} + + @Override + public int getBufferSize() { + return 0; + } + + @Override + public void flushBuffer() throws IOException {} + + @Override + public void resetBuffer() {} + + @Override + public boolean isCommitted() { + return false; + } + + @Override + public void reset() {} + + @Override + public void setLocale(Locale loc) {} + + @Override + public Locale getLocale() { + return null; + } + + public StringWriter getStringWriter() { + return stringWriter; + } + + public int getStatus() { + return status; + } + + @Override + public void setContentLengthLong(long len) {} + + @Override + public String getHeader(String name) { + return null; + } + + @Override + public Collection getHeaders(String name) { + return null; + } + + @Override + public Collection getHeaderNames() { + return null; + } +} diff --git a/src/test/java/org/apache/sling/models/testing/rtbound/FakeRequest.java b/src/test/java/org/apache/sling/models/testing/rtbound/FakeRequest.java new file mode 100644 index 0000000..56a8a78 --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/rtbound/FakeRequest.java @@ -0,0 +1,498 @@ +/* + * 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.rtbound; + +import javax.servlet.AsyncContext; +import javax.servlet.DispatcherType; +import javax.servlet.RequestDispatcher; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.Cookie; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; +import javax.servlet.http.HttpUpgradeHandler; +import javax.servlet.http.Part; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.security.Principal; +import java.util.Collection; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.ResourceBundle; + +import org.apache.sling.api.SlingHttpServletRequest; +import org.apache.sling.api.request.RequestDispatcherOptions; +import org.apache.sling.api.request.RequestParameter; +import org.apache.sling.api.request.RequestParameterMap; +import org.apache.sling.api.request.RequestPathInfo; +import org.apache.sling.api.request.RequestProgressTracker; +import org.apache.sling.api.resource.Resource; +import org.apache.sling.api.resource.ResourceResolver; +import org.jetbrains.annotations.NotNull; + +public class FakeRequest implements SlingHttpServletRequest { + + private final Resource resource; + private final Map attributes = new HashMap<>(); + + public FakeRequest(Resource r) { + this.resource = r; + } + + @Override + public @NotNull Resource getResource() { + return resource; + } + + @Override + @SuppressWarnings("null") + public @NotNull ResourceResolver getResourceResolver() { + return null; + } + + @Override + @SuppressWarnings("null") + public @NotNull RequestPathInfo getRequestPathInfo() { + return null; + } + + @Override + public RequestParameter getRequestParameter(@NotNull String s) { + return null; + } + + @Override + public RequestParameter[] getRequestParameters(@NotNull String s) { + return new RequestParameter[0]; + } + + @Override + @SuppressWarnings("null") + public @NotNull RequestParameterMap getRequestParameterMap() { + return null; + } + + @Override + public RequestDispatcher getRequestDispatcher( + @NotNull String s, RequestDispatcherOptions requestDispatcherOptions) { + return null; + } + + @Override + public RequestDispatcher getRequestDispatcher( + @NotNull Resource resource, RequestDispatcherOptions requestDispatcherOptions) { + return null; + } + + @Override + public RequestDispatcher getRequestDispatcher(@NotNull Resource resource) { + return null; + } + + @Override + public Cookie getCookie(String s) { + return null; + } + + @Override + public String getResponseContentType() { + return null; + } + + @Override + @SuppressWarnings("null") + public @NotNull Enumeration getResponseContentTypes() { + return null; + } + + @Override + public ResourceBundle getResourceBundle(Locale locale) { + return null; + } + + @Override + public ResourceBundle getResourceBundle(String s, Locale locale) { + return null; + } + + @Override + @SuppressWarnings("null") + public RequestProgressTracker getRequestProgressTracker() { + return null; + } + + @Override + public String getAuthType() { + return null; + } + + @Override + public Cookie[] getCookies() { + return new Cookie[0]; + } + + @Override + public long getDateHeader(String s) { + return 0; + } + + @Override + public String getHeader(String s) { + return null; + } + + @Override + public Enumeration getHeaders(String s) { + return null; + } + + @Override + public Enumeration getHeaderNames() { + return null; + } + + @Override + public int getIntHeader(String s) { + return 0; + } + + @Override + public String getMethod() { + return null; + } + + @Override + public String getPathInfo() { + return null; + } + + @Override + public String getPathTranslated() { + return null; + } + + @Override + public String getContextPath() { + return null; + } + + @Override + public String getQueryString() { + return null; + } + + @Override + public String getRemoteUser() { + return null; + } + + @Override + public boolean isUserInRole(String s) { + return false; + } + + @Override + public Principal getUserPrincipal() { + return null; + } + + @Override + public String getRequestedSessionId() { + return null; + } + + @Override + public String getRequestURI() { + return null; + } + + @Override + public StringBuffer getRequestURL() { + return null; + } + + @Override + public String getServletPath() { + return null; + } + + @Override + public HttpSession getSession(boolean b) { + return null; + } + + @Override + public HttpSession getSession() { + return null; + } + + @Override + public boolean isRequestedSessionIdValid() { + return false; + } + + @Override + public boolean isRequestedSessionIdFromCookie() { + return false; + } + + @Override + public boolean isRequestedSessionIdFromURL() { + return false; + } + + @Override + public boolean isRequestedSessionIdFromUrl() { + return false; + } + + @Override + public Object getAttribute(String s) { + return attributes.get(s); + } + + @Override + public Enumeration getAttributeNames() { + return null; + } + + @Override + public String getCharacterEncoding() { + return null; + } + + @Override + public void setCharacterEncoding(String s) throws UnsupportedEncodingException {} + + @Override + public int getContentLength() { + return 0; + } + + @Override + public String getContentType() { + return null; + } + + @Override + public ServletInputStream getInputStream() throws IOException { + return null; + } + + @Override + public String getParameter(String s) { + return null; + } + + @Override + public Enumeration getParameterNames() { + return null; + } + + @Override + public String[] getParameterValues(String s) { + return new String[0]; + } + + @Override + public Map getParameterMap() { + return null; + } + + @Override + public String getProtocol() { + return null; + } + + @Override + public String getScheme() { + return null; + } + + @Override + public String getServerName() { + return null; + } + + @Override + public int getServerPort() { + return 0; + } + + @Override + public BufferedReader getReader() throws IOException { + return null; + } + + @Override + public String getRemoteAddr() { + return null; + } + + @Override + public String getRemoteHost() { + return null; + } + + @Override + public void setAttribute(String s, Object o) { + attributes.put(s, o); + } + + @Override + public void removeAttribute(String s) {} + + @Override + public Locale getLocale() { + return null; + } + + @Override + public Enumeration getLocales() { + return null; + } + + @Override + public boolean isSecure() { + return false; + } + + @Override + public RequestDispatcher getRequestDispatcher(String s) { + return null; + } + + @Override + public String getRealPath(String s) { + return null; + } + + @Override + public int getRemotePort() { + return 0; + } + + @Override + public String getLocalName() { + return null; + } + + @Override + public String getLocalAddr() { + return null; + } + + @Override + public int getLocalPort() { + return 0; + } + + @Override + @SuppressWarnings("null") + public AdapterType adaptTo(@NotNull Class aClass) { + return null; + } + + @Override + public String changeSessionId() { + return null; + } + + @Override + public boolean authenticate(HttpServletResponse response) throws IOException, ServletException { + return false; + } + + @Override + public void login(String username, String password) throws ServletException {} + + @Override + public void logout() throws ServletException {} + + @Override + public Collection getParts() throws IOException, ServletException { + return null; + } + + @Override + public Part getPart(String name) throws IOException, ServletException { + return null; + } + + @Override + @SuppressWarnings("null") + public T upgrade(Class handlerClass) throws IOException, ServletException { + return null; + } + + @Override + public long getContentLengthLong() { + return 0; + } + + @Override + public ServletContext getServletContext() { + return null; + } + + @Override + public AsyncContext startAsync() throws IllegalStateException { + return null; + } + + @Override + public AsyncContext startAsync(ServletRequest servletRequest, ServletResponse servletResponse) + throws IllegalStateException { + return null; + } + + @Override + public boolean isAsyncStarted() { + return false; + } + + @Override + public boolean isAsyncSupported() { + return false; + } + + @Override + public AsyncContext getAsyncContext() { + return null; + } + + @Override + public DispatcherType getDispatcherType() { + return null; + } + + @Override + @SuppressWarnings("null") + public List getRequestParameterList() { + return null; + } +} diff --git a/src/test/java/org/apache/sling/models/testing/rtbound/ResourceTypeBindingIT.java b/src/test/java/org/apache/sling/models/testing/rtbound/ResourceTypeBindingIT.java new file mode 100644 index 0000000..74ec330 --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/rtbound/ResourceTypeBindingIT.java @@ -0,0 +1,146 @@ +/* + * 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.rtbound; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.sling.api.SlingConstants; +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.rtbound.BaseComponent; +import org.apache.sling.models.it.rtbound.ExtendedComponent; +import org.apache.sling.models.it.rtbound.FromRequestComponent; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +public class ResourceTypeBindingIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + private ResourceResolverFactory rrFactory; + + private ModelFactory modelFactory; + + private final String baseComponentPath = "/content/rt/baseComponent"; + private final String childComponentPath = "/content/rt/childComponent"; + private final String child2ComponentPath = "/content/rt/child2Component"; + private final String extendedComponentPath = "/content/rt/extendedComponent"; + private final String fromRequestComponentPath = "/content/rt/fromRequest"; + + @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 properties = new HashMap(); + properties.put("sampleValue", "baseTESTValue"); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_TYPE, "sling/rt/base"); + ResourceUtil.getOrCreateResource(adminResolver, baseComponentPath, properties, null, false); + properties.clear(); + + properties.put("sampleValue", "childTESTValue"); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_TYPE, "sling/rt/child"); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, + "sling/rt/base"); + ResourceUtil.getOrCreateResource(adminResolver, childComponentPath, properties, null, false); + properties.clear(); + + properties.put("sampleValue", "childTESTValue2"); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_TYPE, "sling/rt/child"); + ResourceUtil.getOrCreateResource(adminResolver, child2ComponentPath, properties, null, false); + properties.clear(); + + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, + "sling/rt/base"); + ResourceUtil.getOrCreateResource(adminResolver, "/apps/sling/rt/child", properties, null, false); + properties.clear(); + + properties.put("sampleValue", "extendedTESTValue"); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_TYPE, "sling/rt/extended"); + ResourceUtil.getOrCreateResource(adminResolver, extendedComponentPath, properties, null, false); + + properties.clear(); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_TYPE, + "sling/rt/fromRequest"); + ResourceUtil.getOrCreateResource(adminResolver, fromRequestComponentPath, properties, null, false); + + adminResolver.commit(); + } + } + + @Test + public void testClientModelCreateFromResource() throws LoginException { + try (ResourceResolver resolver = rrFactory.getServiceResourceResolver(null); ) { + final Resource baseComponentResource = resolver.getResource(baseComponentPath); + Assert.assertNotNull(baseComponentResource); + final Object baseModel = modelFactory.getModelFromResource(baseComponentResource); + Assert.assertNotNull("Model should not be null", baseModel); + Assert.assertTrue("Model should be a BaseComponent", baseModel instanceof BaseComponent); + + final Resource childComponentResource = resolver.getResource(childComponentPath); + Assert.assertNotNull(childComponentResource); + final Object childModel = modelFactory.getModelFromResource(childComponentResource); + Assert.assertNotNull("Model should not be null", childModel); + Assert.assertTrue("Model should be a BaseComponent", childModel instanceof BaseComponent); + + final Resource child2ComponentResource = resolver.getResource(child2ComponentPath); + Assert.assertNotNull(child2ComponentResource); + final Object child2Model = modelFactory.getModelFromResource(child2ComponentResource); + Assert.assertNotNull("Model should not be null", child2Model); + Assert.assertTrue("Model should be a BaseComponent", child2Model instanceof BaseComponent); + + final Resource extendedComponentResource = resolver.getResource(extendedComponentPath); + Assert.assertNotNull(extendedComponentResource); + final Object extendedModel = modelFactory.getModelFromResource(extendedComponentResource); + Assert.assertNotNull("Model should not be null", extendedModel); + Assert.assertTrue("Model should be a BaseComponent", extendedModel instanceof BaseComponent); + Assert.assertTrue("Model should be an ExtendedComponent", extendedModel instanceof ExtendedComponent); + } + } + + @Test + public void testClientModelCreateFromRequest() throws LoginException { + try (ResourceResolver resolver = rrFactory.getServiceResourceResolver(null); ) { + final Resource baseComponentResource = resolver.getResource(fromRequestComponentPath); + Assert.assertNotNull(baseComponentResource); + final Object baseModel = modelFactory.getModelFromRequest(new FakeRequest(baseComponentResource)); + Assert.assertNotNull("Model should not be null", baseModel); + Assert.assertTrue("Model should be a FromRequestComponent", baseModel instanceof FromRequestComponent); + } + } +} diff --git a/src/test/java/org/apache/sling/models/testing/rtboundpicker/ResourceTypePickerIT.java b/src/test/java/org/apache/sling/models/testing/rtboundpicker/ResourceTypePickerIT.java new file mode 100644 index 0000000..3faa6e9 --- /dev/null +++ b/src/test/java/org/apache/sling/models/testing/rtboundpicker/ResourceTypePickerIT.java @@ -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.testing.rtboundpicker; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.sling.api.SlingConstants; +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.it.rtboundpicker.BaseComponent; +import org.apache.sling.models.it.rtboundpicker.SubRTComponent; +import org.apache.sling.models.it.rtboundpicker.TestComponent; +import org.junit.Assert; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +public class ResourceTypePickerIT { + + @Rule + public final TeleporterRule teleporter = TeleporterRule.forClass(getClass(), "SM_Teleporter"); + + private ResourceResolverFactory rrFactory; + + private final String baseComponentPath = "/content/rtpicker/baseComponent"; + private final String childComponentPath = "/content/rtpicker/childComponent"; + + @Before + @SuppressWarnings("null") + public void setup() throws LoginException, PersistenceException { + rrFactory = teleporter.getService(ResourceResolverFactory.class); + try (ResourceResolver adminResolver = rrFactory.getServiceResourceResolver(null); ) { + Map properties = new HashMap(); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_TYPE, + "sling/rtpicker/base"); + ResourceUtil.getOrCreateResource(adminResolver, baseComponentPath, properties, null, false); + properties.clear(); + + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_TYPE, + "sling/rtpicker/sub"); + properties.put( + SlingConstants.NAMESPACE_PREFIX + ":" + SlingConstants.PROPERTY_RESOURCE_SUPER_TYPE, + "sling/rtpicker/base"); + ResourceUtil.getOrCreateResource(adminResolver, childComponentPath, properties, null, false); + properties.clear(); + + adminResolver.commit(); + } + } + + @Test + public void testClientModelCreateFromResource() throws LoginException { + try (ResourceResolver resolver = rrFactory.getServiceResourceResolver(null); ) { + final Resource baseComponentResource = resolver.getResource(baseComponentPath); + Assert.assertNotNull(baseComponentResource); + TestComponent baseModel = baseComponentResource.adaptTo(TestComponent.class); + Assert.assertNotNull("Model should not be null", baseModel); + Assert.assertTrue("Model should be a BaseComponent", baseModel instanceof BaseComponent); + + final Resource childComponentResource = resolver.getResource(childComponentPath); + Assert.assertNotNull(childComponentResource); + baseModel = childComponentResource.adaptTo(TestComponent.class); + Assert.assertNotNull("Model should not be null", baseModel); + Assert.assertTrue("Model should be a SubRTComponent", baseModel instanceof SubRTComponent); + } + } +} From 0e11be21d6a9bb641f1c55e8c58254c9a9cd20f4 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 23 Jan 2026 11:59:17 +0100 Subject: [PATCH 07/17] SLING-13050 rename IT packages --- .../models/{testing => it}/DecoratedIT.java | 4 ++-- .../{testing => it}/ImplementsExtendsIT.java | 14 ++++++------- .../InjectorSpecificAnnotationIT.java | 4 ++-- .../{testing => it}/ModelFactorySimpleIT.java | 10 ++++----- .../{testing => it}/PathBoundServletIT.java | 6 +++--- ...erviceInjectionWithDifferentRankingIT.java | 8 +++---- .../models/{testing => it}/SimpleIT.java | 8 +++---- .../sling/models/{testing => it}/ViaIT.java | 6 +++--- .../delegate/DelegateRequestIT.java | 10 ++++----- .../delegate/DelegateResourceIT.java | 8 +++---- .../ViaOriginalResourceDelegationIT.java | 14 ++++++------- .../{testing => it}/helper/FakeRequest.java | 2 +- .../{testing => it}/helper/FakeResponse.java | 2 +- .../sling/models/it/models/package-info.java | 21 ------------------- .../{testing => it}/rtbound/FakeRequest.java | 2 +- .../rtbound/ResourceTypeBindingIT.java | 8 +++---- .../sling/models/it/rtbound/package-info.java | 21 ------------------- .../rtboundpicker/ResourceTypePickerIT.java | 8 +++---- .../models/it/rtboundpicker/package-info.java | 21 ------------------- .../models/it/services/package-info.java | 21 ------------------- .../delegate/request/DelegateBaseModel.java | 2 +- .../request/DelegateExtendedModel.java | 2 +- .../delegate/request}/DelegateInterface.java | 2 +- .../delegate/request/package-info.java | 21 +++++++++++++++++++ .../delegate/resource/DelegateBaseModel.java | 2 +- .../resource/DelegateExtendedModel.java | 2 +- .../delegate/resource}/DelegateInterface.java | 2 +- .../delegate/resource}/package-info.java | 2 +- .../delegate/viaoriginalresource/A.java | 2 +- .../delegate/viaoriginalresource/A1.java | 2 +- .../delegate/viaoriginalresource/B.java | 2 +- .../delegate/viaoriginalresource/B1.java | 2 +- .../viaoriginalresource/models/A1Impl.java | 8 +++---- .../viaoriginalresource/models/AImpl.java | 6 +++--- .../viaoriginalresource/models/B1Impl.java | 6 +++--- .../viaoriginalresource/models/BImpl.java | 4 ++-- .../models/package-info.java | 21 +++++++++++++++++++ .../viaoriginalresource}/package-info.java | 2 +- .../CustomLastImplementationPicker.java | 2 +- .../implpicker}/package-info.java | 2 +- .../models/ConstructorInjectionTestModel.java | 2 +- .../models/FieldInjectionTestModel.java | 2 +- .../models/InterfaceInjectionTestModel.java | 2 +- .../models/JakartaRequestSelfModel.java | 2 +- .../models/JakartaRequestSelfModelImpl.java | 2 +- .../models/ModelWithOptionalImport.java | 2 +- .../models/RequestSelfModel.java | 2 +- .../models/RequestSelfModelImpl.java | 2 +- .../it/{ => testbundle}/models/SelfModel.java | 2 +- .../models/ServiceInjectionTestModel.java | 4 ++-- .../SlingPropertyAnnotationTestModel.java | 2 +- .../{ => testbundle}/models/SourceObject.java | 2 +- .../it/{ => testbundle}/models/ViaModel.java | 2 +- .../implextend/ExtendsClassPropertyModel.java | 2 +- .../ImplementsInterfacePropertyModel.java | 2 +- .../ImplementsInterfacePropertyModel2.java | 2 +- ...validImplementsInterfacePropertyModel.java | 2 +- .../InvalidSampleServiceInterface.java | 2 +- .../implextend/SampleServiceInterface.java | 2 +- .../implextend/SimplePropertyModel.java | 2 +- .../models/implextend/package-info.java | 21 +++++++++++++++++++ .../models}/package-info.java | 2 +- .../rtbound/BaseComponent.java | 2 +- .../rtbound/ExtendedComponent.java | 2 +- .../rtbound/FromRequestComponent.java | 2 +- .../rtbound}/package-info.java | 2 +- .../rtboundpicker/BaseComponent.java | 2 +- .../rtboundpicker/SubRTComponent.java | 2 +- .../rtboundpicker/TestComponent.java | 2 +- .../rtboundpicker/package-info.java | 21 +++++++++++++++++++ .../AnotherTestBindingsValuesProvider.java | 2 +- .../services/SimpleService.java | 2 +- .../SimpleServiceWithCustomRanking.java | 2 +- .../services/TestBindingsValuesProvider.java | 2 +- .../services/TestResourceDecorator.java | 2 +- .../services}/package-info.java | 2 +- .../servlets/PathBoundJakartaServlet.java | 4 ++-- .../servlets/PathBoundServlet.java | 4 ++-- 78 files changed, 206 insertions(+), 206 deletions(-) rename src/test/java/org/apache/sling/models/{testing => it}/DecoratedIT.java (97%) rename src/test/java/org/apache/sling/models/{testing => it}/ImplementsExtendsIT.java (90%) rename src/test/java/org/apache/sling/models/{testing => it}/InjectorSpecificAnnotationIT.java (95%) rename src/test/java/org/apache/sling/models/{testing => it}/ModelFactorySimpleIT.java (92%) rename src/test/java/org/apache/sling/models/{testing => it}/PathBoundServletIT.java (93%) rename src/test/java/org/apache/sling/models/{testing => it}/ServiceInjectionWithDifferentRankingIT.java (95%) rename src/test/java/org/apache/sling/models/{testing => it}/SimpleIT.java (93%) rename src/test/java/org/apache/sling/models/{testing => it}/ViaIT.java (94%) rename src/test/java/org/apache/sling/models/{testing => it}/delegate/DelegateRequestIT.java (93%) rename src/test/java/org/apache/sling/models/{testing => it}/delegate/DelegateResourceIT.java (94%) rename src/test/java/org/apache/sling/models/{testing => it}/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java (91%) rename src/test/java/org/apache/sling/models/{testing => it}/helper/FakeRequest.java (99%) rename src/test/java/org/apache/sling/models/{testing => it}/helper/FakeResponse.java (98%) delete mode 100644 src/test/java/org/apache/sling/models/it/models/package-info.java rename src/test/java/org/apache/sling/models/{testing => it}/rtbound/FakeRequest.java (99%) rename src/test/java/org/apache/sling/models/{testing => it}/rtbound/ResourceTypeBindingIT.java (96%) delete mode 100644 src/test/java/org/apache/sling/models/it/rtbound/package-info.java rename src/test/java/org/apache/sling/models/{testing => it}/rtboundpicker/ResourceTypePickerIT.java (93%) delete mode 100644 src/test/java/org/apache/sling/models/it/rtboundpicker/package-info.java delete mode 100644 src/test/java/org/apache/sling/models/it/services/package-info.java rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/request/DelegateBaseModel.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/request/DelegateExtendedModel.java (96%) rename src/test/java/org/apache/sling/models/it/{delegate/resource => testbundle/delegate/request}/DelegateInterface.java (93%) create mode 100644 src/test/java/org/apache/sling/models/it/testbundle/delegate/request/package-info.java rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/resource/DelegateBaseModel.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/resource/DelegateExtendedModel.java (95%) rename src/test/java/org/apache/sling/models/it/{delegate/request => testbundle/delegate/resource}/DelegateInterface.java (93%) rename src/test/java/org/apache/sling/models/it/{delegate/viaoriginalresource => testbundle/delegate/resource}/package-info.java (93%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/viaoriginalresource/A.java (91%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/viaoriginalresource/A1.java (91%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/viaoriginalresource/B.java (91%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/viaoriginalresource/B1.java (91%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/viaoriginalresource/models/A1Impl.java (82%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/viaoriginalresource/models/AImpl.java (85%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/viaoriginalresource/models/B1Impl.java (85%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/delegate/viaoriginalresource/models/BImpl.java (88%) create mode 100644 src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/package-info.java rename src/test/java/org/apache/sling/models/it/{delegate/viaoriginalresource/models => testbundle/delegate/viaoriginalresource}/package-info.java (91%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/implpicker/CustomLastImplementationPicker.java (96%) rename src/test/java/org/apache/sling/models/it/{delegate/request => testbundle/implpicker}/package-info.java (93%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/ConstructorInjectionTestModel.java (97%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/FieldInjectionTestModel.java (97%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/InterfaceInjectionTestModel.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/JakartaRequestSelfModel.java (94%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/JakartaRequestSelfModelImpl.java (96%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/ModelWithOptionalImport.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/RequestSelfModel.java (94%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/RequestSelfModelImpl.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/SelfModel.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/ServiceInjectionTestModel.java (93%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/SlingPropertyAnnotationTestModel.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/SourceObject.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/ViaModel.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/implextend/ExtendsClassPropertyModel.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/implextend/ImplementsInterfacePropertyModel.java (96%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/implextend/ImplementsInterfacePropertyModel2.java (96%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/implextend/InvalidImplementsInterfacePropertyModel.java (96%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/implextend/InvalidSampleServiceInterface.java (94%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/implextend/SampleServiceInterface.java (94%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/models/implextend/SimplePropertyModel.java (95%) create mode 100644 src/test/java/org/apache/sling/models/it/testbundle/models/implextend/package-info.java rename src/test/java/org/apache/sling/models/it/{implpicker => testbundle/models}/package-info.java (94%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/rtbound/BaseComponent.java (96%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/rtbound/ExtendedComponent.java (96%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/rtbound/FromRequestComponent.java (95%) rename src/test/java/org/apache/sling/models/it/{delegate/resource => testbundle/rtbound}/package-info.java (94%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/rtboundpicker/BaseComponent.java (94%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/rtboundpicker/SubRTComponent.java (94%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/rtboundpicker/TestComponent.java (93%) create mode 100644 src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/package-info.java rename src/test/java/org/apache/sling/models/it/{ => testbundle}/services/AnotherTestBindingsValuesProvider.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/services/SimpleService.java (93%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/services/SimpleServiceWithCustomRanking.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/services/TestBindingsValuesProvider.java (95%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/services/TestResourceDecorator.java (97%) rename src/test/java/org/apache/sling/models/it/{models/implextend => testbundle/services}/package-info.java (93%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/servlets/PathBoundJakartaServlet.java (93%) rename src/test/java/org/apache/sling/models/it/{ => testbundle}/servlets/PathBoundServlet.java (93%) diff --git a/src/test/java/org/apache/sling/models/testing/DecoratedIT.java b/src/test/java/org/apache/sling/models/it/DecoratedIT.java similarity index 97% rename from src/test/java/org/apache/sling/models/testing/DecoratedIT.java rename to src/test/java/org/apache/sling/models/it/DecoratedIT.java index 8c0a39b..4092ae0 100644 --- a/src/test/java/org/apache/sling/models/testing/DecoratedIT.java +++ b/src/test/java/org/apache/sling/models/it/DecoratedIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing; +package org.apache.sling.models.it; import javax.jcr.Node; import javax.jcr.Session; @@ -28,7 +28,7 @@ import org.apache.sling.api.resource.ResourceWrapper; import org.apache.sling.junit.rules.TeleporterRule; import org.apache.sling.models.factory.ModelFactory; -import org.apache.sling.models.it.models.SelfModel; +import org.apache.sling.models.it.testbundle.models.SelfModel; import org.junit.After; import org.junit.Before; import org.junit.Rule; diff --git a/src/test/java/org/apache/sling/models/testing/ImplementsExtendsIT.java b/src/test/java/org/apache/sling/models/it/ImplementsExtendsIT.java similarity index 90% rename from src/test/java/org/apache/sling/models/testing/ImplementsExtendsIT.java rename to src/test/java/org/apache/sling/models/it/ImplementsExtendsIT.java index cc42661..fb1e9bf 100644 --- a/src/test/java/org/apache/sling/models/testing/ImplementsExtendsIT.java +++ b/src/test/java/org/apache/sling/models/it/ImplementsExtendsIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing; +package org.apache.sling.models.it; import javax.jcr.Node; import javax.jcr.RepositoryException; @@ -28,12 +28,12 @@ import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.resource.ResourceResolverFactory; import org.apache.sling.junit.rules.TeleporterRule; -import org.apache.sling.models.it.implpicker.CustomLastImplementationPicker; -import org.apache.sling.models.it.models.implextend.ImplementsInterfacePropertyModel; -import org.apache.sling.models.it.models.implextend.ImplementsInterfacePropertyModel2; -import org.apache.sling.models.it.models.implextend.InvalidSampleServiceInterface; -import org.apache.sling.models.it.models.implextend.SampleServiceInterface; -import org.apache.sling.models.it.models.implextend.SimplePropertyModel; +import org.apache.sling.models.it.testbundle.implpicker.CustomLastImplementationPicker; +import org.apache.sling.models.it.testbundle.models.implextend.ImplementsInterfacePropertyModel; +import org.apache.sling.models.it.testbundle.models.implextend.ImplementsInterfacePropertyModel2; +import org.apache.sling.models.it.testbundle.models.implextend.InvalidSampleServiceInterface; +import org.apache.sling.models.it.testbundle.models.implextend.SampleServiceInterface; +import org.apache.sling.models.it.testbundle.models.implextend.SimplePropertyModel; import org.junit.After; import org.junit.Before; import org.junit.Rule; diff --git a/src/test/java/org/apache/sling/models/testing/InjectorSpecificAnnotationIT.java b/src/test/java/org/apache/sling/models/it/InjectorSpecificAnnotationIT.java similarity index 95% rename from src/test/java/org/apache/sling/models/testing/InjectorSpecificAnnotationIT.java rename to src/test/java/org/apache/sling/models/it/InjectorSpecificAnnotationIT.java index 3764dbc..68cdd78 100644 --- a/src/test/java/org/apache/sling/models/testing/InjectorSpecificAnnotationIT.java +++ b/src/test/java/org/apache/sling/models/it/InjectorSpecificAnnotationIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing; +package org.apache.sling.models.it; import javax.jcr.Node; import javax.jcr.Session; @@ -26,7 +26,7 @@ import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.resource.ResourceResolverFactory; import org.apache.sling.junit.rules.TeleporterRule; -import org.apache.sling.models.it.models.SlingPropertyAnnotationTestModel; +import org.apache.sling.models.it.testbundle.models.SlingPropertyAnnotationTestModel; import org.junit.Rule; import org.junit.Test; diff --git a/src/test/java/org/apache/sling/models/testing/ModelFactorySimpleIT.java b/src/test/java/org/apache/sling/models/it/ModelFactorySimpleIT.java similarity index 92% rename from src/test/java/org/apache/sling/models/testing/ModelFactorySimpleIT.java rename to src/test/java/org/apache/sling/models/it/ModelFactorySimpleIT.java index 5468113..7e4f05b 100644 --- a/src/test/java/org/apache/sling/models/testing/ModelFactorySimpleIT.java +++ b/src/test/java/org/apache/sling/models/it/ModelFactorySimpleIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing; +package org.apache.sling.models.it; import javax.jcr.Node; import javax.jcr.Session; @@ -27,10 +27,10 @@ import org.apache.sling.api.resource.ResourceResolverFactory; import org.apache.sling.junit.rules.TeleporterRule; import org.apache.sling.models.factory.ModelFactory; -import org.apache.sling.models.it.models.ConstructorInjectionTestModel; -import org.apache.sling.models.it.models.FieldInjectionTestModel; -import org.apache.sling.models.it.models.implextend.InvalidImplementsInterfacePropertyModel; -import org.apache.sling.models.it.models.implextend.SampleServiceInterface; +import org.apache.sling.models.it.testbundle.models.ConstructorInjectionTestModel; +import org.apache.sling.models.it.testbundle.models.FieldInjectionTestModel; +import org.apache.sling.models.it.testbundle.models.implextend.InvalidImplementsInterfacePropertyModel; +import org.apache.sling.models.it.testbundle.models.implextend.SampleServiceInterface; import org.junit.After; import org.junit.Before; import org.junit.Ignore; diff --git a/src/test/java/org/apache/sling/models/testing/PathBoundServletIT.java b/src/test/java/org/apache/sling/models/it/PathBoundServletIT.java similarity index 93% rename from src/test/java/org/apache/sling/models/testing/PathBoundServletIT.java rename to src/test/java/org/apache/sling/models/it/PathBoundServletIT.java index bec53f8..5efef2d 100644 --- a/src/test/java/org/apache/sling/models/testing/PathBoundServletIT.java +++ b/src/test/java/org/apache/sling/models/it/PathBoundServletIT.java @@ -16,14 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing; +package org.apache.sling.models.it; import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.resource.ResourceResolverFactory; import org.apache.sling.engine.SlingRequestProcessor; import org.apache.sling.junit.rules.TeleporterRule; -import org.apache.sling.models.testing.helper.FakeRequest; -import org.apache.sling.models.testing.helper.FakeResponse; +import org.apache.sling.models.it.helper.FakeRequest; +import org.apache.sling.models.it.helper.FakeResponse; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; diff --git a/src/test/java/org/apache/sling/models/testing/ServiceInjectionWithDifferentRankingIT.java b/src/test/java/org/apache/sling/models/it/ServiceInjectionWithDifferentRankingIT.java similarity index 95% rename from src/test/java/org/apache/sling/models/testing/ServiceInjectionWithDifferentRankingIT.java rename to src/test/java/org/apache/sling/models/it/ServiceInjectionWithDifferentRankingIT.java index 7a9b1a0..29b4894 100644 --- a/src/test/java/org/apache/sling/models/testing/ServiceInjectionWithDifferentRankingIT.java +++ b/src/test/java/org/apache/sling/models/it/ServiceInjectionWithDifferentRankingIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing; +package org.apache.sling.models.it; import javax.jcr.Node; import javax.jcr.Session; @@ -34,9 +34,9 @@ import org.apache.sling.junit.Activator; import org.apache.sling.junit.rules.TeleporterRule; import org.apache.sling.models.factory.ModelFactory; -import org.apache.sling.models.it.models.ServiceInjectionTestModel; -import org.apache.sling.models.it.services.SimpleService; -import org.apache.sling.models.it.services.SimpleServiceWithCustomRanking; +import org.apache.sling.models.it.testbundle.models.ServiceInjectionTestModel; +import org.apache.sling.models.it.testbundle.services.SimpleService; +import org.apache.sling.models.it.testbundle.services.SimpleServiceWithCustomRanking; import org.junit.After; import org.junit.Before; import org.junit.Rule; diff --git a/src/test/java/org/apache/sling/models/testing/SimpleIT.java b/src/test/java/org/apache/sling/models/it/SimpleIT.java similarity index 93% rename from src/test/java/org/apache/sling/models/testing/SimpleIT.java rename to src/test/java/org/apache/sling/models/it/SimpleIT.java index 7ab3c7f..2d94f18 100644 --- a/src/test/java/org/apache/sling/models/testing/SimpleIT.java +++ b/src/test/java/org/apache/sling/models/it/SimpleIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing; +package org.apache.sling.models.it; import javax.jcr.Node; import javax.jcr.Session; @@ -26,9 +26,9 @@ import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.resource.ResourceResolverFactory; import org.apache.sling.junit.rules.TeleporterRule; -import org.apache.sling.models.it.models.ConstructorInjectionTestModel; -import org.apache.sling.models.it.models.FieldInjectionTestModel; -import org.apache.sling.models.it.models.InterfaceInjectionTestModel; +import org.apache.sling.models.it.testbundle.models.ConstructorInjectionTestModel; +import org.apache.sling.models.it.testbundle.models.FieldInjectionTestModel; +import org.apache.sling.models.it.testbundle.models.InterfaceInjectionTestModel; import org.junit.After; import org.junit.Before; import org.junit.Rule; diff --git a/src/test/java/org/apache/sling/models/testing/ViaIT.java b/src/test/java/org/apache/sling/models/it/ViaIT.java similarity index 94% rename from src/test/java/org/apache/sling/models/testing/ViaIT.java rename to src/test/java/org/apache/sling/models/it/ViaIT.java index 07f973e..9db5d9f 100644 --- a/src/test/java/org/apache/sling/models/testing/ViaIT.java +++ b/src/test/java/org/apache/sling/models/it/ViaIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing; +package org.apache.sling.models.it; import javax.jcr.Node; import javax.jcr.Session; @@ -27,8 +27,8 @@ import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.resource.ResourceResolverFactory; import org.apache.sling.junit.rules.TeleporterRule; -import org.apache.sling.models.it.models.SourceObject; -import org.apache.sling.models.it.models.ViaModel; +import org.apache.sling.models.it.testbundle.models.SourceObject; +import org.apache.sling.models.it.testbundle.models.ViaModel; import org.junit.Rule; import org.junit.Test; diff --git a/src/test/java/org/apache/sling/models/testing/delegate/DelegateRequestIT.java b/src/test/java/org/apache/sling/models/it/delegate/DelegateRequestIT.java similarity index 93% rename from src/test/java/org/apache/sling/models/testing/delegate/DelegateRequestIT.java rename to src/test/java/org/apache/sling/models/it/delegate/DelegateRequestIT.java index a6b494a..dd38d09 100644 --- a/src/test/java/org/apache/sling/models/testing/delegate/DelegateRequestIT.java +++ b/src/test/java/org/apache/sling/models/it/delegate/DelegateRequestIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing.delegate; +package org.apache.sling.models.it.delegate; import java.util.HashMap; import java.util.Map; @@ -30,10 +30,10 @@ 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.request.DelegateBaseModel; -import org.apache.sling.models.it.delegate.request.DelegateExtendedModel; -import org.apache.sling.models.it.delegate.request.DelegateInterface; -import org.apache.sling.models.testing.rtbound.FakeRequest; +import org.apache.sling.models.it.rtbound.FakeRequest; +import org.apache.sling.models.it.testbundle.delegate.request.DelegateBaseModel; +import org.apache.sling.models.it.testbundle.delegate.request.DelegateExtendedModel; +import org.apache.sling.models.it.testbundle.delegate.request.DelegateInterface; import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/src/test/java/org/apache/sling/models/testing/delegate/DelegateResourceIT.java b/src/test/java/org/apache/sling/models/it/delegate/DelegateResourceIT.java similarity index 94% rename from src/test/java/org/apache/sling/models/testing/delegate/DelegateResourceIT.java rename to src/test/java/org/apache/sling/models/it/delegate/DelegateResourceIT.java index 97f8094..0a0d21c 100644 --- a/src/test/java/org/apache/sling/models/testing/delegate/DelegateResourceIT.java +++ b/src/test/java/org/apache/sling/models/it/delegate/DelegateResourceIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing.delegate; +package org.apache.sling.models.it.delegate; import java.util.HashMap; import java.util.Map; @@ -29,9 +29,9 @@ 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.it.delegate.resource.DelegateBaseModel; -import org.apache.sling.models.it.delegate.resource.DelegateExtendedModel; -import org.apache.sling.models.it.delegate.resource.DelegateInterface; +import org.apache.sling.models.it.testbundle.delegate.resource.DelegateBaseModel; +import org.apache.sling.models.it.testbundle.delegate.resource.DelegateExtendedModel; +import org.apache.sling.models.it.testbundle.delegate.resource.DelegateInterface; import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/src/test/java/org/apache/sling/models/testing/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java similarity index 91% rename from src/test/java/org/apache/sling/models/testing/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java rename to src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java index ee119b7..b4bd6bd 100644 --- a/src/test/java/org/apache/sling/models/testing/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java +++ b/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing.delegate.viaoriginalresource; +package org.apache.sling.models.it.delegate.viaoriginalresource; import java.util.HashMap; import java.util.Map; @@ -29,12 +29,12 @@ 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.apache.sling.models.it.rtbound.FakeRequest; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.A; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.models.A1Impl; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.models.AImpl; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.models.B1Impl; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.models.BImpl; import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/src/test/java/org/apache/sling/models/testing/helper/FakeRequest.java b/src/test/java/org/apache/sling/models/it/helper/FakeRequest.java similarity index 99% rename from src/test/java/org/apache/sling/models/testing/helper/FakeRequest.java rename to src/test/java/org/apache/sling/models/it/helper/FakeRequest.java index 1290f8a..35f8725 100644 --- a/src/test/java/org/apache/sling/models/testing/helper/FakeRequest.java +++ b/src/test/java/org/apache/sling/models/it/helper/FakeRequest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing.helper; +package org.apache.sling.models.it.helper; import javax.servlet.AsyncContext; import javax.servlet.DispatcherType; diff --git a/src/test/java/org/apache/sling/models/testing/helper/FakeResponse.java b/src/test/java/org/apache/sling/models/it/helper/FakeResponse.java similarity index 98% rename from src/test/java/org/apache/sling/models/testing/helper/FakeResponse.java rename to src/test/java/org/apache/sling/models/it/helper/FakeResponse.java index fa474aa..70317cf 100644 --- a/src/test/java/org/apache/sling/models/testing/helper/FakeResponse.java +++ b/src/test/java/org/apache/sling/models/it/helper/FakeResponse.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing.helper; +package org.apache.sling.models.it.helper; import javax.servlet.ServletOutputStream; import javax.servlet.http.Cookie; diff --git a/src/test/java/org/apache/sling/models/it/models/package-info.java b/src/test/java/org/apache/sling/models/it/models/package-info.java deleted file mode 100644 index d387b59..0000000 --- a/src/test/java/org/apache/sling/models/it/models/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.models; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/testing/rtbound/FakeRequest.java b/src/test/java/org/apache/sling/models/it/rtbound/FakeRequest.java similarity index 99% rename from src/test/java/org/apache/sling/models/testing/rtbound/FakeRequest.java rename to src/test/java/org/apache/sling/models/it/rtbound/FakeRequest.java index 56a8a78..d84705b 100644 --- a/src/test/java/org/apache/sling/models/testing/rtbound/FakeRequest.java +++ b/src/test/java/org/apache/sling/models/it/rtbound/FakeRequest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing.rtbound; +package org.apache.sling.models.it.rtbound; import javax.servlet.AsyncContext; import javax.servlet.DispatcherType; diff --git a/src/test/java/org/apache/sling/models/testing/rtbound/ResourceTypeBindingIT.java b/src/test/java/org/apache/sling/models/it/rtbound/ResourceTypeBindingIT.java similarity index 96% rename from src/test/java/org/apache/sling/models/testing/rtbound/ResourceTypeBindingIT.java rename to src/test/java/org/apache/sling/models/it/rtbound/ResourceTypeBindingIT.java index 74ec330..a7af956 100644 --- a/src/test/java/org/apache/sling/models/testing/rtbound/ResourceTypeBindingIT.java +++ b/src/test/java/org/apache/sling/models/it/rtbound/ResourceTypeBindingIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing.rtbound; +package org.apache.sling.models.it.rtbound; import java.util.HashMap; import java.util.Map; @@ -30,9 +30,9 @@ 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.rtbound.BaseComponent; -import org.apache.sling.models.it.rtbound.ExtendedComponent; -import org.apache.sling.models.it.rtbound.FromRequestComponent; +import org.apache.sling.models.it.testbundle.rtbound.BaseComponent; +import org.apache.sling.models.it.testbundle.rtbound.ExtendedComponent; +import org.apache.sling.models.it.testbundle.rtbound.FromRequestComponent; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; diff --git a/src/test/java/org/apache/sling/models/it/rtbound/package-info.java b/src/test/java/org/apache/sling/models/it/rtbound/package-info.java deleted file mode 100644 index 19332e3..0000000 --- a/src/test/java/org/apache/sling/models/it/rtbound/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.rtbound; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/testing/rtboundpicker/ResourceTypePickerIT.java b/src/test/java/org/apache/sling/models/it/rtboundpicker/ResourceTypePickerIT.java similarity index 93% rename from src/test/java/org/apache/sling/models/testing/rtboundpicker/ResourceTypePickerIT.java rename to src/test/java/org/apache/sling/models/it/rtboundpicker/ResourceTypePickerIT.java index 3faa6e9..9f5c654 100644 --- a/src/test/java/org/apache/sling/models/testing/rtboundpicker/ResourceTypePickerIT.java +++ b/src/test/java/org/apache/sling/models/it/rtboundpicker/ResourceTypePickerIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.testing.rtboundpicker; +package org.apache.sling.models.it.rtboundpicker; import java.util.HashMap; import java.util.Map; @@ -29,9 +29,9 @@ 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.it.rtboundpicker.BaseComponent; -import org.apache.sling.models.it.rtboundpicker.SubRTComponent; -import org.apache.sling.models.it.rtboundpicker.TestComponent; +import org.apache.sling.models.it.testbundle.rtboundpicker.BaseComponent; +import org.apache.sling.models.it.testbundle.rtboundpicker.SubRTComponent; +import org.apache.sling.models.it.testbundle.rtboundpicker.TestComponent; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; diff --git a/src/test/java/org/apache/sling/models/it/rtboundpicker/package-info.java b/src/test/java/org/apache/sling/models/it/rtboundpicker/package-info.java deleted file mode 100644 index 950815c..0000000 --- a/src/test/java/org/apache/sling/models/it/rtboundpicker/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.rtboundpicker; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/services/package-info.java b/src/test/java/org/apache/sling/models/it/services/package-info.java deleted file mode 100644 index 1f5740a..0000000 --- a/src/test/java/org/apache/sling/models/it/services/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.services; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/DelegateBaseModel.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/request/DelegateBaseModel.java index 1e4369e..6cca66e 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/request/DelegateBaseModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/DelegateBaseModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.request; +package org.apache.sling.models.it.testbundle.delegate.request; import javax.inject.Inject; diff --git a/src/test/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/DelegateExtendedModel.java similarity index 96% rename from src/test/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/request/DelegateExtendedModel.java index c2a01a7..ad455cd 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/request/DelegateExtendedModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/DelegateExtendedModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.request; +package org.apache.sling.models.it.testbundle.delegate.request; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.models.annotations.Model; diff --git a/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/DelegateInterface.java similarity index 93% rename from src/test/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/request/DelegateInterface.java index 2b208e2..ddab798 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateInterface.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/DelegateInterface.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.resource; +package org.apache.sling.models.it.testbundle.delegate.request; public interface DelegateInterface { diff --git a/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/package-info.java new file mode 100644 index 0000000..ad984f5 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/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.testbundle.delegate.request; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/DelegateBaseModel.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/DelegateBaseModel.java index 0b2031b..de36cce 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateBaseModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/DelegateBaseModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.resource; +package org.apache.sling.models.it.testbundle.delegate.resource; import javax.inject.Inject; diff --git a/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/DelegateExtendedModel.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/DelegateExtendedModel.java index df901f5..b591707 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/resource/DelegateExtendedModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/DelegateExtendedModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.resource; +package org.apache.sling.models.it.testbundle.delegate.resource; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Model; diff --git a/src/test/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/DelegateInterface.java similarity index 93% rename from src/test/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/DelegateInterface.java index 9826052..8d07de9 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/request/DelegateInterface.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/DelegateInterface.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.request; +package org.apache.sling.models.it.testbundle.delegate.resource; public interface DelegateInterface { diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/package-info.java similarity index 93% rename from src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/package-info.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/package-info.java index fa049a5..0b42b01 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/package-info.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/package-info.java @@ -16,6 +16,6 @@ */ @Version("1.0") -package org.apache.sling.models.it.delegate.viaoriginalresource; +package org.apache.sling.models.it.testbundle.delegate.resource; import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/A.java similarity index 91% rename from src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/A.java index 7581fea..65f1d97 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/A.java @@ -16,6 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.viaoriginalresource; +package org.apache.sling.models.it.testbundle.delegate.viaoriginalresource; public interface A {} diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A1.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/A1.java similarity index 91% rename from src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A1.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/A1.java index 6d3048b..67e249a 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/A1.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/A1.java @@ -16,6 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.viaoriginalresource; +package org.apache.sling.models.it.testbundle.delegate.viaoriginalresource; public interface A1 extends A {} diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/B.java similarity index 91% rename from src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/B.java index 8fbbdab..fde7c55 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/B.java @@ -16,6 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.viaoriginalresource; +package org.apache.sling.models.it.testbundle.delegate.viaoriginalresource; public interface B {} diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B1.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/B1.java similarity index 91% rename from src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B1.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/B1.java index 50fb27c..ea4f0ad 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/B1.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/B1.java @@ -16,6 +16,6 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.viaoriginalresource; +package org.apache.sling.models.it.testbundle.delegate.viaoriginalresource; public interface B1 extends B {} diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/A1Impl.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/A1Impl.java similarity index 82% rename from src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/A1Impl.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/A1Impl.java index 62e4b63..079f63a 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/A1Impl.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/A1Impl.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.viaoriginalresource.models; +package org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.models; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.resource.Resource; @@ -24,9 +24,9 @@ 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; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.A; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.A1; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.B1; @Model( adaptables = {SlingHttpServletRequest.class, Resource.class}, diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/AImpl.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/AImpl.java similarity index 85% rename from src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/AImpl.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/AImpl.java index 9622bdb..6c46eab 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/AImpl.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/AImpl.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.viaoriginalresource.models; +package org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.models; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.resource.Resource; @@ -24,8 +24,8 @@ import org.apache.sling.models.annotations.Via; import org.apache.sling.models.annotations.injectorspecific.Self; import org.apache.sling.models.annotations.via.OriginalResourceType; -import org.apache.sling.models.it.delegate.viaoriginalresource.A; -import org.apache.sling.models.it.delegate.viaoriginalresource.B; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.A; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.B; @Model( adaptables = {SlingHttpServletRequest.class, Resource.class}, diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/B1Impl.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/B1Impl.java similarity index 85% rename from src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/B1Impl.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/B1Impl.java index 85e744f..18050ab 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/B1Impl.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/B1Impl.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.viaoriginalresource.models; +package org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.models; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.resource.Resource; @@ -24,8 +24,8 @@ 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; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.B; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.B1; @Model( adaptables = {SlingHttpServletRequest.class, Resource.class}, diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/BImpl.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/BImpl.java similarity index 88% rename from src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/BImpl.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/BImpl.java index e3b8569..86e1053 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/BImpl.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/BImpl.java @@ -16,12 +16,12 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.viaoriginalresource.models; +package org.apache.sling.models.it.testbundle.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; +import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.B; @Model( adaptables = {SlingHttpServletRequest.class, Resource.class}, diff --git a/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/package-info.java new file mode 100644 index 0000000..e2565dc --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/testbundle/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.testbundle.delegate.viaoriginalresource.models; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/package-info.java similarity index 91% rename from src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/package-info.java rename to src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/package-info.java index 88f82b0..d657fc9 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/models/package-info.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/package-info.java @@ -16,6 +16,6 @@ */ @Version("1.0") -package org.apache.sling.models.it.delegate.viaoriginalresource.models; +package org.apache.sling.models.it.testbundle.delegate.viaoriginalresource; import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/implpicker/CustomLastImplementationPicker.java b/src/test/java/org/apache/sling/models/it/testbundle/implpicker/CustomLastImplementationPicker.java similarity index 96% rename from src/test/java/org/apache/sling/models/it/implpicker/CustomLastImplementationPicker.java rename to src/test/java/org/apache/sling/models/it/testbundle/implpicker/CustomLastImplementationPicker.java index 5979847..6d8faf4 100644 --- a/src/test/java/org/apache/sling/models/it/implpicker/CustomLastImplementationPicker.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/implpicker/CustomLastImplementationPicker.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.implpicker; +package org.apache.sling.models.it.testbundle.implpicker; import org.apache.commons.lang3.StringUtils; import org.apache.sling.api.resource.Resource; diff --git a/src/test/java/org/apache/sling/models/it/delegate/request/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/implpicker/package-info.java similarity index 93% rename from src/test/java/org/apache/sling/models/it/delegate/request/package-info.java rename to src/test/java/org/apache/sling/models/it/testbundle/implpicker/package-info.java index 3e7e701..f65a8f6 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/request/package-info.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/implpicker/package-info.java @@ -16,6 +16,6 @@ */ @Version("1.0") -package org.apache.sling.models.it.delegate.request; +package org.apache.sling.models.it.testbundle.implpicker; import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/models/ConstructorInjectionTestModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/ConstructorInjectionTestModel.java similarity index 97% rename from src/test/java/org/apache/sling/models/it/models/ConstructorInjectionTestModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/ConstructorInjectionTestModel.java index c80b1c5..a97870c 100644 --- a/src/test/java/org/apache/sling/models/it/models/ConstructorInjectionTestModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/ConstructorInjectionTestModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import javax.inject.Inject; import javax.inject.Named; diff --git a/src/test/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/FieldInjectionTestModel.java similarity index 97% rename from src/test/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/FieldInjectionTestModel.java index f8ed3a8..e22021d 100644 --- a/src/test/java/org/apache/sling/models/it/models/FieldInjectionTestModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/FieldInjectionTestModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import javax.inject.Inject; import javax.inject.Named; diff --git a/src/test/java/org/apache/sling/models/it/models/InterfaceInjectionTestModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/InterfaceInjectionTestModel.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/models/InterfaceInjectionTestModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/InterfaceInjectionTestModel.java index 52e2e40..d12e8bb 100644 --- a/src/test/java/org/apache/sling/models/it/models/InterfaceInjectionTestModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/InterfaceInjectionTestModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import javax.inject.Inject; import javax.servlet.Filter; diff --git a/src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/JakartaRequestSelfModel.java similarity index 94% rename from src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/JakartaRequestSelfModel.java index 24282af..ba95f8b 100644 --- a/src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/JakartaRequestSelfModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import org.apache.sling.api.SlingJakartaHttpServletRequest; diff --git a/src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModelImpl.java b/src/test/java/org/apache/sling/models/it/testbundle/models/JakartaRequestSelfModelImpl.java similarity index 96% rename from src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModelImpl.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/JakartaRequestSelfModelImpl.java index ab7261a..7455643 100644 --- a/src/test/java/org/apache/sling/models/it/models/JakartaRequestSelfModelImpl.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/JakartaRequestSelfModelImpl.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import org.apache.sling.api.SlingJakartaHttpServletRequest; import org.apache.sling.models.annotations.Model; diff --git a/src/test/java/org/apache/sling/models/it/models/ModelWithOptionalImport.java b/src/test/java/org/apache/sling/models/it/testbundle/models/ModelWithOptionalImport.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/models/ModelWithOptionalImport.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/ModelWithOptionalImport.java index d33b05b..f382425 100644 --- a/src/test/java/org/apache/sling/models/it/models/ModelWithOptionalImport.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/ModelWithOptionalImport.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import org.apache.commons.beanutils.BeanUtils; import org.apache.sling.api.resource.Resource; diff --git a/src/test/java/org/apache/sling/models/it/models/RequestSelfModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/RequestSelfModel.java similarity index 94% rename from src/test/java/org/apache/sling/models/it/models/RequestSelfModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/RequestSelfModel.java index b711431..bc1a3ea 100644 --- a/src/test/java/org/apache/sling/models/it/models/RequestSelfModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/RequestSelfModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import org.apache.sling.api.SlingHttpServletRequest; diff --git a/src/test/java/org/apache/sling/models/it/models/RequestSelfModelImpl.java b/src/test/java/org/apache/sling/models/it/testbundle/models/RequestSelfModelImpl.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/models/RequestSelfModelImpl.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/RequestSelfModelImpl.java index de9e83f..3030d39 100644 --- a/src/test/java/org/apache/sling/models/it/models/RequestSelfModelImpl.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/RequestSelfModelImpl.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.models.annotations.Model; diff --git a/src/test/java/org/apache/sling/models/it/models/SelfModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/SelfModel.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/models/SelfModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/SelfModel.java index c635c4e..9cc9f18 100644 --- a/src/test/java/org/apache/sling/models/it/models/SelfModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/SelfModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Model; diff --git a/src/test/java/org/apache/sling/models/it/models/ServiceInjectionTestModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/ServiceInjectionTestModel.java similarity index 93% rename from src/test/java/org/apache/sling/models/it/models/ServiceInjectionTestModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/ServiceInjectionTestModel.java index c9f2cf3..e4ddb96 100644 --- a/src/test/java/org/apache/sling/models/it/models/ServiceInjectionTestModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/ServiceInjectionTestModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import java.util.ArrayList; import java.util.List; @@ -24,7 +24,7 @@ import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Model; import org.apache.sling.models.annotations.injectorspecific.OSGiService; -import org.apache.sling.models.it.services.SimpleService; +import org.apache.sling.models.it.testbundle.services.SimpleService; @Model(adaptables = Resource.class) public class ServiceInjectionTestModel { diff --git a/src/test/java/org/apache/sling/models/it/models/SlingPropertyAnnotationTestModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/SlingPropertyAnnotationTestModel.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/models/SlingPropertyAnnotationTestModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/SlingPropertyAnnotationTestModel.java index abda77a..a192d22 100644 --- a/src/test/java/org/apache/sling/models/it/models/SlingPropertyAnnotationTestModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/SlingPropertyAnnotationTestModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Model; diff --git a/src/test/java/org/apache/sling/models/it/models/SourceObject.java b/src/test/java/org/apache/sling/models/it/testbundle/models/SourceObject.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/models/SourceObject.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/SourceObject.java index d31d57f..dfb39cd 100644 --- a/src/test/java/org/apache/sling/models/it/models/SourceObject.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/SourceObject.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import org.apache.sling.api.resource.Resource; diff --git a/src/test/java/org/apache/sling/models/it/models/ViaModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/ViaModel.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/models/ViaModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/ViaModel.java index a33c24e..a5182ca 100644 --- a/src/test/java/org/apache/sling/models/it/models/ViaModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/ViaModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models; +package org.apache.sling.models.it.testbundle.models; import javax.inject.Inject; diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/ExtendsClassPropertyModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/ExtendsClassPropertyModel.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/models/implextend/ExtendsClassPropertyModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/implextend/ExtendsClassPropertyModel.java index 4dbb0dc..97463c9 100644 --- a/src/test/java/org/apache/sling/models/it/models/implextend/ExtendsClassPropertyModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/ExtendsClassPropertyModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models.implextend; +package org.apache.sling.models.it.testbundle.models.implextend; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Model; diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/ImplementsInterfacePropertyModel.java similarity index 96% rename from src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/implextend/ImplementsInterfacePropertyModel.java index 033d184..8add758 100644 --- a/src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/ImplementsInterfacePropertyModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models.implextend; +package org.apache.sling.models.it.testbundle.models.implextend; import javax.inject.Inject; import javax.inject.Named; diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel2.java b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/ImplementsInterfacePropertyModel2.java similarity index 96% rename from src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel2.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/implextend/ImplementsInterfacePropertyModel2.java index 40d05ec..9c4c275 100644 --- a/src/test/java/org/apache/sling/models/it/models/implextend/ImplementsInterfacePropertyModel2.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/ImplementsInterfacePropertyModel2.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models.implextend; +package org.apache.sling.models.it.testbundle.models.implextend; import javax.inject.Inject; import javax.inject.Named; diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/InvalidImplementsInterfacePropertyModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/InvalidImplementsInterfacePropertyModel.java similarity index 96% rename from src/test/java/org/apache/sling/models/it/models/implextend/InvalidImplementsInterfacePropertyModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/implextend/InvalidImplementsInterfacePropertyModel.java index 6f0dfdf..0ebca36 100644 --- a/src/test/java/org/apache/sling/models/it/models/implextend/InvalidImplementsInterfacePropertyModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/InvalidImplementsInterfacePropertyModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models.implextend; +package org.apache.sling.models.it.testbundle.models.implextend; import javax.inject.Inject; import javax.inject.Named; diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/InvalidSampleServiceInterface.java b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/InvalidSampleServiceInterface.java similarity index 94% rename from src/test/java/org/apache/sling/models/it/models/implextend/InvalidSampleServiceInterface.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/implextend/InvalidSampleServiceInterface.java index 18f26cb..3d98498 100644 --- a/src/test/java/org/apache/sling/models/it/models/implextend/InvalidSampleServiceInterface.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/InvalidSampleServiceInterface.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models.implextend; +package org.apache.sling.models.it.testbundle.models.implextend; /** * Example "service" interface to which sling models can adapt. diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/SampleServiceInterface.java b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/SampleServiceInterface.java similarity index 94% rename from src/test/java/org/apache/sling/models/it/models/implextend/SampleServiceInterface.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/implextend/SampleServiceInterface.java index 84f1155..f2b3814 100644 --- a/src/test/java/org/apache/sling/models/it/models/implextend/SampleServiceInterface.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/SampleServiceInterface.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models.implextend; +package org.apache.sling.models.it.testbundle.models.implextend; /** * Example "service" interface to which sling models can adapt. diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/SimplePropertyModel.java b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/SimplePropertyModel.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/models/implextend/SimplePropertyModel.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/implextend/SimplePropertyModel.java index a942c08..c629155 100644 --- a/src/test/java/org/apache/sling/models/it/models/implextend/SimplePropertyModel.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/SimplePropertyModel.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.models.implextend; +package org.apache.sling.models.it.testbundle.models.implextend; import javax.inject.Inject; import javax.inject.Named; diff --git a/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/package-info.java new file mode 100644 index 0000000..f600677 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/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.testbundle.models.implextend; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/implpicker/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/models/package-info.java similarity index 94% rename from src/test/java/org/apache/sling/models/it/implpicker/package-info.java rename to src/test/java/org/apache/sling/models/it/testbundle/models/package-info.java index c8a5b3e..6bf456a 100644 --- a/src/test/java/org/apache/sling/models/it/implpicker/package-info.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/models/package-info.java @@ -16,6 +16,6 @@ */ @Version("1.0") -package org.apache.sling.models.it.implpicker; +package org.apache.sling.models.it.testbundle.models; import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/rtbound/BaseComponent.java b/src/test/java/org/apache/sling/models/it/testbundle/rtbound/BaseComponent.java similarity index 96% rename from src/test/java/org/apache/sling/models/it/rtbound/BaseComponent.java rename to src/test/java/org/apache/sling/models/it/testbundle/rtbound/BaseComponent.java index b15f9f3..061ddde 100644 --- a/src/test/java/org/apache/sling/models/it/rtbound/BaseComponent.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/rtbound/BaseComponent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.rtbound; +package org.apache.sling.models.it.testbundle.rtbound; import javax.inject.Inject; diff --git a/src/test/java/org/apache/sling/models/it/rtbound/ExtendedComponent.java b/src/test/java/org/apache/sling/models/it/testbundle/rtbound/ExtendedComponent.java similarity index 96% rename from src/test/java/org/apache/sling/models/it/rtbound/ExtendedComponent.java rename to src/test/java/org/apache/sling/models/it/testbundle/rtbound/ExtendedComponent.java index 43cbed7..ebd91a1 100644 --- a/src/test/java/org/apache/sling/models/it/rtbound/ExtendedComponent.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/rtbound/ExtendedComponent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.rtbound; +package org.apache.sling.models.it.testbundle.rtbound; import java.util.Calendar; import java.util.Date; diff --git a/src/test/java/org/apache/sling/models/it/rtbound/FromRequestComponent.java b/src/test/java/org/apache/sling/models/it/testbundle/rtbound/FromRequestComponent.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/rtbound/FromRequestComponent.java rename to src/test/java/org/apache/sling/models/it/testbundle/rtbound/FromRequestComponent.java index c39b754..f6e5f0d 100644 --- a/src/test/java/org/apache/sling/models/it/rtbound/FromRequestComponent.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/rtbound/FromRequestComponent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.rtbound; +package org.apache.sling.models.it.testbundle.rtbound; import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.models.annotations.Model; diff --git a/src/test/java/org/apache/sling/models/it/delegate/resource/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/rtbound/package-info.java similarity index 94% rename from src/test/java/org/apache/sling/models/it/delegate/resource/package-info.java rename to src/test/java/org/apache/sling/models/it/testbundle/rtbound/package-info.java index a0f5c5b..bbbbeaa 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/resource/package-info.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/rtbound/package-info.java @@ -16,6 +16,6 @@ */ @Version("1.0") -package org.apache.sling.models.it.delegate.resource; +package org.apache.sling.models.it.testbundle.rtbound; import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/rtboundpicker/BaseComponent.java b/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/BaseComponent.java similarity index 94% rename from src/test/java/org/apache/sling/models/it/rtboundpicker/BaseComponent.java rename to src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/BaseComponent.java index 292cef0..a88f3dd 100644 --- a/src/test/java/org/apache/sling/models/it/rtboundpicker/BaseComponent.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/BaseComponent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.rtboundpicker; +package org.apache.sling.models.it.testbundle.rtboundpicker; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Model; diff --git a/src/test/java/org/apache/sling/models/it/rtboundpicker/SubRTComponent.java b/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/SubRTComponent.java similarity index 94% rename from src/test/java/org/apache/sling/models/it/rtboundpicker/SubRTComponent.java rename to src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/SubRTComponent.java index 32011b2..5ea3346 100644 --- a/src/test/java/org/apache/sling/models/it/rtboundpicker/SubRTComponent.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/SubRTComponent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.rtboundpicker; +package org.apache.sling.models.it.testbundle.rtboundpicker; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.annotations.Model; diff --git a/src/test/java/org/apache/sling/models/it/rtboundpicker/TestComponent.java b/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/TestComponent.java similarity index 93% rename from src/test/java/org/apache/sling/models/it/rtboundpicker/TestComponent.java rename to src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/TestComponent.java index 3d97aea..8c3362f 100644 --- a/src/test/java/org/apache/sling/models/it/rtboundpicker/TestComponent.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/TestComponent.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.rtboundpicker; +package org.apache.sling.models.it.testbundle.rtboundpicker; public interface TestComponent { diff --git a/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/package-info.java new file mode 100644 index 0000000..f9c8f4b --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/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.testbundle.rtboundpicker; + +import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/services/AnotherTestBindingsValuesProvider.java b/src/test/java/org/apache/sling/models/it/testbundle/services/AnotherTestBindingsValuesProvider.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/services/AnotherTestBindingsValuesProvider.java rename to src/test/java/org/apache/sling/models/it/testbundle/services/AnotherTestBindingsValuesProvider.java index 9dcce31..987bdc4 100644 --- a/src/test/java/org/apache/sling/models/it/services/AnotherTestBindingsValuesProvider.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/services/AnotherTestBindingsValuesProvider.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.services; +package org.apache.sling.models.it.testbundle.services; import java.util.Collections; import java.util.HashMap; diff --git a/src/test/java/org/apache/sling/models/it/services/SimpleService.java b/src/test/java/org/apache/sling/models/it/testbundle/services/SimpleService.java similarity index 93% rename from src/test/java/org/apache/sling/models/it/services/SimpleService.java rename to src/test/java/org/apache/sling/models/it/testbundle/services/SimpleService.java index aeb4ee1..94bfa89 100644 --- a/src/test/java/org/apache/sling/models/it/services/SimpleService.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/services/SimpleService.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.services; +package org.apache.sling.models.it.testbundle.services; public interface SimpleService { int getRanking(); diff --git a/src/test/java/org/apache/sling/models/it/services/SimpleServiceWithCustomRanking.java b/src/test/java/org/apache/sling/models/it/testbundle/services/SimpleServiceWithCustomRanking.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/services/SimpleServiceWithCustomRanking.java rename to src/test/java/org/apache/sling/models/it/testbundle/services/SimpleServiceWithCustomRanking.java index 33a8068..a49afc9 100644 --- a/src/test/java/org/apache/sling/models/it/services/SimpleServiceWithCustomRanking.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/services/SimpleServiceWithCustomRanking.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.services; +package org.apache.sling.models.it.testbundle.services; public class SimpleServiceWithCustomRanking implements SimpleService { diff --git a/src/test/java/org/apache/sling/models/it/services/TestBindingsValuesProvider.java b/src/test/java/org/apache/sling/models/it/testbundle/services/TestBindingsValuesProvider.java similarity index 95% rename from src/test/java/org/apache/sling/models/it/services/TestBindingsValuesProvider.java rename to src/test/java/org/apache/sling/models/it/testbundle/services/TestBindingsValuesProvider.java index a7dcb68..4f871db 100644 --- a/src/test/java/org/apache/sling/models/it/services/TestBindingsValuesProvider.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/services/TestBindingsValuesProvider.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.services; +package org.apache.sling.models.it.testbundle.services; import java.util.Collections; import java.util.HashMap; diff --git a/src/test/java/org/apache/sling/models/it/services/TestResourceDecorator.java b/src/test/java/org/apache/sling/models/it/testbundle/services/TestResourceDecorator.java similarity index 97% rename from src/test/java/org/apache/sling/models/it/services/TestResourceDecorator.java rename to src/test/java/org/apache/sling/models/it/testbundle/services/TestResourceDecorator.java index 8d2a0a1..e9d112d 100644 --- a/src/test/java/org/apache/sling/models/it/services/TestResourceDecorator.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/services/TestResourceDecorator.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.services; +package org.apache.sling.models.it.testbundle.services; import javax.servlet.http.HttpServletRequest; diff --git a/src/test/java/org/apache/sling/models/it/models/implextend/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/services/package-info.java similarity index 93% rename from src/test/java/org/apache/sling/models/it/models/implextend/package-info.java rename to src/test/java/org/apache/sling/models/it/testbundle/services/package-info.java index 3d4840c..b3c9b24 100644 --- a/src/test/java/org/apache/sling/models/it/models/implextend/package-info.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/services/package-info.java @@ -16,6 +16,6 @@ */ @Version("1.0") -package org.apache.sling.models.it.models.implextend; +package org.apache.sling.models.it.testbundle.services; import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/servlets/PathBoundJakartaServlet.java b/src/test/java/org/apache/sling/models/it/testbundle/servlets/PathBoundJakartaServlet.java similarity index 93% rename from src/test/java/org/apache/sling/models/it/servlets/PathBoundJakartaServlet.java rename to src/test/java/org/apache/sling/models/it/testbundle/servlets/PathBoundJakartaServlet.java index 4900f29..4068f13 100644 --- a/src/test/java/org/apache/sling/models/it/servlets/PathBoundJakartaServlet.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/servlets/PathBoundJakartaServlet.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.servlets; +package org.apache.sling.models.it.testbundle.servlets; import java.io.IOException; @@ -25,7 +25,7 @@ import org.apache.sling.api.SlingJakartaHttpServletRequest; import org.apache.sling.api.SlingJakartaHttpServletResponse; import org.apache.sling.api.servlets.SlingJakartaSafeMethodsServlet; -import org.apache.sling.models.it.models.JakartaRequestSelfModel; +import org.apache.sling.models.it.testbundle.models.JakartaRequestSelfModel; import org.apache.sling.servlets.annotations.SlingServletPaths; import org.jetbrains.annotations.NotNull; import org.osgi.service.component.annotations.Component; diff --git a/src/test/java/org/apache/sling/models/it/servlets/PathBoundServlet.java b/src/test/java/org/apache/sling/models/it/testbundle/servlets/PathBoundServlet.java similarity index 93% rename from src/test/java/org/apache/sling/models/it/servlets/PathBoundServlet.java rename to src/test/java/org/apache/sling/models/it/testbundle/servlets/PathBoundServlet.java index 7657275..9341119 100644 --- a/src/test/java/org/apache/sling/models/it/servlets/PathBoundServlet.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/servlets/PathBoundServlet.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.servlets; +package org.apache.sling.models.it.testbundle.servlets; import javax.servlet.Servlet; import javax.servlet.ServletException; @@ -26,7 +26,7 @@ import org.apache.sling.api.SlingHttpServletRequest; import org.apache.sling.api.SlingHttpServletResponse; import org.apache.sling.api.servlets.SlingSafeMethodsServlet; -import org.apache.sling.models.it.models.RequestSelfModel; +import org.apache.sling.models.it.testbundle.models.RequestSelfModel; import org.apache.sling.servlets.annotations.SlingServletPaths; import org.jetbrains.annotations.NotNull; import org.osgi.service.component.annotations.Component; From 56da0906a53238f843f7a1b64b1256ee0d34a668 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 23 Jan 2026 16:04:53 +0100 Subject: [PATCH 08/17] SLING-13050 generate IT test bundle on the fly --- pom.xml | 46 ++++++++- src/test/it-features/launcher.json | 2 +- .../customizers/SM_TeleporterCustomizer.java | 2 +- .../sling/models/it/GenerateTestBundle.java | 93 +++++++++++++++++++ .../delegate/request/package-info.java | 21 ----- .../delegate/resource/package-info.java | 21 ----- .../models/package-info.java | 21 ----- .../viaoriginalresource/package-info.java | 21 ----- .../testbundle/implpicker/package-info.java | 21 ----- .../models/implextend/package-info.java | 21 ----- .../it/testbundle/models/package-info.java | 21 ----- .../it/testbundle/rtbound/package-info.java | 21 ----- .../rtboundpicker/package-info.java | 21 ----- .../it/testbundle/services/package-info.java | 21 ----- .../models/it/{ => testing}/DecoratedIT.java | 2 +- .../it/{ => testing}/ImplementsExtendsIT.java | 2 +- .../InjectorSpecificAnnotationIT.java | 2 +- .../{ => testing}/ModelFactorySimpleIT.java | 2 +- .../it/{ => testing}/PathBoundServletIT.java | 6 +- ...erviceInjectionWithDifferentRankingIT.java | 2 +- .../models/it/{ => testing}/SimpleIT.java | 2 +- .../sling/models/it/{ => testing}/ViaIT.java | 2 +- .../delegate/DelegateRequestIT.java | 4 +- .../delegate/DelegateResourceIT.java | 2 +- .../ViaOriginalResourceDelegationIT.java | 4 +- .../it/{ => testing}/helper/FakeRequest.java | 2 +- .../it/{ => testing}/helper/FakeResponse.java | 2 +- .../it/{ => testing}/rtbound/FakeRequest.java | 2 +- .../rtbound/ResourceTypeBindingIT.java | 2 +- .../rtboundpicker/ResourceTypePickerIT.java | 2 +- 30 files changed, 160 insertions(+), 233 deletions(-) create mode 100644 src/test/java/org/apache/sling/models/it/GenerateTestBundle.java delete mode 100644 src/test/java/org/apache/sling/models/it/testbundle/delegate/request/package-info.java delete mode 100644 src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/package-info.java delete mode 100644 src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/package-info.java delete mode 100644 src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/package-info.java delete mode 100644 src/test/java/org/apache/sling/models/it/testbundle/implpicker/package-info.java delete mode 100644 src/test/java/org/apache/sling/models/it/testbundle/models/implextend/package-info.java delete mode 100644 src/test/java/org/apache/sling/models/it/testbundle/models/package-info.java delete mode 100644 src/test/java/org/apache/sling/models/it/testbundle/rtbound/package-info.java delete mode 100644 src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/package-info.java delete mode 100644 src/test/java/org/apache/sling/models/it/testbundle/services/package-info.java rename src/test/java/org/apache/sling/models/it/{ => testing}/DecoratedIT.java (98%) rename src/test/java/org/apache/sling/models/it/{ => testing}/ImplementsExtendsIT.java (99%) rename src/test/java/org/apache/sling/models/it/{ => testing}/InjectorSpecificAnnotationIT.java (98%) rename src/test/java/org/apache/sling/models/it/{ => testing}/ModelFactorySimpleIT.java (99%) rename src/test/java/org/apache/sling/models/it/{ => testing}/PathBoundServletIT.java (93%) rename src/test/java/org/apache/sling/models/it/{ => testing}/ServiceInjectionWithDifferentRankingIT.java (99%) rename src/test/java/org/apache/sling/models/it/{ => testing}/SimpleIT.java (98%) rename src/test/java/org/apache/sling/models/it/{ => testing}/ViaIT.java (98%) rename src/test/java/org/apache/sling/models/it/{ => testing}/delegate/DelegateRequestIT.java (97%) rename src/test/java/org/apache/sling/models/it/{ => testing}/delegate/DelegateResourceIT.java (98%) rename src/test/java/org/apache/sling/models/it/{ => testing}/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java (97%) rename src/test/java/org/apache/sling/models/it/{ => testing}/helper/FakeRequest.java (99%) rename src/test/java/org/apache/sling/models/it/{ => testing}/helper/FakeResponse.java (98%) rename src/test/java/org/apache/sling/models/it/{ => testing}/rtbound/FakeRequest.java (99%) rename src/test/java/org/apache/sling/models/it/{ => testing}/rtbound/ResourceTypeBindingIT.java (99%) rename src/test/java/org/apache/sling/models/it/{ => testing}/rtboundpicker/ResourceTypePickerIT.java (98%) diff --git a/pom.xml b/pom.xml index 94116ec..8982fac 100644 --- a/pom.xml +++ b/pom.xml @@ -290,6 +290,12 @@ 3.0.0 test + + io.github.classgraph + classgraph + 4.8.184 + test + @@ -367,6 +373,29 @@ + + + org.codehaus.mojo + exec-maven-plugin + 3.6.3 + + + generate-it-testbundle + + java + + prepare-package + + test + org.apache.sling.models.it.GenerateTestBundle + + ${project.build.directory}/it-testbundle.jar + + + + + + org.codehaus.mojo build-helper-maven-plugin @@ -383,6 +412,21 @@ + + attach-it-testbundle + + attach-artifact + + + + + ${project.build.directory}/it-testbundle.jar + jar + ittestbundle + + + + @@ -443,7 +487,7 @@ analyse-features attach-features - prepare-package + pre-integration-test diff --git a/src/test/it-features/launcher.json b/src/test/it-features/launcher.json index 291d66e..9d8bd65 100644 --- a/src/test/it-features/launcher.json +++ b/src/test/it-features/launcher.json @@ -9,7 +9,7 @@ "start-order": 20 }, { - "id": "org.apache.sling/org.apache.sling.models.impl.it.test-models/${project.version}", + "id": "org.apache.sling/org.apache.sling.models.impl/${project.version}//ittestbundle", "start-order": 20 } ], diff --git a/src/test/java/org/apache/sling/junit/teleporter/customizers/SM_TeleporterCustomizer.java b/src/test/java/org/apache/sling/junit/teleporter/customizers/SM_TeleporterCustomizer.java index ed04105..18b9efe 100644 --- a/src/test/java/org/apache/sling/junit/teleporter/customizers/SM_TeleporterCustomizer.java +++ b/src/test/java/org/apache/sling/junit/teleporter/customizers/SM_TeleporterCustomizer.java @@ -45,7 +45,7 @@ public void customize(TeleporterRule t, String options) { cst.setBaseUrl(S.getServerBaseUrl()); cst.setServerCredentials(S.getServerUsername(), S.getServerPassword()); cst.setTestReadyTimeoutSeconds(TimeoutsProvider.getInstance().getTimeout(5)); - cst.includeDependencyPrefix("org.apache.sling.models.testing"); + cst.includeDependencyPrefix("org.apache.sling.models.it.testing"); // additionally check for the registration of mandatory sling models components try (OsgiConsoleClient osgiClient = diff --git a/src/test/java/org/apache/sling/models/it/GenerateTestBundle.java b/src/test/java/org/apache/sling/models/it/GenerateTestBundle.java new file mode 100644 index 0000000..d121ae2 --- /dev/null +++ b/src/test/java/org/apache/sling/models/it/GenerateTestBundle.java @@ -0,0 +1,93 @@ +/* + * 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; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.List; +import java.util.Set; +import java.util.TreeSet; +import java.util.stream.Collectors; + +import io.github.classgraph.ClassGraph; +import io.github.classgraph.ClassInfo; +import io.github.classgraph.ScanResult; +import org.apache.sling.models.annotations.Model; +import org.ops4j.pax.tinybundles.TinyBundle; +import org.ops4j.pax.tinybundles.TinyBundles; +import org.osgi.framework.Constants; + +/** + * This uses tinybundles to create a test bundle that is deployed to sling + * starter. The test bundle contains all classes from the packages + * org.apache.sling.models.it.testbundle.* + */ +public class GenerateTestBundle { + + private static final String DUMMY_TEXT = "Dummy file for Integration Test bundle."; + + public static void main(String[] args) throws Exception { + Path outputFile = Paths.get(args[0]); + try (InputStream bundleStream = createBundle().build(TinyBundles.bndBuilder())) { + Files.copy(bundleStream, outputFile); + } + System.out.println("Test bundle created at " + outputFile.toAbsolutePath()); + } + + static TinyBundle createBundle() { + TinyBundle bundle = TinyBundles.bundle() + .setHeader(Constants.BUNDLE_NAME, "Apache Sling Models Implementation - IT Test Bundle") + .setHeader(Constants.BUNDLE_VERSION, "1.0.0-SNAPSHOT") + .setHeader(Constants.EXPORT_PACKAGE, "org.apache.sling.models.it.testbundle.*") + // optional import for 1 test case + .setHeader(Constants.IMPORT_PACKAGE, "org.apache.commons.beanutils;resolution:=optional,*") + // add dummy files to please verify-legal-files check + .addResource("META-INF/LICENSE", new ByteArrayInputStream(DUMMY_TEXT.getBytes(StandardCharsets.UTF_8))) + .addResource("META-INF/NOTICE", new ByteArrayInputStream(DUMMY_TEXT.getBytes(StandardCharsets.UTF_8))); + + // add all testbundle classes + Set modelClassNames = new TreeSet<>(); + getAllClasses().forEach(clazz -> { + bundle.addClass(clazz); + if (clazz.isAnnotationPresent(Model.class)) { + modelClassNames.add(clazz.getName()); + } + }); + + bundle.setHeader("Sling-Model-Classes", modelClassNames.stream().collect(Collectors.joining(","))); + + return bundle; + } + + /** + * Dynamically find all classes in classpath under package(s) org.apache.sling.models.it.testbundle.* + */ + static List> getAllClasses() { + try (ScanResult scanResult = new ClassGraph() + .enableClassInfo() + .acceptPackages("org.apache.sling.models.it.testbundle") + .scan()) { + return scanResult.getAllClasses().stream().map(ClassInfo::loadClass).collect(Collectors.toList()); + } + } +} diff --git a/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/package-info.java deleted file mode 100644 index ad984f5..0000000 --- a/src/test/java/org/apache/sling/models/it/testbundle/delegate/request/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.testbundle.delegate.request; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/package-info.java deleted file mode 100644 index 0b42b01..0000000 --- a/src/test/java/org/apache/sling/models/it/testbundle/delegate/resource/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.testbundle.delegate.resource; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/package-info.java deleted file mode 100644 index e2565dc..0000000 --- a/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/models/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.testbundle.delegate.viaoriginalresource.models; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/package-info.java deleted file mode 100644 index d657fc9..0000000 --- a/src/test/java/org/apache/sling/models/it/testbundle/delegate/viaoriginalresource/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.testbundle.delegate.viaoriginalresource; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/testbundle/implpicker/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/implpicker/package-info.java deleted file mode 100644 index f65a8f6..0000000 --- a/src/test/java/org/apache/sling/models/it/testbundle/implpicker/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.testbundle.implpicker; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/package-info.java deleted file mode 100644 index f600677..0000000 --- a/src/test/java/org/apache/sling/models/it/testbundle/models/implextend/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.testbundle.models.implextend; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/testbundle/models/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/models/package-info.java deleted file mode 100644 index 6bf456a..0000000 --- a/src/test/java/org/apache/sling/models/it/testbundle/models/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.testbundle.models; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/testbundle/rtbound/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/rtbound/package-info.java deleted file mode 100644 index bbbbeaa..0000000 --- a/src/test/java/org/apache/sling/models/it/testbundle/rtbound/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.testbundle.rtbound; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/package-info.java deleted file mode 100644 index f9c8f4b..0000000 --- a/src/test/java/org/apache/sling/models/it/testbundle/rtboundpicker/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.testbundle.rtboundpicker; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/testbundle/services/package-info.java b/src/test/java/org/apache/sling/models/it/testbundle/services/package-info.java deleted file mode 100644 index b3c9b24..0000000 --- a/src/test/java/org/apache/sling/models/it/testbundle/services/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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.testbundle.services; - -import org.osgi.annotation.versioning.Version; diff --git a/src/test/java/org/apache/sling/models/it/DecoratedIT.java b/src/test/java/org/apache/sling/models/it/testing/DecoratedIT.java similarity index 98% rename from src/test/java/org/apache/sling/models/it/DecoratedIT.java rename to src/test/java/org/apache/sling/models/it/testing/DecoratedIT.java index 4092ae0..d808af0 100644 --- a/src/test/java/org/apache/sling/models/it/DecoratedIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/DecoratedIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it; +package org.apache.sling.models.it.testing; import javax.jcr.Node; import javax.jcr.Session; diff --git a/src/test/java/org/apache/sling/models/it/ImplementsExtendsIT.java b/src/test/java/org/apache/sling/models/it/testing/ImplementsExtendsIT.java similarity index 99% rename from src/test/java/org/apache/sling/models/it/ImplementsExtendsIT.java rename to src/test/java/org/apache/sling/models/it/testing/ImplementsExtendsIT.java index fb1e9bf..b84f525 100644 --- a/src/test/java/org/apache/sling/models/it/ImplementsExtendsIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/ImplementsExtendsIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it; +package org.apache.sling.models.it.testing; import javax.jcr.Node; import javax.jcr.RepositoryException; diff --git a/src/test/java/org/apache/sling/models/it/InjectorSpecificAnnotationIT.java b/src/test/java/org/apache/sling/models/it/testing/InjectorSpecificAnnotationIT.java similarity index 98% rename from src/test/java/org/apache/sling/models/it/InjectorSpecificAnnotationIT.java rename to src/test/java/org/apache/sling/models/it/testing/InjectorSpecificAnnotationIT.java index 68cdd78..7b9cb71 100644 --- a/src/test/java/org/apache/sling/models/it/InjectorSpecificAnnotationIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/InjectorSpecificAnnotationIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it; +package org.apache.sling.models.it.testing; import javax.jcr.Node; import javax.jcr.Session; diff --git a/src/test/java/org/apache/sling/models/it/ModelFactorySimpleIT.java b/src/test/java/org/apache/sling/models/it/testing/ModelFactorySimpleIT.java similarity index 99% rename from src/test/java/org/apache/sling/models/it/ModelFactorySimpleIT.java rename to src/test/java/org/apache/sling/models/it/testing/ModelFactorySimpleIT.java index 7e4f05b..13dc9a5 100644 --- a/src/test/java/org/apache/sling/models/it/ModelFactorySimpleIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/ModelFactorySimpleIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it; +package org.apache.sling.models.it.testing; import javax.jcr.Node; import javax.jcr.Session; diff --git a/src/test/java/org/apache/sling/models/it/PathBoundServletIT.java b/src/test/java/org/apache/sling/models/it/testing/PathBoundServletIT.java similarity index 93% rename from src/test/java/org/apache/sling/models/it/PathBoundServletIT.java rename to src/test/java/org/apache/sling/models/it/testing/PathBoundServletIT.java index 5efef2d..5ebc12a 100644 --- a/src/test/java/org/apache/sling/models/it/PathBoundServletIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/PathBoundServletIT.java @@ -16,14 +16,14 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it; +package org.apache.sling.models.it.testing; import org.apache.sling.api.resource.ResourceResolver; import org.apache.sling.api.resource.ResourceResolverFactory; import org.apache.sling.engine.SlingRequestProcessor; import org.apache.sling.junit.rules.TeleporterRule; -import org.apache.sling.models.it.helper.FakeRequest; -import org.apache.sling.models.it.helper.FakeResponse; +import org.apache.sling.models.it.testing.helper.FakeRequest; +import org.apache.sling.models.it.testing.helper.FakeResponse; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; diff --git a/src/test/java/org/apache/sling/models/it/ServiceInjectionWithDifferentRankingIT.java b/src/test/java/org/apache/sling/models/it/testing/ServiceInjectionWithDifferentRankingIT.java similarity index 99% rename from src/test/java/org/apache/sling/models/it/ServiceInjectionWithDifferentRankingIT.java rename to src/test/java/org/apache/sling/models/it/testing/ServiceInjectionWithDifferentRankingIT.java index 29b4894..2aadd04 100644 --- a/src/test/java/org/apache/sling/models/it/ServiceInjectionWithDifferentRankingIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/ServiceInjectionWithDifferentRankingIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it; +package org.apache.sling.models.it.testing; import javax.jcr.Node; import javax.jcr.Session; diff --git a/src/test/java/org/apache/sling/models/it/SimpleIT.java b/src/test/java/org/apache/sling/models/it/testing/SimpleIT.java similarity index 98% rename from src/test/java/org/apache/sling/models/it/SimpleIT.java rename to src/test/java/org/apache/sling/models/it/testing/SimpleIT.java index 2d94f18..5539600 100644 --- a/src/test/java/org/apache/sling/models/it/SimpleIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/SimpleIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it; +package org.apache.sling.models.it.testing; import javax.jcr.Node; import javax.jcr.Session; diff --git a/src/test/java/org/apache/sling/models/it/ViaIT.java b/src/test/java/org/apache/sling/models/it/testing/ViaIT.java similarity index 98% rename from src/test/java/org/apache/sling/models/it/ViaIT.java rename to src/test/java/org/apache/sling/models/it/testing/ViaIT.java index 9db5d9f..c223cb6 100644 --- a/src/test/java/org/apache/sling/models/it/ViaIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/ViaIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it; +package org.apache.sling.models.it.testing; import javax.jcr.Node; import javax.jcr.Session; diff --git a/src/test/java/org/apache/sling/models/it/delegate/DelegateRequestIT.java b/src/test/java/org/apache/sling/models/it/testing/delegate/DelegateRequestIT.java similarity index 97% rename from src/test/java/org/apache/sling/models/it/delegate/DelegateRequestIT.java rename to src/test/java/org/apache/sling/models/it/testing/delegate/DelegateRequestIT.java index dd38d09..a2ea800 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/DelegateRequestIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/delegate/DelegateRequestIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate; +package org.apache.sling.models.it.testing.delegate; import java.util.HashMap; import java.util.Map; @@ -30,10 +30,10 @@ 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.rtbound.FakeRequest; import org.apache.sling.models.it.testbundle.delegate.request.DelegateBaseModel; import org.apache.sling.models.it.testbundle.delegate.request.DelegateExtendedModel; import org.apache.sling.models.it.testbundle.delegate.request.DelegateInterface; +import org.apache.sling.models.it.testing.rtbound.FakeRequest; import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/src/test/java/org/apache/sling/models/it/delegate/DelegateResourceIT.java b/src/test/java/org/apache/sling/models/it/testing/delegate/DelegateResourceIT.java similarity index 98% rename from src/test/java/org/apache/sling/models/it/delegate/DelegateResourceIT.java rename to src/test/java/org/apache/sling/models/it/testing/delegate/DelegateResourceIT.java index 0a0d21c..8a1b621 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/DelegateResourceIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/delegate/DelegateResourceIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate; +package org.apache.sling.models.it.testing.delegate; import java.util.HashMap; import java.util.Map; diff --git a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java b/src/test/java/org/apache/sling/models/it/testing/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java similarity index 97% rename from src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java rename to src/test/java/org/apache/sling/models/it/testing/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java index b4bd6bd..fe631ce 100644 --- a/src/test/java/org/apache/sling/models/it/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/delegate/viaoriginalresource/ViaOriginalResourceDelegationIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.delegate.viaoriginalresource; +package org.apache.sling.models.it.testing.delegate.viaoriginalresource; import java.util.HashMap; import java.util.Map; @@ -29,12 +29,12 @@ 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.rtbound.FakeRequest; import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.A; import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.models.A1Impl; import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.models.AImpl; import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.models.B1Impl; import org.apache.sling.models.it.testbundle.delegate.viaoriginalresource.models.BImpl; +import org.apache.sling.models.it.testing.rtbound.FakeRequest; import org.junit.Before; import org.junit.Rule; import org.junit.Test; diff --git a/src/test/java/org/apache/sling/models/it/helper/FakeRequest.java b/src/test/java/org/apache/sling/models/it/testing/helper/FakeRequest.java similarity index 99% rename from src/test/java/org/apache/sling/models/it/helper/FakeRequest.java rename to src/test/java/org/apache/sling/models/it/testing/helper/FakeRequest.java index 35f8725..97bb952 100644 --- a/src/test/java/org/apache/sling/models/it/helper/FakeRequest.java +++ b/src/test/java/org/apache/sling/models/it/testing/helper/FakeRequest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.helper; +package org.apache.sling.models.it.testing.helper; import javax.servlet.AsyncContext; import javax.servlet.DispatcherType; diff --git a/src/test/java/org/apache/sling/models/it/helper/FakeResponse.java b/src/test/java/org/apache/sling/models/it/testing/helper/FakeResponse.java similarity index 98% rename from src/test/java/org/apache/sling/models/it/helper/FakeResponse.java rename to src/test/java/org/apache/sling/models/it/testing/helper/FakeResponse.java index 70317cf..252e662 100644 --- a/src/test/java/org/apache/sling/models/it/helper/FakeResponse.java +++ b/src/test/java/org/apache/sling/models/it/testing/helper/FakeResponse.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.helper; +package org.apache.sling.models.it.testing.helper; import javax.servlet.ServletOutputStream; import javax.servlet.http.Cookie; diff --git a/src/test/java/org/apache/sling/models/it/rtbound/FakeRequest.java b/src/test/java/org/apache/sling/models/it/testing/rtbound/FakeRequest.java similarity index 99% rename from src/test/java/org/apache/sling/models/it/rtbound/FakeRequest.java rename to src/test/java/org/apache/sling/models/it/testing/rtbound/FakeRequest.java index d84705b..73f91e4 100644 --- a/src/test/java/org/apache/sling/models/it/rtbound/FakeRequest.java +++ b/src/test/java/org/apache/sling/models/it/testing/rtbound/FakeRequest.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.rtbound; +package org.apache.sling.models.it.testing.rtbound; import javax.servlet.AsyncContext; import javax.servlet.DispatcherType; diff --git a/src/test/java/org/apache/sling/models/it/rtbound/ResourceTypeBindingIT.java b/src/test/java/org/apache/sling/models/it/testing/rtbound/ResourceTypeBindingIT.java similarity index 99% rename from src/test/java/org/apache/sling/models/it/rtbound/ResourceTypeBindingIT.java rename to src/test/java/org/apache/sling/models/it/testing/rtbound/ResourceTypeBindingIT.java index a7af956..44d2a37 100644 --- a/src/test/java/org/apache/sling/models/it/rtbound/ResourceTypeBindingIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/rtbound/ResourceTypeBindingIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.rtbound; +package org.apache.sling.models.it.testing.rtbound; import java.util.HashMap; import java.util.Map; diff --git a/src/test/java/org/apache/sling/models/it/rtboundpicker/ResourceTypePickerIT.java b/src/test/java/org/apache/sling/models/it/testing/rtboundpicker/ResourceTypePickerIT.java similarity index 98% rename from src/test/java/org/apache/sling/models/it/rtboundpicker/ResourceTypePickerIT.java rename to src/test/java/org/apache/sling/models/it/testing/rtboundpicker/ResourceTypePickerIT.java index 9f5c654..42c87ee 100644 --- a/src/test/java/org/apache/sling/models/it/rtboundpicker/ResourceTypePickerIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/rtboundpicker/ResourceTypePickerIT.java @@ -16,7 +16,7 @@ * specific language governing permissions and limitations * under the License. */ -package org.apache.sling.models.it.rtboundpicker; +package org.apache.sling.models.it.testing.rtboundpicker; import java.util.HashMap; import java.util.Map; From ffba16acd5e95b046e663be697058c7883bd7fab Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 23 Jan 2026 16:35:38 +0100 Subject: [PATCH 09/17] SLING-13050 workaround to ensure Component Property Type from this annotation is applied properly --- .../java/org/apache/sling/models/it/GenerateTestBundle.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/test/java/org/apache/sling/models/it/GenerateTestBundle.java b/src/test/java/org/apache/sling/models/it/GenerateTestBundle.java index d121ae2..7903f4c 100644 --- a/src/test/java/org/apache/sling/models/it/GenerateTestBundle.java +++ b/src/test/java/org/apache/sling/models/it/GenerateTestBundle.java @@ -33,6 +33,7 @@ import io.github.classgraph.ClassInfo; import io.github.classgraph.ScanResult; import org.apache.sling.models.annotations.Model; +import org.apache.sling.servlets.annotations.SlingServletPaths; import org.ops4j.pax.tinybundles.TinyBundle; import org.ops4j.pax.tinybundles.TinyBundles; import org.osgi.framework.Constants; @@ -65,6 +66,9 @@ static TinyBundle createBundle() { .addResource("META-INF/LICENSE", new ByteArrayInputStream(DUMMY_TEXT.getBytes(StandardCharsets.UTF_8))) .addResource("META-INF/NOTICE", new ByteArrayInputStream(DUMMY_TEXT.getBytes(StandardCharsets.UTF_8))); + // workaround to ensure Component Property Type from this annotation is applied properly + bundle.addClass(SlingServletPaths.class); + // add all testbundle classes Set modelClassNames = new TreeSet<>(); getAllClasses().forEach(clazz -> { From 3409a2aa2ce9d2d8279ee23746cc28dc64dfb47a Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Fri, 23 Jan 2026 16:40:15 +0100 Subject: [PATCH 10/17] SLING-13050 rename classifier/feature --- pom.xml | 2 +- .../{launcher-repoinit.txt => it-launcher-repoinit.txt} | 0 src/test/it-features/{launcher.json => it-launcher.json} | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename src/test/it-features/{launcher-repoinit.txt => it-launcher-repoinit.txt} (100%) rename src/test/it-features/{launcher.json => it-launcher.json} (96%) diff --git a/pom.xml b/pom.xml index 8982fac..c5b41a0 100644 --- a/pom.xml +++ b/pom.xml @@ -422,7 +422,7 @@ ${project.build.directory}/it-testbundle.jar jar - ittestbundle + it-testbundle diff --git a/src/test/it-features/launcher-repoinit.txt b/src/test/it-features/it-launcher-repoinit.txt similarity index 100% rename from src/test/it-features/launcher-repoinit.txt rename to src/test/it-features/it-launcher-repoinit.txt diff --git a/src/test/it-features/launcher.json b/src/test/it-features/it-launcher.json similarity index 96% rename from src/test/it-features/launcher.json rename to src/test/it-features/it-launcher.json index 9d8bd65..95b9aa0 100644 --- a/src/test/it-features/launcher.json +++ b/src/test/it-features/it-launcher.json @@ -9,7 +9,7 @@ "start-order": 20 }, { - "id": "org.apache.sling/org.apache.sling.models.impl/${project.version}//ittestbundle", + "id": "org.apache.sling/org.apache.sling.models.impl/${project.version}//it-testbundle", "start-order": 20 } ], From 56c47e5a01b18c5e4773d332ce8e8f99a4fc283f Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 27 Jan 2026 12:58:02 +0100 Subject: [PATCH 11/17] SLING-13050 update feature launcher maven plugin --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c5b41a0..cccaeab 100644 --- a/pom.xml +++ b/pom.xml @@ -495,7 +495,7 @@ org.apache.sling feature-launcher-maven-plugin - 1.0.2 + 1.0.3-SNAPSHOT From 74f882ca5d37496338009c2ffeeb2aaec2138b1a Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 27 Jan 2026 13:34:52 +0100 Subject: [PATCH 12/17] SLING-13050 eliminate some sonar warnings --- .../org/apache/sling/models/impl/OptionalObjectsTest.java | 2 +- .../java/org/apache/sling/models/it/testing/DecoratedIT.java | 4 ++-- .../apache/sling/models/it/testing/ImplementsExtendsIT.java | 2 +- .../apache/sling/models/it/testing/PathBoundServletIT.java | 1 - .../it/testing/ServiceInjectionWithDifferentRankingIT.java | 3 +-- .../apache/sling/models/it/testing/helper/FakeRequest.java | 1 + .../apache/sling/models/it/testing/helper/FakeResponse.java | 1 + .../apache/sling/models/it/testing/rtbound/FakeRequest.java | 1 + 8 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/test/java/org/apache/sling/models/impl/OptionalObjectsTest.java b/src/test/java/org/apache/sling/models/impl/OptionalObjectsTest.java index e1cf5fa..541315d 100644 --- a/src/test/java/org/apache/sling/models/impl/OptionalObjectsTest.java +++ b/src/test/java/org/apache/sling/models/impl/OptionalObjectsTest.java @@ -163,7 +163,7 @@ public void testFieldInjectionListsAndArrays() { assertNotNull(model); assertEquals(4, model.getIntList().get().size()); - assertEquals(new Integer(2), model.getIntList().get().get(1)); + assertEquals(Integer.valueOf(2), model.getIntList().get().get(1)); assertEquals(2, model.getStringList().get().size()); assertEquals("hello", model.getStringList().get().get(0)); diff --git a/src/test/java/org/apache/sling/models/it/testing/DecoratedIT.java b/src/test/java/org/apache/sling/models/it/testing/DecoratedIT.java index d808af0..2d77576 100644 --- a/src/test/java/org/apache/sling/models/it/testing/DecoratedIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/DecoratedIT.java @@ -56,13 +56,13 @@ public void setUp() throws Exception { resolver = rrFactory.getServiceResourceResolver(null); Session session = resolver.adaptTo(Session.class); Node rootNode = session.getRootNode(); - Node createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + Node createdNode = rootNode.addNode("test_" + RandomStringUtils.secure().nextAlphanumeric(10)); createdNode.setProperty("decorate", true); session.save(); resourceWithDefaultWrapperBehavior = resolver.getResource(createdNode.getPath()); - createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + createdNode = rootNode.addNode("test_" + RandomStringUtils.secure().nextAlphanumeric(10)); createdNode.setProperty("decorate", "customAdaptTo"); session.save(); diff --git a/src/test/java/org/apache/sling/models/it/testing/ImplementsExtendsIT.java b/src/test/java/org/apache/sling/models/it/testing/ImplementsExtendsIT.java index b84f525..06fc724 100644 --- a/src/test/java/org/apache/sling/models/it/testing/ImplementsExtendsIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/ImplementsExtendsIT.java @@ -77,7 +77,7 @@ public void setUp() throws Exception { } @After - public void after() throws Exception { + public void after() { if (resolver != null) { resolver.close(); } diff --git a/src/test/java/org/apache/sling/models/it/testing/PathBoundServletIT.java b/src/test/java/org/apache/sling/models/it/testing/PathBoundServletIT.java index 5ebc12a..bd6360b 100644 --- a/src/test/java/org/apache/sling/models/it/testing/PathBoundServletIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/PathBoundServletIT.java @@ -38,7 +38,6 @@ public class PathBoundServletIT { private SlingRequestProcessor slingRequestProcessor; @Before - @SuppressWarnings("null") public void setup() { rrFactory = teleporter.getService(ResourceResolverFactory.class); slingRequestProcessor = teleporter.getService(SlingRequestProcessor.class); diff --git a/src/test/java/org/apache/sling/models/it/testing/ServiceInjectionWithDifferentRankingIT.java b/src/test/java/org/apache/sling/models/it/testing/ServiceInjectionWithDifferentRankingIT.java index 2aadd04..f543678 100644 --- a/src/test/java/org/apache/sling/models/it/testing/ServiceInjectionWithDifferentRankingIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/ServiceInjectionWithDifferentRankingIT.java @@ -21,7 +21,6 @@ import javax.jcr.Node; import javax.jcr.Session; -import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Dictionary; @@ -108,7 +107,7 @@ private void registerSimpleService(int ranking) { } @Test - public void testServiceInjectionConsideringRankingWithResource() throws IOException { + public void testServiceInjectionConsideringRankingWithResource() { registerSimpleService(0); // cannot use adaptTo due to adaptersCache diff --git a/src/test/java/org/apache/sling/models/it/testing/helper/FakeRequest.java b/src/test/java/org/apache/sling/models/it/testing/helper/FakeRequest.java index 97bb952..18cf7ea 100644 --- a/src/test/java/org/apache/sling/models/it/testing/helper/FakeRequest.java +++ b/src/test/java/org/apache/sling/models/it/testing/helper/FakeRequest.java @@ -44,6 +44,7 @@ import java.util.Locale; import java.util.Map; +@SuppressWarnings("java:S1186") // ignore empty method warnings public class FakeRequest implements HttpServletRequest { private final String path; diff --git a/src/test/java/org/apache/sling/models/it/testing/helper/FakeResponse.java b/src/test/java/org/apache/sling/models/it/testing/helper/FakeResponse.java index 252e662..6d46c68 100644 --- a/src/test/java/org/apache/sling/models/it/testing/helper/FakeResponse.java +++ b/src/test/java/org/apache/sling/models/it/testing/helper/FakeResponse.java @@ -28,6 +28,7 @@ import java.util.Collection; import java.util.Locale; +@SuppressWarnings("java:S1186") // ignore empty method warnings public class FakeResponse implements HttpServletResponse { private StringWriter stringWriter = new StringWriter(); diff --git a/src/test/java/org/apache/sling/models/it/testing/rtbound/FakeRequest.java b/src/test/java/org/apache/sling/models/it/testing/rtbound/FakeRequest.java index 73f91e4..5e0fa93 100644 --- a/src/test/java/org/apache/sling/models/it/testing/rtbound/FakeRequest.java +++ b/src/test/java/org/apache/sling/models/it/testing/rtbound/FakeRequest.java @@ -54,6 +54,7 @@ import org.apache.sling.api.resource.ResourceResolver; import org.jetbrains.annotations.NotNull; +@SuppressWarnings("java:S1186") // ignore empty method warnings public class FakeRequest implements SlingHttpServletRequest { private final Resource resource; From fe48474d9a2709f4067c27b22a836f6a3bd52acd Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 27 Jan 2026 13:53:55 +0100 Subject: [PATCH 13/17] SLING-13050 eliminate some sonar warnings --- .../implpicker/CustomLastImplementationPicker.java | 4 ++-- .../it/testbundle/services/TestResourceDecorator.java | 1 + .../apache/sling/models/it/testing/ImplementsExtendsIT.java | 6 +++--- .../models/it/testing/InjectorSpecificAnnotationIT.java | 4 ++-- .../sling/models/it/testing/ModelFactorySimpleIT.java | 4 ++-- .../it/testing/ServiceInjectionWithDifferentRankingIT.java | 4 ++-- .../java/org/apache/sling/models/it/testing/SimpleIT.java | 6 +++--- src/test/java/org/apache/sling/models/it/testing/ViaIT.java | 4 ++-- 8 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/test/java/org/apache/sling/models/it/testbundle/implpicker/CustomLastImplementationPicker.java b/src/test/java/org/apache/sling/models/it/testbundle/implpicker/CustomLastImplementationPicker.java index 6d8faf4..cc14251 100644 --- a/src/test/java/org/apache/sling/models/it/testbundle/implpicker/CustomLastImplementationPicker.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/implpicker/CustomLastImplementationPicker.java @@ -18,7 +18,7 @@ */ package org.apache.sling.models.it.testbundle.implpicker; -import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Strings; import org.apache.sling.api.resource.Resource; import org.apache.sling.models.spi.ImplementationPicker; import org.jetbrains.annotations.NotNull; @@ -36,7 +36,7 @@ public class CustomLastImplementationPicker implements ImplementationPicker { public static final String CUSTOM_NAME = "custom"; public Class pick(@NotNull Class adapterType, Class[] implementationsTypes, @NotNull Object adaptable) { - if (adaptable instanceof Resource && StringUtils.equals(((Resource) adaptable).getName(), CUSTOM_NAME)) { + if (adaptable instanceof Resource && Strings.CS.equals(((Resource) adaptable).getName(), CUSTOM_NAME)) { return implementationsTypes[implementationsTypes.length - 1]; } return null; diff --git a/src/test/java/org/apache/sling/models/it/testbundle/services/TestResourceDecorator.java b/src/test/java/org/apache/sling/models/it/testbundle/services/TestResourceDecorator.java index e9d112d..d09cb99 100644 --- a/src/test/java/org/apache/sling/models/it/testbundle/services/TestResourceDecorator.java +++ b/src/test/java/org/apache/sling/models/it/testbundle/services/TestResourceDecorator.java @@ -60,6 +60,7 @@ public AdapterType adaptTo(Class type) { } @Override + @Deprecated public Resource decorate(@NotNull Resource resource, @NotNull HttpServletRequest request) { return decorate(resource); } diff --git a/src/test/java/org/apache/sling/models/it/testing/ImplementsExtendsIT.java b/src/test/java/org/apache/sling/models/it/testing/ImplementsExtendsIT.java index 06fc724..0724a38 100644 --- a/src/test/java/org/apache/sling/models/it/testing/ImplementsExtendsIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/ImplementsExtendsIT.java @@ -62,13 +62,13 @@ public class ImplementsExtendsIT { public void setUp() throws Exception { ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); adapterManager = teleporter.getService(AdapterManager.class); - firstValue = RandomStringUtils.randomAlphanumeric(10); - thirdValue = RandomStringUtils.randomAlphanumeric(10); + firstValue = RandomStringUtils.secure().nextAlphanumeric(10); + thirdValue = RandomStringUtils.secure().nextAlphanumeric(10); resolver = rrFactory.getServiceResourceResolver(null); Session session = resolver.adaptTo(Session.class); Node rootNode = session.getRootNode(); - createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + createdNode = rootNode.addNode("test_" + RandomStringUtils.secure().nextAlphanumeric(10)); createdNode.setProperty("first", firstValue); createdNode.setProperty("third", thirdValue); session.save(); diff --git a/src/test/java/org/apache/sling/models/it/testing/InjectorSpecificAnnotationIT.java b/src/test/java/org/apache/sling/models/it/testing/InjectorSpecificAnnotationIT.java index 7b9cb71..de736d4 100644 --- a/src/test/java/org/apache/sling/models/it/testing/InjectorSpecificAnnotationIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/InjectorSpecificAnnotationIT.java @@ -42,7 +42,7 @@ public class InjectorSpecificAnnotationIT { @SuppressWarnings("null") public void test() throws Exception { ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); - String value = RandomStringUtils.randomAlphanumeric(10); + String value = RandomStringUtils.secure().nextAlphanumeric(10); ResourceResolver resolver = null; Node createdNode = null; @@ -50,7 +50,7 @@ public void test() throws Exception { resolver = rrFactory.getServiceResourceResolver(null); Session session = resolver.adaptTo(Session.class); Node rootNode = session.getRootNode(); - createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + createdNode = rootNode.addNode("test_" + RandomStringUtils.secure().nextAlphanumeric(10)); createdNode.setProperty("testProperty", value); session.save(); diff --git a/src/test/java/org/apache/sling/models/it/testing/ModelFactorySimpleIT.java b/src/test/java/org/apache/sling/models/it/testing/ModelFactorySimpleIT.java index 13dc9a5..3a80f8c 100644 --- a/src/test/java/org/apache/sling/models/it/testing/ModelFactorySimpleIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/ModelFactorySimpleIT.java @@ -60,12 +60,12 @@ public class ModelFactorySimpleIT { public void setUp() throws Exception { ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); modelFactory = teleporter.getService(ModelFactory.class); - value = RandomStringUtils.randomAlphanumeric(10); + value = RandomStringUtils.secure().nextAlphanumeric(10); resolver = rrFactory.getServiceResourceResolver(null); Session session = resolver.adaptTo(Session.class); Node rootNode = session.getRootNode(); - createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + createdNode = rootNode.addNode("test_" + RandomStringUtils.secure().nextAlphanumeric(10)); createdNode.setProperty("testProperty", value); session.save(); diff --git a/src/test/java/org/apache/sling/models/it/testing/ServiceInjectionWithDifferentRankingIT.java b/src/test/java/org/apache/sling/models/it/testing/ServiceInjectionWithDifferentRankingIT.java index f543678..1396343 100644 --- a/src/test/java/org/apache/sling/models/it/testing/ServiceInjectionWithDifferentRankingIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/ServiceInjectionWithDifferentRankingIT.java @@ -67,12 +67,12 @@ public class ServiceInjectionWithDifferentRankingIT { public void setUp() throws Exception { ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); modelFactory = teleporter.getService(ModelFactory.class); - value = RandomStringUtils.randomAlphanumeric(10); + value = RandomStringUtils.secure().nextAlphanumeric(10); resolver = rrFactory.getServiceResourceResolver(null); Session session = resolver.adaptTo(Session.class); Node rootNode = session.getRootNode(); - createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + createdNode = rootNode.addNode("test_" + RandomStringUtils.secure().nextAlphanumeric(10)); createdNode.setProperty("testProperty", value); session.save(); diff --git a/src/test/java/org/apache/sling/models/it/testing/SimpleIT.java b/src/test/java/org/apache/sling/models/it/testing/SimpleIT.java index 5539600..959a2b4 100644 --- a/src/test/java/org/apache/sling/models/it/testing/SimpleIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/SimpleIT.java @@ -53,13 +53,13 @@ public class SimpleIT { @SuppressWarnings("null") public void setUp() throws Exception { ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); - value = RandomStringUtils.randomAlphanumeric(10); - childValue = RandomStringUtils.randomAlphanumeric(10); + value = RandomStringUtils.secure().nextAlphanumeric(10); + childValue = RandomStringUtils.secure().nextAlphanumeric(10); resolver = rrFactory.getServiceResourceResolver(null); Session session = resolver.adaptTo(Session.class); Node rootNode = session.getRootNode(); - createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + createdNode = rootNode.addNode("test_" + RandomStringUtils.secure().nextAlphanumeric(10)); createdNode.setProperty("testProperty", value); Node child = createdNode.addNode("child"); child.setProperty("childProperty", childValue); diff --git a/src/test/java/org/apache/sling/models/it/testing/ViaIT.java b/src/test/java/org/apache/sling/models/it/testing/ViaIT.java index c223cb6..b447f4c 100644 --- a/src/test/java/org/apache/sling/models/it/testing/ViaIT.java +++ b/src/test/java/org/apache/sling/models/it/testing/ViaIT.java @@ -46,7 +46,7 @@ public void test() throws Exception { ResourceResolverFactory rrFactory = teleporter.getService(ResourceResolverFactory.class); AdapterManager adapterManager = teleporter.getService(AdapterManager.class); - String value = RandomStringUtils.randomAlphanumeric(10); + String value = RandomStringUtils.secure().nextAlphanumeric(10); ResourceResolver resolver = null; Node createdNode = null; @@ -54,7 +54,7 @@ public void test() throws Exception { resolver = rrFactory.getServiceResourceResolver(null); Session session = resolver.adaptTo(Session.class); Node rootNode = session.getRootNode(); - createdNode = rootNode.addNode("test_" + RandomStringUtils.randomAlphanumeric(10)); + createdNode = rootNode.addNode("test_" + RandomStringUtils.secure().nextAlphanumeric(10)); createdNode.setProperty("testProperty", value); session.save(); From f23d63e4f63a09481f3ec49a072581e4591e607b Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 27 Jan 2026 14:14:37 +0100 Subject: [PATCH 14/17] SLING-13050 add jacoco code coverage --- pom.xml | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/pom.xml b/pom.xml index cccaeab..e352c5f 100644 --- a/pom.xml +++ b/pom.xml @@ -409,6 +409,7 @@ http.port + jacoco.port @@ -430,6 +431,42 @@ + + org.jacoco + jacoco-maven-plugin + + + + prepare-agent-integration-launcher + + prepare-agent-integration + + + jacoco.launcher.command + tcpserver +
localhost
+ ${jacoco.port} +
+
+ + dump-coverage-launcher + + dump + + post-integration-test + +
localhost
+ ${jacoco.port} + ${project.build.directory}/jacoco-it.exec + true +
+
+
+
+ org.apache.sling slingfeature-maven-plugin @@ -510,6 +547,7 @@ --add-opens java.base/java.lang=ALL-UNNAMED + ${jacoco.launcher.command} ${http.port} From 4ab151457c7a4f8354e1a639c50f2fbfab4a9d25 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Tue, 27 Jan 2026 14:44:35 +0100 Subject: [PATCH 15/17] SLING-13050 add comment --- src/test/java/org/apache/sling/models/it/GenerateTestBundle.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/java/org/apache/sling/models/it/GenerateTestBundle.java b/src/test/java/org/apache/sling/models/it/GenerateTestBundle.java index 7903f4c..4bd2eaa 100644 --- a/src/test/java/org/apache/sling/models/it/GenerateTestBundle.java +++ b/src/test/java/org/apache/sling/models/it/GenerateTestBundle.java @@ -78,6 +78,7 @@ static TinyBundle createBundle() { } }); + // register sling models bundle.setHeader("Sling-Model-Classes", modelClassNames.stream().collect(Collectors.joining(","))); return bundle; From 6ac4da2774bc3d7a33325cf9f3d5b922047e0999 Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 28 Jan 2026 13:15:57 +0100 Subject: [PATCH 16/17] SLING-13050 set models debug level for ITs by default --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index e352c5f..8ee787d 100644 --- a/pom.xml +++ b/pom.xml @@ -45,7 +45,7 @@ 14-SNAPSHOT 200 60 - info + debug From 548ce58c043e3a5df9fa9369e3b13eb34576994d Mon Sep 17 00:00:00 2001 From: Stefan Seifert Date: Wed, 28 Jan 2026 13:29:40 +0100 Subject: [PATCH 17/17] SLING-13050 update dependency --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8ee787d..581a73f 100644 --- a/pom.xml +++ b/pom.xml @@ -244,7 +244,7 @@ commons-beanutils commons-beanutils - 1.9.4 + 1.11.0 test