You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@aries.apache.org by jw...@apache.org on 2015/09/29 16:18:22 UTC
svn commit: r1705868 - in /aries/trunk/subsystem:
subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/
subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/
subsystem-itests/src/test/java/org/apache/aries/subsystem/ites...
Author: jwross
Date: Tue Sep 29 14:18:21 2015
New Revision: 1705868
URL: http://svn.apache.org/viewvc?rev=1705868&view=rev
Log:
ARIES-1423 IllegalArgumentException when GenericHeader has no clauses
Treat an empty string generic header value the same as an empty quoted string.
This change has the following consequences.
(1) Non-osgi headers with empty string values will pass through without issue. Subsystem headers falling under this category will show up in the generated
manifests with an empty quoted string value. Those with non-empty string values should also not be an issue since the OSGi syntax is compatible with JAR
syntax.
(2) Unmapped OSGi headers (i.e. those without a dedicated class) with empty string values will also be accepted, at least initially, but made syntactically
correct. Those that are recognized will likely still fail once a more robust parsing occurs according to the semantics of the individual header.
Added:
aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/GenericHeaderTest.java
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1423Test.java
Modified:
aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/GenericHeader.java
aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
Modified: aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/GenericHeader.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/GenericHeader.java?rev=1705868&r1=1705867&r2=1705868&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/GenericHeader.java (original)
+++ aries/trunk/subsystem/subsystem-core/src/main/java/org/apache/aries/subsystem/core/archive/GenericHeader.java Tue Sep 29 14:18:21 2015
@@ -35,7 +35,7 @@ public class GenericHeader extends Abstr
public GenericHeader(String name, String value) {
super(
- value,
+ value.isEmpty() ? "\"\"" : value,
new ClauseFactory<Clause>() {
@Override
public Clause newInstance(String clause) {
Added: aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/GenericHeaderTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/GenericHeaderTest.java?rev=1705868&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/GenericHeaderTest.java (added)
+++ aries/trunk/subsystem/subsystem-core/src/test/java/org/apache/aries/subsystem/core/archive/GenericHeaderTest.java Tue Sep 29 14:18:21 2015
@@ -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.aries.subsystem.core.archive;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+
+public class GenericHeaderTest {
+ @Test
+ public void testEmptyHeader() {
+ try {
+ GenericHeader header = new GenericHeader("Foo-Bar", "");
+ assertEquals(
+ "Empty headers are treated the same as those with an empty quoted string",
+ "\"\"",
+ header.getValue());
+ assertEquals("Empty headers should have one clause", 1, header.getClauses().size());
+ }
+ catch (Exception e) {
+ fail("Empty headers are allowed");
+ }
+ }
+}
Modified: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java?rev=1705868&r1=1705867&r2=1705868&view=diff
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java (original)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/SubsystemTest.java Tue Sep 29 14:18:21 2015
@@ -34,7 +34,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
-import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
Added: aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1423Test.java
URL: http://svn.apache.org/viewvc/aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1423Test.java?rev=1705868&view=auto
==============================================================================
--- aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1423Test.java (added)
+++ aries/trunk/subsystem/subsystem-itests/src/test/java/org/apache/aries/subsystem/itests/defect/Aries1423Test.java Tue Sep 29 14:18:21 2015
@@ -0,0 +1,97 @@
+/*
+ * 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.aries.subsystem.itests.defect;
+
+import static org.junit.Assert.fail;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.aries.subsystem.itests.Header;
+import org.apache.aries.subsystem.itests.SubsystemTest;
+import org.junit.Before;
+import org.junit.Test;
+import org.osgi.service.subsystem.Subsystem;
+import org.osgi.service.subsystem.SubsystemConstants;
+import org.osgi.service.subsystem.SubsystemException;
+
+/*
+ * https://issues.apache.org/jira/browse/ARIES-1423
+ *
+ * IllegalArgumentException when GenericHeader has no clauses
+ */
+public class Aries1423Test extends SubsystemTest {
+ /*
+ * Subsystem-SymbolicName: application.a.esa
+ *
+ * Included In Archive
+ * bundle.a.jar
+ */
+ private static final String APPLICATION_A = "application.a.esa";
+ /*
+ * Bundle-SymbolicName: bundle.a.jar
+ * Build-Plan:
+ * Build-Number:
+ */
+ private static final String BUNDLE_A = "bundle.a.jar";
+
+ private static boolean createdTestFiles;
+
+ @Before
+ public void createTestFiles() throws Exception {
+ if (createdTestFiles)
+ return;
+ createBundleA();
+ createApplicationA();
+ createdTestFiles = true;
+ }
+
+ private void createBundleA() throws IOException {
+ createBundle(
+ name(BUNDLE_A),
+ new Header("Build-Plan", ""),
+ new Header("Build-Number", "") {});
+ }
+
+ private static void createApplicationA() throws IOException {
+ createApplicationAManifest();
+ createSubsystem(APPLICATION_A, BUNDLE_A);
+ }
+
+ private static void createApplicationAManifest() throws IOException {
+ Map<String, String> attributes = new HashMap<String, String>();
+ attributes.put(SubsystemConstants.SUBSYSTEM_SYMBOLICNAME, APPLICATION_A);
+ attributes.put("Build-Plan", "");
+ attributes.put("Build-Number", "");
+ createManifest(APPLICATION_A + ".mf", attributes);
+ }
+
+ @Test
+ public void testEmptyNonOsgiHeaders() throws Exception {
+ try {
+ Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
+ uninstallSubsystemSilently(applicationA);
+ }
+ catch (SubsystemException e) {
+ e.printStackTrace();
+ fail("Subsystem should have installed");
+ }
+ }
+}