Example usage for org.springframework.data.classloadersupport HidingClassLoader hide

List of usage examples for org.springframework.data.classloadersupport HidingClassLoader hide

Introduction

In this page you can find the example usage for org.springframework.data.classloadersupport HidingClassLoader hide.

Prototype

public static HidingClassLoader hide(Class<?>... packages) 

Source Link

Document

Creates a new HidingClassLoader with the packages of the given classes hidden.

Usage

From source file:org.springframework.data.web.config.SpringDataWebConfigurationIntegrationTests.java

@Test // DATACMNS-987
public void shouldNotLoadJacksonConverterWhenJacksonNotPresent() {

    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();

    createConfigWithClassLoader(HidingClassLoader.hide(ObjectMapper.class)).extendMessageConverters(converters);

    assertThat(converters).areNot(instanceWithClassName(ProjectingJackson2HttpMessageConverter.class));
}

From source file:org.springframework.data.web.config.SpringDataWebConfigurationIntegrationTests.java

@Test // DATACMNS-987
public void shouldNotLoadJacksonConverterWhenJaywayNotPresent() {

    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();

    createConfigWithClassLoader(HidingClassLoader.hide(DocumentContext.class))
            .extendMessageConverters(converters);

    assertThat(converters).areNot(instanceWithClassName(ProjectingJackson2HttpMessageConverter.class));
}

From source file:org.springframework.data.web.config.SpringDataWebConfigurationIntegrationTests.java

@Test // DATACMNS-987
public void shouldNotLoadXBeamConverterWhenXBeamNotPresent() throws Exception {

    List<HttpMessageConverter<?>> converters = new ArrayList<HttpMessageConverter<?>>();

    ClassLoader classLoader = HidingClassLoader.hide(ProjectionFactory.class);
    createConfigWithClassLoader(classLoader).extendMessageConverters(converters);

    assertThat(converters).areNot(instanceWithClassName(XmlBeamHttpMessageConverter.class));
}

From source file:org.springframework.data.web.config.EnableSpringDataWebSupportIntegrationTests.java

@Test // DATACMNS-330
public void doesNotRegisterHateoasSpecificComponentsIfHateoasNotPresent() throws Exception {

    HidingClassLoader classLoader = HidingClassLoader.hide(Link.class);

    ApplicationContext context = WebTestUtils.createApplicationContext(classLoader, SampleConfig.class);

    List<String> names = Arrays.asList(context.getBeanDefinitionNames());

    assertThat(names).contains("pageableResolver", "sortResolver");
    assertThat(names).doesNotContain("pagedResourcesAssembler", "pagedResourcesAssemblerArgumentResolver");
}

From source file:org.springframework.data.web.config.EnableSpringDataWebSupportIntegrationTests.java

@Test // DATACMNS-475
public void doesNotRegisterJacksonSpecificComponentsIfJacksonNotPresent() throws Exception {

    ApplicationContext context = WebTestUtils
            .createApplicationContext(HidingClassLoader.hide(ObjectMapper.class), SampleConfig.class);

    List<String> names = Arrays.asList(context.getBeanDefinitionNames());

    assertThat(names).doesNotContain("jacksonGeoModule");
}