Search in sources :

Example 6 with DisabledForJreRange

use of org.junit.jupiter.api.condition.DisabledForJreRange in project spring-data-mongodb by spring-projects.

the class BasicQueryUnitTests method equalsContract.

// DATAMONGO-1093
@Test
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "EqualsVerifier uses reflection on Optional")
public void equalsContract() {
    BasicQuery query1 = new BasicQuery("{ \"name\" : \"Thomas\"}", "{\"name\":1, \"age\":1}");
    query1.setSortObject(new Document("name", -1));
    BasicQuery query2 = new BasicQuery("{ \"name\" : \"Oliver\"}", "{\"name\":1, \"address\":1}");
    query2.setSortObject(new Document("name", 1));
    // 
    EqualsVerifier.forExamples(query1, query2).withRedefinedSuperclass().suppress(Warning.NONFINAL_FIELDS, Warning.NULL_FIELDS, // 
    Warning.STRICT_INHERITANCE).verify();
}
Also used : Document(org.bson.Document) Test(org.junit.jupiter.api.Test) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange)

Example 7 with DisabledForJreRange

use of org.junit.jupiter.api.condition.DisabledForJreRange in project spring-data-mongodb by spring-projects.

the class DbRefMappingMongoConverterUnitTests method lazyLoadingProxyForLazyDbRefOnConcreteCollection.

// DATAMONGO-348
@Test
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
void lazyLoadingProxyForLazyDbRefOnConcreteCollection() {
    String id = "42";
    String value = "bubu";
    MappingMongoConverter converterSpy = spy(converter);
    doReturn(new Document("_id", id).append("value", value)).when(converterSpy).readRef(any());
    Document document = new Document();
    ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs();
    lazyDbRefs.dbRefToConcreteCollection = new ArrayList<>(Collections.singletonList(new LazyDbRefTarget(id, value)));
    converterSpy.write(lazyDbRefs, document);
    ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document);
    assertProxyIsResolved(result.dbRefToConcreteCollection, false);
    assertThat(result.dbRefToConcreteCollection.get(0).getId()).isEqualTo(id);
    assertProxyIsResolved(result.dbRefToConcreteCollection, true);
    assertThat(result.dbRefToConcreteCollection.get(0).getValue()).isEqualTo(value);
}
Also used : Document(org.bson.Document) Test(org.junit.jupiter.api.Test) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange)

Example 8 with DisabledForJreRange

use of org.junit.jupiter.api.condition.DisabledForJreRange in project spring-data-mongodb by spring-projects.

the class DbRefMappingMongoConverterUnitTests method shouldNotTriggerResolvingOfLazyLoadedProxyWhenFinalizeMethodIsInvoked.

// DATAMONGO-1076
@Test
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
void shouldNotTriggerResolvingOfLazyLoadedProxyWhenFinalizeMethodIsInvoked() throws Exception {
    MongoPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(WithObjectMethodOverrideLazyDbRefs.class);
    MongoPersistentProperty property = entity.getRequiredPersistentProperty("dbRefToPlainObject");
    String idValue = new ObjectId().toString();
    DBRef dbRef = converter.toDBRef(new LazyDbRefTargetPropertyAccess(idValue), property);
    WithObjectMethodOverrideLazyDbRefs result = converter.read(WithObjectMethodOverrideLazyDbRefs.class, new Document("dbRefToPlainObject", dbRef));
    ReflectionTestUtils.invokeMethod(result.dbRefToPlainObject, "finalize");
    assertProxyIsResolved(result.dbRefToPlainObject, false);
}
Also used : MongoPersistentProperty(org.springframework.data.mongodb.core.mapping.MongoPersistentProperty) ObjectId(org.bson.types.ObjectId) DBRef(com.mongodb.DBRef) Document(org.bson.Document) Test(org.junit.jupiter.api.Test) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange)

Example 9 with DisabledForJreRange

use of org.junit.jupiter.api.condition.DisabledForJreRange in project spring-data-mongodb by spring-projects.

