[jboss-cvs] JBossAS SVN: r61753 - in branches/Branch_4_2/testsuite: src/main/org/jboss/test/cmp2 and 4 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Mar 27 12:41:53 EDT 2007
Author: alex.loubyansky at jboss.com
Date: 2007-03-27 12:41:52 -0400 (Tue, 27 Mar 2007)
New Revision: 61753
Added:
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ABean.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ALocal.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ALocalHome.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/DistinctUnitTestCase.java
branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/MyData.java
branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/
branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/
branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/ejb-jar.xml
branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/jboss.xml
branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/jbosscmp-jdbc.xml
Modified:
branches/Branch_4_2/testsuite/imports/sections/cmp.xml
Log:
JBAS-3800 testcase
Modified: branches/Branch_4_2/testsuite/imports/sections/cmp.xml
===================================================================
--- branches/Branch_4_2/testsuite/imports/sections/cmp.xml 2007-03-27 16:03:50 UTC (rev 61752)
+++ branches/Branch_4_2/testsuite/imports/sections/cmp.xml 2007-03-27 16:41:52 UTC (rev 61753)
@@ -284,6 +284,19 @@
</zipfileset>
</jar>
+ <!-- build cmp2-distinct.jar -->
+ <jar destfile="${build.lib}/cmp2-distinct.jar">
+ <fileset dir="${build.classes}">
+ <patternset refid="jboss.test.util.ejb.set"/>
+ <include name="org/jboss/test/cmp2/distinct/**"/>
+ </fileset>
+ <fileset dir="${build.resources}/cmp2/distinct">
+ <include name="**/*.*"/>
+ </fileset>
+ <zipfileset src="${junit.junit.lib}/junit.jar"
+ includes="junit/**/*.*"/>
+ </jar>
+
<!-- build cmp2-jbas1361.jar -->
<jar destfile="${build.lib}/cmp2-jbas1361.jar">
<fileset dir="${build.classes}">
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ABean.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ABean.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ABean.java 2007-03-27 16:41:52 UTC (rev 61753)
@@ -0,0 +1,134 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.test.cmp2.distinct;
+
+
+import javax.ejb.EntityBean;
+import javax.ejb.EntityContext;
+import javax.ejb.RemoveException;
+import javax.ejb.CreateException;
+
+
+/**
+ * @ejb.bean name="A"
+ * type="CMP"
+ * cmp-version="2.x"
+ * view-type="local"
+ * reentrant="false"
+ * @ejb.pk generate="true"
+ * @ejb.util generate="physical"
+ * @ejb.persistence table-name="A"
+ * @jboss.persistence datasource="${ds.name}"
+ * datasource-mapping="${ds.mapping}"
+ * create-table="${jboss.create.table}"
+ * remove-table="${jboss.remove.table}"
+ * pk-constraint="true"
+ * @ejb:transaction type="Required"
+ * @ejb.finder signature="Collection findByName(java.lang.String i)"
+ * query="select distinct object(o) from A o where o.name=?1"
+ *
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public abstract class ABean implements EntityBean
+{
+ // CMP accessors --------------------------------------------
+ /**
+ * @ejb.pk-field
+ * @ejb.persistent-field
+ * @ejb.interface-method
+ */
+ public abstract Integer getId();
+
+ public abstract void setId(Integer id);
+
+ /**
+ * @ejb.persistent-field
+ * @ejb.interface-method
+ */
+ public abstract MyData getMyData();
+
+ /**
+ * @ejb.interface-method
+ */
+ public abstract void setMyData(MyData data);
+
+ /**
+ * @ejb.persistent-field
+ * @ejb.interface-method
+ */
+ public abstract String getName();
+
+ /**
+ * @ejb.interface-method
+ */
+ public abstract void setName(String name);
+
+ /**
+ * @throws javax.ejb.CreateException
+ * @ejb.create-method
+ */
+ public Integer ejbCreate(Integer id, String name)
+ throws CreateException
+ {
+ setId(id);
+ setName(name);
+ return null;
+ }
+
+ public void ejbPostCreate(Integer id, String name)
+ {
+ }
+
+ /**
+ * @param ctx The new entityContext value
+ */
+ public void setEntityContext(EntityContext ctx)
+ {
+ }
+
+ /**
+ * Unset the associated entity context.
+ */
+ public void unsetEntityContext()
+ {
+ }
+
+ public void ejbActivate()
+ {
+ }
+
+ public void ejbLoad()
+ {
+ }
+
+ public void ejbPassivate()
+ {
+ }
+
+ public void ejbRemove() throws RemoveException
+ {
+ }
+
+ public void ejbStore()
+ {
+ }
+}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ALocal.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ALocal.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ALocal.java 2007-03-27 16:41:52 UTC (rev 61753)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.test.cmp2.distinct;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ */
+public interface ALocal
+ extends javax.ejb.EJBLocalObject
+{
+ public Integer getId( ) ;
+
+ public String getName( ) ;
+
+ public void setName( String name ) ;
+
+ public MyData getMyData( ) ;
+
+ public void setMyData(MyData data) ;
+}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ALocalHome.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ALocalHome.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/ALocalHome.java 2007-03-27 16:41:52 UTC (rev 61753)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.test.cmp2.distinct;
+
+public interface ALocalHome
+ extends javax.ejb.EJBLocalHome
+{
+ public static final String COMP_NAME="java:comp/env/ejb/ALocal";
+ public static final String JNDI_NAME="ALocal";
+
+ public ALocal create(Integer id , String name)
+ throws javax.ejb.CreateException;
+
+ public ALocal findByPrimaryKey(Integer pk)
+ throws javax.ejb.FinderException;
+
+ public java.util.Collection findByName(java.lang.String s)
+ throws javax.ejb.FinderException;
+}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/DistinctUnitTestCase.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/DistinctUnitTestCase.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/DistinctUnitTestCase.java 2007-03-27 16:41:52 UTC (rev 61753)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.test.cmp2.distinct;
+
+import javax.naming.NamingException;
+import javax.naming.InitialContext;
+import javax.ejb.FinderException;
+import org.jboss.test.util.ejb.EJBTestCase;
+import org.jboss.test.JBossTestCase;
+import junit.framework.Test;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public class DistinctUnitTestCase
+ extends EJBTestCase
+{
+ public static Test suite() throws Exception
+ {
+ return JBossTestCase.getDeploySetup(DistinctUnitTestCase.class, "cmp2-distinct.jar");
+ }
+
+ public DistinctUnitTestCase(String methodName)
+ {
+ super(methodName);
+ }
+
+ public void setUpEJB(java.util.Properties props) throws Exception
+ {
+ ALocalHome ah = getALocalHome();
+ try
+ {
+ ah.findByPrimaryKey(new Integer(1));
+ }
+ catch(FinderException fe)
+ {
+ ALocal a = ah.create(new Integer(1), "a1");
+ MyData data = new MyData();
+ data.setData("data");
+ a.setMyData(data);
+ }
+ }
+
+ public void tearDownEJB(java.util.Properties props) throws Exception
+ {
+ getALocalHome().remove(new Integer(1));
+ }
+
+ public void testDistinctAndBLOB() throws Exception
+ {
+ java.util.Collection col = getALocalHome().findByName("a1");
+ assertEquals(1, col.size());
+ ALocal a = (ALocal)col.iterator().next();
+ MyData myData = a.getMyData();
+ assertNotNull(myData);
+ assertEquals("data", myData.getData());
+ }
+
+ private ALocalHome getALocalHome()
+ throws NamingException
+ {
+ return (ALocalHome)lookup(ALocalHome.JNDI_NAME);
+ }
+
+ private Object lookup(String name) throws NamingException
+ {
+ InitialContext ic = new InitialContext();
+ return ic.lookup(name);
+ }
+}
Added: branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/MyData.java
===================================================================
--- branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/MyData.java (rev 0)
+++ branches/Branch_4_2/testsuite/src/main/org/jboss/test/cmp2/distinct/MyData.java 2007-03-27 16:41:52 UTC (rev 61753)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, 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.test.cmp2.distinct;
+
+import java.io.Serializable;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public class MyData
+ implements Serializable
+{
+ private String data;
+
+ public String getData()
+ {
+ return data;
+ }
+
+ public void setData(String data)
+ {
+ this.data = data;
+ }
+
+ public String toString()
+ {
+ return "[MyData " + data + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof MyData))
+ {
+ return false;
+ }
+
+ final MyData myData = (MyData)o;
+
+ if(data != null ? !data.equals(myData.data) : myData.data != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return (data != null ? data.hashCode() : 0);
+ }
+}
Added: branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/ejb-jar.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/ejb-jar.xml (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/ejb-jar.xml 2007-03-27 16:41:52 UTC (rev 61753)
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE ejb-jar PUBLIC "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN" "http://java.sun.com/dtd/ejb-jar_2_0.dtd">
+
+<ejb-jar >
+
+ <enterprise-beans>
+
+ <!-- Session Beans -->
+ <session>
+ <description>JUnit Session Bean Test Runner</description>
+ <ejb-name>EJBTestRunnerEJB</ejb-name>
+ <home>org.jboss.test.util.ejb.EJBTestRunnerHome</home>
+ <remote>org.jboss.test.util.ejb.EJBTestRunner</remote>
+ <ejb-class>org.jboss.test.util.ejb.EJBTestRunnerBean</ejb-class>
+ <session-type>Stateless</session-type>
+ <transaction-type>Bean</transaction-type>
+ </session>
+
+ <!-- Entity Beans -->
+ <entity>
+ <ejb-name>A</ejb-name>
+
+ <local-home>org.jboss.test.cmp2.distinct.ALocalHome</local-home>
+ <local>org.jboss.test.cmp2.distinct.ALocal</local>
+
+ <ejb-class>org.jboss.test.cmp2.distinct.ABean</ejb-class>
+ <persistence-type>Container</persistence-type>
+ <prim-key-class>java.lang.Integer</prim-key-class>
+ <reentrant>false</reentrant>
+ <cmp-version>2.x</cmp-version>
+ <abstract-schema-name>A</abstract-schema-name>
+ <cmp-field >
+ <description><![CDATA[]]></description>
+ <field-name>id</field-name>
+ </cmp-field>
+ <cmp-field >
+ <description><![CDATA[]]></description>
+ <field-name>name</field-name>
+ </cmp-field>
+ <cmp-field >
+ <description><![CDATA[]]></description>
+ <field-name>myData</field-name>
+ </cmp-field>
+ <primkey-field>id</primkey-field>
+
+ <query>
+ <query-method>
+ <method-name>findByName</method-name>
+ <method-params>
+ <method-param>java.lang.String</method-param>
+ </method-params>
+ </query-method>
+ <ejb-ql><![CDATA[select distinct object(o) from A o where o.name=?1]]></ejb-ql>
+ </query>
+ </entity>
+
+ </enterprise-beans>
+
+ <!-- Assembly Descriptor -->
+ <assembly-descriptor >
+ <container-transaction >
+ <method >
+ <ejb-name>A</ejb-name>
+ <method-name>*</method-name>
+ </method>
+ <trans-attribute>Required</trans-attribute>
+ </container-transaction>
+ </assembly-descriptor>
+
+</ejb-jar>
Added: branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/jboss.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/jboss.xml (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/jboss.xml 2007-03-27 16:41:52 UTC (rev 61753)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jboss PUBLIC "-//JBoss//DTD JBOSS 3.2//EN" "http://www.jboss.org/j2ee/dtd/jboss_3_2.dtd">
+
+<jboss>
+
+ <enterprise-beans>
+
+ <entity>
+ <ejb-name>A</ejb-name>
+ <local-jndi-name>ALocal</local-jndi-name>
+ <configuration-name>custom container</configuration-name>
+ </entity>
+
+ <session>
+ <ejb-name>EJBTestRunnerEJB</ejb-name>
+ <jndi-name>ejb/EJBTestRunner</jndi-name>
+ </session>
+
+ </enterprise-beans>
+
+ <container-configurations>
+ <container-configuration extends="cmp2.x jdbc2 pm">
+ <container-name>custom container</container-name>
+ <container-cache-conf/>
+ </container-configuration>
+ </container-configurations>
+</jboss>
Added: branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/jbosscmp-jdbc.xml
===================================================================
--- branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/jbosscmp-jdbc.xml (rev 0)
+++ branches/Branch_4_2/testsuite/src/resources/cmp2/distinct/META-INF/jbosscmp-jdbc.xml 2007-03-27 16:41:52 UTC (rev 61753)
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE jbosscmp-jdbc PUBLIC "-//JBoss//DTD JBOSSCMP-JDBC 3.2//EN" "http://www.jboss.org/j2ee/dtd/jbosscmp-jdbc_3_2.dtd">
+
+<jbosscmp-jdbc>
+ <enterprise-beans>
+ <entity>
+ <ejb-name>A</ejb-name>
+ <create-table>true</create-table>
+ <remove-table>true</remove-table>
+ <pk-constraint>true</pk-constraint>
+ <table-name>A</table-name>
+
+ <cmp-field>
+ <field-name>id</field-name>
+
+ </cmp-field>
+ <cmp-field>
+ <field-name>name</field-name>
+
+ </cmp-field>
+ <cmp-field>
+ <field-name>myData</field-name>
+
+ </cmp-field>
+ </entity>
+
+ </enterprise-beans>
+
+</jbosscmp-jdbc>
More information about the jboss-cvs-commits
mailing list