Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotation scan ear libs #30592

Open
wants to merge 3 commits into
base: integration
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 0 additions & 20 deletions dev/cnf/dependabot/check_this_in_if_it_changes/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2601,26 +2601,6 @@
<artifactId>checker-compat-qual</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-xc</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
Expand Down
3 changes: 3 additions & 0 deletions dev/com.ibm.ws.anno_fat/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
<classpathentry kind="src" path="test-applications/LooseConfig/LooseServlet1.jar/src"/>
<classpathentry kind="src" path="test-applications/LooseConfig/LooseServlet2.jar/src"/>
<classpathentry kind="src" path="test-applications/LooseConfig/LooseServlet3.jar/src"/>
<classpathentry kind="src" path="test-applications/SpringAnnoTest/SpringAnnoTest.war/src"/>
<classpathentry kind="src" path="test-applications/SpringAnnoTest/SpringAnnoTest.jar/src"/>
<classpathentry kind="con" path="aQute.bnd.classpath.container"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="output" path="bin"/>
</classpath>
29 changes: 19 additions & 10 deletions dev/com.ibm.ws.anno_fat/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,26 @@ src: \
test-applications/LooseConfig/LooseWeb2.war/src, \
test-applications/LooseConfig/LooseServlet1.jar/src, \
test-applications/LooseConfig/LooseServlet2.jar/src, \
test-applications/LooseConfig/LooseServlet3.jar/src
test-applications/LooseConfig/LooseServlet3.jar/src, \
test-applications/SpringAnnoTest/SpringAnnoTest.war/src, \
test-applications/SpringAnnoTest/SpringAnnoTest.jar/src

fat.project: true

tested.features: persistencecontainer-3.1, enterprisebeanslite-4.0, cdi-4.0, servlet-6.0, servlet-6.1

-buildpath: \
io.openliberty.org.apache.commons.logging;version=latest, \
io.openliberty.org.apache.commons.codec;version=latest, \
com.ibm.websphere.javaee.servlet.3.0;version=latest, \
com.ibm.websphere.javaee.jsp.2.2;version=latest, \
commons-httpclient:commons-httpclient;version=3.1, \
httpunit:httpunit;version=1.5.4, \
net.sf.jtidy:jtidy;version=9.3.8, \
org.apache.httpcomponents.client5:httpclient5;version=5.0.2, \
org.apache.httpcomponents.core5:httpcore5;version=5.0.2
io.openliberty.org.apache.commons.logging;version=latest,\
io.openliberty.org.apache.commons.codec;version=latest,\
com.ibm.websphere.javaee.servlet.3.0;version=latest,\
com.ibm.websphere.javaee.jsp.2.2;version=latest,\
commons-httpclient:commons-httpclient;version='3.1',\
httpunit:httpunit;version='1.5.4',\
net.sf.jtidy:jtidy;version='9.3.8',\
org.apache.httpcomponents.client5:httpclient5;version='5.0.2',\
org.apache.httpcomponents.core5:httpcore5;version='5.0.2',\
org.springframework:spring-beans;version='6.1.14',\
org.springframework:spring-context;version='6.1.14',\
org.springframework:spring-web;version='6.1.14',\
org.springframework:spring-webmvc;version='6.1.14',\
io.openliberty.jakarta.servlet.6.1
22 changes: 22 additions & 0 deletions dev/com.ibm.ws.anno_fat/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ configurations {
requiredLibs {
transitive = false
}
springLibs {
transitive = false
}
}

// Define G:A:V coordinates of each dependency
Expand All @@ -23,4 +26,23 @@ dependencies {
'org.apache.httpcomponents.client5:httpclient5:5.0.2',
'org.apache.httpcomponents.core5:httpcore5:5.0.2',
project(':io.openliberty.org.apache.commons.codec')
springLibs 'org.springframework:spring-beans:6.1.14',
'org.springframework:spring-context:6.1.14',
'org.springframework:spring-core:6.1.14',
'org.springframework:spring-expression:6.1.14',
'org.springframework:spring-web:6.1.14',
'org.springframework:spring-webmvc:6.1.14',
project(':io.openliberty.org.apache.commons.logging')
}

task downloadSpringLibs(type: Copy) {
from configurations.springLibs
into new File(autoFvtDir, 'publish/shared/resources/spring')
}

addRequiredLibraries {
dependsOn downloadSpringLibs
dependsOn addJakartaTransformer
}


Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.junit.runners.Suite.SuiteClasses;

import com.ibm.ws.fat.util.FatLogHandler;
import com.ibm.ws.tests.anno.caching.AnnotationScanInJarTest;
import com.ibm.ws.tests.anno.caching.CacheEnablementTest;
import com.ibm.ws.tests.anno.caching.FragmentOrderTest;
import com.ibm.ws.tests.anno.caching.LooseConfigTest;
Expand Down Expand Up @@ -54,7 +55,7 @@
@RunWith(Suite.class)
@SuiteClasses({
// Jandex tests
JandexAppDefaultAppMgrDefaultTest.class,
JandexAppDefaultAppMgrDefaultTest.class,
JandexAppDefaultAppMgrTrueTest.class,
JandexAppFalseAppMgrFalseTest.class,
JandexAppFalseAppMgrTrueTest.class,
Expand All @@ -66,7 +67,9 @@
MetadataCompleteTest.class,
MetadataIncompleteTest.class,
FragmentOrderTest.class,
LooseConfigTest.class,
LooseConfigTest.class,

AnnotationScanInJarTest.class

// BigAppTest.class
})
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package com.ibm.ws.tests.anno.caching;

