geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r479766 - in /geronimo/sandbox/gcache/tests: ./ src/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/test/java/org/apache/geronimo/ src/test/java/org/apache/geronimo/gcache/ src/test/resources/
Date Mon, 27 Nov 2006 21:12:10 GMT
Author: jgenender
Date: Mon Nov 27 13:12:09 2006
New Revision: 479766

URL: http://svn.apache.org/viewvc?view=rev&rev=479766
Log:
Add testing module

Added:
    geronimo/sandbox/gcache/tests/   (with props)
    geronimo/sandbox/gcache/tests/pom.xml
    geronimo/sandbox/gcache/tests/src/
    geronimo/sandbox/gcache/tests/src/test/
    geronimo/sandbox/gcache/tests/src/test/java/
    geronimo/sandbox/gcache/tests/src/test/java/org/
    geronimo/sandbox/gcache/tests/src/test/java/org/apache/
    geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/
    geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/gcache/
    geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/gcache/AbstractParent.java
    geronimo/sandbox/gcache/tests/src/test/resources/
    geronimo/sandbox/gcache/tests/src/test/resources/gcache-server-config.xml
    geronimo/sandbox/gcache/tests/src/test/resources/log4j.xml

Propchange: geronimo/sandbox/gcache/tests/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Nov 27 13:12:09 2006
@@ -0,0 +1,10 @@
+*.log
+*.log.*
+*.ipr
+*.iws
+*.iml
+.project
+.classpath
+junit*.properties
+temp-testng-customsuite.xml
+target

Added: geronimo/sandbox/gcache/tests/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/tests/pom.xml?view=auto&rev=479766
==============================================================================
--- geronimo/sandbox/gcache/tests/pom.xml (added)
+++ geronimo/sandbox/gcache/tests/pom.xml Mon Nov 27 13:12:09 2006
@@ -0,0 +1,49 @@
+<project>
+
+	<modelVersion>4.0.0</modelVersion>
+
+	<parent>
+		<groupId>org.apache.geronimo.gcache</groupId>
+		<artifactId>gcache</artifactId>
+		<version>1.0-SNAPSHOT</version>
+	</parent>
+
+	<artifactId>gcache-tests</artifactId>
+	<packaging>jar</packaging>
+	<version>${gcacheVersion}</version>
+
+	<name>GCache :: Tests</name>
+
+	<dependencies>
+
+		<dependency>
+			<groupId>org.testng</groupId>
+			<artifactId>testng</artifactId>
+			<classifier>jdk15</classifier>
+			<scope>test</scope>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.geronimo.gcache</groupId>
+			<artifactId>gcache-common</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.geronimo.gcache</groupId>
+			<artifactId>gcache-server</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.geronimo.gcache</groupId>
+			<artifactId>gcache-client</artifactId>
+		</dependency>
+
+		<dependency>
+			<groupId>net.sf.ehcache</groupId>
+			<artifactId>ehcache</artifactId>
+		</dependency>
+
+	</dependencies>
+	<build></build>
+
+</project>

