diff options
Diffstat (limited to 'container-jersey2')
23 files changed, 0 insertions, 660 deletions
diff --git a/container-jersey2/.gitignore b/container-jersey2/.gitignore deleted file mode 100644 index ea8c4bf7f35..00000000000 --- a/container-jersey2/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/container-jersey2/CMakeLists.txt b/container-jersey2/CMakeLists.txt deleted file mode 100644 index d2490563372..00000000000 --- a/container-jersey2/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -install_fat_java_artifact(container-jersey2) diff --git a/container-jersey2/OWNERS b/container-jersey2/OWNERS deleted file mode 100644 index 3b2ba1ede81..00000000000 --- a/container-jersey2/OWNERS +++ /dev/null @@ -1 +0,0 @@ -gjoranv diff --git a/container-jersey2/README.md b/container-jersey2/README.md deleted file mode 100644 index 43f83ddccbe..00000000000 --- a/container-jersey2/README.md +++ /dev/null @@ -1,4 +0,0 @@ -<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -# JDisc Jersey integration - -The integration layer between JDisc and Jersey2. diff --git a/container-jersey2/abi-spec.json b/container-jersey2/abi-spec.json deleted file mode 100644 index 2f5ef3efb70..00000000000 --- a/container-jersey2/abi-spec.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "com.yahoo.container.jaxrs.annotation.Component": { - "superClass": "java.lang.Object", - "interfaces": [ - "java.lang.annotation.Annotation" - ], - "attributes": [ - "public", - "interface", - "abstract", - "annotation" - ], - "methods": [], - "fields": [] - } -}
\ No newline at end of file diff --git a/container-jersey2/pom.xml b/container-jersey2/pom.xml deleted file mode 100644 index 8f24b5edcb7..00000000000 --- a/container-jersey2/pom.xml +++ /dev/null @@ -1,89 +0,0 @@ -<?xml version="1.0"?> -<!-- Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> -<project xmlns="http://maven.apache.org/POM/4.0.0" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 - http://maven.apache.org/xsd/maven-4.0.0.xsd"> - <modelVersion>4.0.0</modelVersion> - <parent> - <groupId>com.yahoo.vespa</groupId> - <artifactId>parent</artifactId> - <version>7-SNAPSHOT</version> - <relativePath>../parent/pom.xml</relativePath> - </parent> - <artifactId>container-jersey2</artifactId> - <version>7-SNAPSHOT</version> - <packaging>container-plugin</packaging> - <dependencies> - - <!-- COMPILE scope --> - <dependency> - <groupId>org.ow2.asm</groupId> - <artifactId>asm</artifactId> - </dependency> - - - <!-- PROVIDED scope --> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>annotations</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>component</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>container-core</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>jdisc_core</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - </dependency> - <dependency> - <groupId>com.yahoo.vespa</groupId> - <artifactId>vespa_jersey2</artifactId> - <version>${project.version}</version> - <scope>provided</scope> - <type>pom</type> - </dependency> - <dependency> - <groupId>org.eclipse.jetty</groupId> - <artifactId>jetty-servlet</artifactId> - <scope>provided</scope> - </dependency> - - <!-- TEST scope --> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <scope>test</scope> - </dependency> - </dependencies> - <build> - <plugins> - <plugin> - <groupId>com.yahoo.vespa</groupId> - <artifactId>bundle-plugin</artifactId> - <extensions>true</extensions> - </plugin> - <plugin> - <groupId>com.yahoo.vespa</groupId> - <artifactId>abi-check-plugin</artifactId> - </plugin> - <plugin> - <!-- Explicit for IntelliJ to detect correct language level from parent --> - <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-compiler-plugin</artifactId> - </plugin> - </plugins> - </build> -</project> diff --git a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/Component.java b/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/Component.java deleted file mode 100644 index da8f35eaa00..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/Component.java +++ /dev/null @@ -1,17 +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.jaxrs.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Annotation for injecting jdisc container components into jaxrs resources and providers - * @author Tony Vaagenes - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.PARAMETER) -public @interface Component {} - - diff --git a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/package-info.java b/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/package-info.java deleted file mode 100644 index 8628d52bbb8..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/jaxrs/annotation/package-info.java +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -/** - * @author Tony Vaagenes - */ -@PublicApi -@ExportPackage -package com.yahoo.container.jaxrs.annotation; - -import com.yahoo.api.annotations.PublicApi; -import com.yahoo.osgi.annotation.ExportPackage; diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ComponentGraphProvider.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ComponentGraphProvider.java deleted file mode 100644 index 7ff9646cb27..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ComponentGraphProvider.java +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import com.yahoo.container.di.config.ResolveDependencyException; -import com.yahoo.container.di.config.RestApiContext; -import com.yahoo.container.jaxrs.annotation.Component; -import org.glassfish.hk2.api.Injectee; -import org.glassfish.hk2.api.InjectionResolver; -import org.glassfish.hk2.api.ServiceHandle; - -import javax.inject.Singleton; - -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.stream.Collectors; - -/** - * Resolves jdisc container components for jersey 2 components. - * - * @author Tony Vaagenes - * @author ollivir - */ -@Singleton // jersey2 requirement: InjectionResolvers must be in the Singleton scope -public class ComponentGraphProvider implements InjectionResolver<Component> { - private Collection<RestApiContext.Injectable> injectables; - - public ComponentGraphProvider(Collection<RestApiContext.Injectable> injectables) { - this.injectables = injectables; - } - - @Override - public Object resolve(Injectee injectee, ServiceHandle<?> root) { - Class<?> wantedClass; - Type type = injectee.getRequiredType(); - if (type instanceof Class) { - wantedClass = (Class<?>) type; - } else { - throw new UnsupportedOperationException("Only classes are supported, got " + type); - } - - List<RestApiContext.Injectable> componentsWithMatchingType = new ArrayList<>(); - for (RestApiContext.Injectable injectable : injectables) { - if (wantedClass.isInstance(injectable.instance)) { - componentsWithMatchingType.add(injectable); - } - } - - if (componentsWithMatchingType.size() == 1) { - return componentsWithMatchingType.get(0).instance; - } else { - String injectionDescription = "class '" + wantedClass + "' to inject into Jersey resource/provider '" - + injectee.getInjecteeClass() + "')"; - if (componentsWithMatchingType.size() > 1) { - String ids = componentsWithMatchingType.stream().map(c -> c.id.toString()).collect(Collectors.joining(",")); - throw new ResolveDependencyException("Multiple components found of " + injectionDescription + ": " + ids); - } else { - throw new ResolveDependencyException("Could not find a component of " + injectionDescription + "."); - } - } - } - - @Override - public boolean isMethodParameterIndicator() { - return true; - } - - @Override - public boolean isConstructorParameterIndicator() { - return true; - } -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyApplication.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyApplication.java deleted file mode 100644 index 4c4e43bc8d5..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyApplication.java +++ /dev/null @@ -1,25 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import javax.ws.rs.core.Application; - -import java.util.Collection; -import java.util.HashSet; -import java.util.Set; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -public class JerseyApplication extends Application { - private Set<Class<?>> classes; - - public JerseyApplication(Collection<Class<?>> resourcesAndProviderClasses) { - this.classes = new HashSet<>(resourcesAndProviderClasses); - } - - @Override - public Set<Class<?>> getClasses() { - return classes; - } -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyServletProvider.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyServletProvider.java deleted file mode 100644 index b8c714fd3e3..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/JerseyServletProvider.java +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.datatype.jdk8.Jdk8Module; -import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; -import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; -import com.yahoo.container.di.componentgraph.Provider; -import com.yahoo.container.di.config.RestApiContext; -import com.yahoo.container.di.config.RestApiContext.BundleInfo; -import com.yahoo.container.jaxrs.annotation.Component; -import org.eclipse.jetty.servlet.ServletHolder; -import org.glassfish.hk2.api.InjectionResolver; -import org.glassfish.hk2.api.TypeLiteral; -import org.glassfish.hk2.utilities.Binder; -import org.glassfish.hk2.utilities.binding.AbstractBinder; -import org.glassfish.jersey.media.multipart.MultiPartFeature; -import org.glassfish.jersey.server.ResourceConfig; -import org.glassfish.jersey.servlet.ServletContainer; -import org.objectweb.asm.ClassReader; - -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Optional; - -import static com.yahoo.container.servlet.jersey.util.ResourceConfigUtil.registerComponent; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -@SuppressWarnings("unused") // Injected -public class JerseyServletProvider implements Provider<ServletHolder> { - - private final ServletHolder jerseyServletHolder; - - public JerseyServletProvider(RestApiContext restApiContext) { - this.jerseyServletHolder = new ServletHolder(new ServletContainer(resourceConfig(restApiContext))); - } - - private ResourceConfig resourceConfig(RestApiContext restApiContext) { - ResourceConfig resourceConfig = ResourceConfig - .forApplication(new JerseyApplication(resourcesAndProviders(restApiContext.getBundles()))); - - registerComponent(resourceConfig, componentInjectorBinder(restApiContext)); - registerComponent(resourceConfig, jacksonDatatypeJdk8Provider()); - resourceConfig.register(MultiPartFeature.class); - - return resourceConfig; - } - - private static Collection<Class<?>> resourcesAndProviders(Collection<BundleInfo> bundles) { - List<Class<?>> ret = new ArrayList<>(); - - for (BundleInfo bundle : bundles) { - for (String classEntry : bundle.getClassEntries()) { - Optional<String> className = detectResourceOrProvider(bundle.classLoader, classEntry); - className.ifPresent(cname -> ret.add(loadClass(bundle.symbolicName, bundle.classLoader, cname))); - } - } - return ret; - } - - private static Optional<String> detectResourceOrProvider(ClassLoader bundleClassLoader, String classEntry) { - try (InputStream inputStream = getResourceAsStream(bundleClassLoader, classEntry)) { - ResourceOrProviderClassVisitor visitor = ResourceOrProviderClassVisitor.visit(new ClassReader(inputStream)); - return visitor.getJerseyClassName(); - } catch (IOException e) { - throw new RuntimeException(e); - } - } - - private static InputStream getResourceAsStream(ClassLoader bundleClassLoader, String classEntry) { - InputStream is = bundleClassLoader.getResourceAsStream(classEntry); - if (is == null) { - throw new RuntimeException("No entry " + classEntry + " in bundle " + bundleClassLoader); - } else { - return is; - } - } - - private static Class<?> loadClass(String bundleSymbolicName, ClassLoader classLoader, String className) { - try { - return classLoader.loadClass(className); - } catch (Exception e) { - throw new RuntimeException("Failed loading class " + className + " from bundle " + bundleSymbolicName, e); - } - } - - private static Binder componentInjectorBinder(RestApiContext restApiContext) { - final ComponentGraphProvider componentGraphProvider = new ComponentGraphProvider(restApiContext.getInjectableComponents()); - final TypeLiteral<InjectionResolver<Component>> componentAnnotationType = new TypeLiteral<InjectionResolver<Component>>() { - }; - - return new AbstractBinder() { - @Override - public void configure() { - bind(componentGraphProvider).to(componentAnnotationType); - } - }; - } - - private static JacksonJaxbJsonProvider jacksonDatatypeJdk8Provider() { - JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(); - provider.setMapper(new ObjectMapper().registerModule(new Jdk8Module()).registerModule(new JavaTimeModule())); - return provider; - } - - @Override - public ServletHolder get() { - return jerseyServletHolder; - } - - @Override - public void deconstruct() { - } - -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ResourceOrProviderClassVisitor.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ResourceOrProviderClassVisitor.java deleted file mode 100644 index bf53cec670e..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/ResourceOrProviderClassVisitor.java +++ /dev/null @@ -1,103 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey; - -import org.objectweb.asm.AnnotationVisitor; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.Opcodes; -import org.objectweb.asm.Type; - -import javax.ws.rs.Path; -import javax.ws.rs.ext.Provider; - -import java.util.HashSet; -import java.util.Optional; -import java.util.Set; - -/** - * @author Tony Vaagenes - * @author ollivir - */ -public class ResourceOrProviderClassVisitor extends ClassVisitor { - private String className = null; - private boolean isPublic = false; - private boolean isAbstract = false; - - private boolean isInnerClass = false; - private boolean isStatic = false; - - private boolean isAnnotated = false; - - public ResourceOrProviderClassVisitor() { - super(Opcodes.ASM7); - } - - public Optional<String> getJerseyClassName() { - if (isJerseyClass()) { - return Optional.of(getClassName()); - } else { - return Optional.empty(); - } - } - - public boolean isJerseyClass() { - return isAnnotated && isPublic && !isAbstract && (!isInnerClass || isStatic); - } - - public String getClassName() { - assert (className != null); - return org.objectweb.asm.Type.getObjectType(className).getClassName(); - } - - @Override - public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) { - isPublic = isPublic(access); - className = name; - isAbstract = isAbstract(access); - } - - @Override - public void visitInnerClass(String name, String outerName, String innerName, int access) { - assert (className != null); - - if (name.equals(className)) { - isInnerClass = true; - isStatic = isStatic(access); - } - } - - @Override - public AnnotationVisitor visitAnnotation(String desc, boolean visible) { - isAnnotated |= annotationClassDescriptors.contains(desc); - return null; - } - - private static Set<String> annotationClassDescriptors = new HashSet<>(); - - static { - annotationClassDescriptors.add(Type.getDescriptor(Path.class)); - annotationClassDescriptors.add(Type.getDescriptor(Provider.class)); - } - - private static boolean isPublic(int access) { - return isSet(Opcodes.ACC_PUBLIC, access); - } - - private static boolean isStatic(int access) { - return isSet(Opcodes.ACC_STATIC, access); - } - - private static boolean isAbstract(int access) { - return isSet(Opcodes.ACC_ABSTRACT, access); - } - - private static boolean isSet(int bits, int access) { - return (access & bits) == bits; - } - - public static ResourceOrProviderClassVisitor visit(ClassReader classReader) { - ResourceOrProviderClassVisitor visitor = new ResourceOrProviderClassVisitor(); - classReader.accept(visitor, ClassReader.SKIP_DEBUG | ClassReader.SKIP_CODE | ClassReader.SKIP_FRAMES); - return visitor; - } -} diff --git a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/util/ResourceConfigUtil.java b/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/util/ResourceConfigUtil.java deleted file mode 100644 index fdfcf6565cd..00000000000 --- a/container-jersey2/src/main/java/com/yahoo/container/servlet/jersey/util/ResourceConfigUtil.java +++ /dev/null @@ -1,17 +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.servlet.jersey.util; - -import org.glassfish.jersey.server.ResourceConfig; - -/** - * @author Tony Vaagenes - */ -public class ResourceConfigUtil { - /** - * Solves ambiguous reference to overloaded definition, see - * http://stackoverflow.com/questions/3313929/how-do-i-disambiguate-in-scala-between-methods-with-vararg-and-without - */ - public static void registerComponent(ResourceConfig config, Object component) { - config.register(component); - } -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/AbstractResource.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/AbstractResource.java deleted file mode 100644 index dfa3354032a..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/AbstractResource.java +++ /dev/null @@ -1,12 +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.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -public abstract class AbstractResource { - -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/DummyAnnotation.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/DummyAnnotation.java deleted file mode 100644 index ca6e20aba4d..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/DummyAnnotation.java +++ /dev/null @@ -1,11 +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.servlet.jersey.classvisitor; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - -/** - * @author Tony Vaagenes - */ -@Retention(RetentionPolicy.RUNTIME) -public @interface DummyAnnotation {} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InnerClass.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InnerClass.java deleted file mode 100644 index 048ac4cdd9b..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InnerClass.java +++ /dev/null @@ -1,12 +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.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -public class InnerClass { - @Path("ignored") - public class Inner {} -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InterfaceResource.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InterfaceResource.java deleted file mode 100644 index d013028db19..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/InterfaceResource.java +++ /dev/null @@ -1,12 +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.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -public interface InterfaceResource { - -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NestedClass.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NestedClass.java deleted file mode 100644 index 11ff6364074..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NestedClass.java +++ /dev/null @@ -1,12 +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.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -public class NestedClass { - @Path("ignored") - public static class Nested {} -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NonPublicNestedClass.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NonPublicNestedClass.java deleted file mode 100644 index 8e4499fe6dc..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/NonPublicNestedClass.java +++ /dev/null @@ -1,12 +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.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -public class NonPublicNestedClass { - @Path("ignored") - static class Nested {} -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Provider.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Provider.java deleted file mode 100644 index c2c605db22c..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Provider.java +++ /dev/null @@ -1,9 +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.servlet.jersey.classvisitor; - -/** - * @author Tony Vaagenes - */ -@javax.ws.rs.ext.Provider -public class Provider { -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Resource.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Resource.java deleted file mode 100644 index edfa2449fc3..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/Resource.java +++ /dev/null @@ -1,11 +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.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -public class Resource { -} diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java deleted file mode 100644 index 1f5ccf4bb10..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceOrProviderClassVisitorTest.java +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.container.servlet.jersey.classvisitor; - -import com.yahoo.container.servlet.jersey.ResourceOrProviderClassVisitor; -import org.junit.Test; -import org.objectweb.asm.ClassReader; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -public class ResourceOrProviderClassVisitorTest { - @Test - public void resource_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.Resource.class); - } - - @Test - public void provider_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.Provider.class); - } - - @Test - public void inner_class_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.InnerClass.Inner.class); - } - - @Test - public void nested_public_class_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.NestedClass.Nested.class); - } - - @Test - public void nested_non_public_class_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.NonPublicNestedClass.Nested.class); - } - - @Test - public void resource_with_multiple_annotations_is_detected() throws Exception { - assert_is_accepted(com.yahoo.container.servlet.jersey.classvisitor.ResourceWithMultipleAnnotations.class); - } - - @Test - public void interface_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.InterfaceResource.class); - } - - @Test - public void abstract_class_is_ignored() throws Exception { - assert_is_ignored(com.yahoo.container.servlet.jersey.classvisitor.AbstractResource.class); - } - - @Test - public void className_is_equal_to_getName() throws Exception { - assertEquals(com.yahoo.container.servlet.jersey.classvisitor.Resource.class.getName(), analyzeClass(com.yahoo.container.servlet.jersey.classvisitor.Resource.class).getClassName()); - } - - public void assert_is_accepted(Class<?> clazz) throws Exception { - assertTrue(className(clazz) + " was not accepted", - analyzeClass(clazz).isJerseyClass()); - } - - public void assert_is_ignored(Class<?> clazz) throws Exception { - assertFalse(className(clazz) + " was not ignored", - analyzeClass(clazz).isJerseyClass()); - } - - public ResourceOrProviderClassVisitor analyzeClass(Class<?> clazz) throws Exception { - return ResourceOrProviderClassVisitor.visit(new ClassReader(className(clazz))); - } - - public String className(Class<?> clazz) { - return clazz.getName(); - } -} - - diff --git a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceWithMultipleAnnotations.java b/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceWithMultipleAnnotations.java deleted file mode 100644 index 7047422736e..00000000000 --- a/container-jersey2/src/test/java/com/yahoo/container/servlet/jersey/classvisitor/ResourceWithMultipleAnnotations.java +++ /dev/null @@ -1,13 +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.servlet.jersey.classvisitor; - -import javax.ws.rs.Path; - -/** - * @author Tony Vaagenes - */ -@Path("ignored") -@DummyAnnotation -public class ResourceWithMultipleAnnotations { - -} |