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 #9711 from maeste/WFLY-8074
Wfly 8074
- Loading branch information
Showing
8 changed files
with
373 additions
and
2 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
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
92 changes: 92 additions & 0 deletions
92
...est/java/org/jboss/as/test/integration/ejb/mdb/activationname/ActivationNameTestCase.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,92 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017, Red Hat Middleware LLC, and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.test.integration.ejb.mdb.activationname; | ||
|
||
import org.jboss.arquillian.container.test.api.Deployment; | ||
import org.jboss.arquillian.junit.Arquillian; | ||
import org.jboss.arquillian.test.api.ArquillianResource; | ||
import org.jboss.as.connector.util.ConnectorServices; | ||
import org.jboss.as.test.integration.ejb.mdb.activationname.adapter.SimpleListener; | ||
import org.jboss.as.test.integration.ejb.mdb.activationname.adapter.SimpleResourceAdapter; | ||
import org.jboss.as.test.integration.ejb.mdb.activationname.mdb.SimpleMdb; | ||
import org.jboss.jca.core.spi.rar.Endpoint; | ||
import org.jboss.jca.core.spi.rar.ResourceAdapterRepository; | ||
import org.jboss.msc.service.ServiceContainer; | ||
import org.jboss.msc.service.ServiceController; | ||
import org.jboss.shrinkwrap.api.Archive; | ||
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.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import javax.resource.spi.ActivationSpec; | ||
import javax.resource.spi.endpoint.MessageEndpointFactory; | ||
import java.util.Set; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
import static org.junit.Assert.assertNotNull; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
/** | ||
* This tests if IronJacamar follows JCA 1.7 and properly defines {@code activation name} on {@code MessageEndpointFactory}. | ||
* For details see {@link SimpleResourceAdapter#endpointActivation(MessageEndpointFactory, ActivationSpec)} and WFLY-8074. | ||
* | ||
* @author Ivo Studensky | ||
*/ | ||
@RunWith(Arquillian.class) | ||
public class ActivationNameTestCase { | ||
|
||
@Deployment | ||
public static Archive createDeplyoment() { | ||
final EnterpriseArchive ear = ShrinkWrap.create(EnterpriseArchive.class, "ear-with-simple-adapter.ear") | ||
.addAsModule(ShrinkWrap.create(JavaArchive.class, "simple-adapter.rar") | ||
.addAsManifestResource(SimpleResourceAdapter.class.getPackage(), "ra.xml", "ra.xml") | ||
.addPackage(SimpleResourceAdapter.class.getPackage())) | ||
.addAsModule(ShrinkWrap.create(JavaArchive.class, "mdb.jar") | ||
.addClasses(SimpleMdb.class, ActivationNameTestCase.class) | ||
.addAsManifestResource(new StringAsset("Dependencies: org.jboss.as.connector, org.jboss.ironjacamar.api\n"), "MANIFEST.MF")); | ||
|
||
return ear; | ||
} | ||
|
||
@ArquillianResource | ||
ServiceContainer serviceContainer; | ||
|
||
@Test | ||
public void testSimpleResourceAdapterAvailability() throws Exception { | ||
ServiceController<?> controller = serviceContainer.getService(ConnectorServices.RA_REPOSITORY_SERVICE); | ||
assertNotNull(controller); | ||
ResourceAdapterRepository repository = (ResourceAdapterRepository) controller.getValue(); | ||
assertNotNull(repository); | ||
Set<String> ids = repository.getResourceAdapters(SimpleListener.class); | ||
assertNotNull(ids); | ||
assertEquals(1, ids.size()); | ||
|
||
String piId = ids.iterator().next(); | ||
assertTrue(piId.indexOf("SimpleResourceAdapter") != -1); | ||
|
||
Endpoint endpoint = repository.getEndpoint(piId); | ||
assertNotNull(endpoint); | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...va/org/jboss/as/test/integration/ejb/mdb/activationname/adapter/SimpleActivationSpec.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,53 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017, Red Hat Middleware LLC, and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.test.integration.ejb.mdb.activationname.adapter; | ||
|
||
import javax.resource.ResourceException; | ||
import javax.resource.spi.ActivationSpec; | ||
import javax.resource.spi.InvalidPropertyException; | ||
import javax.resource.spi.ResourceAdapter; | ||
|
||
/** | ||
* @author Ivo Studensky | ||
*/ | ||
public class SimpleActivationSpec implements ActivationSpec { | ||
|
||
private ResourceAdapter resourceAdapter; | ||
|
||
public SimpleActivationSpec() { | ||
} | ||
|
||
@Override | ||
public void validate() throws InvalidPropertyException { | ||
// nothing to validate here | ||
} | ||
|
||
@Override | ||
public ResourceAdapter getResourceAdapter() { | ||
return resourceAdapter; | ||
} | ||
|
||
@Override | ||
public void setResourceAdapter(ResourceAdapter ra) throws ResourceException { | ||
this.resourceAdapter = ra; | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...est/java/org/jboss/as/test/integration/ejb/mdb/activationname/adapter/SimpleListener.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,29 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017, Red Hat Middleware LLC, and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.test.integration.ejb.mdb.activationname.adapter; | ||
|
||
/** | ||
* @author Ivo Studensky | ||
*/ | ||
public interface SimpleListener { | ||
void onMessage(); | ||
} |
123 changes: 123 additions & 0 deletions
123
...a/org/jboss/as/test/integration/ejb/mdb/activationname/adapter/SimpleResourceAdapter.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,123 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source. | ||
* Copyright 2017, Red Hat Middleware LLC, and individual contributors | ||
* as indicated by the @author tags. See the copyright.txt file in the | ||
* distribution for a full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
package org.jboss.as.test.integration.ejb.mdb.activationname.adapter; | ||
|
||
import javax.resource.ResourceException; | ||
import javax.resource.spi.ActivationSpec; | ||
import javax.resource.spi.BootstrapContext; | ||
import javax.resource.spi.ResourceAdapter; | ||
import javax.resource.spi.ResourceAdapterInternalException; | ||
import javax.resource.spi.endpoint.MessageEndpointFactory; | ||
import javax.transaction.xa.XAResource; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* @author Ivo Studensky | ||
*/ | ||
public class SimpleResourceAdapter implements ResourceAdapter { | ||
|
||
private Map<SimpleActivationSpec, SimpleActivation> activations; | ||
|
||
public SimpleResourceAdapter() { | ||
this.activations = Collections.synchronizedMap(new HashMap<SimpleActivationSpec, SimpleActivation>()); | ||
} | ||
|
||
@Override | ||
public void start(BootstrapContext bootstrapContext) throws ResourceAdapterInternalException { | ||
} | ||
|
||
@Override | ||
public void stop() { | ||
} | ||
|
||
@Override | ||
public void endpointActivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) throws ResourceException { | ||
final String activationName = messageEndpointFactory.getActivationName(); | ||
if (activationName == null) { | ||
throw new ResourceException("MessageEndpointFactory#getActivationName() cannot be null [WFLY-8074]."); | ||
} | ||
SimpleActivation activation = new SimpleActivation(this, messageEndpointFactory, (SimpleActivationSpec) activationSpec); | ||
activations.put((SimpleActivationSpec) activationSpec, activation); | ||
activation.start(); | ||
} | ||
|
||
@Override | ||
public void endpointDeactivation(MessageEndpointFactory messageEndpointFactory, ActivationSpec activationSpec) { | ||
SimpleActivation activation = activations.remove(activationSpec); | ||
if (activation != null) { activation.stop(); } | ||
} | ||
|
||
@Override | ||
public XAResource[] getXAResources(ActivationSpec[] activationSpecs) throws ResourceException { | ||
return new XAResource[0]; | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = 17; | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(final Object other) { | ||
if (other == null) { return false; } | ||
|
||
if (other == this) { return true; } | ||
|
||
if (!(other instanceof SimpleResourceAdapter)) { return false; } | ||
|
||
SimpleResourceAdapter obj = (SimpleResourceAdapter) other; | ||
boolean result = true; | ||
return result; | ||
} | ||
|
||
class SimpleActivation { | ||
private SimpleResourceAdapter ra; | ||
private SimpleActivationSpec spec; | ||
private MessageEndpointFactory endpointFactory; | ||
|
||
public SimpleActivation(SimpleResourceAdapter ra, | ||
MessageEndpointFactory endpointFactory, | ||
SimpleActivationSpec spec) | ||
throws ResourceException { | ||
this.ra = ra; | ||
this.endpointFactory = endpointFactory; | ||
this.spec = spec; | ||
} | ||
|
||
public SimpleActivationSpec getActivationSpec() { | ||
return spec; | ||
} | ||
|
||
public MessageEndpointFactory getMessageEndpointFactory() { | ||
return endpointFactory; | ||
} | ||
|
||
public void start() throws ResourceException { | ||
} | ||
|
||
public void stop() { | ||
} | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
...n/basic/src/test/java/org/jboss/as/test/integration/ejb/mdb/activationname/adapter/ra.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,32 @@ | ||
<connector xmlns="http://java.sun.com/xml/ns/j2ee" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee | ||
http://java.sun.com/xml/ns/j2ee/connector_1_5.xsd" | ||
version="1.5"> | ||
|
||
<description>Simple Resource Adapter</description> | ||
<display-name>Simple Resource Adapter</display-name> | ||
|
||
<vendor-name>JBoss</vendor-name> | ||
|
||
<eis-type>Simple Adapter</eis-type> | ||
|
||
<resourceadapter-version>1.0</resourceadapter-version> | ||
|
||
<resourceadapter id="SimpleResourceAdapter"> | ||
|
||
<resourceadapter-class>org.jboss.as.test.integration.ejb.mdb.activationname.adapter.SimpleResourceAdapter</resourceadapter-class> | ||
|
||
<inbound-resourceadapter> | ||
<messageadapter> | ||
<messagelistener> | ||
<messagelistener-type>org.jboss.as.test.integration.ejb.mdb.activationname.adapter.SimpleListener</messagelistener-type> | ||
<activationspec> | ||
<activationspec-class>org.jboss.as.test.integration.ejb.mdb.activationname.adapter.SimpleActivationSpec</activationspec-class> | ||
</activationspec> | ||
</messagelistener> | ||
</messageadapter> | ||
</inbound-resourceadapter> | ||
|
||
</resourceadapter> | ||
</connector> |
Oops, something went wrong.