begin_unit|revision:0.9.5;language:Java;cregit-version:0.0.1
begin_comment
comment|/**  * 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.  */
end_comment

begin_package
package|package
name|org
operator|.
name|apache
operator|.
name|cxf
operator|.
name|common
operator|.
name|util
package|;
end_package

begin_import
import|import
name|org
operator|.
name|junit
operator|.
name|Test
import|;
end_import

begin_import
import|import static
name|org
operator|.
name|junit
operator|.
name|Assert
operator|.
name|assertEquals
import|;
end_import

begin_import
import|import static
name|org
operator|.
name|junit
operator|.
name|Assert
operator|.
name|assertFalse
import|;
end_import

begin_import
import|import static
name|org
operator|.
name|junit
operator|.
name|Assert
operator|.
name|assertTrue
import|;
end_import

begin_class
specifier|public
class|class
name|StringUtilsTest
block|{
annotation|@
name|Test
specifier|public
name|void
name|testDiff
parameter_list|()
throws|throws
name|Exception
block|{
name|String
name|str1
init|=
literal|"http://local/SoapContext/SoapPort/greetMe/me/CXF"
decl_stmt|;
name|String
name|str2
init|=
literal|"http://local/SoapContext/SoapPort"
decl_stmt|;
name|String
name|str3
init|=
literal|"http://local/SoapContext/SoapPort/"
decl_stmt|;
name|assertEquals
argument_list|(
literal|"/greetMe/me/CXF"
argument_list|,
name|StringUtils
operator|.
name|diff
argument_list|(
name|str1
argument_list|,
name|str2
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"greetMe/me/CXF"
argument_list|,
name|StringUtils
operator|.
name|diff
argument_list|(
name|str1
argument_list|,
name|str3
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"http://local/SoapContext/SoapPort/"
argument_list|,
name|StringUtils
operator|.
name|diff
argument_list|(
name|str3
argument_list|,
name|str1
argument_list|)
argument_list|)
expr_stmt|;
block|}
annotation|@
name|Test
specifier|public
name|void
name|testGetFirstFound
parameter_list|()
throws|throws
name|Exception
block|{
name|String
name|regex
init|=
literal|"velocity-\\d+\\.\\d+\\.jar"
decl_stmt|;
name|assertTrue
argument_list|(
name|StringUtils
operator|.
name|isEmpty
argument_list|(
name|StringUtils
operator|.
name|getFirstFound
argument_list|(
literal|"velocity-dep-1.4.jar"
argument_list|,
name|regex
argument_list|)
argument_list|)
argument_list|)
expr_stmt|;
name|assertFalse
argument_list|(
name|StringUtils
operator|.
name|isEmpty
argument_list|(
name|StringUtils
operator|.
name|getFirstFound
argument_list|(
literal|"velocity-1.4.jar"
argument_list|,
name|regex
argument_list|)
argument_list|)
argument_list|)
expr_stmt|;
name|assertTrue
argument_list|(
name|StringUtils
operator|.
name|isEmpty
argument_list|(
name|StringUtils
operator|.
name|getFirstFound
argument_list|(
literal|null
argument_list|,
name|regex
argument_list|)
argument_list|)
argument_list|)
expr_stmt|;
block|}
annotation|@
name|Test
specifier|public
name|void
name|testAddPortIfMissing
parameter_list|()
throws|throws
name|Exception
block|{
name|assertEquals
argument_list|(
literal|"http://localhost:80"
argument_list|,
name|StringUtils
operator|.
name|addDefaultPortIfMissing
argument_list|(
literal|"http://localhost"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"http://localhost:80/"
argument_list|,
name|StringUtils
operator|.
name|addDefaultPortIfMissing
argument_list|(
literal|"http://localhost/"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"http://localhost:80/abc"
argument_list|,
name|StringUtils
operator|.
name|addDefaultPortIfMissing
argument_list|(
literal|"http://localhost/abc"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"http://localhost:80"
argument_list|,
name|StringUtils
operator|.
name|addDefaultPortIfMissing
argument_list|(
literal|"http://localhost:80"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"http://localhost:9090"
argument_list|,
name|StringUtils
operator|.
name|addDefaultPortIfMissing
argument_list|(
literal|"http://localhost"
argument_list|,
literal|"9090"
argument_list|)
argument_list|)
expr_stmt|;
block|}
annotation|@
name|Test
specifier|public
name|void
name|testCapitalize
parameter_list|()
block|{
name|assertEquals
argument_list|(
literal|null
argument_list|,
name|StringUtils
operator|.
name|capitalize
argument_list|(
literal|null
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|""
argument_list|,
name|StringUtils
operator|.
name|capitalize
argument_list|(
literal|""
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"A"
argument_list|,
name|StringUtils
operator|.
name|capitalize
argument_list|(
literal|"A"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"A"
argument_list|,
name|StringUtils
operator|.
name|capitalize
argument_list|(
literal|"a"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"Aa"
argument_list|,
name|StringUtils
operator|.
name|capitalize
argument_list|(
literal|"aa"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"Aa"
argument_list|,
name|StringUtils
operator|.
name|capitalize
argument_list|(
literal|"Aa"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"AA"
argument_list|,
name|StringUtils
operator|.
name|capitalize
argument_list|(
literal|"AA"
argument_list|)
argument_list|)
expr_stmt|;
block|}
annotation|@
name|Test
specifier|public
name|void
name|testUncapitalize
parameter_list|()
block|{
name|assertEquals
argument_list|(
literal|null
argument_list|,
name|StringUtils
operator|.
name|uncapitalize
argument_list|(
literal|null
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|""
argument_list|,
name|StringUtils
operator|.
name|uncapitalize
argument_list|(
literal|""
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"a"
argument_list|,
name|StringUtils
operator|.
name|uncapitalize
argument_list|(
literal|"A"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"a"
argument_list|,
name|StringUtils
operator|.
name|uncapitalize
argument_list|(
literal|"a"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"aa"
argument_list|,
name|StringUtils
operator|.
name|uncapitalize
argument_list|(
literal|"aa"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"aa"
argument_list|,
name|StringUtils
operator|.
name|uncapitalize
argument_list|(
literal|"Aa"
argument_list|)
argument_list|)
expr_stmt|;
name|assertEquals
argument_list|(
literal|"aA"
argument_list|,
name|StringUtils
operator|.
name|uncapitalize
argument_list|(
literal|"AA"
argument_list|)
argument_list|)
expr_stmt|;
block|}
annotation|@
name|Test
specifier|public
name|void
name|testToHexString
parameter_list|()
block|{
name|byte
index|[]
name|bytes
init|=
operator|new
name|byte
index|[]
block|{
name|Byte
operator|.
name|MIN_VALUE
block|,
literal|0x20
block|,
name|Byte
operator|.
name|MAX_VALUE
block|,
literal|0x00
block|,
operator|(
name|byte
operator|)
literal|0xFF
block|}
decl_stmt|;
name|String
name|hexString
init|=
name|StringUtils
operator|.
name|toHexString
argument_list|(
name|bytes
argument_list|)
decl_stmt|;
name|assertEquals
argument_list|(
name|bytes
operator|.
name|length
operator|*
literal|2
argument_list|,
name|hexString
operator|.
name|length
argument_list|()
argument_list|)
expr_stmt|;
block|}
block|}
end_class

end_unit

