1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 package com.sun.star.lib.uno.environments.remote; 25 26 import complexlib.ComplexTestCase; 27 import java.util.Arrays; 28 29 public final class ThreadId_Test extends ComplexTestCase { getTestMethodNames()30 public String[] getTestMethodNames() { 31 return new String[] { "test" }; 32 } 33 test()34 public void test() { 35 ThreadId i1 = ThreadId.createFresh(); 36 assure(i1.equals(i1)); 37 assure(!i1.equals(null)); 38 assure(!i1.equals(new Object())); 39 assure(i1.hashCode() == i1.hashCode()); 40 byte[] i1bytes = i1.getBytes(); 41 assure(i1bytes != null); 42 assure( 43 i1bytes.length >= 5 && i1bytes[0] == 'j' && i1bytes[1] == 'a' 44 && i1bytes[2] == 'v' && i1bytes[3] == 'a' && i1bytes[4] == ':'); 45 assure(Arrays.equals(i1bytes, i1.getBytes())); 46 47 ThreadId i2 = ThreadId.createFresh(); 48 assure(!i1.equals(i2)); 49 assure(!i2.equals(i1)); 50 assure(!Arrays.equals(i1bytes, i2.getBytes())); 51 52 ThreadId i3 = new ThreadId(i1bytes); 53 assure(i3.equals(i1)); 54 assure(!i3.equals(i2)); 55 assure(i1.equals(i3)); 56 assure(i1.hashCode() == i3.hashCode()); 57 assure(Arrays.equals(i1bytes, i3.getBytes())); 58 } 59 } 60