import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.not;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;

import java.nio.file.DirectoryStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;

import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.StringAsset;
import org.jboss.shrinkwrap.api.spec.EnterpriseArchive;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.jboss.shrinkwrap.api.spec.WebArchive;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;

import com.ibm.websphere.simplicity.ShrinkHelper;
import com.ibm.websphere.simplicity.ShrinkHelper.DeployOptions;

import componenttest.annotation.Server;
import componenttest.custom.junit.runner.FATRunner;
import componenttest.rules.repeater.EERepeatActions;
import componenttest.rules.repeater.RepeatTests;
import componenttest.topology.impl.LibertyServer;
import componenttest.topology.utils.FATServletClient;
import spring.test.init.jar.JarInit;
import spring.test.init.war.WebInit;

@RunWith(FATRunner.class)
public class AnnotationScanInJarTest extends FATServletClient {

public static final String APP_NAME = "springTest";
public static final String SERVER_NAME = "springTest_server";

@Server(SERVER_NAME)
public static LibertyServer server;

@ClassRule
public static RepeatTests r = EERepeatActions.repeat(SERVER_NAME,
EERepeatActions.EE10,
EERepeatActions.EE11);

@BeforeClass
public static void setUp() throws Exception {

WebArchive war = ShrinkWrap.create(WebArchive.class, APP_NAME + ".war")
.addPackages(true, WebInit.class.getPackage())
.addAsWebInfResource(new StringAsset("logging.level.org.springframework.context.annotation=DEBUG"), "application.properties");

String userDir = System.getProperty("user.dir"); //ends with: com.ibm.ws.anno_fat/build/libs/autoFVT
String springDir = userDir + "/publish/shared/resources/spring/";



JavaArchive jar = ShrinkWrap.create(JavaArchive.class, APP_NAME + ".jar")
.addPackages(true, JarInit.class.getPackage());

EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, APP_NAME + ".ear")
.addAsModule(war)
.addAsLibraries(jar);

try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(springDir), "*.jar")) {
for (Path path : stream) {
if (!Files.isDirectory(path)) {
ear.addAsLibraries(path.toFile());
}
}
}

ShrinkHelper.exportDropinAppToServer(server, ear, DeployOptions.SERVER_ONLY);

server.startServer();
}

@AfterClass
public static void tearDown() throws Exception {
server.stopServer();
}


@Test
public void testSpringAnnotationFoundInwar() throws Exception {
List<String> matching = server.findStringsInLogsAndTraceUsingMark("AnnotationScanInJarTest test output");

String allOutput = String.join(" : ", matching);

assertTrue("Did not find \"onStartup method in war file\" in " + allOutput, allOutput.contains("onStartup method in war file"));
assertTrue("Did not find \"onStartup method found via jar file\" in " + allOutput, allOutput.contains("onStartup method found via jar file"));
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
bootstrap.include=../testports.properties
osgi.console=7777
com.ibm.ws.anno.ScanEarLibs=true
#com.ibm.ws.logging.trace.specification=*=info=enabled:com.ibm.ws.anno*=finer:com.ibm.ws.container.service*=finer

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<server description="Liberty server">

<include location="../fatTestPorts.xml" />

<featureManager>
<feature>componentTest-1.0</feature>
<feature>servlet-6.0</feature>
</featureManager>

<javaPermission className="java.security.AllPermission" name="*" actions="*" />
</server>
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package spring.test.init.jar;


import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;

import org.springframework.web.WebApplicationInitializer;

public class JarInit implements WebApplicationInitializer {

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
System.out.println("AnnotationScanInJarTest test output: onStartup method found via jar file");
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package spring.test.init.war;


import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;

import org.springframework.web.WebApplicationInitializer;

public class WebInit implements WebApplicationInitializer {

@Override
public void onStartup(ServletContext servletContext) throws ServletException {
System.out.println("AnnotationScanInJarTest test output: onStartup method in war file");
}

}
4 changes: 4 additions & 0 deletions dev/com.ibm.ws.container.service/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ Service-Component: \
greedy:=version;\
configuration-policy:=optional; \
properties:="service.vendor=IBM,toType=com.ibm.ws.container.service.config.WebFragmentsInfo", \
com.ibm.ws.container.service.config.WebFragmentInfoAdapter; \
implementation:=com.ibm.ws.container.service.config.internal.WebFragmentInfoAdapter; \
provide:=com.ibm.wsspi.adaptable.module.adapters.ContainerAdapter; \
properties:="service.vendor=IBM,toType=com.ibm.ws.container.service.config.WebFragmentInfo", \
com.ibm.ws.container.service.metadata.MetaDataService; \
implementation:=com.ibm.ws.container.service.metadata.internal.MetaDataServiceImpl; \
provide:='com.ibm.ws.container.service.metadata.MetaDataService,com.ibm.ws.container.service.metadata.internal.MetaDataServiceImpl,com.ibm.ws.container.service.metadata.extended.MetaDataIdentifierService'; \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public ModuleAnnotationsImpl(

//

private final ModuleInfo moduleInfo;
protected final ModuleInfo moduleInfo;

@Override
public ModuleInfo getModuleInfo() {
Expand Down
Loading