-
Notifications
You must be signed in to change notification settings - Fork 583
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2598 from gmarcy/2566-mpOpenTracing-fixes
fix annotation issue in opentracing
- Loading branch information
Showing
22 changed files
with
343 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
dev/com.ibm.ws.microprofile.opentracing/resources/META-INF/beans.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!-- | ||
Copyright (c) 2017 IBM Corporation and others. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
Contributors: | ||
IBM Corporation - initial API and implementation | ||
--> | ||
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd" | ||
version="1.1" | ||
bean-discovery-mode="all"> | ||
</beans> |
1 change: 1 addition & 0 deletions
1
...icroprofile.opentracing/resources/META-INF/services/javax.enterprise.inject.spi.Extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
com.ibm.ws.microprofile.opentracing.cdi.OpenTracingCDIInjectionExtension |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
...tracing/src/com/ibm/ws/microprofile/opentracing/cdi/OpenTracingCDIInjectionExtension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package com.ibm.ws.microprofile.opentracing.cdi; | ||
|
||
import javax.enterprise.inject.spi.Extension; | ||
|
||
import org.osgi.service.component.annotations.Component; | ||
import org.osgi.service.component.annotations.ConfigurationPolicy; | ||
|
||
import com.ibm.ws.cdi.extension.WebSphereCDIExtension; | ||
|
||
@Component(service = WebSphereCDIExtension.class, configurationPolicy = ConfigurationPolicy.IGNORE, immediate = true) | ||
public class OpenTracingCDIInjectionExtension implements WebSphereCDIExtension, Extension {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
....ibm.ws.opentracing_fat/fat/src/com/ibm/ws/testing/opentracing/test/FATMPOpenTracing.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2017 IBM Corpo<ration and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - initial API and implementation | ||
*******************************************************************************/ | ||
package com.ibm.ws.testing.opentracing.test; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
import org.jboss.shrinkwrap.api.ShrinkWrap; | ||
import org.jboss.shrinkwrap.api.spec.WebArchive; | ||
import org.junit.AfterClass; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import com.ibm.websphere.simplicity.ShrinkHelper; | ||
|
||
import componenttest.annotation.MinimumJavaLevel; | ||
import componenttest.custom.junit.runner.Mode; | ||
import componenttest.custom.junit.runner.Mode.TestMode; | ||
import componenttest.topology.impl.LibertyServer; | ||
import componenttest.topology.impl.LibertyServerFactory; | ||
import junit.framework.Assert; | ||
|
||
/** | ||
* <p>Test that a JAXRS application with @Traced(false) works.</p> | ||
* | ||
* <p>The test suite:</p> | ||
* | ||
* <ul> | ||
* <li>{@link #testHelloWorld()}</li> | ||
* </ul> | ||
*/ | ||
@Mode(TestMode.FULL) | ||
@MinimumJavaLevel(javaLevel = 1.8) | ||
public class FATMPOpenTracing { | ||
/** | ||
* For tracing. | ||
*/ | ||
private static final Class<?> CLASS = FATMPOpenTracing.class; | ||
|
||
/** | ||
* Set to the generated server before any tests are run. | ||
*/ | ||
private static LibertyServer server; | ||
|
||
/** | ||
* Deploy the application and start the server. | ||
* | ||
* @throws Exception Errors deploying the application. | ||
*/ | ||
@BeforeClass | ||
public static void setUp() throws Exception { | ||
server = LibertyServerFactory.getLibertyServer("opentracingFATServer3"); | ||
WebArchive serviceWar = ShrinkWrap.create(WebArchive.class, "mpOpenTracing.war"); | ||
serviceWar.addPackages(true, "com.ibm.ws.testing.mpOpenTracing"); | ||
serviceWar.addAsWebInfResource( | ||
new File("test-applications/mpOpenTracing/resources/beans.xml")); | ||
ShrinkHelper.exportAppToServer(server, serviceWar); | ||
server.startServer(); | ||
} | ||
|
||
/** | ||
* Stop the server. | ||
* | ||
* @throws Exception Errors stopping the server. | ||
*/ | ||
@AfterClass | ||
public static void tearDown() throws Exception { | ||
server.stopServer(); | ||
} | ||
|
||
/** | ||
* Execute the Hello World JAXRS service and ensure it returns the expected response. | ||
* | ||
* @throws Exception Errors executing the service. | ||
*/ | ||
@Test | ||
public void testHelloWorld() throws Exception { | ||
String methodName = "testHelloWorld"; | ||
|
||
List<String> actualResponseLines = executeWebService("helloWorld"); | ||
|
||
FATLogging.info(CLASS, methodName, "Actual Response", actualResponseLines); | ||
|
||
Assert.assertEquals(1, actualResponseLines.size()); | ||
Assert.assertEquals("Hello World", actualResponseLines.get(0)); | ||
|
||
actualResponseLines = executeWebService("getTracerState"); | ||
|
||
String tracerState = ""; | ||
for (String actualResponseLine : actualResponseLines) { | ||
tracerState += actualResponseLine; | ||
} | ||
|
||
int expectedSpans = 2; | ||
int spanCount = getSpanCount(tracerState); | ||
if (spanCount != expectedSpans) { | ||
Assert.assertEquals("Expected " + expectedSpans + " spans but found " + spanCount + ":", tracerState); | ||
} | ||
} | ||
|
||
protected List<String> executeWebService(String method) throws Exception { | ||
String requestUrl = "http://" + | ||
server.getHostname() + ":" + | ||
server.getHttpDefaultPort() + | ||
"/mpOpenTracing/rest/ws/" + method; | ||
|
||
return FATUtilsServer.gatherHttpRequest(FATUtilsServer.HttpRequestMethod.GET, requestUrl); | ||
} | ||
|
||
protected int getSpanCount(String tracerState) { | ||
int result = 0; | ||
int i = 0; | ||
i = tracerState.indexOf("spanId", i); | ||
while (i != -1) { | ||
result++; | ||
i = tracerState.indexOf("spanId", i + 1); | ||
} | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
dev/com.ibm.ws.opentracing_fat/publish/servers/opentracingFATServer3/.gitignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
apps/ |
1 change: 1 addition & 0 deletions
1
dev/com.ibm.ws.opentracing_fat/publish/servers/opentracingFATServer3/bootstrap.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bootstrap.include=../testports.properties |
Oops, something went wrong.