Your test is correct, except that it's missing a declaration for the mocked type. The EJB class, in this case.
Normally, mocked types are mocked in full (all methods). In such cases, you would declare a @Mocked MyEJB archivingBean
parameter to the test method, for example.
For partial mocking, on the other hand, you use the NonStrictExpectations(Object...)
constructor, like this:
new NonStrictExpectations(archivingBean) {{ // <== note the argument here
invoke(archivingBean, "getConnection"); result = connection;
}};