hprange / wounit

The WOUnit framework contains a set of utilities for testing WebObjects applications using JUnit 4.7 or later capabilities.
http://hprange.github.io/wounit/
Apache License 2.0
19 stars 18 forks source link

ClassCastException when testing partial entities #32

Closed paulhoadley closed 10 years ago

paulhoadley commented 11 years ago

(Henrique, this is just a placeholder issue for completeness. I know you're all over this, and the fix in your 1.3-SNAPSHOT-partials-fix worked.)

I want to write some WOUnit tests for a class that extends ERXPartialGenericRecord—that is, a "base entity" in the partial entities terminology. I have a simple User class in a model called Ident:

public class UserTest {
    @Rule
    public MockEditingContext ec = new MockEditingContext("Ident");

    @Test
    public void createUser() {
        User u = User.createUser(ec, "password", "username");
        confirm(u, canBeSaved());
        return;
    }
}

This test fails with the following (abridged) stack trace:

java.lang.ClassCastException: com.webobjects.eoaccess.EOEntityClassDescription cannot be cast to er.extensions.eof.ERXEntityClassDescription
    at er.extensions.partials.ERXPartialGenericRecord._partialsDictionary(ERXPartialGenericRecord.java:40)
    at er.extensions.partials.ERXPartialGenericRecord._partials(ERXPartialGenericRecord.java:64)
    at er.extensions.partials.ERXPartialGenericRecord.awakeFromInsertion(ERXPartialGenericRecord.java:179)
    at com.webobjects.eocontrol.EOEditingContext.insertObjectWithGlobalID(EOEditingContext.java:2871)
    at er.extensions.eof.ERXEC.insertObjectWithGlobalID(ERXEC.java:976)
    at com.webobjects.eocontrol.EOEditingContext.insertObject(EOEditingContext.java:2889)
    at er.extensions.eof.ERXEC.insertObject(ERXEC.java:987)
    at com.webobjects.eoaccess.EOUtilities.createAndInsertInstance(EOUtilities.java:862)
    at net.logicsquad.access.model._User.createUser(_User.java:180)
    at net.logicsquad.access.tests.UserTest.createUser(UserTest.java:20)
paulhoadley commented 10 years ago

ad75034 fixes this issue.

hprange commented 10 years ago

I'm going to release WOUnit 1.2.3 this afternoon.