container.flush() did the trick in this case. I have some other cases with 
almost the same problem. It's not always clear how these transactions act in 
tests but I managed to run all my tests.

Also had a case where it didn't work to persist some data in the setup-method 
but it worked when I did exactly the same thing at the start of my test-method. 
:-/

It even looks like it works in a random way: sometimes an error, sometimes 
everything ok.

Erik


On 05/14/2014 01:23 PM, Dan Haywood wrote:



2014-05-14 11:38 GMT+01:00 GESCONSULTOR - Óscar Bou 
<o....@gesconsultor.com<mailto:o....@gesconsultor.com>>:
Hi, Erik.

Perhaps DN holds them still "in memory" and has not been flushed to the 
database.


I don't think that DN does, but Isis certainly does holds them in memory until 
the flush or commit.


Dan



Normally, it can be done by calling "flush" on the DomainContainer, similar to:

this.getContainer().flush();


HTH,

Oscar






El 14/05/2014, a las 12:27, Erik de Hair <e...@pocos.nl<mailto:e...@pocos.nl>> 
escribió:


Hi,

I'm writing a test with some inserts in the @Before and a query to find the 
inserted objects (ResellerPortalIntegTest is the original 
SimpleIntegTest-class):

public class ContactsTest extends ResellerPortalIntegTest {

   private Role role;

   private final String uniqueEmail = 
"j...@pokos.nl<mailto:j...@pokos.nl>"<mailto:j...@pokos.nl>;
   private final String duplicateEmail = 
"ma...@pokos.nl<mailto:ma...@pokos.nl>"<mailto:ma...@pokos.nl>;
   private final String unkownEmail = 
"xyz...@bladiblah.com<mailto:xyz...@bladiblah.com>"<mailto:xyz...@bladiblah.com>;

   @Before
   public void setUp(){
       this.role = container().newTransientInstance(Role.class);
       this.role.setLabel("ROLE_ADMIN");
       this.role.setDescription("(Reseller) admin");
       container().persistIfNotAlready(this.role);

       service(Contacts.class).create("Piet", "van de", "Pet", Gender.MALE, 
"p...@pokos.nl<mailto:p...@pokos.nl>"<mailto:p...@pokos.nl>, "pietmetpet", 
this.role);
       service(Contacts.class).create("Jan", "van de", "Jas", Gender.MALE, 
this.uniqueEmail, "janvandejas", this.role);
       service(Contacts.class).create("Marie", "van de", "Markt", 
Gender.FEMALE, this.duplicateEmail, "marievandemarkt", this.role);
       service(Contacts.class).create("Marie", "van de", "Markt", 
Gender.FEMALE, this.duplicateEmail, "marievandemarkt1", this.role);
   }

   @Test
   public void testFindUseraccountsByEmail() throws Exception {
       int expected = 1;
       int actual = 
wrap(service(Contacts.class)).findUseraccountsByEmail(this.uniqueEmail).size();
       Assert.assertEquals(expected, actual);
   }
}

The actual value is '0' while I'm sure the requested object is inserted by the 
@Before-method and the query is all right.

Is this an Isis issue or do I have to look for a Datanucleus/other solution?

Thanks,
Erik


Óscar Bou Bou
Responsable de Producto
Auditor Jefe de Certificación ISO 27001 en BSI
CISA, CRISC, APMG ISO 20000, ITIL-F

[cid:4C38BF6A-D280-4C7F-BFC2-4285B2033897]   902 900 231 / 620 267 520
[cid:6DF89309-F557-4C28-BDFC-AE5B9D964612]   http://www.twitter.com/oscarbou

[cid:DDC0BB1F-E0FC-4120-97F8-E2D5F0DA9BC5]   http://es.linkedin.com/in/oscarbou

[cid:F31E93E9-D0D0-4F96-9A7C-496F094117DC]   
http://www.GesConsultor.com<http://www.gesconsultor.com/>

[cid:04E888F1-A5E9-49D1-832D-465FE2C6C940]


Este mensaje y los ficheros anexos son confidenciales. Los mismos contienen 
información reservada que no puede ser difundida. Si usted ha recibido este 
correo por error, tenga la amabilidad de eliminarlo de su sistema y avisar al 
remitente mediante reenvío a su dirección electrónica; no deberá copiar el 
mensaje ni divulgar su contenido a ninguna persona.
Su dirección de correo electrónico junto a sus datos personales constan en un 
fichero titularidad de Gesdatos Software, S.L. cuya finalidad es la de mantener 
el contacto con Ud. Si quiere saber de qué información disponemos de Ud., 
modificarla, y en su caso, cancelarla, puede hacerlo enviando un escrito al 
efecto, acompañado de una fotocopia de su D.N.I. a la siguiente dirección: 
Gesdatos Software, S.L. , Paseo de la Castellana, 153 bajo - 28046 (Madrid), y 
Avda. Cortes Valencianas num. 50, 1ºC - 46015 (Valencia). Asimismo, es su 
responsabilidad comprobar que este mensaje o sus archivos adjuntos no contengan 
virus informáticos, y en caso que los tuvieran eliminarlos.







Reply via email to