/** * {@inheritDoc} */ public void enrich(Object testCase) { if (embeddedInst.get() != null) { injectClass(testCase); } }
@SuppressWarnings("unchecked") private void injectClass(Object testCase) { try { List<Field> annotatedFields = SecurityActions.getFieldsWithAnnotation(testCase.getClass(), org.jboss.jca.embedded.arquillian.Inject.class); for (Field field : annotatedFields) { try { org.jboss.jca.embedded.arquillian.Inject annotation = field.getAnnotation(org.jboss.jca.embedded.arquillian.Inject.class); field.set(testCase, resolveResource(field, annotation)); } catch (Throwable t) { // Unable to set field } } } catch (Throwable t) { throw new RuntimeException("Could not inject fields", t); } }
@SuppressWarnings("unchecked") private Object resolveResource(Field field, org.jboss.jca.embedded.arquillian.Inject annotation) { try { return embeddedInst.get().lookup(annotation.name(), field.getType()); } catch (Throwable t) { // Nothing to do } return null; } }
/** * {@inheritDoc} * @see org.jboss.arquillian.spi.DeployableContainer#start */ @Override public void start() throws LifecycleException { embedded = EmbeddedFactory.create(true); try { embedded.startup(); contextProducer.set(createContext()); embeddedProducer.set(embedded); } catch (Throwable t) { throw new LifecycleException("Could not start the EmbeddedJCA container: " + t.getMessage(), t); } }