You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2020/04/20 13:52:47 UTC
[felix-dev] branch master updated: FELIX-6261 : Finish test and add
assertions for property tags without a value
This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new 1e28a6a FELIX-6261 : Finish test and add assertions for property tags without a value
1e28a6a is described below
commit 1e28a6ab057e3f84c502a1bb26045fcb01b1ed0b
Author: Carsten Ziegeler <cz...@apache.org>
AuthorDate: Mon Apr 20 15:51:32 2020 +0200
FELIX-6261 : Finish test and add assertions for property tags without a value
---
.../org/apache/felix/scr/impl/xml/XmlHandlerTest.java | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/scr/src/test/java/org/apache/felix/scr/impl/xml/XmlHandlerTest.java b/scr/src/test/java/org/apache/felix/scr/impl/xml/XmlHandlerTest.java
index 94d8c62..5484acd 100755
--- a/scr/src/test/java/org/apache/felix/scr/impl/xml/XmlHandlerTest.java
+++ b/scr/src/test/java/org/apache/felix/scr/impl/xml/XmlHandlerTest.java
@@ -18,14 +18,19 @@
*/
package org.apache.felix.scr.impl.xml;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.util.List;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
import org.apache.felix.scr.impl.logger.MockBundleLogger;
+import org.apache.felix.scr.impl.metadata.ComponentMetadata;
import org.junit.Test;
import org.mockito.Mockito;
import org.osgi.framework.Bundle;
@@ -35,10 +40,19 @@ public class XmlHandlerTest {
@Test
public void testPropertiesWithoutValue() throws Exception {
final URL url = this.getClass().getClassLoader().getResource("parsertest-nopropvalue.xml");
- parse(url);
+ final List<ComponentMetadata> components = parse(url);
+ assertEquals(1, components.size());
+
+ final ComponentMetadata cm = components.get(0);
+ cm.validate();
+ // the xml has four properties, two of them with no value, so they should not be part of the
+ // component metadata
+ assertEquals(2, cm.getProperties().size());
+ assertNotNull(cm.getProperties().get("service.vendor"));
+ assertNotNull(cm.getProperties().get("jmx.objectname"));
}
- private void parse(final URL descriptorURL) throws Exception {
+ private List<ComponentMetadata> parse(final URL descriptorURL) throws Exception {
final Bundle bundle = Mockito.mock(Bundle.class);
Mockito.when(bundle.getLocation()).thenReturn("bundle");
@@ -53,6 +67,7 @@ public class XmlHandlerTest {
parser.parse(stream, handler);
+ return handler.getComponentMetadataList();
} finally {
if (stream != null) {
try {