Author: justin
Date: Mon Mar 3 17:58:20 2014
New Revision: 1573638
URL: http://svn.apache.org/r1573638
Log:
SLING-3430 - only embedding necessary parts of beanutils
Added:
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/ViaTest.java
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/SourceObject.java
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/ViaModel.java
Modified:
sling/trunk/bundles/extensions/models/impl/pom.xml
Modified: sling/trunk/bundles/extensions/models/impl/pom.xml
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/impl/pom.xml?rev=1573638&r1=1573637&r2=1573638&view=diff
==============================================================================
--- sling/trunk/bundles/extensions/models/impl/pom.xml (original)
+++ sling/trunk/bundles/extensions/models/impl/pom.xml Mon Mar 3 17:58:20 2014
@@ -52,7 +52,7 @@
<configuration>
<instructions>
<Embed-Dependency>
- *;scope=compile,
+
commons-beanutils;inline="org/apache/commons/beanutils/PropertyUtils.class|org/apache/commons/beanutils/PropertyUtilsBean.class|org/apache/commons/beanutils/DynaProperty.class|org/apache/commons/beanutils/expression/*.class",
org.osgi.compendium;inline="org/osgi/util/tracker/*"</Embed-Dependency>
</instructions>
</configuration>
Added:
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/ViaTest.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/ViaTest.java?rev=1573638&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/ViaTest.java
(added)
+++
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/ViaTest.java
Mon Mar 3 17:58:20 2014
@@ -0,0 +1,75 @@
+/*
+ * 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 static org.junit.Assert.*;
+
+import javax.jcr.Node;
+import javax.jcr.Session;
+
+import org.apache.commons.lang.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.annotations.SlingAnnotationsTestRunner;
+import org.apache.sling.junit.annotations.TestReference;
+import org.apache.sling.models.it.models.SourceObject;
+import org.apache.sling.models.it.models.ViaModel;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(SlingAnnotationsTestRunner.class)
+public class ViaTest {
+
+ @TestReference
+ private ResourceResolverFactory rrFactory;
+
+ @TestReference
+ private AdapterManager adapterManager;
+
+ @Test
+ public void test() throws Exception {
+ String value = RandomStringUtils.randomAlphanumeric(10);
+
+ ResourceResolver resolver = null;
+ Node createdNode = null;
+ try {
+ resolver = rrFactory.getAdministrativeResourceResolver(null);
+ Session session = resolver.adaptTo(Session.class);
+ Node rootNode = session.getRootNode();
+ createdNode = rootNode.addNode("test_" +
RandomStringUtils.randomAlphanumeric(10));
+ createdNode.setProperty("testProperty", value);
+ session.save();
+
+ Resource resource = resolver.getResource(createdNode.getPath());
+ 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();
+ }
+ }
+ }
+}
Added:
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/SourceObject.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/SourceObject.java?rev=1573638&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/SourceObject.java
(added)
+++
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/SourceObject.java
Mon Mar 3 17:58:20 2014
@@ -0,0 +1,33 @@
+/*
+ * 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;
+ }
+
+}
Added:
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/ViaModel.java
URL:
http://svn.apache.org/viewvc/sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/ViaModel.java?rev=1573638&view=auto
==============================================================================
---
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/ViaModel.java
(added)
+++
sling/trunk/bundles/extensions/models/integration-tests/src/main/java/org/apache/sling/models/it/models/ViaModel.java
Mon Mar 3 17:58:20 2014
@@ -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 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;
+ }
+}