Skip to content

Commit

Permalink
CXF-5543 Removing dependency jms dependency from jaxrs systests. Some…
Browse files Browse the repository at this point in the history
… other cleanup and fixes

git-svn-id: https://svn.apache.org/repos/asf/cxf/trunk@1565157 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cschneider committed Feb 6, 2014
1 parent b235b11 commit 0bfee67
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/**
* 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.
*/

/**
* Utility classes to make it easier to work with the JMS API.
*
* This package might later be moved to a jms library independent of cxf.
* So any classes in this package should only depend on the jms API.
*/
package org.apache.cxf.transport.jms.util;
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* 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.cxf.transport.jms.util;

import java.util.UUID;
import java.util.concurrent.atomic.AtomicLong;

import org.junit.Assert;
import org.junit.Test;

public class JMSUtilTest extends Assert {

@Test
public void testCorrelationIDGeneration() {
final String conduitId = UUID.randomUUID().toString().replaceAll("-", "");

// test min edge case
AtomicLong messageMinCount = new AtomicLong(0);
createAndCheck(conduitId, "0000000000000000", messageMinCount.get());

// test max edge case
AtomicLong messageMaxCount = new AtomicLong(0xFFFFFFFFFFFFFFFFL);
createAndCheck(conduitId, "ffffffffffffffff", messageMaxCount.get());

// test overflow case
AtomicLong overflowCount = new AtomicLong(0xFFFFFFFFFFFFFFFFL);
createAndCheck(conduitId, "0000000000000000", overflowCount.incrementAndGet());

// Test sequence
AtomicLong sequence = new AtomicLong(0);
createAndCheck(conduitId, "0000000000000001", sequence.incrementAndGet());
createAndCheck(conduitId, "0000000000000002", sequence.incrementAndGet());
}

private void createAndCheck(String prefix, final String expectedIndex, long sequenceNum) {
String correlationID = JMSUtil.createCorrelationId(prefix, sequenceNum);
assertEquals("The correlationID value does not match expected value",
prefix + expectedIndex, correlationID);
}
}

0 comments on commit 0bfee67

Please sign in to comment.