diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..67e87ee
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,28 @@
+# ignore .svn metadata files
+.svn
+# ignore Maven generated target folders
+target
+# ignore eclipse files
+.project
+.classpath
+.settings
+.scala_dependencies
+# ignore IDEA files
+*.iml
+*.ipr
+*.iws
+.idea
+atlassian-ide-plugin.xml
+maven-ant-tasks.jar
+test-output
+# log files
+*.log
+# vim files
+*.swp
+# generated rhq plugin xml
+rhq-plugin.xml
+# generated schema
+core/src/main/resources/schema
+# Compiled python files
+*.pyc
+
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..009b2d4
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,28 @@
+
+
+ 4.0.0
+
+
+ org.infinispan
+ infinispan-parent
+ 4.1.0.FINAL
+
+
+ org.infinispan.archetypes
+ infinispan-archetypes
+ 1.0.0-SNAPSHOT
+
+ Infinispan Archetypes
+ Archetypes for the Infinispan project
+ pom
+ http://community.jboss.org/wiki/InfinispanMavenArchetypes
+
+
+ sampleproject
+ testcase
+
+
+
+
diff --git a/sampleproject/pom.xml b/sampleproject/pom.xml
new file mode 100644
index 0000000..9e97f9a
--- /dev/null
+++ b/sampleproject/pom.xml
@@ -0,0 +1,26 @@
+
+ 4.0.0
+
+
+ org.infinispan
+ infinispan-parent
+ 4.1.0.FINAL
+
+
+ org.infinispan.archetypes
+ sample-project
+ jar
+ 1.0.0-SNAPSHOT
+ Infinispan Sample Project Archetype
+ Builds a skeleton sample project using Infinispan.
+
+
+
+
+ org.infinispan
+ infinispan-core
+ 5.0.0-SNAPSHOT
+
+
+
diff --git a/sampleproject/src/main/resources/META-INF/maven/archetype-metadata.xml b/sampleproject/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000..5776bbd
--- /dev/null
+++ b/sampleproject/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,15 @@
+
+
+
+ src/main/java
+
+
+
+ src/main/resources
+
+
+
+
\ No newline at end of file
diff --git a/sampleproject/src/main/resources/archetype-resources/pom.xml b/sampleproject/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000..50f3a85
--- /dev/null
+++ b/sampleproject/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,102 @@
+
+ 4.0.0
+ ${groupId}
+ ${artifactId}
+ jar
+ ${version}
+ A sample project using Infinispan
+ http://www.myorganization.org
+
+
+
+ org.infinispan
+ infinispan-core
+ ${infinispan.version}
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 1.0-beta-1
+
+
+ enforce-java
+
+ enforce
+
+
+
+
+ [1.6,)
+
+
+ [2.1.0,)
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.3.1
+
+
+ 1.6
+ UTF-8
+
+
+
+
+
+
+
+ JBoss.org Public Repository
+
+ true
+
+
+ true
+
+ http://repository.jboss.org/nexus/content/groups/public/
+
+
+
+
+
+
+ run
+
+ false
+
+
+
+
+ org.codehaus.mojo
+ exec-maven-plugin
+ 1.1
+
+
+ process-classes
+
+ java
+
+
+
+
+ ${groupId}.Application
+
+
+
+
+
+
+
diff --git a/sampleproject/src/main/resources/archetype-resources/src/main/java/Application.java b/sampleproject/src/main/resources/archetype-resources/src/main/java/Application.java
new file mode 100644
index 0000000..9d9bf62
--- /dev/null
+++ b/sampleproject/src/main/resources/archetype-resources/src/main/java/Application.java
@@ -0,0 +1,123 @@
+package ${groupId};
+
+import org.infinispan.Cache;
+import org.infinispan.notifications.Listener;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryCreated;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryModified;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryRemoved;
+import org.infinispan.notifications.cachelistener.annotation.CacheEntryVisited;
+import org.infinispan.notifications.cachelistener.event.CacheEntryEvent;
+import org.infinispan.notifications.cachelistener.event.CacheEntryVisitedEvent;
+import org.infinispan.notifications.cachemanagerlistener.event.Event;
+import org.infinispan.util.concurrent.NotifyingFuture;
+
+import java.util.Arrays;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Sample application code. For more examples visit http://community.jboss.org/wiki/5minutetutorialonInfinispan
+ */
+public class Application {
+
+ public void basicUse() {
+ System.out.println("\n\n1. Demonstrating basic usage of Infinispan. This cache stores arbitrary Strings.");
+ Cache cache = SampleCacheContainer.getCache();
+
+ System.out.println(" Storing value 'World' under key 'Hello'");
+ String oldValue = cache.put("Hello", "World");
+ System.out.printf(" Done. Saw old value as '%s'\n", oldValue);
+
+ System.out.println(" Replacing 'World' with 'Mars'.");
+ boolean worked = cache.replace("Hello", "World", "Mars");
+ System.out.printf(" Successful? %s\n", worked);
+
+ assert oldValue == null;
+ assert worked == true;
+ }
+
+ public void lifespans() throws InterruptedException {
+ System.out.println("\n\n2. Demonstrating usage of Infinispan with expirable entries.");
+ Cache stocksCache = SampleCacheContainer.getCache("stock tickers");
+ System.out.println(" Storing key 'RHT' for 10 seconds.");
+ stocksCache.put("RHT", 45.0f, 10, TimeUnit.SECONDS);
+ System.out.printf(" Checking for existence of key. Is it there? %s\n", stocksCache.containsKey("RHT"));
+ System.out.println(" Sleeping for 10 seconds...");
+ Thread.sleep(10000);
+ System.out.printf(" Checking for existence of key. Is it there? %s\n", stocksCache.containsKey("RHT"));
+ assert stocksCache.get("RHT") == null;
+ }
+
+ public void asyncOperations() {
+ System.out.println("\n\n3. Demonstrating asynchronous operations - where writes can be done in a non-blocking fashion.");
+ Cache wineCache = SampleCacheContainer.getCache("wine cache");
+
+ System.out.println(" Put #1");
+ NotifyingFuture f1 = wineCache.putAsync("Pinot Noir", 300);
+ System.out.println(" Put #1");
+ NotifyingFuture f2 = wineCache.putAsync("Merlot", 120);
+ System.out.println(" Put #1");
+ NotifyingFuture f3 = wineCache.putAsync("Chardonnay", 180);
+
+ // now poll the futures to make sure any remote calls have completed!
+ for (NotifyingFuture f: Arrays.asList(f1, f2, f3)) {
+ try {
+ System.out.println(" Checking future... ");
+ f.get();
+ } catch (Exception e) {
+ throw new RuntimeException("Operation failed!", e);
+ }
+ }
+ System.out.println(" Everything stored!");
+
+ // TIP: For more examples on using the asynchronous API, visit http://community.jboss.org/wiki/AsynchronousAPI
+ }
+
+ public void registeringListeners() {
+ System.out.println("\n\n4. Demonstrating use of listeners.");
+ Cache anotherCache = SampleCacheContainer.getCache("another");
+ System.out.println(" Attaching listener");
+ MyListener l = new MyListener();
+ anotherCache.addListener(l);
+
+ System.out.println(" Put #1");
+ anotherCache.put(1, "One");
+ System.out.println(" Put #2");
+ anotherCache.put(2, "Two");
+ System.out.println(" Put #3");
+ anotherCache.put(3, "Three");
+
+ // TIP: For more examples on using listeners visit http://community.jboss.org/wiki/ListenersandNotifications
+ }
+
+ public static void main(String[] args) throws Exception {
+ System.out.println("\n\n\n ******************************** \n\n\n");
+ System.out.println("Hello. This is a sample application making use of Infinispan.");
+ Application a = new Application();
+ a.basicUse();
+ a.lifespans();
+ a.asyncOperations();
+ a.registeringListeners();
+ System.out.println("Sample complete.");
+ System.out.println("\n\n\n ******************************** \n\n\n");
+ }
+
+ @Listener
+ public class MyListener {
+
+ @CacheEntryCreated
+ @CacheEntryModified
+ @CacheEntryRemoved
+ public void printDetailsOnChange(CacheEntryEvent e) {
+ System.out.printf("Thread %s has modified an entry in the cache named %s under key %s!\n",
+ Thread.currentThread().getName(), e.getCache().getName(), e.getKey());
+ }
+
+ @CacheEntryVisited
+ public void pribtDetailsOnVisit(CacheEntryVisitedEvent e) {
+ System.out.printf("Thread %s has visited an entry in the cache named %s under key %s!\n",
+ Thread.currentThread().getName(), e.getCache().getName(), e.getKey());
+ }
+ }
+}
+
diff --git a/sampleproject/src/main/resources/archetype-resources/src/main/java/SampleCacheContainer.java b/sampleproject/src/main/resources/archetype-resources/src/main/java/SampleCacheContainer.java
new file mode 100644
index 0000000..0182c4b
--- /dev/null
+++ b/sampleproject/src/main/resources/archetype-resources/src/main/java/SampleCacheContainer.java
@@ -0,0 +1,69 @@
+package ${groupId};
+
+import org.infinispan.Cache;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.manager.EmbeddedCacheManager;
+
+import java.io.IOException;
+
+/**
+ * This sample cache container acts as a factory and a mechanism with which to create and configure an embedded cache
+ * manager, and to hold this cache manager such that other code can access it.
+ *
+ * Variants of this pattern include storing the EmbeddedCacheManager in JNDI or as a bean in JMX, or even using CDI
+ * or some other dependency injection framework to hold the cache manager (and even cache) references and inject them
+ * as needed into various bits of application code.
+ */
+public class SampleCacheContainer {
+
+ // ************************************************************************************************************
+ // This should point to the Infinispan configuration file. Either an absolute path or the name of a config
+ // file in your classpath could be used. See http://community.jboss.org/wiki/Configuringcache for more details.
+ // ************************************************************************************************************
+
+ // This skeleton project ships with 4 different Infinispan configurations. Uncomment the one most appropriate to you.
+ private static final String INFINISPAN_CONFIGURATION = "infinispan-local.xml";
+// private static final String INFINISPAN_CONFIGURATION = "infinispan-clustered-tcp.xml";
+// private static final String INFINISPAN_CONFIGURATION = "infinispan-clustered-udp.xml";
+// private static final String INFINISPAN_CONFIGURATION = "infinispan-clustered-ec2.xml";
+
+ private static final EmbeddedCacheManager CACHE_MANAGER;
+
+ static {
+ try {
+ CACHE_MANAGER = new DefaultCacheManager(INFINISPAN_CONFIGURATION);
+ } catch (IOException e) {
+ throw new RuntimeException("Unable to configure Infinispan", e);
+ }
+ }
+
+ /**
+ * Retrieves the default cache.
+ * @param type used as keys in this cache
+ * @param type used as values in this cache
+ * @return a cache
+ */
+ public static Cache getCache() {
+ return CACHE_MANAGER.getCache();
+ }
+
+ /**
+ * Retrieves a named cache.
+ * @param cacheName name of cache to retrieve
+ * @param type used as keys in this cache
+ * @param type used as values in this cache
+ * @return a cache
+ */
+ public static Cache getCache(String cacheName) {
+ if (cacheName == null) throw new NullPointerException("Cache name cannot be null!");
+ return CACHE_MANAGER.getCache(cacheName);
+ }
+
+ /**
+ * Retrieves the embedded cache manager.
+ * @return a cache manager
+ */
+ public static EmbeddedCacheManager getCacheContainer() {
+ return CACHE_MANAGER;
+ }
+}
diff --git a/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-clustered-ec2.xml b/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-clustered-ec2.xml
new file mode 100644
index 0000000..3d26819
--- /dev/null
+++ b/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-clustered-ec2.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-clustered-tcp.xml b/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-clustered-tcp.xml
new file mode 100644
index 0000000..f98dd73
--- /dev/null
+++ b/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-clustered-tcp.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-clustered-udp.xml b/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-clustered-udp.xml
new file mode 100644
index 0000000..604cae8
--- /dev/null
+++ b/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-clustered-udp.xml
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-local.xml b/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-local.xml
new file mode 100644
index 0000000..cb91a80
--- /dev/null
+++ b/sampleproject/src/main/resources/archetype-resources/src/main/resources/infinispan-local.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/testcase/pom.xml b/testcase/pom.xml
new file mode 100644
index 0000000..c33d9b0
--- /dev/null
+++ b/testcase/pom.xml
@@ -0,0 +1,34 @@
+
+ 4.0.0
+
+
+ org.infinispan
+ infinispan-parent
+ 4.1.0.FINAL
+
+
+ org.infinispan.archetypes
+ testcase
+ jar
+ 1.0.0-SNAPSHOT
+ Infinispan Sample Testcase Archetype
+ Builds a skeleton test case using Infinispan. Very useful when reporting bugs.
+
+
+
+
+ org.infinispan
+ infinispan-core
+ 5.0.0-SNAPSHOT
+
+
+
+ org.infinispan
+ infinispan-core
+ 5.0.0-SNAPSHOT
+ test-jar
+ test
+
+
+
diff --git a/testcase/src/main/resources/META-INF/maven/archetype-metadata.xml b/testcase/src/main/resources/META-INF/maven/archetype-metadata.xml
new file mode 100644
index 0000000..b648895
--- /dev/null
+++ b/testcase/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -0,0 +1,15 @@
+
+
+
+ src/test/java
+
+
+
+ src/test/resources
+
+
+
+
\ No newline at end of file
diff --git a/testcase/src/main/resources/archetype-resources/pom.xml b/testcase/src/main/resources/archetype-resources/pom.xml
new file mode 100644
index 0000000..a1daff6
--- /dev/null
+++ b/testcase/src/main/resources/archetype-resources/pom.xml
@@ -0,0 +1,233 @@
+
+ 4.0.0
+ ${groupId}
+ ${artifactId}
+ jar
+ ${version}
+ A sample test case for Infinispan
+ http://www.myorganization.org
+
+
+
+
+ tcp
+
+ dummytm
+
+
+ ${infinispan.version}
+ 1.1
+ 2.4
+ 2.4
+ 4.9.0.GA
+ 4.9.0.GA
+ 4.6.1.GA
+ 1.2.16
+ 5.11
+ 1.3.1
+
+
+
+
+ org.infinispan
+ infinispan-core
+ ${version.infinispan}
+
+
+
+ org.infinispan
+ infinispan-core
+ ${version.infinispan}
+ test
+ test-jar
+
+
+
+
+ org.testng
+ testng
+ ${version.testng}
+ test
+ jdk15
+
+
+ org.easymock
+ easymockclassextension
+ ${version.easymockclassext}
+ test
+
+
+ org.easymock
+ easymock
+ ${version.easymock}
+ test
+
+
+ jboss.jbossts
+ jbossjta
+ ${version.jbossjta}
+ test
+
+
+ jboss.jbossts
+ jbossjts
+ ${version.jbossjts}
+ test
+
+
+ commons-logging
+ commons-logging
+ ${version.commons.logging}
+ test
+
+
+ jboss.jbossts
+ jbossts-common
+ ${version.jbossts-common}
+ test
+
+
+ log4j
+ log4j
+ ${version.log4j}
+ true
+
+
+
+
+ com.thoughtworks.xstream
+ xstream
+ ${version.xstream}
+ test
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ 1.0-beta-1
+
+
+ enforce-java
+
+ enforce
+
+
+
+
+ [1.6,)
+
+
+ [2.1.0,)
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 2.3.1
+
+
+ 1.6
+ UTF-8
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ none
+
+
+ infinispan.test.jgroups.protocol
+ ${infinispan.test.jgroups.protocol}
+
+
+ bind.address
+ 127.0.0.1
+
+
+ java.net.preferIPv4Stack
+ true
+
+
+ infinispan.test.jta.tm
+ ${infinispan.test.jta.tm}
+
+
+ log4j.configuration
+ test-log4j.xml
+
+
+ false
+
+
+ listener
+ org.infinispan.test.fwk.DebuggingUnitTestNGListener
+
+
+
+
+
+
+
+
+
+
+ JBoss.org Public Repository
+
+ true
+
+
+ true
+
+ http://repository.jboss.org/nexus/content/groups/public/
+
+
+
+
+
+
+ jbosstm
+
+ false
+
+
+ jbosstm
+
+
+
+
+
+ tcp
+
+ false
+
+
+ tcp
+
+
+
+
+
+ udp
+
+ false
+
+
+ udp
+
+
+
+
diff --git a/testcase/src/main/resources/archetype-resources/src/test/java/org/infinispan/SampleFunctionalTest.java b/testcase/src/main/resources/archetype-resources/src/test/java/org/infinispan/SampleFunctionalTest.java
new file mode 100644
index 0000000..d0640f6
--- /dev/null
+++ b/testcase/src/main/resources/archetype-resources/src/test/java/org/infinispan/SampleFunctionalTest.java
@@ -0,0 +1,94 @@
+package org.infinispan;
+
+
+import org.infinispan.config.Configuration;
+import org.infinispan.test.MultipleCacheManagersTest;
+import org.infinispan.test.TestingUtil;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+import javax.transaction.Transaction;
+import java.util.List;
+
+
+// ****************************************************************************************
+// This sample test should be used as a starting point when writing tests for Infinispan.
+//
+// See http://community.jboss.org/wiki/ParallelTestSuite for more information.
+// ****************************************************************************************
+
+
+// All tests must be annotated with @Test and contain the groups and testName attributes.
+@Test (groups = "functional", testName = "SampleFunctionalTest")
+
+// This test class extends MultipleCacheManagersTest which is designed to test a multiple node instances in a cluster.
+// Use SingleCacheManagerTest for tests designed to test a single, isolated Infinispan node.
+public class SampleFunctionalTest extends MultipleCacheManagersTest {
+
+ @Override
+ protected void createCacheManagers() throws Throwable {
+ // This method constructs and registers as many cache managers as you wish.
+ Configuration cfg = new Configuration();
+ cfg.setCacheMode(Configuration.CacheMode.DIST_SYNC);
+ cfg.setLockAcquisitionTimeout(100);
+
+ // One easy way to do this is the createCluster method which takes a configuration and the number of nodes to create.
+ createCluster(cfg, true, 5);
+
+ // or if you wish to use configuration defaults you could just do:
+// createCluster(Configuration.CacheMode.DIST_SYNC, 5);
+// createCluster(Configuration.CacheMode.DIST_SYNC, true, 5);
+
+ // alternately, you could manually create your own cache managers and register them:
+// EmbeddedCacheManager ecm1 = TestCacheManagerFactory.createClusteredCacheManager(cfg);
+// EmbeddedCacheManager ecm2 = TestCacheManagerFactory.createClusteredCacheManager(cfg);
+// EmbeddedCacheManager ecm3 = TestCacheManagerFactory.createClusteredCacheManager(cfg);
+// registerCacheManager(ecm1, ecm2, ecm3);
+ }
+
+ @BeforeMethod
+ public void setUp() {
+ // You could use this to set up your own init data
+ // Note that you don't need to set up any Infinispan resources as this is taken care of by the superclass
+ }
+
+ @AfterMethod
+ public void tearDown() {
+ // You could use this to clean up your own init data
+ // Note that you don't need to clean up any Infinispan resources as this is taken care of by the superclass
+ }
+
+ // Functional tests should not use multiple invocations.
+ public void testCacheOperations() {
+ // this is made available by the superclass. Each cache in this list is a reference to a specific default cache
+ // in the cluster.
+ List> caches = caches();
+
+ caches.get(0).put("Key", "Value");
+
+ for (Cache c: caches) {
+ assert "Value".equals(c.get("Key")): "Was expecting to see state on cache " + address(c);
+ }
+ }
+
+ public void testWithTransactions() throws Exception {
+ tm(0).begin(); // starts a transaction on node 0
+ cache(0).put("key", "value");
+ Transaction tx = tm(0).suspend();
+
+ assert !cache(1).containsKey("key") : "Should not see uncommitted changes";
+
+ tm(0).resume(tx);
+ tm(0).commit();
+
+ assert cache(1).containsKey("key") : "Should see committed changes";
+ }
+
+ public void testHelpers() {
+ cache(0).putAsync("key", "value");
+ TestingUtil.sleepRandom(500); // Try to avoid sleeps in your tests!
+
+ System.out.println("Contents of cache: " + TestingUtil.printCache(cache(0)));
+ }
+}
diff --git a/testcase/src/main/resources/archetype-resources/src/test/java/org/infinispan/SampleStressTest.java b/testcase/src/main/resources/archetype-resources/src/test/java/org/infinispan/SampleStressTest.java
new file mode 100644
index 0000000..576db5d
--- /dev/null
+++ b/testcase/src/main/resources/archetype-resources/src/test/java/org/infinispan/SampleStressTest.java
@@ -0,0 +1,67 @@
+package org.infinispan;
+
+
+import org.infinispan.config.Configuration;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.infinispan.test.SingleCacheManagerTest;
+
+
+// ****************************************************************************************
+// This sample test should be used as a starting point when writing tests for Infinispan.
+//
+// See http://community.jboss.org/wiki/ParallelTestSuite for more information.
+// ****************************************************************************************
+
+
+// All tests must be annotated with @Test and contain the groups and testName attributes.
+@Test(groups = "stress", testName = "SampleStressTest")
+
+// This test class extends SingleCacheManagerTest which is designed to test a single node instance. Use
+// MultipleCacheManagerTest for tests designed to test Infinispan in a cluster.
+public class SampleStressTest extends SingleCacheManagerTest {
+
+ @Override
+ protected EmbeddedCacheManager createCacheManager() throws Exception {
+ // In this method, you should construct your cache manager instance using the TestCacheManagerFactory.
+
+ // First create a Configuration and configure your system.
+ Configuration cfg = new Configuration();
+ cfg.setLockAcquisitionTimeout(1000);
+ cfg.setConcurrencyLevel(100);
+
+ // If you wish to use a transaction manager, you should pass the flag on to the TestCacheManagerFactory. This
+ // allows the factory to pick the appropriate transaction manager at test execution time.
+ EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(cfg, true);
+
+ // the superclass will register this EmbeddedCacheManager and handle cleanup of resources for you. It will also
+ // create the default cache instance and make it available to your tests.
+ return cm;
+ }
+
+ @BeforeMethod
+ public void setUp() {
+ // You could use this to set up your own init data
+ // Note that you don't need to set up any Infinispan resources as this is taken care of by the superclass
+ }
+
+ @AfterMethod
+ public void tearDown() {
+ // You could use this to clean up your own init data
+ // Note that you don't need to clean up any Infinispan resources as this is taken care of by the superclass
+ }
+
+ // This is where you write your test(s). Stress tests would typically require multiple invocations
+ @Test(invocationCount = 5)
+ public void testCacheOperations() {
+ // the cache instance is made available by the superclass.
+
+ cache.put("Hello", "World");
+ assert "World".equals(cache.get("Hello")) : "Was expecting 'World' but saw something else instead!";
+
+ // no need to clean up.
+ }
+}
diff --git a/testcase/src/main/resources/archetype-resources/src/test/java/org/infinispan/SampleUnitTest.java b/testcase/src/main/resources/archetype-resources/src/test/java/org/infinispan/SampleUnitTest.java
new file mode 100644
index 0000000..e9f1447
--- /dev/null
+++ b/testcase/src/main/resources/archetype-resources/src/test/java/org/infinispan/SampleUnitTest.java
@@ -0,0 +1,85 @@
+package org.infinispan;
+
+
+import org.easymock.EasyMock;
+import org.infinispan.config.Configuration;
+import org.infinispan.distribution.ch.DefaultConsistentHash;
+import org.infinispan.manager.EmbeddedCacheManager;
+import org.infinispan.remoting.transport.Address;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+import org.infinispan.test.SingleCacheManagerTest;
+
+import java.util.Arrays;
+import java.util.List;
+
+
+// ****************************************************************************************
+// This sample test should be used as a starting point when writing tests for Infinispan.
+//
+// See http://community.jboss.org/wiki/ParallelTestSuite for more information.
+// ****************************************************************************************
+
+
+// All tests must be annotated with @Test and contain the groups and testName attributes.
+@Test(groups = "unit", testName = "SampleUnitTest")
+
+// This test class extends SingleCacheManagerTest which is designed to test a single node instance. Use
+// MultipleCacheManagerTest for tests designed to test Infinispan in a cluster.
+public class SampleUnitTest extends SingleCacheManagerTest {
+
+ @Override
+ protected EmbeddedCacheManager createCacheManager() throws Exception {
+ // In this method, you should construct your cache manager instance using the TestCacheManagerFactory.
+
+ // First create a Configuration and configure your system.
+ Configuration cfg = new Configuration();
+ cfg.setLockAcquisitionTimeout(1000);
+ cfg.setConcurrencyLevel(100);
+
+ // If you wish to use a transaction manager, you should pass the flag on to the TestCacheManagerFactory. This
+ // allows the factory to pick the appropriate transaction manager at test execution time.
+ EmbeddedCacheManager cm = TestCacheManagerFactory.createCacheManager(cfg, true);
+
+ // the superclass will register this EmbeddedCacheManager and handle cleanup of resources for you. It will also
+ // create the default cache instance and make it available to your tests.
+ return cm;
+ }
+
+ @BeforeMethod
+ public void setUp() {
+ // You could use this to set up your own init data
+ // Note that you don't need to set up any Infinispan resources as this is taken care of by the superclass
+ }
+
+ @AfterMethod
+ public void tearDown() {
+ // You could use this to clean up your own init data
+ // Note that you don't need to clean up any Infinispan resources as this is taken care of by the superclass
+ }
+
+ // Unit tests should not use multiple invocations.
+ public void testCacheOperations() {
+ // the cache instance is made available by the superclass and can be used to test public API behavior.
+
+ cache.put("Hello", "World");
+ assert "World".equals(cache.get("Hello")) : "Was expecting 'World' but saw something else instead!";
+
+ // no need to clean up.
+ }
+
+ // Internal components can be tested in Unit Tests as well.
+ public void testSomeInternalComponent() {
+ DefaultConsistentHash dch = new DefaultConsistentHash();
+
+ // Making use of Mock Objects for non-critical components helps isolate the problem you are trying to test.
+ dch.setCaches(Arrays.asList(EasyMock.createNiceMock(Address.class),
+ EasyMock.createNiceMock(Address.class),
+ EasyMock.createNiceMock(Address.class)));
+
+ List a = dch.locate("somekey", 2);
+ assert a.size() == 2 : "Was expecting 2 entries in the location list";
+ }
+}
diff --git a/testcase/src/main/resources/archetype-resources/src/test/resources/test-log4j.xml b/testcase/src/main/resources/archetype-resources/src/test/resources/test-log4j.xml
new file mode 100644
index 0000000..931dda3
--- /dev/null
+++ b/testcase/src/main/resources/archetype-resources/src/test/resources/test-log4j.xml
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+