Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WELD-493 Restore Converted Arquillian Test Suite
- Loading branch information
1 parent
68a5398
commit 1861ab4
Showing
666 changed files
with
32,656 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
tests-arquillian/src/main/java/org/jboss/shrinkwrap/api/BeanArchive.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,38 @@ | ||
package org.jboss.shrinkwrap.api; | ||
|
||
import org.jboss.shrinkwrap.api.spec.JavaArchive; | ||
|
||
public interface BeanArchive extends JavaArchive | ||
{ | ||
|
||
/** | ||
* Adds Decorators to the beans.xml. | ||
* @param classes | ||
* @return | ||
*/ | ||
BeanArchive decorate(Class<?>... classes); | ||
|
||
/** | ||
* Adds Interceptors to the beans.xml. | ||
* | ||
* @param classes | ||
* @return | ||
*/ | ||
BeanArchive intercept(Class<?>... classes); | ||
|
||
/** | ||
* Adds Alternatives to the beans.xml. | ||
* | ||
* @param classes | ||
* @return | ||
*/ | ||
BeanArchive alternate(Class<?>... classes); | ||
|
||
/** | ||
* Adds a Stereotype Alternative to beans.xml. | ||
* | ||
* @param classes | ||
* @return | ||
*/ | ||
BeanArchive stereotype(Class<?>... classes); | ||
} |
137 changes: 137 additions & 0 deletions
137
tests-arquillian/src/main/java/org/jboss/shrinkwrap/impl/BeanArchiveImpl.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,137 @@ | ||
package org.jboss.shrinkwrap.impl; | ||
|
||
import org.jboss.shrinkwrap.api.Archive; | ||
import org.jboss.shrinkwrap.api.ArchivePath; | ||
import org.jboss.shrinkwrap.api.ArchivePaths; | ||
import org.jboss.shrinkwrap.api.BeanArchive; | ||
import org.jboss.shrinkwrap.impl.base.path.BasicPath; | ||
import org.jboss.shrinkwrap.impl.base.spec.JavaArchiveImpl; | ||
|
||
public class BeanArchiveImpl extends JavaArchiveImpl implements BeanArchive | ||
{ | ||
//-------------------------------------------------------------------------------------|| | ||
// Class Members ----------------------------------------------------------------------|| | ||
//-------------------------------------------------------------------------------------|| | ||
|
||
/** | ||
* Path to the manifests inside of the Archive. | ||
*/ | ||
private static final ArchivePath PATH_MANIFEST = new BasicPath("META-INF"); | ||
|
||
/** | ||
* Path to the resources inside of the Archive. | ||
*/ | ||
private static final ArchivePath PATH_RESOURCE = new BasicPath("/"); | ||
|
||
/** | ||
* Path to the classes inside of the Archive. | ||
*/ | ||
private static final ArchivePath PATH_CLASSES = new BasicPath("/"); | ||
|
||
/** | ||
* Beans XML object | ||
*/ | ||
private BeansXml descriptor; | ||
|
||
public BeanArchiveImpl(final Archive<?> delegate) | ||
{ | ||
super(delegate); | ||
|
||
// add beans.xml descriptor | ||
descriptor = new BeansXml(); | ||
addManifestResource(descriptor, ArchivePaths.create("beans.xml")); | ||
} | ||
|
||
//-------------------------------------------------------------------------------------|| | ||
// Required Implementations -----------------------------------------------------------|| | ||
//-------------------------------------------------------------------------------------|| | ||
|
||
/* (non-Javadoc) | ||
* @see org.jboss.declarchive.impl.base.ContainerBase#getManinfestPath() | ||
*/ | ||
@Override | ||
protected ArchivePath getManifestPath() | ||
{ | ||
return PATH_MANIFEST; | ||
} | ||
|
||
/* | ||
* (non-Javadoc) | ||
* @see org.jboss.shrinkwrap.impl.base.container.ContainerBase#getClassesPath() | ||
*/ | ||
@Override | ||
protected ArchivePath getClassesPath() | ||
{ | ||
return PATH_CLASSES; | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see org.jboss.declarchive.impl.base.ContainerBase#getResourcePath() | ||
*/ | ||
@Override | ||
protected ArchivePath getResourcePath() | ||
{ | ||
return PATH_RESOURCE; | ||
} | ||
|
||
/** | ||
* Libraries are not supported by JavaArchive. | ||
* | ||
* @throws UnsupportedOperationException Libraries are not supported by JavaArchive | ||
*/ | ||
@Override | ||
public ArchivePath getLibraryPath() | ||
{ | ||
throw new UnsupportedOperationException("JavaArchive spec does not support Libraries"); | ||
} | ||
|
||
//-------------------------------------------------------------------------------------|| | ||
// Required Implementations - BeanArchive ---------------------------------------------|| | ||
//-------------------------------------------------------------------------------------|| | ||
|
||
/* (non-Javadoc) | ||
* @see org.jboss.shrinkwrap.api.BeanArchive#decorate(java.lang.Class<?>[]) | ||
*/ | ||
public BeanArchive decorate(Class<?>... classes) | ||
{ | ||
descriptor.decorators(classes); | ||
addClasses(classes); | ||
return covarientReturn(); | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see org.jboss.shrinkwrap.api.BeanArchive#intercept(java.lang.Class<?>[]) | ||
*/ | ||
public BeanArchive intercept(Class<?>... classes) | ||
{ | ||
descriptor.interceptors(classes); | ||
addClasses(classes); | ||
return covarientReturn(); | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see org.jboss.shrinkwrap.api.BeanArchive#alternate(java.lang.Class<?>[]) | ||
*/ | ||
public BeanArchive alternate(Class<?>... classes) | ||
{ | ||
descriptor.alternatives(classes); | ||
addClasses(classes); | ||
return covarientReturn(); | ||
} | ||
|
||
/* (non-Javadoc) | ||
* @see org.jboss.shrinkwrap.api.BeanArchive#stereotype(java.lang.Class<?>[]) | ||
*/ | ||
public BeanArchive stereotype(Class<?>... classes) | ||
{ | ||
descriptor.stereotype(classes); | ||
addClasses(classes); | ||
return covarientReturn(); | ||
} | ||
|
||
@Override | ||
protected BeanArchive covarientReturn() | ||
{ | ||
return (BeanArchive)super.covarientReturn(); | ||
} | ||
} |
88 changes: 88 additions & 0 deletions
88
tests-arquillian/src/main/java/org/jboss/shrinkwrap/impl/BeansXml.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,88 @@ | ||
package org.jboss.shrinkwrap.impl; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.InputStream; | ||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.jboss.shrinkwrap.api.asset.Asset; | ||
|
||
class BeansXml implements Asset | ||
{ | ||
private List<Class<?>> alternatives = new ArrayList<Class<?>>(); | ||
private List<Class<?>> interceptors = new ArrayList<Class<?>>(); | ||
private List<Class<?>> decorators = new ArrayList<Class<?>>(); | ||
private List<Class<?>> stereotypes = new ArrayList<Class<?>>(); | ||
|
||
BeansXml() { | ||
|
||
} | ||
|
||
public BeansXml alternatives(Class<?>... alternatives) | ||
{ | ||
this.alternatives.addAll(Arrays.asList(alternatives)); | ||
return this; | ||
} | ||
|
||
public BeansXml interceptors(Class<?>... interceptors) | ||
{ | ||
this.interceptors.addAll(Arrays.asList(interceptors)); | ||
return this; | ||
} | ||
|
||
public BeansXml decorators(Class<?>... decorators) | ||
{ | ||
this.decorators.addAll(Arrays.asList(decorators)); | ||
return this; | ||
} | ||
|
||
public BeansXml stereotype(Class<?>... stereotypes) | ||
{ | ||
this.stereotypes.addAll(Arrays.asList(stereotypes)); | ||
return this; | ||
} | ||
|
||
public InputStream openStream() | ||
{ | ||
StringBuilder xml = new StringBuilder(); | ||
xml.append("<beans>\n"); | ||
appendAlternatives(alternatives, stereotypes, xml); | ||
appendSection("interceptors", "class", interceptors, xml); | ||
appendSection("decorators", "class", decorators, xml); | ||
xml.append("</beans>"); | ||
|
||
return new ByteArrayInputStream(xml.toString().getBytes()); | ||
} | ||
|
||
private void appendAlternatives(List<Class<?>> alternatives, List<Class<?>> stereotypes, StringBuilder xml) | ||
{ | ||
if(alternatives.size() > 0 || stereotypes.size() > 0) | ||
{ | ||
xml.append("<").append("alternatives").append(">\n"); | ||
appendClasses("class", alternatives, xml); | ||
appendClasses("stereotype", stereotypes, xml); | ||
xml.append("</").append("alternatives").append(">\n"); | ||
} | ||
} | ||
|
||
private void appendSection(String name, String subName, List<Class<?>> classes, StringBuilder xml) | ||
{ | ||
if(classes.size() > 0) | ||
{ | ||
xml.append("<").append(name).append(">\n"); | ||
appendClasses(subName, classes, xml); | ||
xml.append("</").append(name).append(">\n"); | ||
} | ||
} | ||
|
||
private void appendClasses(String name, List<Class<?>> classes, StringBuilder xml) | ||
{ | ||
for(Class<?> clazz : classes) | ||
{ | ||
xml.append("<").append(name).append(">") | ||
.append(clazz.getName()) | ||
.append("</").append(name).append(">\n"); | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
tests-arquillian/src/main/java/org/jboss/weld/mock/AbstractMockDeployment.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,50 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2010, Red Hat, Inc., and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.jboss.weld.mock; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.jboss.weld.bootstrap.api.ServiceRegistry; | ||
import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry; | ||
import org.jboss.weld.bootstrap.spi.BeanDeploymentArchive; | ||
import org.jboss.weld.bootstrap.spi.Deployment; | ||
|
||
public abstract class AbstractMockDeployment implements Deployment | ||
{ | ||
|
||
private final List<BeanDeploymentArchive> beanDeploymentArchives; | ||
private final ServiceRegistry services; | ||
|
||
public AbstractMockDeployment(BeanDeploymentArchive... beanDeploymentArchives) | ||
{ | ||
this.services = new SimpleServiceRegistry(); | ||
this.beanDeploymentArchives = new ArrayList<BeanDeploymentArchive>(Arrays.asList(beanDeploymentArchives)); | ||
} | ||
|
||
public List<BeanDeploymentArchive> getBeanDeploymentArchives() | ||
{ | ||
return beanDeploymentArchives; | ||
} | ||
|
||
public ServiceRegistry getServices() | ||
{ | ||
return services; | ||
} | ||
|
||
} |
Oops, something went wrong.