You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ro...@apache.org on 2017/10/18 23:24:36 UTC
[sling-org-apache-sling-hapi] 20/27: SLING-6709 The HAPI
implementation doesn't provide the correct attribute type for "itemscope" *
Added unit test
This is an automated email from the ASF dual-hosted git repository.
rombert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-hapi.git
commit a1b37a93c1f13fccccd6c6302011f21eff10a8e9
Author: Andrei Dulvac <du...@apache.org>
AuthorDate: Mon Mar 27 11:42:33 2017 +0000
SLING-6709 The HAPI implementation doesn't provide the correct attribute type for "itemscope"
* Added unit test
git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1788906 13f79535-47bb-0310-9956-ffa450edef68
---
pom.xml | 19 ++++--
.../sling/hapi/MicrodataAttributeHelperTest.java | 71 ++++++++++++++++++++++
2 files changed, 84 insertions(+), 6 deletions(-)
diff --git a/pom.xml b/pom.xml
index 572c840..2545d3d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -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>
diff --git a/src/test/java/org/apache/sling/hapi/MicrodataAttributeHelperTest.java b/src/test/java/org/apache/sling/hapi/MicrodataAttributeHelperTest.java
new file mode 100644
index 0000000..711ce64
--- /dev/null
+++ b/src/test/java/org/apache/sling/hapi/MicrodataAttributeHelperTest.java
@@ -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\""));
+ }
+}
--
To stop receiving notification emails like this one, please contact
"commits@sling.apache.org" <co...@sling.apache.org>.