diff options
Diffstat (limited to 'bundle-plugin/src/test/scala/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.scala')
-rw-r--r-- | bundle-plugin/src/test/scala/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.scala | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/bundle-plugin/src/test/scala/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.scala b/bundle-plugin/src/test/scala/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.scala new file mode 100644 index 00000000000..7b2a840bc44 --- /dev/null +++ b/bundle-plugin/src/test/scala/com/yahoo/container/plugin/bundle/AnalyzeBundleTest.scala @@ -0,0 +1,39 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.container.plugin.bundle + +import org.scalatest.junit.{JUnitSuite, ShouldMatchersForJUnit} +import org.junit.Test +import com.yahoo.container.plugin.bundle.AnalyzeBundle.PublicPackages +import com.yahoo.container.plugin.osgi.ExportPackages +import java.io.File + +/** + * @author tonytv + */ +class AnalyzeBundleTest extends JUnitSuite with ShouldMatchersForJUnit { + val jarDir = new File("src/test/resources/jar") + + val PublicPackages(exports, globals) = AnalyzeBundle.publicPackagesAggregated( + List("notAOsgiBundle.jar", "simple1.jar").map(jarFile)) + + val exportsByPackageName = ExportPackages.exportsByPackageName(exports) + + def jarFile(name : String) : File = new File(jarDir, name) + + @Test + def require_that_non_osgi_bundles_are_ignored() { + exportsByPackageName should not contain key("com.yahoo.sample.exported.package.ignored") + } + + @Test + def require_that_exports_are_retrieved_from_manifest_in_jars() { + exportsByPackageName.keySet should be (Set("com.yahoo.sample.exported.package")) + } + + @Test + def require_that_invalid_exports_throws_exception() { + val exception = intercept[Exception](AnalyzeBundle.publicPackages(jarFile("errorExport.jar"))) + exception.getMessage should startWith regex ("Invalid manifest in bundle '.*errorExport.jar'") + exception.getCause.getMessage should startWith ("Failed parsing Export-Package") + } +} |