Q:

How do I use Weld and EclipseLink together in an SE environment?

I am trying to create a unit test that uses EclipseLink via JPA and I noticed that I needed to inject a DAO into a listener.  The code itself works as expected inside a container, but I am having trouble making a unit test for it.
The listener looks like this.
@ApplicationScoped
public class ParticipantListener {

    @Inject
    private ParticipantDAO dao;

    @PrePersist
    @PreUpdate
    void ensureNoDuplicateSin(final Participant e) throws DuplicateSinException {

        final Participant bySin = dao.getBySinAndNotSelf(e.getSin(), e);
        if (bySin != null && bySin.getId() != e.getId()) {
            throw new DuplicateSinException();
        }
    }
}

When I run in a unit test dao is not injected.
My test is initialized as follows:
    weld = new Weld();
    final WeldContainer container = weld.initialize();
    vf = Validation.buildDefaultValidatorFactory();
    final Map<String, String> props = new HashMap<>();
    props.put("javax.persistence.provider", "org.eclipse.persistence.jpa.PersistenceProvider");
    emf = Persistence.createEntityManagerFactory("test-pu", props);
    em = emf.createEntityManager();

which obviously should not work because there's no relationship between the em/emf and the container

A:

I needed to set the javax.persistence.bean.manager to point to Weld's bean manager.  In addition I found that I also 
    weld = new Weld();
    final WeldContainer container = weld.initialize();
    final JpaProvider jpaProvider = container.select(JpaProvider.class).get();

    final Map<String, Object> props = new HashMap<>();
    props.put("javax.persistence.provider", "org.eclipse.persistence.jpa.PersistenceProvider");
    props.put("javax.persistence.bean.manager", container.getBeanManager());
    emf = Persistence.createEntityManagerFactory("test-pu", props);
    em = emf.createEntityManager();
    jpaProvider.setEntityManager(em);

In addition I had to change the DAO to not use @PersistenceContext and use @Inject for the entity manager and create a JpaProvider class.  During the test it will set the entity manager from the container instance.
@ApplicationScoped
public class JpaProvider {

    private EntityManager em;

    @Produces
    public EntityManager getEntityManager() {

        return em;
    }

    @PersistenceContext
    public void setEntityManager(final EntityManager em) {

        this.em = em;
    }
}

