Convert internal-lambda test from groovy to java (#9611)
This commit is contained in:
parent
e24f0be597
commit
98976e9edb
|
@ -1,21 +0,0 @@
|
||||||
/*
|
|
||||||
* Copyright The OpenTelemetry Authors
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
import io.opentelemetry.instrumentation.test.AgentInstrumentationSpecification
|
|
||||||
import io.opentelemetry.javaagent.bootstrap.VirtualFieldInstalledMarker
|
|
||||||
|
|
||||||
class LambdaInstrumentationTest extends AgentInstrumentationSpecification {
|
|
||||||
|
|
||||||
def "test transform Runnable lambda"() {
|
|
||||||
setup:
|
|
||||||
Runnable runnable = TestLambda.makeRunnable()
|
|
||||||
|
|
||||||
expect:
|
|
||||||
// RunnableInstrumentation adds a VirtualField to all implementors of Runnable. If lambda class
|
|
||||||
// is transformed then it must have context store marker interface.
|
|
||||||
runnable instanceof VirtualFieldInstalledMarker
|
|
||||||
!VirtualFieldInstalledMarker.isAssignableFrom(Runnable)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
* Copyright The OpenTelemetry Authors
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*/
|
||||||
|
|
||||||
|
package io.opentelemetry.javaagent.instrumentation.internal.lambda;
|
||||||
|
|
||||||
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
import io.opentelemetry.javaagent.bootstrap.VirtualFieldInstalledMarker;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class LambdaInstrumentationTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testTransformRunnableLambda() {
|
||||||
|
Runnable runnable = TestLambda.makeRunnable();
|
||||||
|
|
||||||
|
// RunnableInstrumentation adds a VirtualField to all implementors of Runnable. If lambda class
|
||||||
|
// is transformed then it must have context store marker interface.
|
||||||
|
assertThat(runnable).isInstanceOf(VirtualFieldInstalledMarker.class);
|
||||||
|
assertThat(VirtualFieldInstalledMarker.class.isAssignableFrom(Runnable.class)).isFalse();
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,8 @@
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
package io.opentelemetry.javaagent.instrumentation.internal.lambda;
|
||||||
|
|
||||||
public class TestLambda {
|
public class TestLambda {
|
||||||
|
|
||||||
static Runnable makeRunnable() {
|
static Runnable makeRunnable() {
|
Loading…
Reference in New Issue