From 882a98c31e6ceb34e41c67562da9069dfb4cfda1 Mon Sep 17 00:00:00 2001 From: Martin Ritchie Date: Mon, 25 Feb 2008 03:22:39 +0000 Subject: QPID-806 : Added startsWith and endsWith methods to AMQShortString, including test. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@630723 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/qpid/framing/AMQShortStringTest.java | 62 ++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java (limited to 'java/common/src/test') diff --git a/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java b/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java new file mode 100644 index 0000000000..0ea2c8b9c1 --- /dev/null +++ b/java/common/src/test/java/org/apache/qpid/framing/AMQShortStringTest.java @@ -0,0 +1,62 @@ +/* + * 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.qpid.framing; + +import junit.framework.TestCase; +public class AMQShortStringTest extends TestCase +{ + + AMQShortString Hello = new AMQShortString("Hello"); + AMQShortString Hell = new AMQShortString("Hell"); + AMQShortString Goodbye = new AMQShortString("Goodbye"); + AMQShortString Good = new AMQShortString("Good"); + AMQShortString Bye = new AMQShortString("Bye"); + + public void testStartsWith() + { + assertTrue(Hello.startsWith(Hell)); + + assertFalse(Hell.startsWith(Hello)); + + assertTrue(Goodbye.startsWith(Good)); + + assertFalse(Good.startsWith(Goodbye)); + } + + public void testEndWith() + { + assertFalse(Hell.endsWith(Hello)); + + assertTrue(Goodbye.endsWith(new AMQShortString("bye"))); + + assertFalse(Goodbye.endsWith(Bye)); + } + + + public void testEquals() + { + assertEquals(Goodbye, new AMQShortString("Goodbye")); + assertEquals(new AMQShortString("A"), new AMQShortString("A")); + assertFalse(new AMQShortString("A").equals(new AMQShortString("a"))); + } + + +} -- cgit v1.2.1