geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r448740 - in /geronimo/sandbox/gcache/server/src: main/java/org/apache/geronimo/gcache/command/ test/java/org/apache/geronimo/gcache/command/ test/java/org/apache/geronimo/gcache/transports/tcp/
Date Thu, 21 Sep 2006 23:42:26 GMT
Author: jgenender
Date: Thu Sep 21 16:42:25 2006
New Revision: 448740

URL: http://svn.apache.org/viewvc?view=rev&rev=448740
Log:
Begin command infrastructure

Added:
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java
  (with props)
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java
  (with props)
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java
  (with props)
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java
  (with props)
Modified:
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/AddEntryCommand.java
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BaseCommand.java
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/AddEntryCommandTest.java
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TcpSocketServerTest.java

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/AddEntryCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/AddEntryCommand.java?view=diff&rev=448740&r1=448739&r2=448740
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/AddEntryCommand.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/AddEntryCommand.java
Thu Sep 21 16:42:25 2006
@@ -18,64 +18,10 @@
  */
 package org.apache.geronimo.gcache.command;
 
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-import java.nio.ByteBuffer;
-import java.nio.channels.Channels;
-import java.nio.channels.WritableByteChannel;
-
-import org.apache.geronimo.gcache.marshal.MarshalAware;
-import org.apache.geronimo.gcache.util.ByteArrayOutputStream;
-
-public class AddEntryCommand extends BaseCommand {
-    private static final int DEFAULT_CAPACITY = 1024;
-
-    // the key to store the payload under
-    private String key;
-
-    // this is the actual data that must be added to the distributed cache
-    private ByteBuffer payload = ByteBuffer.allocate(DEFAULT_CAPACITY);
-
-    public String getKey() {
-        return key;
-    }
-
-    public void setKey(String key) {
-        this.key = key;
-    }
+public class AddEntryCommand extends CachePayloadBaseCommand {
 
     public void execute() {
         //TODO: make this add the payload to the local cache then call back to the pusher
-    }
-
-    public void setValue(Object value) throws IOException {
-        if (value instanceof Serializable) {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream();
-            ObjectOutputStream stream = new ObjectOutputStream(baos);
-            stream.writeObject(value);
-            stream.flush();
-            stream.close();
-            setPayload(ByteBuffer.wrap(baos.toByteArray()));
-        } else if (value instanceof MarshalAware) {
-            ByteArrayOutputStream baos = new ByteArrayOutputStream(34);
-            WritableByteChannel channel = Channels.newChannel(baos);
-            ((MarshalAware)value).writeExternal(channel);
-            channel.close();
-            setPayload(ByteBuffer.wrap(baos.toByteArray()));
-        } else {
-            throw new RuntimeException("Invalid argument - " + value
-                    + " is not an instance of java.io.Seriallizable"
-                    + " or MarshalAware");
-        }
-    }
-
-    public ByteBuffer getPayload() {
-        return payload;
-    }
-
-    public void setPayload(ByteBuffer payload) {
-        this.payload = payload;
     }
 
 }

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BaseCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BaseCommand.java?view=diff&rev=448740&r1=448739&r2=448740
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BaseCommand.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/BaseCommand.java
Thu Sep 21 16:42:25 2006
@@ -18,11 +18,18 @@
  */
 package org.apache.geronimo.gcache.command;
 
+import org.apache.geronimo.gcache.util.ByteArrayOutputStream;
+import org.apache.geronimo.gcache.util.ByteArrayInputStream;
+import org.apache.geronimo.gcache.marshal.MarshalAware;
+
 import java.io.IOException;
 import java.io.Serializable;
+import java.io.ObjectOutputStream;
+import java.io.ObjectInputStream;
 import java.nio.ByteBuffer;
 import java.nio.channels.ReadableByteChannel;
 import java.nio.channels.WritableByteChannel;
+import java.nio.channels.Channels;
 import java.nio.charset.Charset;
 
 public class BaseCommand implements Command {
@@ -40,11 +47,40 @@
     public void execute() {
         // nothing to do in the base
     }
-    
+
     public void readExternal(ReadableByteChannel channel) throws IOException {
         // this is the root so no super impl, others should call super first
+        commandId = readString(channel);
 
-        // first the length of the string
+    }
+
+    public void writeExternal(WritableByteChannel channel) throws IOException {
+        // this is the root so no super impl, others should call super first
+        writeString(channel, commandId);
+    }
+
+    public byte[] marshal() throws IOException {
+        ByteArrayOutputStream baos = new ByteArrayOutputStream(34);
+        WritableByteChannel channel = Channels.newChannel(baos);
+        writeExternal(channel);
+        channel.close();
+        return baos.toByteArray();
+    }
+
+    protected Object convertObjectFromBytes(byte data[]) throws IOException {
+        if (data == null)
+            return null;
+
+        ByteArrayInputStream bais = new ByteArrayInputStream(data);
+        ObjectInputStream ois = new ObjectInputStream(bais);
+        try {
+            return ois.readObject();
+        } catch (ClassNotFoundException e) {
+            throw new IOException(e.getMessage());
+        }
+    }
+
+    protected String readString(ReadableByteChannel channel) throws IOException {
         ByteBuffer buffer = ByteBuffer.allocateDirect(4);
         int read = channel.read(buffer);
         int idLength = 0;
@@ -59,24 +95,93 @@
         // the length method on String returns the number of 16 bit characters
         buffer = ByteBuffer.allocateDirect(idLength);
         read = channel.read(buffer);
-        if(read != idLength) {
+        if (read != idLength) {
             throw new IOException("Could not read identifier from the channel");
         }
         buffer.flip();
-        commandId = Charset.defaultCharset().decode(buffer).toString();
+        String str = Charset.defaultCharset().decode(buffer).toString();
         buffer = null;
+
+        return str;
     }
 
-    public void writeExternal(WritableByteChannel channel) throws IOException {
-        // this is the root so no super impl, others should call super first
+    protected void writeString(WritableByteChannel channel, String str) throws IOException
{
+
         // first the length of the string
         ByteBuffer buffer = ByteBuffer.allocateDirect(4);
-        buffer.putInt(commandId.length());
+        buffer.putInt(str.length());
         buffer.flip();
         channel.write(buffer);
+
         // now write the string - buffer comes back flipped
-        buffer = Charset.defaultCharset().encode(commandId);
+        buffer = Charset.defaultCharset().encode(str);
         channel.write(buffer);
+    }
+
+    protected byte[] readBytes(ReadableByteChannel channel) throws IOException {
+
+        ByteBuffer buffer = ByteBuffer.allocateDirect(4);
+
+        //Read size
+        int read = channel.read(buffer);
+        int idLength = 0;
+        if (read == 4) {
+            buffer.flip();
+            idLength = buffer.getInt();
+        } else {
+            throw new IOException("Could not read identifier length from the channel");
+        }
+        buffer = null;
+
+        if (idLength == 0)
+            return null;
+
+        //Read the bytes
+        buffer = ByteBuffer.allocate(idLength);
+        read = channel.read(buffer);
+        if (read != idLength) {
+            throw new IOException("Could not read identifier from the channel");
+        }
+        buffer.flip();
+        return buffer.array();
+    }
+
+    protected void writeBytes(WritableByteChannel channel, byte[] bytes) throws IOException
{
+
+        // first the length of the string
+        ByteBuffer buffer = ByteBuffer.allocateDirect(4);
+        if (bytes != null)
+            buffer.putInt(bytes.length);
+        else{
+            buffer.putInt(0);
+        }
+        buffer.flip();
+        channel.write(buffer);
+
+        if (bytes != null)
+            channel.write(ByteBuffer.wrap(bytes));
+    }
+
+    protected byte[] convertObjectToBytes(Object object) throws IOException {
+
+        if (object instanceof MarshalAware) {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream(34);
+            WritableByteChannel channel = Channels.newChannel(baos);
+            ((MarshalAware) object).writeExternal(channel);
+            channel.close();
+            return baos.toByteArray();
+        } else if (object instanceof Serializable) {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            ObjectOutputStream stream = new ObjectOutputStream(baos);
+            stream.writeObject(object);
+            stream.flush();
+            stream.close();
+            return baos.toByteArray();
+        } else {
+            throw new RuntimeException("Invalid argument - Object"
+                    + " is not an instance of java.io.Serializable"
+                    + " or MarshalAware");
+        }
     }
 
 }

Added: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java?view=auto&rev=448740
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java
(added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java
Thu Sep 21 16:42:25 2006
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.gcache.command;
+
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.WritableByteChannel;
+import java.nio.charset.Charset;
+
+public class CacheBaseCommand extends BaseCommand {
+
+    // The Session to store the payload under
+    private String sessionId;
+
+    // The key to store the payload under
+    private String key;
+
+    public String getKey() {
+        return key;
+    }
+
+    public void setKey(String key) {
+        this.key = key;
+    }
+
+    public String getSessionId() {
+        return sessionId;
+    }
+
+    public void setSessionId(String sessionId) {
+        this.sessionId = sessionId;
+    }
+
+    public void readExternal(ReadableByteChannel channel) throws IOException {
+        super.readExternal(channel);
+
+        //Process what we want read
+        key = readString(channel);
+        sessionId = readString(channel);
+    }
+
+    public void writeExternal(WritableByteChannel channel) throws IOException {
+        super.writeExternal(channel);
+
+        //Process what we want to write
+        writeString(channel, key);
+        writeString(channel, sessionId);
+    }
+}

Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CacheBaseCommand.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java?view=auto&rev=448740
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java
(added)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java
Thu Sep 21 16:42:25 2006
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.gcache.command;
+
+import java.io.IOException;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.WritableByteChannel;
+
+public class CachePayloadBaseCommand extends CacheBaseCommand{
+
+    // this is the actual data that must be added to the distributed cache
+    private byte[] payload = null;
+
+    public void readExternal(ReadableByteChannel channel) throws IOException {
+        super.readExternal(channel);
+
+        //Process what we want to read
+        payload = this.readBytes(channel);
+    }
+
+    public void writeExternal(WritableByteChannel channel) throws IOException {
+        super.writeExternal(channel);
+
+        //Process what we want to write
+        writeBytes(channel, payload);
+    }
+
+
+    public void setPayloadObject(Object value) throws IOException {
+        setPayload(convertObjectToBytes(value));
+    }
+
+    public Object getPayloadObject() throws IOException{
+        return convertObjectFromBytes(getPayload());
+    }
+
+    public byte[] getPayload() {
+        return payload;
+    }
+
+    public void setPayload(byte[] data) {
+        this.payload = data;
+    }
+
+}

Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommand.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/AddEntryCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/AddEntryCommandTest.java?view=diff&rev=448740&r1=448739&r2=448740
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/AddEntryCommandTest.java
(original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/AddEntryCommandTest.java
Thu Sep 21 16:42:25 2006
@@ -18,29 +18,14 @@
  */
 package org.apache.geronimo.gcache.command;
 
+import org.testng.annotations.Test;
+
 import java.io.ByteArrayInputStream;
-import java.nio.ByteBuffer;
 import java.nio.channels.Channels;
 import java.nio.channels.ReadableByteChannel;
 
-import org.testng.annotations.Test;
-
 public class AddEntryCommandTest {
     @Test
     public void testPayload() throws Exception {
-        String commandId = "the command id";
-        AddEntryCommand command = new AddEntryCommand();
-        command.setCommandId(commandId);
-        BaseCommand baseCommand = new BaseCommand();
-        String baseCommandId = "base command id";
-        baseCommand.setCommandId(baseCommandId);
-        // setValue will call setPayload
-        command.setValue(baseCommand);
-        ByteBuffer buffer = command.getPayload();
-        ByteArrayInputStream bias = new ByteArrayInputStream(buffer.array());
-        ReadableByteChannel channel = Channels.newChannel(bias);
-        BaseCommand readCommand = new BaseCommand();
-        readCommand.readExternal(channel);
-        assert readCommand.getCommandId().equals(baseCommandId);
     }
 }

Added: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java?view=auto&rev=448740
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java
(added)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java
Thu Sep 21 16:42:25 2006
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.gcache.command;
+
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayInputStream;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.Channels;
+
+public class CacheBaseCommandTest {
+
+    @Test
+    public void testCacheBaseCommand() throws Exception {
+
+        String commandId = "the command id";
+        String key = "My Key";
+        String sessionId = "My Session Id";
+
+        CacheBaseCommand command = new CacheBaseCommand();
+        command.setCommandId(commandId);
+        command.setKey(key);
+        command.setSessionId(sessionId);
+
+        //Convert the command to bytes
+        byte[] marshalled = command.marshal();
+
+        ByteArrayInputStream bias = new ByteArrayInputStream(marshalled);
+        ReadableByteChannel channel = Channels.newChannel(bias);
+        CacheBaseCommand readCommand = new CacheBaseCommand();
+        readCommand.readExternal(channel);
+        assert readCommand.getCommandId().equals(commandId);
+        assert readCommand.getKey().equals(key);
+        assert readCommand.getSessionId().equals(sessionId);
+
+        /**
+        BaseCommand baseCommand = new BaseCommand();
+        String baseCommandId = "base command id";
+        baseCommand.setCommandId(baseCommandId);
+
+        command.setValue(baseCommand);
+
+        ByteArrayInputStream bias = new ByteArrayInputStream(command.getPayload());
+        ReadableByteChannel channel = Channels.newChannel(bias);
+        BaseCommand readCommand = new BaseCommand();
+        readCommand.readExternal(channel);
+        assert readCommand.getCommandId().equals(baseCommandId);
+         **/
+    }
+
+}

Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CacheBaseCommandTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java?view=auto&rev=448740
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java
(added)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java
Thu Sep 21 16:42:25 2006
@@ -0,0 +1,59 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.gcache.command;
+
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayInputStream;
+import java.nio.channels.ReadableByteChannel;
+import java.nio.channels.Channels;
+
+public class CachePayloadBaseCommandTest {
+
+    @Test
+    public void testCacheValueBaseCommand() throws Exception {
+        String commandId = "the command id";
+        String key = "My Key";
+        String sessionId = "My Session Id";
+        String data = "This is some serializable data...";
+
+        CachePayloadBaseCommand command = new CachePayloadBaseCommand();
+        command.setCommandId(commandId);
+        command.setKey(key);
+        command.setSessionId(sessionId);
+        command.setPayloadObject(data);
+
+        //Convert the command to bytes
+        byte[] marshalled = command.marshal();
+
+        ByteArrayInputStream bias = new ByteArrayInputStream(marshalled);
+        ReadableByteChannel channel = Channels.newChannel(bias);
+        CachePayloadBaseCommand readCommand = new CachePayloadBaseCommand();
+        readCommand.readExternal(channel);
+
+        byte readData[] = readCommand.getPayload();
+        String readString = (String)readCommand.convertObjectFromBytes(readData);
+        assert readString.equals(data);
+
+        assert readCommand.getCommandId().equals(commandId);
+        assert readCommand.getKey().equals(key);
+        assert readCommand.getSessionId().equals(sessionId);
+    }
+
+}

Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/CachePayloadBaseCommandTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TcpSocketServerTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TcpSocketServerTest.java?view=diff&rev=448740&r1=448739&r2=448740
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TcpSocketServerTest.java
(original)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/transports/tcp/TcpSocketServerTest.java
Thu Sep 21 16:42:25 2006
@@ -21,8 +21,11 @@
 import org.apache.geronimo.gcache.server.impl.DefaultThreadPoolImpl;
 
 public class TcpSocketServerTest {
+    
     @Test()
     public void runServer() throws Exception {
+
+        /**
         ThreadPool pool = new DefaultThreadPoolImpl(10);
         MockSelectionKeyProcessor mock = new MockSelectionKeyProcessor();
         //TCPSocketServer server = new TCPSocketServer("localhost", 45678, pool, 2000, mock);
@@ -30,5 +33,7 @@
         server.start();
         Thread.sleep(100000);
         server.stop();
+         **/
+
     }
 }



Mime
View raw message