You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by jg...@apache.org on 2006/09/19 00:07:14 UTC
svn commit: r447591 [2/2] - in /geronimo/sandbox/gcache: ./ client/
openwire/ openwire/src/main/java/org/apache/geronimo/openwire/
openwire/src/main/java/org/apache/geronimo/openwire/command/
openwire/src/main/java/org/apache/geronimo/openwire/thread/ ...
Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/VMTransportServer.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/VMTransportServer.java?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/VMTransportServer.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/VMTransportServer.java Mon Sep 18 15:07:10 2006
@@ -0,0 +1,137 @@
+/**
+ *
+ * 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.openwire.transport.vm;
+
+import java.io.IOException;
+import java.net.InetSocketAddress;
+import java.net.URI;
+
+import org.apache.geronimo.openwire.command.NodeInfo;
+import org.apache.geronimo.openwire.transport.MutexTransport;
+import org.apache.geronimo.openwire.transport.ResponseCorrelator;
+import org.apache.geronimo.openwire.transport.Transport;
+import org.apache.geronimo.openwire.transport.TransportAcceptListener;
+import org.apache.geronimo.openwire.transport.TransportServer;
+
+import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Broker side of the VMTransport
+ *
+ */
+public class VMTransportServer implements TransportServer {
+
+ private TransportAcceptListener acceptListener;
+ private final URI location;
+ private boolean disposed;
+
+ private final AtomicInteger connectionCount = new AtomicInteger(0);
+ private final boolean disposeOnDisconnect;
+
+ /**
+ * @param location
+ * @param disposeOnDisconnect
+ */
+ public VMTransportServer(URI location, boolean disposeOnDisconnect) {
+ this.location = location;
+ this.disposeOnDisconnect=disposeOnDisconnect;
+ }
+
+ /**
+ *@return a pretty print of this
+ */
+ public String toString(){
+ return "VMTransportServer(" + location +")";
+ }
+
+ /**
+ * @return new VMTransport
+ * @throws IOException
+ */
+ public VMTransport connect() throws IOException {
+ TransportAcceptListener al;
+ synchronized (this) {
+ if( disposed )
+ throw new IOException("Server has been disposed.");
+ al = acceptListener;
+ }
+ if( al == null)
+ throw new IOException("Server TransportAcceptListener is null.");
+
+ connectionCount.incrementAndGet();
+ VMTransport client = new VMTransport(location) {
+ public void stop() throws Exception {
+ if( disposed )
+ return;
+ super.stop();
+ if( connectionCount.decrementAndGet()==0 && disposeOnDisconnect ) {
+ VMTransportServer.this.stop();
+ }
+ };
+ };
+
+ VMTransport server = new VMTransport(location);
+ client.setPeer(server);
+ server.setPeer(client);
+ al.onAccept(configure(server));
+ return client;
+ }
+
+ /**
+ * Configure transport
+ * @param transport
+ * @return the Transport
+ */
+ public static Transport configure(Transport transport) {
+ transport = new MutexTransport(transport);
+ transport = new ResponseCorrelator(transport);
+ return transport;
+ }
+
+
+ /**
+ * Set the Transport accept listener for new Connections
+ * @param acceptListener
+ *
+ */
+ synchronized public void setAcceptListener(TransportAcceptListener acceptListener) {
+ this.acceptListener = acceptListener;
+ }
+
+ public void start() throws IOException {
+ }
+
+ public void stop() throws IOException {
+ VMTransportFactory.stopped(this);
+ }
+
+ public URI getConnectURI() {
+ return location;
+ }
+
+ public URI getBindURI() {
+ return location;
+ }
+
+ public void setNodeInfo(NodeInfo nodeInfo) {
+ }
+
+ public InetSocketAddress getSocketAddress() {
+ return null;
+ }
+}
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/VMTransportServer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/VMTransportServer.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/VMTransportServer.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/package.html
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/package.html?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/package.html (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/package.html Mon Sep 18 15:07:10 2006
@@ -0,0 +1,25 @@
+<!--
+ 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.
+-->
+<html>
+<head>
+</head>
+<body>
+
+In-JVM based Transport implementation.
+
+</body>
+</html>
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/package.html
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/transport/vm/package.html
------------------------------------------------------------------------------
svn:mime-type = text/html
Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ByteSequenceData.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ByteSequenceData.java?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ByteSequenceData.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ByteSequenceData.java Mon Sep 18 15:07:10 2006
@@ -0,0 +1,267 @@
+/**
+ *
+ * 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.openwire.util;
+
+import java.io.IOException;
+
+
+/**
+ * Used to write and read primitives to and from a ByteSequence.
+ */
+final public class ByteSequenceData {
+
+
+ public static byte[] toByteArray(ByteSequence packet) {
+ if( packet.offset==0 && packet.length == packet.data.length )
+ return packet.data;
+
+ byte rc[] = new byte[packet.length];
+ System.arraycopy(packet.data, packet.offset, rc, 0, packet.length);
+ return rc;
+ }
+
+ private static void spaceNeeded(ByteSequence packet, int i) {
+ assert packet.offset+i <= packet.length;
+ }
+
+ public static int remaining(ByteSequence packet) {
+ return packet.length - packet.offset;
+ }
+
+ public static int read(ByteSequence packet) {
+ return packet.data[packet.offset++] & 0xff;
+ }
+
+
+ public static void readFully(ByteSequence packet, byte[] b) throws IOException {
+ readFully(packet, b, 0, b.length);
+ }
+
+ public static void readFully(ByteSequence packet, byte[] b, int off, int len) throws IOException {
+ spaceNeeded(packet, len);
+ System.arraycopy(packet.data, packet.offset, b, off, len);
+ packet.offset += len;
+ }
+
+ public static int skipBytes(ByteSequence packet, int n) throws IOException {
+ int rc = Math.min(n, remaining(packet));
+ packet.offset += rc;
+ return rc;
+ }
+
+ public static boolean readBoolean(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 1);
+ return read(packet) != 0;
+ }
+
+ public static byte readByte(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 1);
+ return (byte) read(packet);
+ }
+
+ public static int readUnsignedByte(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 1);
+ return read(packet);
+ }
+
+ public static short readShortBig(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 2);
+ return (short) ((read(packet) << 8) + (read(packet) << 0));
+ }
+ public static short readShortLittle(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 2);
+ return (short) ((read(packet) << 0) + (read(packet) << 8) );
+ }
+
+ public static int readUnsignedShortBig(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 2);
+ return ((read(packet) << 8) + (read(packet) << 0));
+ }
+ public static int readUnsignedShortLittle(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 2);
+ return ((read(packet) << 0) + (read(packet) << 8) );
+ }
+
+ public static char readCharBig(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 2);
+ return (char) ((read(packet) << 8) + (read(packet) << 0));
+ }
+ public static char readCharLittle(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 2);
+ return (char) ((read(packet) << 0) + (read(packet) << 8) );
+ }
+
+ public static int readIntBig(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 4);
+ return ((read(packet) << 24) +
+ (read(packet) << 16) +
+ (read(packet) << 8) +
+ (read(packet) << 0));
+ }
+ public static int readIntLittle(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 4);
+ return ((read(packet) << 0) +
+ (read(packet) << 8) +
+ (read(packet) << 16) +
+ (read(packet) << 24));
+ }
+
+ public static long readLongBig(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 8);
+ return (((long) read(packet) << 56) +
+ ((long) read(packet) << 48) +
+ ((long) read(packet) << 40) +
+ ((long) read(packet) << 32) +
+ ((long) read(packet) << 24) +
+ ((read(packet)) << 16) +
+ ((read(packet)) << 8) +
+ ((read(packet)) << 0));
+ }
+ public static long readLongLittle(ByteSequence packet) throws IOException {
+ spaceNeeded(packet, 8);
+ return ((read(packet) << 0) +
+ (read(packet) << 8) +
+ (read(packet) << 16) +
+ ((long) read(packet) << 24) +
+ ((long) read(packet) << 32) +
+ ((long) read(packet) << 40) +
+ ((long) read(packet) << 48) +
+ ((long) read(packet) << 56));
+ }
+
+ public static double readDoubleBig(ByteSequence packet) throws IOException {
+ return Double.longBitsToDouble(readLongBig(packet));
+ }
+ public static double readDoubleLittle(ByteSequence packet) throws IOException {
+ return Double.longBitsToDouble(readLongLittle(packet));
+ }
+
+ public static float readFloatBig(ByteSequence packet) throws IOException {
+ return Float.intBitsToFloat(readIntBig(packet));
+ }
+ public static float readFloatLittle(ByteSequence packet) throws IOException {
+ return Float.intBitsToFloat(readIntLittle(packet));
+ }
+
+ public static void write(ByteSequence packet, int b) throws IOException {
+ spaceNeeded(packet, 1);
+ packet.data[packet.offset++] = (byte) b;
+ }
+
+ public static void write(ByteSequence packet, byte[] b) throws IOException {
+ write(packet, b, 0, b.length);
+ }
+ public static void write(ByteSequence packet, byte[] b, int off, int len) throws IOException {
+ spaceNeeded(packet, len);
+ System.arraycopy(b, off, packet.data, packet.offset, len);
+ packet.offset += len;
+ }
+ public static void writeBoolean(ByteSequence packet, boolean v) throws IOException {
+ spaceNeeded(packet, 1);
+ write(packet,v ? 1 : 0);
+ }
+ public static void writeByte(ByteSequence packet, int v) throws IOException {
+ spaceNeeded(packet, 1);
+ write(packet,v);
+ }
+ public static void writeShortBig(ByteSequence packet, int v) throws IOException {
+ spaceNeeded(packet, 2);
+ write(packet,(v >>> 8) & 0xFF);
+ write(packet,(v >>> 0) & 0xFF);
+ }
+ public static void writeShortLittle(ByteSequence packet, int v) throws IOException {
+ spaceNeeded(packet, 2);
+ write(packet,(v >>> 0) & 0xFF);
+ write(packet,(v >>> 8) & 0xFF);
+ }
+ public static void writeCharBig(ByteSequence packet, int v) throws IOException {
+ spaceNeeded(packet, 2);
+ write(packet,(v >>> 8) & 0xFF);
+ write(packet,(v >>> 0) & 0xFF);
+ }
+ public static void writeCharLittle(ByteSequence packet, int v) throws IOException {
+ spaceNeeded(packet, 2);
+ write(packet,(v >>> 0) & 0xFF);
+ write(packet,(v >>> 8) & 0xFF);
+ }
+ public static void writeIntBig(ByteSequence packet, int v) throws IOException {
+ spaceNeeded(packet, 4);
+ write(packet,(v >>> 24) & 0xFF);
+ write(packet,(v >>> 16) & 0xFF);
+ write(packet,(v >>> 8) & 0xFF);
+ write(packet,(v >>> 0) & 0xFF);
+ }
+ public static void writeIntLittle(ByteSequence packet, int v) throws IOException {
+ spaceNeeded(packet, 4);
+ write(packet,(v >>> 0) & 0xFF);
+ write(packet,(v >>> 8) & 0xFF);
+ write(packet,(v >>> 16) & 0xFF);
+ write(packet,(v >>> 24) & 0xFF);
+ }
+ public static void writeLongBig(ByteSequence packet, long v) throws IOException {
+ spaceNeeded(packet, 8);
+ write(packet,(int) (v >>> 56) & 0xFF);
+ write(packet,(int) (v >>> 48) & 0xFF);
+ write(packet,(int) (v >>> 40) & 0xFF);
+ write(packet,(int) (v >>> 32) & 0xFF);
+ write(packet,(int) (v >>> 24) & 0xFF);
+ write(packet,(int) (v >>> 16) & 0xFF);
+ write(packet,(int) (v >>> 8) & 0xFF);
+ write(packet,(int) (v >>> 0) & 0xFF);
+ }
+ public static void writeLongLittle(ByteSequence packet, long v) throws IOException {
+ spaceNeeded(packet, 8);
+ write(packet,(int) (v >>> 0) & 0xFF);
+ write(packet,(int) (v >>> 8) & 0xFF);
+ write(packet,(int) (v >>> 16) & 0xFF);
+ write(packet,(int) (v >>> 24) & 0xFF);
+ write(packet,(int) (v >>> 32) & 0xFF);
+ write(packet,(int) (v >>> 40) & 0xFF);
+ write(packet,(int) (v >>> 48) & 0xFF);
+ write(packet,(int) (v >>> 56) & 0xFF);
+ }
+
+ public static void writeDoubleBig(ByteSequence packet, double v) throws IOException {
+ writeLongBig(packet, Double.doubleToLongBits(v));
+ }
+ public static void writeDoubleLittle(ByteSequence packet, double v) throws IOException {
+ writeLongLittle(packet, Double.doubleToLongBits(v));
+ }
+
+ public static void writeFloatBig(ByteSequence packet, float v) throws IOException {
+ writeIntBig(packet, Float.floatToIntBits(v));
+ }
+ public static void writeFloatLittle(ByteSequence packet, float v) throws IOException {
+ writeIntLittle(packet, Float.floatToIntBits(v));
+ }
+
+ public static void writeRawDoubleBig(ByteSequence packet, double v) throws IOException {
+ writeLongBig(packet, Double.doubleToRawLongBits(v));
+ }
+ public static void writeRawDoubleLittle(ByteSequence packet, double v) throws IOException {
+ writeLongLittle(packet, Double.doubleToRawLongBits(v));
+ }
+
+ public static void writeRawFloatBig(ByteSequence packet, float v) throws IOException {
+ writeIntBig(packet, Float.floatToRawIntBits(v));
+ }
+ public static void writeRawFloatLittle(ByteSequence packet, float v) throws IOException {
+ writeIntLittle(packet, Float.floatToRawIntBits(v));
+ }
+
+}
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ByteSequenceData.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ByteSequenceData.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/ByteSequenceData.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/IdGenerator.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/IdGenerator.java?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/IdGenerator.java (added)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/IdGenerator.java Mon Sep 18 15:07:10 2006
@@ -0,0 +1,122 @@
+/*
+ * 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.openwire.util;
+
+import java.net.InetAddress;
+import java.net.ServerSocket;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * Generator for Globally unique Strings.
+ */
+
+public class IdGenerator {
+
+ private static final Logger log = Logger.getLogger(IdGenerator.class
+ .getName());
+
+ private static final String UNIQUE_STUB;
+
+ private static int instanceCount;
+
+ private static String hostName;
+
+ private String seed;
+
+ private long sequence;
+
+ static {
+ String stub = "";
+ boolean canAccessSystemProps = true;
+ try {
+ SecurityManager sm = System.getSecurityManager();
+ if (sm != null) {
+ sm.checkPropertiesAccess();
+ }
+ } catch (SecurityException se) {
+ canAccessSystemProps = false;
+ }
+
+ if (canAccessSystemProps) {
+ try {
+ hostName = InetAddress.getLocalHost().getHostName();
+ ServerSocket ss = new ServerSocket(0);
+ stub = "-" + ss.getLocalPort() + "-"
+ + System.currentTimeMillis() + "-";
+ Thread.sleep(100);
+ ss.close();
+ } catch (Exception ioe) {
+ log.log(Level.WARNING, "could not generate unique stub", ioe);
+ }
+ } else {
+ hostName = "localhost";
+ stub = "-1-" + System.currentTimeMillis() + "-";
+ }
+ UNIQUE_STUB = stub;
+ }
+
+ /**
+ * As we have to find the hostname as a side-affect of generating a unique
+ * stub, we allow it's easy retrevial here
+ *
+ * @return the local host name
+ */
+
+ public static String getHostName() {
+ return hostName;
+ }
+
+ /**
+ * Construct an IdGenerator
+ *
+ */
+
+ public IdGenerator(String prefix) {
+ synchronized (UNIQUE_STUB) {
+ this.seed = prefix + UNIQUE_STUB + (instanceCount++) + ":";
+ }
+ }
+
+ public IdGenerator() {
+ this("ID:" + hostName);
+ }
+
+ /**
+ * Generate a unqiue id
+ *
+ * @return a unique id
+ */
+
+ public synchronized String generateId() {
+ return this.seed + (this.sequence++);
+ }
+
+ /**
+ * Generate a unique ID - that is friendly for a URL or file system
+ *
+ * @return a unique id
+ */
+ public String generateSanitizedId() {
+ String result = generateId();
+ result = result.replace(':', '-');
+ result = result.replace('_', '-');
+ result = result.replace('.', '-');
+ return result;
+ }
+
+}
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/IdGenerator.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/IdGenerator.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/util/IdGenerator.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/wireformat/ObjectStreamWireFormat.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/wireformat/ObjectStreamWireFormat.java?view=diff&rev=447591&r1=447590&r2=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/wireformat/ObjectStreamWireFormat.java (original)
+++ geronimo/sandbox/gcache/openwire/src/main/java/org/apache/geronimo/openwire/wireformat/ObjectStreamWireFormat.java Mon Sep 18 15:07:10 2006
@@ -34,6 +34,7 @@
* @version $Revision$
*/
public class ObjectStreamWireFormat implements WireFormat {
+ private WireFormatInfo preferedWireFormatInfo = new WireFormatInfo();
public ByteSequence marshal(Object command) throws IOException {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -74,12 +75,11 @@
}
public void setPreferedWireFormatInfo(WireFormatInfo info) {
- // TODO Auto-generated method stub
+ preferedWireFormatInfo = info;
}
public WireFormatInfo getPreferedWireFormatInfo() {
- // TODO Auto-generated method stub
- return null;
+ return preferedWireFormatInfo;
}
public void renegotiateWireFormat(WireFormatInfo info) throws IOException {
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/DISCLAIMER.txt
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/DISCLAIMER.txt?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/DISCLAIMER.txt (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/DISCLAIMER.txt Mon Sep 18 15:07:10 2006
@@ -0,0 +1,7 @@
+ActiveMQ is an effort undergoing incubation at the Apache Software Foundation
+(ASF), sponsored by the Geronimo PMC. Incubation is required of all newly
+accepted projects until a further review indicates that the infrastructure,
+communications, and decision making process have stabilized in a manner
+consistent with other successful ASF projects. While incubation status is not
+necessarily a reflection of the completeness or stability of the code, it does
+indicate that the project has yet to be fully endorsed by the ASF.
\ No newline at end of file
Propchange: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/DISCLAIMER.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/DISCLAIMER.txt
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/DISCLAIMER.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/LICENSE.txt
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/LICENSE.txt?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/LICENSE.txt (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/LICENSE.txt Mon Sep 18 15:07:10 2006
@@ -0,0 +1,203 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ Licensed 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.
+
Propchange: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/LICENSE.txt
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discovery
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discovery?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discovery (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discovery Mon Sep 18 15:07:10 2006
@@ -0,0 +1 @@
+class=org.apache.geronimo.openwire.transport.discovery.DiscoveryTransportFactory
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/multicast
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/multicast?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/multicast (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/multicast Mon Sep 18 15:07:10 2006
@@ -0,0 +1 @@
+class=org.apache.activemq.transport.discovery.multicast.MulticastDiscoveryAgentFactory
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/simple
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/simple?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/simple (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/simple Mon Sep 18 15:07:10 2006
@@ -0,0 +1 @@
+class=org.apache.activemq.transport.discovery.simple.SimpleDiscoveryAgentFactory
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/static
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/static?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/static (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/discoveryagent/static Mon Sep 18 15:07:10 2006
@@ -0,0 +1 @@
+class=org.apache.activemq.transport.discovery.simple.SimpleDiscoveryAgentFactory
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/failover
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/failover?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/failover (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/failover Mon Sep 18 15:07:10 2006
@@ -0,0 +1 @@
+class=org.apache.geronimo.openwire.transport.failover.FailoverTransportFactory
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/mock
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/mock?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/mock (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/mock Mon Sep 18 15:07:10 2006
@@ -0,0 +1 @@
+class=org.apache.geronimo.openwire.transport.mock.MockTransportFactory
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/ssl
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/ssl?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/ssl (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/ssl Mon Sep 18 15:07:10 2006
@@ -0,0 +1 @@
+class=org.apache.geronimo.openwire.transport.tcp.SslTransportFactory
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/tcp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/tcp?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/tcp (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/tcp Mon Sep 18 15:07:10 2006
@@ -0,0 +1 @@
+class=org.apache.geronimo.openwire.transport.tcp.TcpTransportFactory
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/vm
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/vm?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/vm (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/transport/vm Mon Sep 18 15:07:10 2006
@@ -0,0 +1 @@
+class=org.apache.activemq.transport.vm.VMTransportFactory
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/wireformat/default
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/wireformat/default?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/wireformat/default (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/wireformat/default Mon Sep 18 15:07:10 2006
@@ -0,0 +1 @@
+class=org.apache.geronimo.openwire.wireformat.ObjectStreamWireFormatFactory
Added: geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/wireformat/stomp
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/wireformat/stomp?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/wireformat/stomp (added)
+++ geronimo/sandbox/gcache/openwire/src/main/resources/META-INF/services/org/apache/activemq/wireformat/stomp Mon Sep 18 15:07:10 2006
@@ -0,0 +1 @@
+class=org.apache.geronimo.openwire.transport.stomp.StompWireFormatFactory
\ No newline at end of file
Added: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/NumberRangesWhileMarshallingTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/NumberRangesWhileMarshallingTest.java?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/NumberRangesWhileMarshallingTest.java (added)
+++ geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/NumberRangesWhileMarshallingTest.java Mon Sep 18 15:07:10 2006
@@ -0,0 +1,125 @@
+/**
+ *
+ * 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.openwire;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataInputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.openwire.command.SessionId;
+import org.apache.geronimo.openwire.wireformat.ObjectStreamWireFormatFactory;
+import org.apache.geronimo.openwire.wireformat.WireFormat;
+import org.apache.geronimo.openwire.wireformat.WireFormatFactory;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class NumberRangesWhileMarshallingTest {
+
+ private static final Log log = LogFactory
+ .getLog(NumberRangesWhileMarshallingTest.class);
+
+ protected String connectionId = "Cheese";
+
+ protected WireFormat wireFormat;
+
+ protected int endOfStreamMarker = 0x12345678;
+
+ @Test(expectedExceptions = { IOException.class })
+ public void testLongNumberRanges() throws Exception {
+ long[] numberValues = {
+ // bytes
+ 0, 1, 0x7e, 0x7f, 0x80, 0x81, 0xf0, 0xff,
+ // shorts
+ 0x7eff, 0x7fffL, 0x8001L, 0x8000L, 0xe000L, 0xe0001L, 0xff00L,
+ 0xffffL,
+ // ints
+ 0x10000L, 0x700000L, 0x12345678L, 0x72345678L, 0x7fffffffL,
+ 0x80000000L, 0x80000001L, 0xE0000001L, 0xFFFFFFFFL,
+
+ // 3 byte longs
+ 0x123456781L, 0x1234567812L, 0x12345678123L, 0x123456781234L,
+ 0x1234567812345L, 0x12345678123456L, 0x7e345678123456L,
+ 0x7fffffffffffffL, 0x80000000000000L, 0x80000000000001L,
+ 0xe0000000000001L, 0xffffffffffffffL,
+
+ // 4 byte longs
+ 0x1234567812345678L, 0x7fffffffffffffffL, 0x8000000000000000L,
+ 0x8000000000000001L, 0xe000000000000001L, 0xffffffffffffffffL,
+ 1 };
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ DataOutputStream ds = new DataOutputStream(buffer);
+
+ for (int i = 0; i < numberValues.length; i++) {
+ long value = numberValues[i];
+
+ SessionId object = new SessionId();
+ object.setConnectionId(connectionId);
+ object.setValue(value);
+ writeObject(object, ds);
+ }
+ ds.writeInt(endOfStreamMarker);
+
+ // now lets read from the stream
+ ds.close();
+
+ ByteArrayInputStream in = new ByteArrayInputStream(buffer.toByteArray());
+ DataInputStream dis = new DataInputStream(in);
+ for (int i = 0; i < numberValues.length; i++) {
+ long value = numberValues[i];
+ String expected = Long.toHexString(value);
+ log.info("Unmarshaling value: " + i + " = " + expected);
+
+ SessionId command = (SessionId) wireFormat.unmarshal(dis);
+ assert connectionId.equals(command.getConnectionId());
+ String actual = Long.toHexString(command.getValue());
+ assert expected.equals(actual);
+ }
+ int marker = dis.readInt();
+ assert Integer.toHexString(endOfStreamMarker).equals(
+ Integer.toHexString(marker));
+
+ // lets try read and we should get an exception
+ @SuppressWarnings("unused")
+ byte value;
+ value = dis.readByte();
+ }
+
+ @BeforeTest
+ protected void setUp() throws Exception {
+ wireFormat = createObjectStreamWireFormat();
+ }
+
+ protected WireFormat createObjectStreamWireFormat() {
+ WireFormatFactory factory = new ObjectStreamWireFormatFactory();
+ WireFormat wf = factory.createWireFormat();
+ wf.setVersion(1);
+ return wf;
+ }
+
+ private void writeObject(Object object , DataOutputStream ds) throws IOException {
+ wireFormat.marshal(object, ds);
+ }
+}
Propchange: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/NumberRangesWhileMarshallingTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/NumberRangesWhileMarshallingTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/NumberRangesWhileMarshallingTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/transport/tcp/TcpTransportFactoryTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/transport/tcp/TcpTransportFactoryTest.java?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/transport/tcp/TcpTransportFactoryTest.java (added)
+++ geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/transport/tcp/TcpTransportFactoryTest.java Mon Sep 18 15:07:10 2006
@@ -0,0 +1,86 @@
+/**
+ *
+ * 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.openwire.transport.tcp;
+
+import java.net.URI;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.geronimo.openwire.command.NodeInfo;
+import org.apache.geronimo.openwire.transport.DefaultTransportListener;
+import org.apache.geronimo.openwire.transport.Transport;
+import org.apache.geronimo.openwire.transport.TransportAcceptListener;
+import org.apache.geronimo.openwire.transport.TransportFactory;
+import org.testng.annotations.AfterSuite;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.Test;
+
+/**
+ *
+ * @version $Revision$
+ */
+public class TcpTransportFactoryTest {
+
+ private static final Log log = LogFactory
+ .getLog(TcpTransportFactoryTest.class);
+
+ private static final String serverURI = "tcp://localhost:62401";
+
+ private static final String clientURI = "tcp://localhost:62401";
+
+ private TcpTransportServer server = null;
+
+ private TransportFactory factory = null;
+
+ @BeforeSuite()
+ public void createTransportServer() throws Exception {
+ factory = new TcpTransportFactory();
+ server = (TcpTransportServer) factory.doBind(
+ "this parameter is ignored", new URI(serverURI));
+ server.setAcceptListener(new TransportAcceptListener () {
+ public void onAccept(Transport transport) {
+ }
+
+ public void onAcceptError(Exception error) {
+ }
+ });
+ server.start();
+ assert server.isStarted();
+ log.info("Server " + server.getBindLocation() + " started");
+ }
+
+ @Test()
+ public void postMessage() throws Exception {
+ Transport remoteTransport = TransportFactory
+ .connect(new URI(serverURI));
+ Transport localTransport = TransportFactory.connect(new URI(clientURI));
+ localTransport.setTransportListener(new DefaultTransportListener());
+ remoteTransport.setTransportListener(new DefaultTransportListener());
+ remoteTransport.start();
+ localTransport.start();
+ NodeInfo command = new NodeInfo();
+ remoteTransport.oneway(command);
+ log.info("send " + command);
+ }
+
+ @AfterSuite()
+ public void cleanup() throws Exception {
+ server.stop();
+ assert server.isStopped();
+ }
+}
Propchange: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/transport/tcp/TcpTransportFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/transport/tcp/TcpTransportFactoryTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/transport/tcp/TcpTransportFactoryTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/util/URISupportTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/util/URISupportTest.java?view=auto&rev=447591
==============================================================================
--- geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/util/URISupportTest.java (added)
+++ geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/util/URISupportTest.java Mon Sep 18 15:07:10 2006
@@ -0,0 +1,94 @@
+/*
+ *
+ * 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.openwire.util;
+
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Map;
+
+import org.apache.geronimo.openwire.util.URISupport.CompositeData;
+import org.testng.annotations.Test;
+
+/**
+ * @version $Revision$
+ */
+public class URISupportTest {
+
+ @Test()
+ public void testEmptyCompositePath() throws Exception {
+ CompositeData data = URISupport.parseComposite(new URI("broker:()/localhost?persistent=false"));
+ assert 0 == data.getComponents().length;
+ }
+
+ @Test()
+ public void testCompositePath() throws Exception {
+ CompositeData data = URISupport.parseComposite(new URI("test:(path)/path"));
+ assert "path".equals(data.getPath());
+ data = URISupport.parseComposite(new URI("test:path"));
+ assert null == data.getPath();
+ }
+
+ @Test()
+ public void testSimpleComposite() throws Exception {
+ CompositeData data = URISupport.parseComposite(new URI("test:part1"));
+ assert 1 == data.getComponents().length;
+ }
+
+ @Test()
+ public void testComposite() throws Exception {
+ CompositeData data = URISupport.parseComposite(new URI("test:(part1://host,part2://(sub1://part,sube2:part))"));
+ assert 2 == data.getComponents().length;
+ }
+
+ @Test()
+ public void testParsingURI() throws Exception {
+ URI source = new URI("tcp://localhost:61626/foo/bar?cheese=Edam&x=123");
+
+ Map map = URISupport.parseParamters(source);
+
+ assert 2 == map.size();
+
+ assertMapKey(map, "cheese", "Edam");
+ assertMapKey(map, "x", "123");
+
+ URI result = URISupport.removeQuery(source);
+
+ assert new URI("tcp://localhost:61626/foo/bar").equals(result);
+ }
+
+ protected void assertMapKey(Map map, String key, Object expected) {
+ assert map.get(key).equals(expected);
+ }
+
+ @Test()
+ public void testParsingCompositeURI() throws URISyntaxException {
+ URISupport.parseComposite(new URI("broker://(tcp://localhost:61616)?name=foo"));
+ }
+
+ @Test()
+ public void testCheckParenthesis() throws Exception {
+ String str = "fred:(((ddd))";
+ // assert that the parenthesis don't match
+ assert !URISupport.checkParenthesis(str);
+ // finish off the set then assert that the parens do match
+ str += ")";
+ assert URISupport.checkParenthesis(str);
+ }
+
+}
Propchange: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/util/URISupportTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/util/URISupportTest.java
------------------------------------------------------------------------------
svn:keywords = Date Revision
Propchange: geronimo/sandbox/gcache/openwire/src/test/java/org/apache/geronimo/openwire/util/URISupportTest.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: geronimo/sandbox/gcache/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/pom.xml?view=diff&rev=447591&r1=447590&r2=447591
==============================================================================
--- geronimo/sandbox/gcache/pom.xml (original)
+++ geronimo/sandbox/gcache/pom.xml Mon Sep 18 15:07:10 2006
@@ -59,9 +59,10 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <classifier>jdk15</classifier>
+ <version>5.1</version>
<scope>test</scope>
</dependency>
@@ -112,16 +113,65 @@
</executions>
<configuration>
- <schemaDirectory>${pom.basedir}/src/main/schema</schemaDirectory>
+ <schemaDirectory>
+ ${pom.basedir}/src/main/schema
+ </schemaDirectory>
<xmlConfigs>
- <xmlConfig implementation="java.io.File">${pom.basedir}/src/main/schema/xmlconfig.xml</xmlConfig>
+ <xmlConfig implementation="java.io.File">
+ ${pom.basedir}/src/main/schema/xmlconfig.xml
+ </xmlConfig>
</xmlConfigs>
<download>true</download>
<quiet>false</quiet>
</configuration>
</plugin>
+ <plugin>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.5</source>
+ <target>1.5</target>
+ </configuration>
+ </plugin>
+ <!--
+ NOTE: Using custom maven-surefire-plugin that supports TestNG:
+
+ http://testng.org/doc/maven.html
+ -->
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.8-SNAPSHOT</version>
+ </plugin>
</plugins>
</pluginManagement>
</build>
+
+ <!--
+ NOTE: This is the repository where maven-surefire-plugin:2.8-SNAPSHOT comes from.
+ -->
+ <pluginRepositories>
+ <pluginRepository>
+ <id>tapestry.javaforge</id>
+ <url>http://howardlewisship.com/repository</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot-repo</id>
+ <url>http://people.apache.org/repo/m2-snapshot-repository</url>
+ <name>Apache Maven Snapshots Repository</name>
+ <layout>default</layout>
+ <snapshots>
+ <enabled>true</enabled>
+ <updatePolicy>daily</updatePolicy>
+ <checksumPolicy>ignore</checksumPolicy>
+ </snapshots>
+ <releases>
+ <enabled>true</enabled>
+ </releases>
+ </repository>
+ </repositories>
+
</project>
Modified: geronimo/sandbox/gcache/server/pom.xml
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/pom.xml?view=diff&rev=447591&r1=447590&r2=447591
==============================================================================
--- geronimo/sandbox/gcache/server/pom.xml (original)
+++ geronimo/sandbox/gcache/server/pom.xml Mon Sep 18 15:07:10 2006
@@ -22,8 +22,10 @@
</dependency>
<dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
+ <groupId>org.testng</groupId>
+ <artifactId>testng</artifactId>
+ <classifier>jdk15</classifier>
+ <scope>test</scope>
</dependency>
<dependency>