Author: dulvac Date: Mon Mar 27 11:42:33 2017 New Revision: 1788906 URL: http://svn.apache.org/viewvc?rev=1788906&view=rev Log: SLING-6709 The HAPI implementation doesn't provide the correct attribute type for "itemscope" * Added unit test
Added: sling/trunk/contrib/extensions/hapi/core/src/test/ sling/trunk/contrib/extensions/hapi/core/src/test/java/ sling/trunk/contrib/extensions/hapi/core/src/test/java/org/ sling/trunk/contrib/extensions/hapi/core/src/test/java/org/apache/ sling/trunk/contrib/extensions/hapi/core/src/test/java/org/apache/sling/ sling/trunk/contrib/extensions/hapi/core/src/test/java/org/apache/sling/hapi/ sling/trunk/contrib/extensions/hapi/core/src/test/java/org/apache/sling/hapi/MicrodataAttributeHelperTest.java Modified: sling/trunk/contrib/extensions/hapi/core/pom.xml Modified: sling/trunk/contrib/extensions/hapi/core/pom.xml URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/core/pom.xml?rev=1788906&r1=1788905&r2=1788906&view=diff ============================================================================== --- sling/trunk/contrib/extensions/hapi/core/pom.xml (original) +++ sling/trunk/contrib/extensions/hapi/core/pom.xml Mon Mar 27 11:42:33 2017 @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.sling</groupId> <artifactId>sling</artifactId> - <version>26</version> + <version>28</version> <relativePath /> </parent> @@ -72,25 +72,25 @@ <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.commons.osgi</artifactId> - <version>2.1.0</version> + <version>2.4.0</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.api</artifactId> - <version>2.3.0</version> + <version>2.14.2</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.scripting.api</artifactId> - <version>2.1.0</version> + <version>2.1.8</version> <scope>provided</scope> </dependency> <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.commons.json</artifactId> - <version>2.0.6</version> + <version>2.0.18</version> <scope>provided</scope> </dependency> <dependency> @@ -102,7 +102,7 @@ <dependency> <groupId>org.apache.felix</groupId> <artifactId>org.apache.felix.scr.annotations</artifactId> - <version>1.9.6</version> + <version>1.11.0</version> <scope>provided</scope> </dependency> <dependency> @@ -113,10 +113,12 @@ <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.core</artifactId> + <version>6.0.0</version> </dependency> <dependency> <groupId>org.osgi</groupId> <artifactId>org.osgi.compendium</artifactId> + <version>5.0.0</version> </dependency> <dependency> <groupId>org.slf4j</groupId> @@ -128,5 +130,10 @@ <version>1.0.18</version> <scope>provided</scope> </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> </dependencies> </project> Added: sling/trunk/contrib/extensions/hapi/core/src/test/java/org/apache/sling/hapi/MicrodataAttributeHelperTest.java URL: http://svn.apache.org/viewvc/sling/trunk/contrib/extensions/hapi/core/src/test/java/org/apache/sling/hapi/MicrodataAttributeHelperTest.java?rev=1788906&view=auto ============================================================================== --- sling/trunk/contrib/extensions/hapi/core/src/test/java/org/apache/sling/hapi/MicrodataAttributeHelperTest.java (added) +++ sling/trunk/contrib/extensions/hapi/core/src/test/java/org/apache/sling/hapi/MicrodataAttributeHelperTest.java Mon Mar 27 11:42:33 2017 @@ -0,0 +1,71 @@ +/******************************************************************************* + * 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 + * <p/> + * http://www.apache.org/licenses/LICENSE-2.0 + * <p/> + * 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.hapi; + +import org.apache.sling.hapi.impl.HApiPropertyImpl; +import org.apache.sling.hapi.impl.HApiTypeImpl; +import org.apache.sling.hapi.impl.MicrodataAttributeHelperImpl; +import org.hamcrest.core.StringContains; +import org.junit.Assert; +import org.junit.Test; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +public class MicrodataAttributeHelperTest { + + public static final String SERVER_URL = "http://localhost:8080"; + public static final String TEST_PROP = "testProp"; + + static HApiType propType = new HApiTypeImpl("propType", "propTypeDesc", SERVER_URL, "/a/b/propType", "a.b.propType", null, + Collections.<String, HApiProperty>emptyMap(), null, false); + static HApiProperty prop = new HApiPropertyImpl(TEST_PROP, "test property", propType, false); + static Map<String, HApiProperty> props; + static { + Map<String, HApiProperty> map = new HashMap<String, HApiProperty>(); + map.put(TEST_PROP, prop); + props = Collections.unmodifiableMap(map); + } + + HApiType type = new HApiTypeImpl("testType", "testDescription", SERVER_URL, "/a/b/c/testType", "a.b.c.testType", + null, props, null, false); + + MicrodataAttributeHelper helper = new MicrodataAttributeHelperImpl(null, type); + + @Test + public void testItemType() throws Exception { + final String itemtype = helper.itemtype(); + Assert.assertThat("itemtype attr is wrong or not present", itemtype, + StringContains.containsString("itemtype=\"http://localhost:8080/a/b/c/testType.html\"")); + Assert.assertThat("itemscope attr is wrong or not present", itemtype, + StringContains.containsString("itemscope=\"itemscope\"")); + } + + @Test + public void testItemProp() throws Exception { + final String itemprop = helper.itemprop(TEST_PROP); + Assert.assertThat("itemprop attr is wrong or not present", itemprop, + StringContains.containsString("itemprop=\"" + TEST_PROP + "\"")); + Assert.assertThat("itemscopee attr is wrong or not present", itemprop, + StringContains.containsString("itemscope=\"itemscope\"")); + Assert.assertThat("itemscopee attr is wrong or not present", itemprop, + StringContains.containsString("itemtype=\"http://localhost:8080/a/b/propType.html\"")); + } +}