Search in sources :

Example 11 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project janusgraph by JanusGraph.

the class RelationIdentifierGraphBinarySerializerTest method readValueAndWriteValueShouldBeSymmetric.

@ParameterizedTest
@MethodSource("relationIdentifierProvider")
public void readValueAndWriteValueShouldBeSymmetric(final RelationIdentifier relationIdentifier) throws IOException {
    final TypeSerializerRegistry registry = TypeSerializerRegistry.build().addCustomType(RelationIdentifier.class, new RelationIdentifierGraphBinarySerializer()).create();
    final GraphBinaryReader reader = new GraphBinaryReader(registry);
    final GraphBinaryWriter writer = new GraphBinaryWriter(registry);
    for (boolean nullable : new boolean[] { true, false }) {
        final Buffer buffer = bufferFactory.create(allocator.buffer());
        writer.writeValue(relationIdentifier, buffer, nullable);
        final RelationIdentifier actual = reader.readValue(buffer, RelationIdentifier.class, nullable);
        assertEquals(actual.toString(), relationIdentifier.toString());
        buffer.release();
    }
}
Also used : Buffer(org.apache.tinkerpop.gremlin.structure.io.Buffer) GraphBinaryWriter(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter) TypeSerializerRegistry(org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry) GraphBinaryReader(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader) RelationIdentifier(org.janusgraph.graphdb.relations.RelationIdentifier) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 12 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project janusgraph by JanusGraph.

the class JanusGraphPGraphBinarySerializerTest method readValueAndWriteValueShouldBeSymmetric.

@ParameterizedTest
@MethodSource("janusGraphPProvider")
public void readValueAndWriteValueShouldBeSymmetric(final JanusGraphP predicate) throws IOException {
    final TypeSerializerRegistry registry = TypeSerializerRegistry.build().addCustomType(JanusGraphP.class, new JanusGraphPBinarySerializer()).addCustomType(Geoshape.class, new GeoshapeGraphBinarySerializer()).create();
    final GraphBinaryReader reader = new GraphBinaryReader(registry);
    final GraphBinaryWriter writer = new GraphBinaryWriter(registry);
    for (boolean nullable : new boolean[] { true, false }) {
        final Buffer buffer = bufferFactory.create(allocator.buffer());
        writer.writeValue(predicate, buffer, nullable);
        final JanusGraphP actual = reader.readValue(buffer, JanusGraphP.class, nullable);
        assertEquals(actual.toString(), predicate.toString());
        buffer.release();
    }
}
Also used : Buffer(org.apache.tinkerpop.gremlin.structure.io.Buffer) GraphBinaryWriter(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryWriter) TypeSerializerRegistry(org.apache.tinkerpop.gremlin.structure.io.binary.TypeSerializerRegistry) GraphBinaryReader(org.apache.tinkerpop.gremlin.structure.io.binary.GraphBinaryReader) Geoshape(org.janusgraph.core.attribute.Geoshape) JanusGraphP(org.janusgraph.graphdb.tinkerpop.io.JanusGraphP) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 13 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project OpenGrok by OpenGrok.

the class UserWhiteListPluginTest method shouldNotAllowRandomUserForAnyGroup.

@ParameterizedTest
@MethodSource("parameters")
public void shouldNotAllowRandomUserForAnyGroup(String param) {
    init(param);
    plugin.load(validPluginParameters);
    DummyHttpServletRequest req = new DummyHttpServletRequest();
    req.setAttribute(UserPlugin.REQUEST_ATTR, new User(RandomStringUtils.randomAlphanumeric(8)));
    Group randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
    boolean projectAllowed = plugin.isAllowed(req, randomGroup);
    assertFalse(projectAllowed, "should not allow random group 1");
    randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
    projectAllowed = plugin.isAllowed(req, randomGroup);
    assertFalse(projectAllowed, "should not allow random group 2");
}
Also used : Group(org.opengrok.indexer.configuration.Group) User(opengrok.auth.plugin.entity.User) DummyHttpServletRequest(org.opengrok.indexer.web.DummyHttpServletRequest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 14 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project OpenGrok by OpenGrok.

the class UserWhiteListPluginTest method shouldAllowWhitelistedUserForAnyGroup.

@ParameterizedTest
@MethodSource("parameters")
public void shouldAllowWhitelistedUserForAnyGroup(String param) {
    init(param);
    plugin.load(validPluginParameters);
    DummyHttpServletRequest req = new DummyHttpServletRequest();
    User user;
    if (param.equals(UserWhiteListPlugin.USERNAME_FIELD)) {
        user = new User(OK_USER);
    } else {
        user = new User("blurb", OK_ID);
    }
    req.setAttribute(UserPlugin.REQUEST_ATTR, user);
    Group randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
    boolean groupAllowed = plugin.isAllowed(req, randomGroup);
    assertTrue(groupAllowed, "should allow OK entity for random group 1");
    randomGroup = new Group(RandomStringUtils.randomAlphanumeric(10));
    groupAllowed = plugin.isAllowed(req, randomGroup);
    assertTrue(groupAllowed, "should allow OK entity for random group 2");
}
Also used : Group(org.opengrok.indexer.configuration.Group) User(opengrok.auth.plugin.entity.User) DummyHttpServletRequest(org.opengrok.indexer.web.DummyHttpServletRequest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 15 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project OpenGrok by OpenGrok.

the class UserWhiteListPluginTest method shouldAllowWhitelistedUserForAnyProject.

@ParameterizedTest
@MethodSource("parameters")
public void shouldAllowWhitelistedUserForAnyProject(String param) {
    init(param);
    plugin.load(validPluginParameters);
    DummyHttpServletRequest req = new DummyHttpServletRequest();
    User user;
    if (param.equals(UserWhiteListPlugin.USERNAME_FIELD)) {
        user = new User(OK_USER);
    } else {
        user = new User("blurb", OK_ID);
    }
    req.setAttribute(UserPlugin.REQUEST_ATTR, user);
    Project randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
    boolean projectAllowed = plugin.isAllowed(req, randomProject);
    assertTrue(projectAllowed, "should allow OK entity for random project 1");
    randomProject = new Project(RandomStringUtils.randomAlphanumeric(10));
    projectAllowed = plugin.isAllowed(req, randomProject);
    assertTrue(projectAllowed, "should allow OK entity for random project 2");
}
Also used : Project(org.opengrok.indexer.configuration.Project) User(opengrok.auth.plugin.entity.User) DummyHttpServletRequest(org.opengrok.indexer.web.DummyHttpServletRequest) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

MethodSource (org.junit.jupiter.params.provider.MethodSource)1376 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1361 Transaction (org.neo4j.graphdb.Transaction)103 Stream (java.util.stream.Stream)70 Test (org.junit.jupiter.api.Test)67 ArrayList (java.util.ArrayList)63 InterruptAfter (io.aeron.test.InterruptAfter)60 List (java.util.List)60 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)58 IOException (java.io.IOException)58 ArrowableSingleShape (net.sf.latexdraw.model.api.shape.ArrowableSingleShape)55 TimeUnit (java.util.concurrent.TimeUnit)54 CountDownLatch (java.util.concurrent.CountDownLatch)53 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)52 lombok.val (lombok.val)52 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)51 Arguments (org.junit.jupiter.params.provider.Arguments)47 AfterEach (org.junit.jupiter.api.AfterEach)46 SSLEngine (javax.net.ssl.SSLEngine)44 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)43