Skip to content

Commit

Permalink
Add test for empty packages
Browse files Browse the repository at this point in the history
  • Loading branch information
tjwatson committed Jun 11, 2024
1 parent 83f21f0 commit 998d27a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.net.URL;
import java.nio.file.Path;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
Expand All @@ -48,11 +49,17 @@
import org.osgi.framework.BundleContext;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.Version;
import org.osgi.framework.launch.Framework;
import org.osgi.framework.namespace.PackageNamespace;
import org.osgi.framework.wiring.BundleWiring;
import org.osgi.framework.wiring.FrameworkWiring;
import org.osgi.resource.Namespace;
import org.osgi.resource.Requirement;
import org.osgi.resource.Resource;

public class IndexLaunchTest
{
Expand Down Expand Up @@ -305,6 +312,14 @@ void doTestFindEntries(@TempDir Path storage, String indexPath,
}
}

@Test
void testEmptyDirectoryPackages(@TempDir Path storage) throws BundleException {
testFramework = getTestFramework(storage, null);
Bundle b3 = FrameworkUtil.getBundle(TestClass.class);
assertNotNull(b3, "no bundle found.");
assertEquals("bundle.3", b3.getSymbolicName(), "Wrong BSN");
}

private void assertContent(String expected, URL url) throws IOException
{
try (BufferedReader br = new BufferedReader(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Licensed 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.felix.atomos.tests.index.bundles;

public class TestClass {
// nothing needed here; just need a class to load
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ org/apache/felix/atomos/
org/apache/felix/atomos/tests/
org/apache/felix/atomos/tests/index/
org/apache/felix/atomos/tests/index/bundles/
org/apache/felix/atomos/tests/index/bundles/TestClass.java
org/apache/felix/atomos/tests/index/bundles/b3/
org/apache/felix/atomos/tests/index/bundles/b3/ActivatorBundle3.class
ATOMOS_BUNDLE
Expand Down

0 comments on commit 998d27a

Please sign in to comment.