[jboss-cvs] JBossAS SVN: r65083 - in projects/ejb3/trunk: ejb3-cache and 16 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Sep 5 08:03:28 EDT 2007
Author: wolfc
Date: 2007-09-05 08:03:27 -0400 (Wed, 05 Sep 2007)
New Revision: 65083
Added:
projects/ejb3/trunk/ejb3-cache/
projects/ejb3/trunk/ejb3-cache/.classpath
projects/ejb3/trunk/ejb3-cache/.project
projects/ejb3/trunk/ejb3-cache/.settings/
projects/ejb3/trunk/ejb3-cache/.settings/org.eclipse.jdt.core.prefs
projects/ejb3/trunk/ejb3-cache/pom.xml
projects/ejb3/trunk/ejb3-cache/src/
projects/ejb3/trunk/ejb3-cache/src/main/
projects/ejb3/trunk/ejb3-cache/src/main/java/
projects/ejb3/trunk/ejb3-cache/src/main/java/org/
projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/
projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/
projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/
projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cache.java
projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Identifiable.java
projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/ObjectStore.java
projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/StatefulObjectFactory.java
projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/
projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/SimpleCache.java
projects/ejb3/trunk/ejb3-cache/src/test/
projects/ejb3/trunk/ejb3-cache/src/test/java/
projects/ejb3/trunk/ejb3-cache/src/test/java/org/
projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/
projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/
projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/
projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/
projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/MockIdentifiable.java
projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/MockStatefulObjectFactory.java
projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/SimpleCacheUnitTestCase.java
Log:
Initial release
Property changes on: projects/ejb3/trunk/ejb3-cache
___________________________________________________________________
Name: svn:ignore
+ target
Added: projects/ejb3/trunk/ejb3-cache/.classpath
===================================================================
--- projects/ejb3/trunk/ejb3-cache/.classpath (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/.classpath 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,10 @@
+<classpath>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="src" path="src/test/java" output="target/test-classes"/>
+ <classpathentry kind="output" path="target/classes"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-transaction-api/1.0.1-SNAPSHOT/jboss-transaction-api-1.0.1-SNAPSHOT.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jboss-ejb-api/3.0.0-SNAPSHOT/jboss-ejb-api-3.0.0-SNAPSHOT.jar"/>
+</classpath>
\ No newline at end of file
Added: projects/ejb3/trunk/ejb3-cache/.project
===================================================================
--- projects/ejb3/trunk/ejb3-cache/.project (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/.project 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,13 @@
+<projectDescription>
+ <name>jboss-ejb3-cache</name>
+ <comment>The Java EJB 3.0 Cache classes</comment>
+ <projects/>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
\ No newline at end of file
Added: projects/ejb3/trunk/ejb3-cache/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- projects/ejb3/trunk/ejb3-cache/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/.settings/org.eclipse.jdt.core.prefs 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,5 @@
+#Thu Aug 23 14:38:57 CEST 2007
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.source=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
Added: projects/ejb3/trunk/ejb3-cache/pom.xml
===================================================================
--- projects/ejb3/trunk/ejb3-cache/pom.xml (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/pom.xml 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,56 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <groupId>jboss</groupId>
+ <!--
+ <artifactId>jboss-ejb3</artifactId>
+ <version>0.11-SNAPSHOT</version>
+ <relativePath>../build/pom.xml</relativePath>
+ -->
+ <artifactId>jboss-parent</artifactId>
+ <version>2</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.jboss</groupId>
+ <artifactId>jboss-ejb3-cache</artifactId>
+ <version>0.11-SNAPSHOT</version>
+ <packaging>jar</packaging>
+ <name>JBoss EJB 3.0 Cache</name>
+ <url>http://www.jboss.org</url>
+ <description>The Java EJB 3.0 Cache classes</description>
+ <build>
+ <plugins>
+ <!-- Normally defined in the parent -->
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jboss-deploy-plugin</artifactId>
+ <version>1.4</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>jboss-deploy</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <jbossDeployRoot>${jboss.repository.root}</jbossDeployRoot>
+ <groupId>jboss</groupId>
+ </configuration>
+ <inherited>true</inherited>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>jboss</groupId>
+ <artifactId>jboss-ejb-api</artifactId>
+ <version>3.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>testing</scope>
+ </dependency>
+ </dependencies>
+</project>
Added: projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cache.java
===================================================================
--- projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cache.java (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Cache.java 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,62 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.cache;
+
+import javax.ejb.NoSuchEJBException;
+
+/**
+ * Cache a stateful object and make sure any life cycle callbacks are
+ * called at the appropiate time.
+ *
+ * A cache is linked to an object factory. How the link is establish is left beyond
+ * scope.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Cache<T extends Identifiable>
+{
+ /**
+ * Create a new object.
+ *
+ * @param initTypes
+ * @param initValues
+ * @return
+ */
+ T create(Class<?> initTypes[], Object initValues[]);
+
+ /**
+ * Get the specified object from cache.
+ *
+ * @param key the identifier of the object
+ * @return the object
+ * @throws NoSuchEJBException if the object does not exist
+ */
+ T get(Object key) throws NoSuchEJBException;
+
+ /**
+ * Remove the specified object from cache.
+ *
+ * @param key the identifier of the object
+ */
+ void remove(Object key);
+}
Added: projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Identifiable.java
===================================================================
--- projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Identifiable.java (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/Identifiable.java 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.cache;
+
+/**
+ * An object that has an identification. How the object obtains
+ * it's identification is left beyond scope. Could be via construction
+ * or via a setter.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface Identifiable
+{
+ /**
+ * The object identifier.
+ * @return the object identifier
+ */
+ Object getId();
+}
Added: projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/ObjectStore.java
===================================================================
--- projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/ObjectStore.java (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/ObjectStore.java 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.cache;
+
+/**
+ * Stores an indentifiable object on a persistence store. Note that the object
+ * does NOT call any callbacks.
+ *
+ * It is assumed the key represents something meaning full to the object store.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface ObjectStore<T extends Identifiable>
+{
+ T load(Object key);
+
+ void store(T obj);
+}
Added: projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/StatefulObjectFactory.java
===================================================================
--- projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/StatefulObjectFactory.java (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/StatefulObjectFactory.java 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.cache;
+
+/**
+ * Creates and destroys stateful objects.
+ *
+ * The object returned by create has dependencies injected. The PostConstruct
+ * callback, if defined, has been called and the Init callback, if defined,
+ * has been called.
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public interface StatefulObjectFactory<T>
+{
+ T create(Class<?> initTypes[], Object initValues[]);
+
+ void destroy(T obj);
+}
Added: projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/SimpleCache.java
===================================================================
--- projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/SimpleCache.java (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/src/main/java/org/jboss/ejb3/cache/impl/SimpleCache.java 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.cache.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.ejb.NoSuchEJBException;
+
+import org.jboss.ejb3.cache.Cache;
+import org.jboss.ejb3.cache.Identifiable;
+import org.jboss.ejb3.cache.StatefulObjectFactory;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleCache<T extends Identifiable> implements Cache<T>
+{
+ private StatefulObjectFactory<T> factory;
+ private Map<Object, T> cache;
+
+ public SimpleCache(StatefulObjectFactory<T> factory)
+ {
+ assert factory != null;
+
+ this.factory = factory;
+ this.cache = new HashMap<Object, T>();
+ }
+
+ public T create(Class<?>[] initTypes, Object[] initValues)
+ {
+ T obj = factory.create(initTypes, initValues);
+ synchronized(cache)
+ {
+ cache.put(obj.getId(), obj);
+ }
+ return obj;
+ }
+
+ public T get(Object key) throws NoSuchEJBException
+ {
+ T obj;
+ synchronized (cache)
+ {
+ obj = cache.get(key);
+ }
+ if(obj == null)
+ throw new NoSuchEJBException(String.valueOf(key));
+ return obj;
+ }
+
+ public void remove(Object key)
+ {
+ T obj;
+ synchronized (cache)
+ {
+ obj = cache.remove(key);
+ }
+ if(obj != null)
+ factory.destroy(obj);
+ }
+}
Added: projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/MockIdentifiable.java
===================================================================
--- projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/MockIdentifiable.java (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/MockIdentifiable.java 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,53 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.cache.impl;
+
+import org.jboss.ejb3.cache.Identifiable;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MockIdentifiable implements Identifiable
+{
+ private static volatile long currentId = 0;
+
+ private long id;
+
+ public MockIdentifiable()
+ {
+ this.id = ++currentId;
+ }
+
+ public Object getId()
+ {
+ return id;
+ }
+
+ @Override
+ public String toString()
+ {
+ return super.toString() + "{id=" + id + "}";
+ }
+}
Added: projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/MockStatefulObjectFactory.java
===================================================================
--- projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/MockStatefulObjectFactory.java (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/MockStatefulObjectFactory.java 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,43 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.cache.impl;
+
+import org.jboss.ejb3.cache.StatefulObjectFactory;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class MockStatefulObjectFactory implements StatefulObjectFactory<MockIdentifiable>
+{
+ public MockIdentifiable create(Class<?>[] initTypes, Object[] initValues)
+ {
+ return new MockIdentifiable();
+ }
+
+ public void destroy(MockIdentifiable obj)
+ {
+ }
+
+}
Added: projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/SimpleCacheUnitTestCase.java
===================================================================
--- projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/SimpleCacheUnitTestCase.java (rev 0)
+++ projects/ejb3/trunk/ejb3-cache/src/test/java/org/jboss/ejb3/cache/impl/SimpleCacheUnitTestCase.java 2007-09-05 12:03:27 UTC (rev 65083)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.ejb3.cache.impl;
+
+import javax.ejb.NoSuchEJBException;
+
+import org.jboss.ejb3.cache.Cache;
+import org.jboss.ejb3.cache.StatefulObjectFactory;
+
+import junit.framework.TestCase;
+
+/**
+ * Comment
+ *
+ * @author <a href="mailto:carlo.dewolf at jboss.com">Carlo de Wolf</a>
+ * @version $Revision: $
+ */
+public class SimpleCacheUnitTestCase extends TestCase
+{
+
+ public void test1()
+ {
+ StatefulObjectFactory<MockIdentifiable> factory = new MockStatefulObjectFactory();
+ Cache<MockIdentifiable> cache = new SimpleCache<MockIdentifiable>(factory);
+
+ try
+ {
+ cache.get(1);
+ fail("Object 1 should not be in cache");
+ }
+ catch(NoSuchEJBException e)
+ {
+ // good
+ }
+ }
+
+ public void test2()
+ {
+ StatefulObjectFactory<MockIdentifiable> factory = new MockStatefulObjectFactory();
+ Cache<MockIdentifiable> cache = new SimpleCache<MockIdentifiable>(factory);
+
+ MockIdentifiable object = cache.create(null, null);
+ Object key = object.getId();
+
+ MockIdentifiable obj2 = cache.get(key);
+ assertEquals(object, obj2);
+
+ cache.remove(key);
+
+ try
+ {
+ cache.get(key);
+ fail("Object should not be in cache");
+ }
+ catch(NoSuchEJBException e)
+ {
+ // good
+ }
+ }
+}
More information about the jboss-cvs-commits
mailing list