Glad I could be of service.

Will do the license file and upload it. Then I'll wait until it's in
SVN and just send patches. Beats uploading the whole thing to JIRA
everytime (it's small, but still feels like overkill).

Then, re. the code. I know it can use a lot of API changes. Not a lot
of time went into designing the layout. I did some quick thoughts on
it, and this is what I came up with - though it still doesn't feel
right. Would be great to see it evolve and learn from you guys.
OpenEJB's design (source level) is brilliant.

Quintin Beukes



On Tue, Sep 29, 2009 at 3:33 AM, David Blevins <[email protected]> wrote:
> Responded on dev@
>
> On Sep 27, 2009, at 12:16 PM, Quintin Beukes wrote:
>
>> Hey,
>>
>> The previous runner I started modifying extensively to customize for
>> our company's tests. I already had a small testing framework for the
>> tests, which used Spring to initial OpenEJB and do the lookups. I
>> changed this to use the runner technique.
>>
>> Then over the weekend I decided to extract the runner code into an
>> openejb-junit project, and make it extensible so I could use the
>> library's code and only extend to give our tests the same
>> functionality.
>>
>> This is what I came up with:
>> https://issues.apache.org/jira/browse/OPENEJB-1078
>>
>> The JUnit tests demonstrate it's behaviour. These 3 tests are the best
>> examples:
>> org.apache.openejb.junit.TestEjbBasic
>> org.apache.openejb.junit.TestEjbSecurity
>> org.apache.openejb.junit.TestDualConfigOverride
>>
>> It supports class level configuration of the InitialContext, and then
>> method specific configurations. You can configure the InitialContext
>> from a file, or by directly specifying properties. You can have
>> OpenEJB do any of it's supported injections, or you can have the
>> runner inject the InitialContext (or it's initialization Properties
>> object) and do your own lookups. You can specify as which role to load
>> the InitialContext (basically a RunAs).
>>
>> I'm planning on doing resource configurations, such as datasources.
>> Any other suggestions, please throw them my way. And please send me
>> feedback. So far it's working very well for my tests. I have yet to
>> complete the spring modification, but for those tests which don't
>> require it, it works very well. Especially the role tests.
>>
>> Not that it still doesn't support JUnit 3. If you require JUnit 3, let
>> me know and I'll prioritize implementing JUnit 3 support.
>>
>> An basic example would be the following:
>> @RunWith(OpenEjbRunner.class)
>> @ContextConfig(
>>  properties={
>>
>> @Property("java.naming.factory.initial=org.apache.openejb.client.LocalInitialContextFactory")
>>  }
>> )
>> @LocalClient
>> public class TestEjbSecurity
>> {
>> �...@ejb
>>  private MyBusinessBean myBean;
>>
>> �...@testresource
>>  private InitialContext currentInitialContext;
>>
>> �...@test
>> �...@contextconfig(
>>   securityRole="Admin"
>>  )
>>  public void testAsAdmin()
>>  {
>>   myBean.someMethod();
>>   currentInitialContext.lookup("some/custom/lookup");
>>  }
>>
>> �...@test
>> �...@contextconfig(
>>   propertiesFile="/META-INF/employee-context.properties",
>>   securityRole="Employe"
>>  )
>>  public void testAsEmployee()
>>  {
>>   myBean.someMethod();
>>  }
>> }
>>
>> Quintin Beukes
>>
>
>

Reply via email to