the class DbRefMappingMongoConverterUnitTests method shouldBulkFetchListOfReferences.

// DATAMONGO-1194
@Test
@DisabledForJreRange(min = JRE.JAVA_16, disabledReason = "Class Proxies for eg. ArrayList require to open java.util.")
void shouldBulkFetchListOfReferences() {
    String id1 = "1";
    String id2 = "2";
    String value = "val";
    MappingMongoConverter converterSpy = spy(converter);
    doReturn(Arrays.asList(new Document("_id", id1).append("value", value), new Document("_id", id2).append("value", value))).when(converterSpy).bulkReadRefs(anyList());
    Document document = new Document();
    ClassWithLazyDbRefs lazyDbRefs = new ClassWithLazyDbRefs();
    lazyDbRefs.dbRefToConcreteCollection = new ArrayList<>(Arrays.asList(new LazyDbRefTarget(id1, value), new LazyDbRefTarget(id2, value)));
    converterSpy.write(lazyDbRefs, document);
    ClassWithLazyDbRefs result = converterSpy.read(ClassWithLazyDbRefs.class, document);
    assertProxyIsResolved(result.dbRefToConcreteCollection, false);
    assertThat(result.dbRefToConcreteCollection.get(0).getId()).isEqualTo(id1);
    assertProxyIsResolved(result.dbRefToConcreteCollection, true);
    assertThat(result.dbRefToConcreteCollection.get(1).getId()).isEqualTo(id2);
    verify(converterSpy, never()).readRef(Mockito.any(DBRef.class));
}
Also used : DBRef(com.mongodb.DBRef) Document(org.bson.Document) Test(org.junit.jupiter.api.Test) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange)

Example 10 with DisabledForJreRange

use of org.junit.jupiter.api.condition.DisabledForJreRange in project logging-log4j2 by apache.

the class AbstractScriptFilterTest method testGroovyFilter.

@Test
@DisabledForJreRange(min = JRE.JAVA_12, disabledReason = "Groovy ScriptEngine incompatibilities")
public void testGroovyFilter(final LoggerContext context, @Named("List") final ListAppender app) throws Exception {
    final Logger logger = context.getLogger("TestGroovyFilter");
    logger.traceEntry();
    logger.info("This should not be logged");
    ThreadContext.put("UserId", "JohnDoe");
    logger.info("This should be logged");
    ThreadContext.clearMap();
    try {
        final List<String> messages = app.getMessages();
        assertNotNull(messages, "No Messages");
        assertEquals(messages.size(), 2, "Incorrect number of messages. Expected 2, Actual " + messages.size());
    } finally {
        app.clear();
    }
}
Also used : Logger(org.apache.logging.log4j.Logger) Test(org.junit.jupiter.api.Test) DisabledForJreRange(org.junit.jupiter.api.condition.DisabledForJreRange)

Aggregations

Test (org.junit.jupiter.api.Test)12 DisabledForJreRange (org.junit.jupiter.api.condition.DisabledForJreRange)12 Document (org.bson.Document)4 SslContextFactory (org.eclipse.jetty.util.ssl.SslContextFactory)4 MetricRegistry (com.codahale.metrics.MetricRegistry)2 InstrumentedConnectionFactory (com.codahale.metrics.jetty9.InstrumentedConnectionFactory)2 DBRef (com.mongodb.DBRef)2 ResourceConfigurationSourceProvider (io.dropwizard.configuration.ResourceConfigurationSourceProvider)2 YamlConfigurationFactory (io.dropwizard.configuration.YamlConfigurationFactory)2 DiscoverableSubtypeResolver (io.dropwizard.jackson.DiscoverableSubtypeResolver)2 Jackson (io.dropwizard.jackson.Jackson)2 BaseValidator (io.dropwizard.validation.BaseValidator)2 File (java.io.File)2 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 URI (java.net.URI)2 KeyStore (java.security.KeyStore)2 KeyStoreException (java.security.KeyStoreException)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2