tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laird Nelson <ljnel...@gmail.com>
Subject Re: Putting data source into local container?
Date Mon, 20 Apr 2009 18:30:54 GMT
Hello; it does not.  Revised test case below:

package openejbbugs;

import java.util.Properties;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingEnumeration;
import javax.naming.NameClassPair;

import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.*;

public class TestCaseOpenEJBBug {

  private Context context;

  @Before
  public final void setUp() throws Exception {
    final Properties properties = new Properties();
    properties.setProperty(Context.INITIAL_CONTEXT_FACTORY,
org.apache.openejb.client.LocalInitialContextFactory.class.getName());
    properties.setProperty("test", "new://Resource?type=DataSource");
    properties.setProperty("test.JdbcDriver", "org.h2.Driver");
    properties.setProperty("test.JdbcUrl",
"jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");
    properties.setProperty("test.Username", "sa");
    properties.setProperty("test.Password", "");
    properties.put("test.DefaultAutoCommit", Boolean.valueOf(false));
    // properties.setProperty("openejb.embedded.remotable", "true");
    this.context = new InitialContext(properties);

    final Object o = this.context.lookup("java:openejb:Resource/test");
    assertTrue(o instanceof javax.sql.DataSource);

    boolean found = false;
    final NamingEnumeration<NameClassPair> ne = new
InitialContext(properties).list("");
    assertNotNull(ne);
    try {
      while (ne.hasMore()) {
        final NameClassPair ncp = ne.next();
        assertNotNull(ncp);
        final String n = ncp.getName();
        assertNotNull(n);
        if (n.indexOf("test") >= 0) {
          found = true;
          break;
        }
      }
    } finally {
      ne.close();
    }
    assertTrue(found);
  }

  @Test
  public void testLoad() throws Exception {
    assertNotNull(context);
  }

}

On Mon, Apr 20, 2009 at 2:26 PM, Jean-Louis MONTEIRO <
jean-louis.monteiro@atosorigin.com> wrote:

>
>
> ljnelson wrote:
> >
> >     final NamingEnumeration<NameClassPair> ne = context.list("");
> >
>
> If you replace this line by this one, it should work
>    final NamingEnumeration<NameClassPair> ne =
> context.list("java:openejb:Resource");
>
>
> Jean-Louis
> --
> View this message in context:
> http://www.nabble.com/Putting-data-source-into-local-container--tp23138888p23142261.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message