2
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
3
* indicated by the @author tags or express copyright attribution
4
* statements applied by the authors. All third-party contributions are
5
* distributed under license by Red Hat Middleware LLC.
7
* This copyrighted material is made available to anyone wishing to use, modify,
8
* copy, or redistribute it subject to the terms and conditions of the GNU
9
* Lesser General Public License, as published by the Free Software Foundation.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16
* You should have received a copy of the GNU Lesser General Public License
17
* along with this distribution; if not, write to:
18
* Free Software Foundation, Inc.
19
* 51 Franklin Street, Fifth Floor
20
* Boston, MA 02110-1301 USA
22
package org.hibernate.util;
24
import junit.framework.TestCase;
29
* @author Steve Ebersole
31
public class StringHelperTest extends TestCase {
32
private static final String BASE_PACKAGE = "org.hibernate";
33
private static final String STRING_HELPER_FQN = "org.hibernate.util.StringHelper";
34
private static final String STRING_HELPER_NAME = StringHelper.unqualify( STRING_HELPER_FQN );
36
public void testNameCollapsing() {
37
assertNull( StringHelper.collapse( null ) );
38
assertEquals( STRING_HELPER_NAME, StringHelper.collapse( STRING_HELPER_NAME ) );
39
assertEquals( "o.h.u.StringHelper", StringHelper.collapse( STRING_HELPER_FQN ) );
42
public void testPartialNameUnqualification() {
43
assertNull( StringHelper.partiallyUnqualify( null, BASE_PACKAGE ) );
44
assertEquals( STRING_HELPER_NAME, StringHelper.partiallyUnqualify( STRING_HELPER_NAME, BASE_PACKAGE ) );
45
assertEquals( "util.StringHelper", StringHelper.partiallyUnqualify( STRING_HELPER_FQN, BASE_PACKAGE ) );
48
public void testBasePackageCollapsing() {
49
assertNull( StringHelper.collapseQualifierBase( null, BASE_PACKAGE ) );
50
assertEquals( STRING_HELPER_NAME, StringHelper.collapseQualifierBase( STRING_HELPER_NAME, BASE_PACKAGE ) );
51
assertEquals( "o.h.util.StringHelper", StringHelper.collapseQualifierBase( STRING_HELPER_FQN, BASE_PACKAGE ) );