(no subject)
(no subject)
- Subject: (no subject)
- From: email@hidden
- Date: Tue, 17 Jun 2008 09:16:35 +0200
Chuck,
I followed your advice and updated my test class to test the content of the
EOModelGroup(see below) which appears to be good (One EOModel without any links
to other eomodels, containing a single entity).
When getting the classdescription using the entity name, everything is ok,
when getting it from the class, it fails (error that also appears while
instantiating the HL7LogEntry class from its constructor).
Any ideas ?
Thanks
Fred
@BeforeClass
public static void loadModel() throws MalformedURLException {
if (EOModelGroup.defaultGroup().modelNamed("InCaHL7") == null)
EOModelGroup.defaultGroup().addModelWithPathURL(new
URL("FILE:///Users/fjecker/Workspaces/Cariatides_1/InCaHL7/Resources/InCaHL7.eomodeld"));
}
@Test
public void testA() {
for(int i=0;i<EOModelGroup.defaultGroup().models().count();i++){
EOModel model=(EOModel)EOModelGroup.defaultGroup().models().get(i);
assertEquals("InCaHL7", model.name());
assertEquals(1, model.entities().count());
EOEntity entity=(EOEntity)model.entities().get(0);
assertEquals("HL7LogEntry", entity.name());
NSArray attributes=entity.attributes();
assertEquals(11, attributes.count());
NSArray names=new NSArray(new String[]{"controlId", "event", "hl7Body", "id",
"log", "pid", "pvn", "sentDate", "status", "type", "version"});
for(int j=0;j<attributes.count();j++){
assertTrue(names.contains(((EOAttribute)attributes.get(j)).name()));
}
//Pass
EOClassDescription
desc=EOClassDescription.classDescriptionForEntityName("HL7LogEntry");
assertNotNull(desc);
//Fails
EOClassDescription
desc2=EOClassDescription.classDescriptionForClass(HL7LogEntry.class);
assertNotNull(desc2);
}
On Jun 15, 2008, at 11:41 PM, email@hidden wrote:
> Hi,
>
> The problem is that I'm relying on an external API that dynamically loads some
> classes in which EOEditingContext are directly created.
> I performed some refactoring in order to ease unit testing but I have the
> following error :
>
> My simple test class
>
> @BeforeClass
> public static void loadModel() throws MalformedURLException {
> if (EOModelGroup.defaultGroup().modelNamed("InCaHL7") == null)
> EOModelGroup.defaultGroup().addModelWithPathURL(new
>
URL("FILE:///Users/fjecker/Workspaces/Cariatides_1/InCaHL7/Resources/InCaHL7.eomodeld"));
> }
> @Test
> public void testA(){
> HL7LogEntry entry=new HL7LogEntry();
> mockEditingContext().insertObject(entry);
> mockEditingContext().saveChanges();
> System.out.println("toto");
> }
>
> I get the following error :
> java.lang.IllegalStateException: Unabled to find an EOClassDescription for
> objects of class com.cariatides.app.incahl7.util.log.HL7LogEntry
> at
>
com.webobjects.eocontrol.EOGenericRecord.__setClassDescription(EOGenericRecord.java:98)
> at
com.webobjects.eocontrol.EOGenericRecord.<init>(EOGenericRecord.java:72)
> at
>
com.cariatides.app.incahl7.util.log.modele._HL7LogEntry.<init>(_HL7LogEntry.java:15)
> at
com.cariatides.app.incahl7.util.log.HL7LogEntry.<init>(HL7LogEntry.java:15)
> ...
>
> Any ideas ?
It seems to not have loaded the model containing HL7LogEntry. Try logging out
all the models in EOModelGroup.defaultGroup() and all of the entities in each
model.
Chuck
>
>
> Henrique Prange a écrit :
>> Hi,
>>
>> Please, correct me if I'm wrong. You can use mockEditingContext like any
other
> EOEditingContext. So, if you are doing in you code:
>>
>> MyEO eo = new MyEO();
>>
>> anEditingContext.insertObject( eo );
>>
>> You can do in your tests:
>>
>> MyEO eo = new MyEO();
>>
>> mockEditingContext().insertObject( eo );
>>
>> MockEditingContext should work in the same way of EOEditingContext, but
> without connecting with a database. Everything is made in memory.
>>
>> Cheers,
>>
>> Henrique
>>
>> email@hidden wrote:
>>> Hi,
>>>
>>> Thanks for the reference, i'll have a look in the book.
>>>
>>> The problem i'm facing is that my app relies on an API
>>> (http://hl7api.sourceforge.net/) which routes incoming requests to
processing
>>> objects inheriting from a common interface which means that I cannot change
>>> their signature. From what I understood, to use wounittest i will need to
> pass
>>> the mockeditingcontext as an argument to my processing objects..
>>>
>>> Regards
>>>
>>> Quoting Henrique Prange <email@hidden>:
>>>
>>>> Hi,
>>>>
>>>> You can use DbUnit [1]. Chuck and Sacha described how to use this tool with
> EOF on 1st chapter of Practical WebObjects book [2].
>>>>
>>>> Anyway, which problems have you been facing with wounittest?
>>>>
>>>> [1]http://www.dbunit.org/
>>>> [2]http://www.amazon.com/Practical-WebObjects-Charles-Hill/dp/1590592964
>>>>
>>>> Cheers,
>>>>
>>>> Henrique
>>>>
>>>> email@hidden wrote:
>>>>> Moin list,
>>>>>
>>>>> A simple and stupid question :
>>>>> I'd like to take advantage of maven and hudson by generating metrics on my
>>>>> project.
>>>>> A this time, we don't write unit tests.
>>>>> What is the best solution for unit testing WOApps? I already had a quick
> look at
>>>>> wounitest but I don't think it will fit our needs.
>>>>> Is it possible to instanciate a EOEditingContext within a Junit test ?
>>>>> How could I achieve to do this ?
>>>>>
>>>>> Thanks for your answer
>>>>> _______________________________________________
>>>>> Do not post admin requests to the list. They will be ignored.
>>>>> Webobjects-dev mailing list (email@hidden)
>>>>> Help/Unsubscribe/Update your Subscription:
>>>>>
>>>>> This email sent to email@hidden
>>>>>
>>>>
>>>
>>>
>>>
>>
>
> --
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
>
> This email sent to email@hidden
>
--
Practical WebObjects - for developers who want to increase their overall
knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden