use of org.jboss.jca.common.spi.annotations.repository.AnnotationRepository in project wildfly by wildfly.
the class AnnotationsTestCase method testProcessAdministeredObject.
/**
* Process: AdministeredObject -- verification of the
* processAdministeredObject method
*
* @throws Throwable throwable exception
*/
@Test
public void testProcessAdministeredObject() throws Throwable {
try {
URI uri = getURI("/ra16annoadminobj.rar");
final VirtualFile virtualFile = VFS.getChild(uri);
final Indexer indexer = new Indexer();
final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", VisitorAttributes.RECURSE_LEAVES_ONLY));
for (VirtualFile classFile : classChildren) {
InputStream inputStream = null;
try {
inputStream = classFile.openStream();
indexer.index(inputStream);
} finally {
VFSUtils.safeClose(inputStream);
}
}
final Index index = indexer.complete();
AnnotationRepository ar = new JandexAnnotationRepositoryImpl(index, Thread.currentThread().getContextClassLoader());
annotations.process(ar, null, Thread.currentThread().getContextClassLoader());
} catch (Throwable t) {
fail(t.getMessage());
}
}
use of org.jboss.jca.common.spi.annotations.repository.AnnotationRepository in project wildfly by wildfly.
the class AnnotationsTestCase method testProcessConnectorManualSpecConnector.
/**
* Process: Connector -- verification of the processConnector method
*
* @throws Throwable throwable exception
*/
public void testProcessConnectorManualSpecConnector() throws Throwable {
// Test prep
AnnotationRepository ar = null;
try {
File srcRars = new File("./target/test-classes/org/jboss/as/connector/deployers/spec/rars");
File srcRa16 = new File("./target/test-classes/org/jboss/as/connector/deployers/spec/rars/ra16inoutmultianno");
final String destRars = MULTIANNO_TARGET + "/org/jboss/as/connector/deployers/spec/rars";
final String destRa16 = MULTIANNO_TARGET + "/org/jboss/as/connector/deployers/spec/rars/ra16inoutmultianno";
for (File srcFile : srcRars.listFiles()) {
if (!srcFile.isDirectory()) {
Files.copy(srcFile, new File(destRars + "/" + srcFile.getName()));
}
}
for (File srcFile : srcRa16.listFiles()) {
if (!srcFile.isDirectory() && !"TestResourceAdapter.class".equals(srcFile.getName())) {
Files.copy(srcFile, new File(destRa16 + "/" + srcFile.getName()));
}
}
URI uri = getURI("/ra16inoutmultianno.rar");
final VirtualFile virtualFile = VFS.getChild(uri);
final Indexer indexer = new Indexer();
final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", VisitorAttributes.RECURSE_LEAVES_ONLY));
for (VirtualFile classFile : classChildren) {
System.out.println("testProcessConnectorFailNoConnector: adding " + classFile.getPathName());
InputStream inputStream = null;
try {
inputStream = classFile.openStream();
indexer.index(inputStream);
} finally {
VFSUtils.safeClose(inputStream);
}
}
final Index index = indexer.complete();
ar = new JandexAnnotationRepositoryImpl(index, Thread.currentThread().getContextClassLoader());
} catch (Throwable e) {
e.printStackTrace();
fail("Test preparation error " + e.getMessage());
}
Collection<Annotation> values = ar.getAnnotation(javax.resource.spi.Connector.class);
assertNull(values);
// Test run
annotations.process(ar, "org.jboss.as.connector.deployers.spec.rars.BaseResourceAdapter", Thread.currentThread().getContextClassLoader());
}
use of org.jboss.jca.common.spi.annotations.repository.AnnotationRepository in project wildfly by wildfly.
the class AnnotationsTestCase method testProcessConnectorFailTooManyConnectors.
/**
* Process: Connector -- verification of the processConnector method
*
* @throws Throwable throwable exception
*/
@Test(expected = ValidateException.class)
public void testProcessConnectorFailTooManyConnectors() throws Throwable {
// Test prep
AnnotationRepository ar = null;
try {
File srcRars = new File("./target/test-classes/org/jboss/as/connector/deployers/spec/rars");
File srcRa16 = new File("./target/test-classes/org/jboss/as/connector/deployers/spec/rars/ra16inoutmultianno");
File srcStandalone = new File("./target/test-classes/org/jboss/as/connector/deployers/spec/rars/rastandalone");
final String destRars = MULTIANNO_TARGET + "/org/jboss/as/connector/deployers/spec/rars";
final String destRa16 = MULTIANNO_TARGET + "/org/jboss/as/connector/deployers/spec/rars/ra16inoutmultianno";
final String destStandalone = MULTIANNO_TARGET + "/org/jboss/as/connector/deployers/spec/rars/rastandalone";
Files.createParentDirs(new File(destStandalone + "/sample.file"));
for (File srcFile : srcRars.listFiles()) {
if (!srcFile.isDirectory()) {
Files.copy(srcFile, new File(destRars + "/" + srcFile.getName()));
}
}
for (File srcFile : srcRa16.listFiles()) {
if (!srcFile.isDirectory()) {
Files.copy(srcFile, new File(destRa16 + "/" + srcFile.getName()));
}
}
for (File srcFile : srcStandalone.listFiles()) {
if (!srcFile.isDirectory()) {
Files.copy(srcFile, new File(destStandalone + "/" + srcFile.getName()));
}
}
URI uri = getURI("/ra16inoutmultianno.rar");
final VirtualFile virtualFile = VFS.getChild(uri);
final Indexer indexer = new Indexer();
final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", VisitorAttributes.RECURSE_LEAVES_ONLY));
for (VirtualFile classFile : classChildren) {
System.out.println("testProcessConnectorFailTooManyConnectors: adding " + classFile.getPathName());
InputStream inputStream = null;
try {
inputStream = classFile.openStream();
indexer.index(inputStream);
} finally {
VFSUtils.safeClose(inputStream);
}
}
final Index index = indexer.complete();
ar = new JandexAnnotationRepositoryImpl(index, Thread.currentThread().getContextClassLoader());
} catch (Throwable e) {
e.printStackTrace();
fail("Test preparation error " + e.getMessage());
}
Collection<Annotation> values = ar.getAnnotation(javax.resource.spi.Connector.class);
assertNotNull(values);
assertEquals(2, values.size());
// Test run
annotations.process(ar, null, Thread.currentThread().getContextClassLoader());
}
use of org.jboss.jca.common.spi.annotations.repository.AnnotationRepository in project wildfly by wildfly.
the class AnnotationsTestCase method testProcessConnector.
/**
* Process: Connector -- verification of the processConnector method
*
* @throws Throwable throwable exception
*/
@Test
public void testProcessConnector() throws Throwable {
// Test prep
File srcRars = new File("./target/test-classes/org/jboss/as/connector/deployers/spec/rars");
File srcRa16 = new File("./target/test-classes/org/jboss/as/connector/deployers/spec/rars/ra16inoutmultianno");
final String destRars = MULTIANNO_TARGET + "/org/jboss/as/connector/deployers/spec/rars";
final String destRa16 = MULTIANNO_TARGET + "/org/jboss/as/connector/deployers/spec/rars/ra16inoutmultianno";
for (File srcFile : srcRars.listFiles()) {
if (!srcFile.isDirectory()) {
Files.copy(srcFile, new File(destRars + "/" + srcFile.getName()));
}
}
for (File srcFile : srcRa16.listFiles()) {
if (!srcFile.isDirectory()) {
Files.copy(srcFile, new File(destRa16 + "/" + srcFile.getName()));
}
}
URI uri = getURI("/ra16inoutmultianno.rar");
final VirtualFile virtualFile = VFS.getChild(uri);
final Indexer indexer = new Indexer();
final List<VirtualFile> classChildren = virtualFile.getChildren(new SuffixMatchFilter(".class", VisitorAttributes.RECURSE_LEAVES_ONLY));
for (VirtualFile classFile : classChildren) {
System.out.println("testProcessConnector: adding " + classFile.getPathName());
InputStream inputStream = null;
try {
inputStream = classFile.openStream();
indexer.index(inputStream);
} finally {
VFSUtils.safeClose(inputStream);
}
}
final Index index = indexer.complete();
AnnotationRepository ar = new JandexAnnotationRepositoryImpl(index, Thread.currentThread().getContextClassLoader());
Collection<Annotation> values = ar.getAnnotation(javax.resource.spi.Connector.class);
assertNotNull(values);
assertEquals(1, values.size());
// Test run
try {
annotations.process(ar, null, Thread.currentThread().getContextClassLoader());
} catch (Throwable t) {
t.printStackTrace();
fail(t.getMessage());
}
}
Aggregations