Skip to content

Commit

Permalink
Add an integration test for vertx.reuseNettyAllocators
Browse files Browse the repository at this point in the history
  • Loading branch information
vietj committed Oct 21, 2024
1 parent e1a4e05 commit da1a68e
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 3 deletions.
17 changes: 16 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,21 @@
</additionalClasspathElements>
</configuration>
</execution>
<execution>
<id>reuse-netty-allocators</id>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<includes>
<include>io/vertx/it/ReuseNettyAllocatorsTest.java</include>
</includes>
<systemProperties>
<vertx.reuseNettyAllocators>true</vertx.reuseNettyAllocators>
</systemProperties>
</configuration>
</execution>
</executions>
</plugin>

Expand Down Expand Up @@ -986,4 +1001,4 @@

</profiles>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@

public class VertxByteBufAllocatorTest {


@Test
public void defaultShouldNotReuseExistingNettyPooledAllocators() {
Assert.assertNull(System.getProperty("vertx.reuseNettyAllocators"));
Assert.assertNotSame(PooledByteBufAllocator.DEFAULT, VertxByteBufAllocator.POOLED_ALLOCATOR);
Assert.assertNotSame(ByteBufAllocator.DEFAULT, VertxByteBufAllocator.POOLED_ALLOCATOR);
Assert.assertSame(ByteBufAllocator.DEFAULT, PooledByteBufAllocator.DEFAULT);
}

}
29 changes: 29 additions & 0 deletions src/test/java/io/vertx/it/ReuseNettyAllocatorsTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (c) 2011-2024 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*/

package io.vertx.it;

import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.PooledByteBufAllocator;
import io.vertx.core.buffer.impl.VertxByteBufAllocator;
import org.junit.Assert;
import org.junit.Test;

public class ReuseNettyAllocatorsTest {

@Test
public void testVertxAllocatorsReuseNettyAllocators() {
Assert.assertEquals("true", System.getProperty("vertx.reuseNettyAllocators"));
Assert.assertSame(PooledByteBufAllocator.DEFAULT, VertxByteBufAllocator.POOLED_ALLOCATOR);
Assert.assertSame(ByteBufAllocator.DEFAULT, VertxByteBufAllocator.POOLED_ALLOCATOR);
Assert.assertSame(ByteBufAllocator.DEFAULT, PooledByteBufAllocator.DEFAULT);
}
}

0 comments on commit da1a68e

Please sign in to comment.