summaryrefslogtreecommitdiffstats
path: root/bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis
diff options
context:
space:
mode:
Diffstat (limited to 'bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis')
-rw-r--r--bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.scala118
-rw-r--r--bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/AnalyzeMethodBodyTest.scala52
-rw-r--r--bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/TestUtilities.scala18
3 files changed, 0 insertions, 188 deletions
diff --git a/bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.scala b/bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.scala
deleted file mode 100644
index e2d0e3c6f10..00000000000
--- a/bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/AnalyzeClassTest.scala
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.container.plugin.classanalysis
-
-import org.junit.Test
-import org.scalatest.junit.{AssertionsForJUnit, JUnitSuite}
-import java.awt.Image
-import java.awt.image.{ImagingOpException, Kernel}
-
-import sampleclasses._
-import TestUtilities._
-import com.yahoo.osgi.annotation.{ExportPackage, Version}
-import javax.security.auth.login.LoginException
-
-import org.scalatest.Matchers
-
-/**
- * Tests that analysis of class files works.
- * @author tonytv
- */
-class AnalyzeClassTest extends JUnitSuite with AssertionsForJUnit with Matchers {
- @Test def require_that_full_class_name_is_returned() {
- analyzeClass[Base].name should be(name[Base])
- }
-
- @Test def require_that_base_class_is_included() {
- analyzeClass[Derived].referencedClasses should contain (name[Base])
- }
-
- @Test def require_that_implemented_interfaces_are_included() {
- analyzeClass[Base].referencedClasses should (contain (name[Interface1]) and contain (name[Interface2]))
- }
-
- @Test def require_that_interface_can_be_analyzed() {
- val classMetaData = analyzeClass[Interface1]
-
- classMetaData.name should be(name[Interface1])
- classMetaData.referencedClasses should contain(name[Interface2])
- }
-
- @Test def require_that_return_type_is_included() {
- analyzeClass[Interface1].referencedClasses should contain (name[Image])
- }
-
- @Test def require_that_parameters_are_included() {
- analyzeClass[Interface1].referencedClasses should contain (name[Kernel])
- }
-
- @Test def require_that_exceptions_are_included() {
- analyzeClass[Interface1].referencedClasses should contain (name[ImagingOpException])
- }
-
- @Test def require_that_basic_types_ignored() {
- analyzeClass[Interface1].referencedClasses should not (contain ("int") or contain ("float"))
- }
-
- @Test def require_that_arrays_of_basic_types_ignored() {
- analyzeClass[Interface1].referencedClasses should not (contain ("int[]") or contain ("int[][]"))
- }
-
- @Test def require_that_instance_field_types_are_included() {
- analyzeClass[Fields].referencedClasses should contain (name[String])
- }
-
- @Test def require_that_static_field_types_are_included() {
- analyzeClass[Fields].referencedClasses should contain (name[java.util.List[_]])
- }
-
- @Test def require_that_field_annotation_is_included() {
- analyzeClass[Fields].referencedClasses should contain (name[DummyAnnotation])
- }
-
- @Test def require_that_class_annotation_is_included() {
- analyzeClass[ClassAnnotation].referencedClasses should contain(name[DummyAnnotation])
- }
-
- @Test def require_that_method_annotation_is_included() {
- analyzeClass[MethodAnnotation].referencedClasses should contain(name[DummyAnnotation])
- }
-
- @Test def require_that_export_package_annotations_are_ignored() {
- Analyze.analyzeClass(classFile("com.yahoo.container.plugin.classanalysis.sampleclasses.package-info")).
- referencedClasses should not (contain (name[ExportPackage]) or contain (name[Version]))
- }
-
- @Test def require_that_export_annotations_are_processed() {
- Analyze.analyzeClass(classFile("com.yahoo.container.plugin.classanalysis.sampleclasses.package-info")).
- exportPackage should be (Some(ExportPackageAnnotation(3, 1, 4, "TEST_QUALIFIER-2")))
- }
-
- @Test def require_that_export_annotations_are_validated() {
- val exception = intercept[RuntimeException] {
- Analyze.analyzeClass(classFile("com.yahoo.container.plugin.classanalysis.sampleclasses.invalid.package-info"))
- }
-
- exception.getMessage should include ("invalid/package-info")
- exception.getCause.getMessage should include ("qualifier must follow the format")
- exception.getCause.getMessage should include ("'EXAMPLE INVALID QUALIFIER'")
- }
-
- @Test def require_that_catch_clauses_are_included() {
- Analyze.analyzeClass(classFile("com.yahoo.container.plugin.classanalysis.sampleclasses.CatchException")).
- referencedClasses should contain(name[LoginException])
- }
-
- @Test def require_that_class_references_are_included() {
- Analyze.analyzeClass(classFile("com.yahoo.container.plugin.classanalysis.sampleclasses.ClassReference")).
- referencedClasses should contain(name[Interface1])
- }
-
- @Test def require_that_return_type_of_method_invocations_are_included() {
- analyzeClass[MethodInvocation].referencedClasses should contain(name[Image])
- }
-
- @Test def require_that_attributes_are_included() {
- //Uses com/coremedia/iso/Utf8.class from com.googlecode.mp4parser:isoparser:1.0-RC-1
- Analyze.analyzeClass(classFile("class/Utf8")).referencedClasses should contain("org.aspectj.weaver.MethodDeclarationLineNumber")
- }
-}
diff --git a/bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/AnalyzeMethodBodyTest.scala b/bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/AnalyzeMethodBodyTest.scala
deleted file mode 100644
index 43f52884f39..00000000000
--- a/bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/AnalyzeMethodBodyTest.scala
+++ /dev/null
@@ -1,52 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.container.plugin.classanalysis
-
-import org.scalatest.junit.{AssertionsForJUnit, JUnitSuite}
-import sampleclasses._
-import TestUtilities._
-import org.junit.Test
-import java.io.PrintStream
-
-import org.scalatest.Matchers
-
-/**
- * Tests that classes used in method bodies are included in the imports list.
- * @author tonytv
- */
-class AnalyzeMethodBodyTest extends JUnitSuite with AssertionsForJUnit with Matchers {
- @Test def require_that_class_of_locals_are_included() {
- analyzeClass[Methods].referencedClasses should contain(name[Base])
- }
-
- @Test def require_that_class_of_locals_in_static_method_are_included() {
- analyzeClass[Methods].referencedClasses should contain(name[Derived])
- }
-
- @Test def require_that_field_references_are_included() {
- analyzeClass[Methods].referencedClasses should (contain (name[java.util.List[_]]) and contain (name[Fields]))
- }
-
- @Test def require_that_class_owning_field_is_included() {
- analyzeClass[Methods].referencedClasses should contain (name[System])
- }
-
- @Test def require_that_class_containing_method_is_included() {
- analyzeClass[Methods].referencedClasses should contain (name[PrintStream])
- }
-
- @Test def require_that_element_of_new_multidimensional_array_is_included() {
- analyzeClass[Methods].referencedClasses should contain (name[Interface1])
- }
-
- @Test def require_that_basic_arrays_are_not_included() {
- analyzeClass[Methods].referencedClasses should not (contain("int[]"))
- }
-
- @Test def require_that_container_generic_parameters_are_included() {
- analyzeClass[Methods].referencedClasses should contain(name[Dummy])
- }
-
- @Test def require_that_class_owning_method_handler_is_included() {
- analyzeClass[Methods].referencedClasses should contain(name[ClassWithMethod])
- }
-}
diff --git a/bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/TestUtilities.scala b/bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/TestUtilities.scala
deleted file mode 100644
index fbc3554e9e9..00000000000
--- a/bundle-plugin/src/test/scala/com/yahoo/container/plugin/classanalysis/TestUtilities.scala
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.container.plugin.classanalysis
-
-import scala.reflect.ClassTag
-import java.io.File
-
-/**
- * @author tonytv
- */
-object TestUtilities {
- def analyzeClass[T](implicit m: ClassTag[T]) =
- Analyze.analyzeClass(classFile(name(m)))
-
- def classFile(className : String) =
- new File("target/test-classes/" + className.replace('.', '/') + ".class")
-
- def name[T](implicit m: ClassTag[T]) = m.runtimeClass.getName
-}