Search in sources :

Example 1 with Application

use of javax.ws.rs.core.Application in project jersey by jersey.

the class ConstrainedToServerTest method testSpecificApplication.

@Test
public void testSpecificApplication() throws ExecutionException, InterruptedException {
    Application app = new Application() {

        @Override
        public Set<Class<?>> getClasses() {
            final HashSet<Class<?>> classes = new HashSet<>();
            classes.add(Resource.class);
            classes.add(MyClientFilter.class);
            classes.add(MyServerWrongFilter.class);
            return classes;
        }
    };
    ApplicationHandler handler = new ApplicationHandler(app);
    final ContainerResponse response = handler.apply(RequestContextBuilder.from("/resource", "GET").build()).get();
    assertEquals(200, response.getStatus());
}
Also used : ContainerResponse(org.glassfish.jersey.server.ContainerResponse) ApplicationHandler(org.glassfish.jersey.server.ApplicationHandler) Application(javax.ws.rs.core.Application) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with Application

use of javax.ws.rs.core.Application in project jersey by jersey.

the class ApplicationTest method testGetClassesNull.

@Test
public void testGetClassesNull() {
    Application a = new Application() {

        @Override
        public Set<Class<?>> getClasses() {
            return null;
        }

        @Override
        public Set<Object> getSingletons() {
            return Collections.emptySet();
        }
    };
    new ApplicationHandler(a);
}
Also used : Application(javax.ws.rs.core.Application) Test(org.junit.Test)

Example 3 with Application

use of javax.ws.rs.core.Application in project jersey by jersey.

the class ApplicationTest method testGetClassesContainsNull.

@Test
public void testGetClassesContainsNull() {
    Application a = new Application() {

        @Override
        public Set<Class<?>> getClasses() {
            return new HashSet<Class<?>>() {

                {
                    add(null);
                    add(DummyResource.class);
                }
            };
        }

        @Override
        public Set<Object> getSingletons() {
            return Collections.emptySet();
        }
    };
    new ApplicationHandler(a);
}
Also used : Application(javax.ws.rs.core.Application) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 4 with Application

use of javax.ws.rs.core.Application in project jersey by jersey.

the class ApplicationTest method testGetSingletonsContainsNull.

@Test
public void testGetSingletonsContainsNull() {
    Application a = new Application() {

        @Override
        public Set<Class<?>> getClasses() {
            return Collections.emptySet();
        }

        @Override
        public Set<Object> getSingletons() {
            return new HashSet<Object>() {

                {
                    add(null);
                    add(new DummyResource());
                }
            };
        }
    };
    new ApplicationHandler(a);
}
Also used : Application(javax.ws.rs.core.Application) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 5 with Application

use of javax.ws.rs.core.Application in project jersey by jersey.

the class AsyncApplicationBuildingTest method testAppBuilderJaxRsApplication.

@Test
public void testAppBuilderJaxRsApplication() throws InterruptedException, ExecutionException {
    Application jaxRsApplication = new Application() {

        @Override
        public Set<Class<?>> getClasses() {
            HashSet<Class<?>> set = new HashSet<Class<?>>();
            set.add(ResourceA.class);
            return set;
        }

        @Override
        public Set<Object> getSingletons() {
            return super.getSingletons();
        }
    };
    final ApplicationHandler application = new ApplicationHandler(jaxRsApplication);
    ContainerRequest req = RequestContextBuilder.from(BASE_URI, BASE_URI, "GET").build();
    assertEquals("get!", application.apply(req).get().getEntity());
}
Also used : Application(javax.ws.rs.core.Application) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Application (javax.ws.rs.core.Application)63 HashSet (java.util.HashSet)14 HashMap (java.util.HashMap)12 ApplicationInfo (org.apache.cxf.jaxrs.model.ApplicationInfo)12 JAXRSServerFactoryBean (org.apache.cxf.jaxrs.JAXRSServerFactoryBean)9 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)8 IOException (java.io.IOException)7 Set (java.util.Set)7 ServletException (javax.servlet.ServletException)7 Annotation (java.lang.annotation.Annotation)5 List (java.util.List)5 Map (java.util.Map)5 ApplicationPath (javax.ws.rs.ApplicationPath)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 ClassResourceInfo (org.apache.cxf.jaxrs.model.ClassResourceInfo)4 DeploymentInfo (io.undertow.servlet.api.DeploymentInfo)3 Method (java.lang.reflect.Method)3 Type (java.lang.reflect.Type)3 Collection (java.util.Collection)3