[JBoss JIRA] (ARQ-1937) Class loading issue with injected deployer
by Aslak Knutsen (JIRA)
[ https://issues.jboss.org/browse/ARQ-1937?page=com.atlassian.jira.plugin.s... ]
Aslak Knutsen commented on ARQ-1937:
------------------------------------
Good catch! :)
> Class loading issue with injected deployer
> -------------------------------------------
>
> Key: ARQ-1937
> URL: https://issues.jboss.org/browse/ARQ-1937
> Project: Arquillian
> Issue Type: Bug
> Components: Deployable Containers SPI
> Affects Versions: 1.1.1.Final
> Reporter: Martin Gencur
> Assignee: Aslak Knutsen
> Fix For: 1.1.11.Final
>
>
> Steps to reproduce:
> 1) inject a Deployer via @ArquillianResource
> 2) declare a deployment as managed=false, use the deployer to deploy artifacts to a managed container
> 3) run a test method that operates on the deployment
> 4) check that classes inside the test method have the same classloader as the test class itself (see the code below where I call cache.getClass().getClassLoader())
> 5) this does not happen when the deployment is managed=true and deployer API is NOT used. In this case, the classes have a different class loader
> In the test below, I tried to load different versions of Infinispan in two deployments and test backward compatibility. However, due to this class loading issue the Infinispan classes are of the latest version regardless of libraries bundled in the WAR. This is probably due to the fact that the Maven test module has the latest Infinispan libraries defined in <dependencies> while the older version is downloaded separately via Maven dependency plugin.
> {code}
> package com.jboss.datagrid.test.backwardcompatibility;
> @RunWith(Arquillian.class)
> public class SingleFileStoreBackwardCompatibilityIT {
> private DefaultCacheManager dfc;
> private String cacheName = "testCache";
> private static final String OLD_ISPN = "dep1_with_old_ispn";
> private static final String NEW_ISPN = "dep2_with_new_ispn";
> private static Map<String, String> storedMap;
> @ArquillianResource
> Deployer deployer;
> @Deployment(name = OLD_ISPN, testable = true, managed = true, order=1)
> @TargetsContainer("container1")
> public static WebArchive createDeploymentOld() {
> WebArchive jar = DeploymentBuilder.createTestArchiveWithPreviousJDG("test1.war", "previous");
> System.out.println("ClassLoader: " + SingleFileStoreBackwardCompatibilityIT.class.getClassLoader());
> return jar;
> }
> @Deployment(name = NEW_ISPN, testable = true, managed = true, order=2)
> @TargetsContainer("container2")
> public static WebArchive createDeploymentNew() {
> WebArchive jar = DeploymentBuilder.createTestArchive("test2.war", "current");
> return jar;
> }
> private DefaultCacheManager configureCacheManager(boolean clearCacheStore) throws Exception {
> GlobalConfiguration glob = new GlobalConfigurationBuilder().nonClusteredDefault()
> .globalJmxStatistics().allowDuplicateDomains(true).
> build();
> ConfigurationBuilder c = new ConfigurationBuilder();
> c.clustering().cacheMode(CacheMode.LOCAL);
> File tmpStore = new File("/tmp/cache/" + cacheName + ".dat");
> if (clearCacheStore && tmpStore.exists()) {
> tmpStore.delete();
> }
> c.persistence().passivation(false).addSingleFileStore().purgeOnStartup(false).location("/tmp/cache/");
> Configuration cnf = c.build();
> DefaultCacheManager manager = new DefaultCacheManager(glob);
> manager.defineConfiguration(cacheName, cnf);
> return manager;
> }
> @Test
> @OperateOnDeployment(OLD_ISPN)
> @InSequence(1)
> public void testStoreWithOldJDG() throws Exception {
> deployer.deploy(OLD_ISPN);
> dfc = configureCacheManager(true);
> dfc.start();
> Cache<Object, Object> cache = dfc.getCache(cacheName);
> System.out.println("Version: " + cache.getVersion());
> System.out.println("ClassLoader: " + cache.getClass().getClassLoader());
> storedMap = new HashMap<String, String>();
> storedMap.put("k", "v");
> cache.put("mapKey", storedMap);
> dfc.stop();
> deployer.undeploy(OLD_ISPN);
> }
> @Test
> @OperateOnDeployment(NEW_ISPN)
> @InSequence(2)
> public void testReadWithNewJDG() throws Exception {
> deployer.deploy(NEW_ISPN);
> dfc = configureCacheManager(false);
> dfc.start();
> Cache<Object, Object> cache = dfc.getCache(cacheName);
> System.out.println("ClassLoader: " + cache.getClass().getClassLoader());
> System.out.println("Version: " + cache.getVersion());
> assertEquals(storedMap, cache.get("mapKey"));
> dfc.stop();
> deployer.undeploy(NEW_ISPN);
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 10 months
[JBoss JIRA] (ARQGRA-472) TestCases are copy-pasted
by Matous Jobanek (JIRA)
[ https://issues.jboss.org/browse/ARQGRA-472?page=com.atlassian.jira.plugin... ]
Work on ARQGRA-472 started by Matous Jobanek.
---------------------------------------------
> TestCases are copy-pasted
> -------------------------
>
> Key: ARQGRA-472
> URL: https://issues.jboss.org/browse/ARQGRA-472
> Project: Arquillian Graphene
> Issue Type: Bug
> Components: unit-test
> Affects Versions: 2.1-Tracking
> Reporter: Vitalii Grygoryuk
> Assignee: Matous Jobanek
> Fix For: 2.1-Tracking
>
>
> TestHandlingOfStaleElements.testDeletion() and TestHandlingOfStaleElements.testReplacement() are both testing deletion, so there is no test case for node replacement logic:
> {code}
> @Test
> public void testDeletion() {
> rootElement.isDisplayed();
> executor.executeScript("return arguments[0].parentNode.removeChild(arguments[0])", rootElement);
> try {
> rootElement.isDisplayed();
> fail("rootElement should not be found");
> } catch (NoSuchElementException e) {
> }
> }
> @Test
> public void testReplacement() {
> rootElement.isDisplayed();
> executor.executeScript("return arguments[0].parentNode.removeChild(arguments[0])", rootElement);
> try {
> rootElement.isDisplayed();
> fail("rootElement should not be found");
> } catch (NoSuchElementException e) {
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 10 months
[JBoss JIRA] (ARQGRA-472) TestCases are copy-pasted
by Matous Jobanek (JIRA)
[ https://issues.jboss.org/browse/ARQGRA-472?page=com.atlassian.jira.plugin... ]
Work on ARQGRA-472 stopped by Matous Jobanek.
---------------------------------------------
> TestCases are copy-pasted
> -------------------------
>
> Key: ARQGRA-472
> URL: https://issues.jboss.org/browse/ARQGRA-472
> Project: Arquillian Graphene
> Issue Type: Bug
> Components: unit-test
> Affects Versions: 2.1-Tracking
> Reporter: Vitalii Grygoryuk
> Assignee: Matous Jobanek
> Fix For: 2.1-Tracking
>
>
> TestHandlingOfStaleElements.testDeletion() and TestHandlingOfStaleElements.testReplacement() are both testing deletion, so there is no test case for node replacement logic:
> {code}
> @Test
> public void testDeletion() {
> rootElement.isDisplayed();
> executor.executeScript("return arguments[0].parentNode.removeChild(arguments[0])", rootElement);
> try {
> rootElement.isDisplayed();
> fail("rootElement should not be found");
> } catch (NoSuchElementException e) {
> }
> }
> @Test
> public void testReplacement() {
> rootElement.isDisplayed();
> executor.executeScript("return arguments[0].parentNode.removeChild(arguments[0])", rootElement);
> try {
> rootElement.isDisplayed();
> fail("rootElement should not be found");
> } catch (NoSuchElementException e) {
> }
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)
8 years, 10 months