Added: geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/gcache/AbstractParent.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/gcache/AbstractParent.java?view=auto&rev=479766
==============================================================================
--- geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/gcache/AbstractParent.java
(added)
+++ geronimo/sandbox/gcache/tests/src/test/java/org/apache/geronimo/gcache/AbstractParent.java
Mon Nov 27 13:12:09 2006
@@ -0,0 +1,123 @@
+package org.apache.geronimo.gcache;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.InetSocketAddress;
+import java.net.Socket;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.geronimo.gcache.command.AuthCommand;
+import org.apache.geronimo.gcache.command.BaseCommand;
+import org.apache.geronimo.gcache.command.Command;
+import org.apache.geronimo.gcache.command.CommandTypes;
+import org.apache.geronimo.gcache.command.HandShakeCommand;
+import org.apache.geronimo.gcache.command.PublicKeyCommand;
+import org.apache.geronimo.gcache.command.PutSessionCommand;
+import org.apache.geronimo.gcache.server.GCacheManager;
+import org.apache.geronimo.gcache.transports.tcp.Constants;
+import org.apache.geronimo.gcache.util.CipherUtil;
+import org.apache.mina.common.ByteBuffer;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+public class AbstractParent{
+    GCacheManager mgr;
+
+    @BeforeClass
+    public void setUp() throws Exception {
+        mgr = new GCacheManager(null);
+        mgr.start();
+    }
+
+    @AfterClass(alwaysRun = true)
+    public void shutdown() throws Exception {
+        mgr.stop();
+    }
+
+    protected void authenticate(Socket socket) throws Exception {
+        HandShakeCommand command = new HandShakeCommand();
+        command.setPublicKey(CipherUtil.publicKey);
+
+        //Send the handshake
+        sendCommand(socket, command);
+
+        PublicKeyCommand keyCommand = (PublicKeyCommand) readCommand(socket);
+
+        AuthCommand auth = new AuthCommand();
+        auth.setUserId("system");
+        auth.setPassword("manager");
+        auth.setPublicKey(keyCommand.getPublicKey());
+
+        sendCommand(socket, auth);
+
+    }
+
+    protected void sendCommand(Socket socket, BaseCommand command)
+            throws Exception {
+
+        byte bytes[] = command.createPacket(true);
+
+        OutputStream out = socket.getOutputStream();
+        out.write(bytes);
+        out.flush();
+
+    }
+
+    protected Command readCommand(Socket socket) throws Exception {
+
+        byte recBuf[] = new byte[Constants.HEADER_SIZE];
+
+        socket.setSoTimeout(2000);
+        InputStream is = socket.getInputStream();
+        int read = is.read(recBuf);
+        assert read == Constants.HEADER_SIZE;
+        ByteBuffer receiveHeader = ByteBuffer.wrap(recBuf);
+
+        //Read the magic
+        byte magic[] = new byte[Constants.MAGIC.length];
+        receiveHeader.get(magic);
+
+        //Better match the Magic
+        assert Arrays.equals(Constants.MAGIC, magic);
+
+        //Get the command
+        byte commandIdentifier = receiveHeader.get();
+
+        //Get the command length
+        int length = receiveHeader.getInt();
+        receiveHeader.release();
+
+        //pull the command
+        recBuf = new byte[length];
+        int count = is.read(recBuf);
+        assert count == length;
+        ByteBuffer commandBuffer = ByteBuffer.wrap(recBuf);
+
+        //Create the command and unmarshal the data
+        Command command = CommandTypes.createCommand(commandIdentifier);
+        command.readExternal(ByteBuffer.wrap(commandBuffer.array()));
+
+        return command;
+
+    }
+
+    private void sendSession(Socket socket) throws Exception {
+
+        //Create a session
+        Map<String, String> session = new HashMap<String, String>();
+        session.put("key1", "data1");
+        session.put("key2", "data2");
+        session.put("key3", "data3");
+        PutSessionCommand command = new PutSessionCommand();
+        command.setCacheName("Cache1");
+        command.setSessionId("Session1");
+        command.setPayloadFromSession(session);
+
+        //Send the packet
+        sendCommand(socket, command);
+
+    }    
+}
\ No newline at end of file

Added: geronimo/sandbox/gcache/tests/src/test/resources/gcache-server-config.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/tests/src/test/resources/gcache-server-config.xml?view=auto&rev=479766
==============================================================================
--- geronimo/sandbox/gcache/tests/src/test/resources/gcache-server-config.xml (added)
+++ geronimo/sandbox/gcache/tests/src/test/resources/gcache-server-config.xml Mon Nov 27 13:12:09
2006
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gcache-config>
+	<server order="1" serverName="gcache">
+		<transport name="default" uri="tcp://default?enableLogging=true" discoveryUri="multicast://default"
/>
+	</server>
+	
+	<diskStore path="${java.io.tmpdir}/gcache" />
+	
+	<defaultCache maxElementsInMemory="10000" eternal="false"
+		timeToIdleSeconds="120" timeToLiveSeconds="120" overflowToDisk="true"
+		diskPersistent="false" diskExpiryThreadIntervalSeconds="120"
+		memoryStoreEvictionPolicy="LRU" />
+		
+	<cache name="Test" maxElementsInMemory="10000" eternal="false"
+		timeToIdleSeconds="1800" timeToLiveSeconds="0" overflowToDisk="true"
+		diskPersistent="false" diskExpiryThreadIntervalSeconds="60"
+		memoryStoreEvictionPolicy="LRU" />
+		
+	<cache name="Test2" maxElementsInMemory="10000" eternal="false"
+		timeToIdleSeconds="0" timeToLiveSeconds="1800" overflowToDisk="false"
+		diskPersistent="true" diskExpiryThreadIntervalSeconds="60"
+		memoryStoreEvictionPolicy="LFU" />
+</gcache-config>

Added: geronimo/sandbox/gcache/tests/src/test/resources/log4j.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/tests/src/test/resources/log4j.xml?view=auto&rev=479766
==============================================================================
--- geronimo/sandbox/gcache/tests/src/test/resources/log4j.xml (added)
+++ geronimo/sandbox/gcache/tests/src/test/resources/log4j.xml Mon Nov 27 13:12:09 2006
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+
+<log4j:configuration xmlns:log4j='http://jakarta.apache.org/log4j/'>
+
+	<appender name="ConsoleAppender" class="org.apache.log4j.ConsoleAppender">
+		<layout class="org.apache.log4j.PatternLayout">
+			<!--param name="ConversionPattern" value="[%p] %c %m%n"/-->
+			<param name="ConversionPattern" value="[%p] [%c{1}] %m%n"/>
+		</layout>
+	</appender>
+
+   <category name="net.sf.ehcache.config.ConfigurationFactory">
+      <priority value="ERROR"/>
+   </category>
+
+	<root>
+		<priority value="debug"/>
+		<appender-ref ref="ConsoleAppender"/>
+	</root>
+
+</log4j:configuration>



Mime
View raw message