* 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.
package org.openecomp.sdc.be.servlets;
+import static org.mockito.Mockito.mock;
+
import com.fasterxml.jackson.databind.DeserializationFeature;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.http.HttpServletRequest;
+import javax.ws.rs.core.Feature;
import org.glassfish.grizzly.servlet.HttpSessionImpl;
import org.glassfish.grizzly.servlet.WebappContext;
import org.glassfish.hk2.utilities.binding.AbstractBinder;
import org.glassfish.jersey.server.filter.RolesAllowedDynamicFeature;
import org.glassfish.jersey.test.JerseyTest;
import org.glassfish.jersey.test.TestProperties;
-import org.junit.BeforeClass;
+import org.junit.jupiter.api.BeforeAll;
import org.openecomp.sdc.be.impl.WebAppContextWrapper;
import org.openecomp.sdc.be.servlets.exception.ComponentExceptionMapper;
import org.openecomp.sdc.be.servlets.exception.DefaultExceptionMapper;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.web.context.WebApplicationContext;
-import javax.servlet.http.HttpServletRequest;
-import javax.ws.rs.core.Feature;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static org.mockito.Mockito.mock;
-
public abstract class JerseySpringBaseTest extends JerseyTest {
private static final Logger log = Logger.getLogger(JerseySpringBaseTest.class.getName());
protected static WebappContext context;
protected static WebAppContextWrapper contextWrapper;
protected static WebApplicationContext applicationContext;
- private final static JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- private final static Feature loggingFeature = new LoggingFeature(log, Level.INFO, LoggingFeature.Verbosity.PAYLOAD_ANY, null);
+ private final static JacksonJsonProvider jacksonJsonProvider = new JacksonJaxbJsonProvider()
+ .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ private final static Feature loggingFeature = new LoggingFeature(log, Level.INFO,
+ LoggingFeature.Verbosity.PAYLOAD_ANY, null);
- @BeforeClass
+ @BeforeAll
public static void initBaseClass() {
request = mock(HttpServletRequest.class);
session = mock(HttpSessionImpl.class);
@Override
protected void configureClient(ClientConfig config) {
config.register(MultiPartFeature.class)
- .register(loggingFeature)
- .register(jacksonJsonProvider);
+ .register(loggingFeature)
+ .register(jacksonJsonProvider);
}
protected ResourceConfig configure() {
ApplicationContext context = new AnnotationConfigApplicationContext(springConfig);
forceSet(TestProperties.CONTAINER_PORT, "0");
return new ResourceConfig()
- .register(new AbstractBinder() {
- @Override
- protected void configure() {
- bind(request).to(HttpServletRequest.class);
- }
- })
- .register(RolesAllowedDynamicFeature.class)
- .register(DefaultExceptionMapper.class)
- .register(ComponentExceptionMapper.class)
- .register(StorageExceptionMapper.class)
- .register(MultiPartFeature.class)
- .register(jacksonJsonProvider)
- .register(loggingFeature)
- .property("jersey.config.server.provider.classnames", "org.openecomp.sdc.be.view.MixinModelWriter")
- .property("contextConfig", context);
+ .register(new AbstractBinder() {
+ @Override
+ protected void configure() {
+ bind(request).to(HttpServletRequest.class);
+ }
+ })
+ .register(RolesAllowedDynamicFeature.class)
+ .register(DefaultExceptionMapper.class)
+ .register(ComponentExceptionMapper.class)
+ .register(StorageExceptionMapper.class)
+ .register(MultiPartFeature.class)
+ .register(jacksonJsonProvider)
+ .register(loggingFeature)
+ .property("jersey.config.server.provider.classnames", "org.openecomp.sdc.be.view.MixinModelWriter")
+ .property("contextConfig", context);
}
}