[jboss-cvs] JBossAS SVN: r62034 - in trunk/embedded/src: main/java/org/jboss/embedded/junit and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Apr 3 10:37:56 EDT 2007
Author: bill.burke at jboss.com
Date: 2007-04-03 10:37:56 -0400 (Tue, 03 Apr 2007)
New Revision: 62034
Added:
trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/VfsTestCase.java
trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/
trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/Customer.java
trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/DAO.java
trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/DAOBean.java
trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/HelloWorld.java
trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/HelloWorldBean.java
trunk/embedded/src/test/resources/vfs-test-persistence.xml
Modified:
trunk/embedded/src/main/java/org/jboss/embedded/Bootstrap.java
trunk/embedded/src/main/java/org/jboss/embedded/junit/EmbeddedTestSetup.java
Log:
refactorings and testing for new assembled directory stuff from vfs
Modified: trunk/embedded/src/main/java/org/jboss/embedded/Bootstrap.java
===================================================================
--- trunk/embedded/src/main/java/org/jboss/embedded/Bootstrap.java 2007-04-03 14:33:32 UTC (rev 62033)
+++ trunk/embedded/src/main/java/org/jboss/embedded/Bootstrap.java 2007-04-03 14:37:56 UTC (rev 62034)
@@ -239,6 +239,13 @@
group.process();
}
+ public void deploy(VirtualFile file) throws DeploymentException
+ {
+ DeploymentGroup group = createDeploymentGroup();
+ group.add(file);
+ group.process();
+ }
+
public void deployResource(String resource) throws DeploymentException
{
DeploymentGroup group = createDeploymentGroup();
Modified: trunk/embedded/src/main/java/org/jboss/embedded/junit/EmbeddedTestSetup.java
===================================================================
--- trunk/embedded/src/main/java/org/jboss/embedded/junit/EmbeddedTestSetup.java 2007-04-03 14:33:32 UTC (rev 62033)
+++ trunk/embedded/src/main/java/org/jboss/embedded/junit/EmbeddedTestSetup.java 2007-04-03 14:37:56 UTC (rev 62034)
@@ -43,6 +43,11 @@
protected void setUp()
{
+ testSetup();
+ }
+
+ public static void testSetup()
+ {
if (Bootstrap.getInstance().isStarted()) return;
try
@@ -55,6 +60,11 @@
}
}
+ public static void testTearDown()
+ {
+
+ }
+
protected void tearDown()
{
}
Added: trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/VfsTestCase.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/VfsTestCase.java (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/idetesting/VfsTestCase.java 2007-04-03 14:37:56 UTC (rev 62034)
@@ -0,0 +1,88 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.embedded.test.idetesting;
+
+import junit.framework.TestCase;
+import org.jboss.embedded.junit.EmbeddedTestSetup;
+import org.jboss.embedded.test.vfs.HelloWorld;
+import org.jboss.embedded.test.vfs.HelloWorldBean;
+import org.jboss.embedded.test.vfs.DAO;
+import org.jboss.embedded.test.vfs.Customer;
+import org.jboss.embedded.Bootstrap;
+import org.jboss.virtual.plugins.context.vfs.AssembledContextFactory;
+import org.jboss.virtual.plugins.context.vfs.AssembledDirectory;
+
+import javax.naming.InitialContext;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:bill at jboss.org">Bill Burke</a>
+ * @version $Revision: 42757 $
+ */
+public class VfsTestCase extends TestCase
+{
+ public VfsTestCase()
+ {
+ super("BootstrapTestCase");
+ }
+
+
+ @Override
+ protected void setUp() throws Exception
+ {
+ EmbeddedTestSetup.testSetup();
+ }
+
+
+ @Override
+ protected void tearDown() throws Exception
+ {
+ EmbeddedTestSetup.testTearDown();
+ }
+
+ public void testEJB() throws Exception
+ {
+ AssembledDirectory jar = AssembledContextFactory.getInstance().create("vfs-test.jar");
+ jar.addClass(HelloWorld.class);
+ jar.addClass(HelloWorldBean.class);
+
+ Bootstrap.getInstance().deploy(jar);
+ HelloWorld hello = (HelloWorld)new InitialContext().lookup("HelloWorldBean/local");
+ hello.hello();
+ Bootstrap.getInstance().undeploy(jar);
+ }
+
+ public void testVfs() throws Exception
+ {
+ AssembledDirectory jar = AssembledContextFactory.getInstance().create("vfs-test2.jar");
+ String[] includes = {"org/jboss/embedded/test/vfs/*.class"};
+ jar.addResources(DAO.class, includes, null);
+ jar.mkdir("META-INF").addResource("vfs-test-persistence.xml", "persistence.xml");
+ Bootstrap.getInstance().deploy(jar);
+ DAO dao = (DAO)new InitialContext().lookup("DAOBean/local");
+ dao.create("Bill");
+ Customer cust = dao.find("Bill");
+ assertNotNull(cust);
+
+ }
+}
Added: trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/Customer.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/Customer.java (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/Customer.java 2007-04-03 14:37:56 UTC (rev 62034)
@@ -0,0 +1,62 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.embedded.test.vfs;
+
+import javax.persistence.Entity;
+import javax.persistence.Id;
+import javax.persistence.GeneratedValue;
+
+/**
+ * comment
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+ at Entity
+public class Customer
+{
+ private int id;
+ private String name;
+
+
+ @Id
+ @GeneratedValue
+ public int getId()
+ {
+ return id;
+ }
+
+ public void setId(int id)
+ {
+ this.id = id;
+ }
+
+ public String getName()
+ {
+ return name;
+ }
+
+ public void setName(String name)
+ {
+ this.name = name;
+ }
+}
Added: trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/DAO.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/DAO.java (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/DAO.java 2007-04-03 14:37:56 UTC (rev 62034)
@@ -0,0 +1,35 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.embedded.test.vfs;
+
+/**
+ * comment
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+public interface DAO
+{
+ void create(String name);
+
+ Customer find(String name);
+}
Added: trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/DAOBean.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/DAOBean.java (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/DAOBean.java 2007-04-03 14:37:56 UTC (rev 62034)
@@ -0,0 +1,52 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.embedded.test.vfs;
+
+import javax.ejb.Stateless;
+import javax.persistence.PersistenceContext;
+import javax.persistence.EntityManager;
+
+/**
+ * comment
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+public class DAOBean implements DAO
+{
+ @PersistenceContext
+ EntityManager manager;
+
+ public void create(String name)
+ {
+ Customer cust = new Customer();
+ cust.setName(name);
+ manager.persist(cust);
+ }
+
+ public Customer find(String name)
+ {
+ return (Customer)manager.createQuery("Select c from Customer c where c.name = '" + name + "'").getSingleResult();
+ }
+
+}
Added: trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/HelloWorld.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/HelloWorld.java (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/HelloWorld.java 2007-04-03 14:37:56 UTC (rev 62034)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.embedded.test.vfs;
+
+/**
+ * comment
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+public interface HelloWorld
+{
+ void hello();
+}
Added: trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/HelloWorldBean.java
===================================================================
--- trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/HelloWorldBean.java (rev 0)
+++ trunk/embedded/src/test/java/org/jboss/embedded/test/vfs/HelloWorldBean.java 2007-04-03 14:37:56 UTC (rev 62034)
@@ -0,0 +1,39 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.embedded.test.vfs;
+
+import javax.ejb.Stateless;
+
+/**
+ * comment
+ *
+ * @author <a href="bill at jboss.com">Bill Burke</a>
+ * @version $Revision: 1.1 $
+ */
+ at Stateless
+public class HelloWorldBean implements HelloWorld
+{
+ public void hello()
+ {
+ System.out.println("Hello world");
+ }
+}
Added: trunk/embedded/src/test/resources/vfs-test-persistence.xml
===================================================================
--- trunk/embedded/src/test/resources/vfs-test-persistence.xml (rev 0)
+++ trunk/embedded/src/test/resources/vfs-test-persistence.xml 2007-04-03 14:37:56 UTC (rev 62034)
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<persistence>
+ <persistence-unit name="vfs">
+ <jta-data-source>java:/DefaultDS</jta-data-source>
+ <properties>
+ <property name="hibernate.hbm2ddl.auto" value="create-drop"/>
+ </properties>
+ </persistence-unit>
+</persistence>
More information about the jboss-cvs-commits
mailing list