From 069f7e155bac1db024a7ba8f9f88f6e0491dc980 Mon Sep 17 00:00:00 2001 From: ltheussl Date: Fri, 10 Feb 2006 08:07:47 +0000 Subject: [PATCH] Add test class for ScmUtil git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@376590 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/maven/xdoc/util/ScmUtilTest.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 xdoc/src/test/org/apache/maven/xdoc/util/ScmUtilTest.java diff --git a/xdoc/src/test/org/apache/maven/xdoc/util/ScmUtilTest.java b/xdoc/src/test/org/apache/maven/xdoc/util/ScmUtilTest.java new file mode 100644 index 00000000..3aa2a1db --- /dev/null +++ b/xdoc/src/test/org/apache/maven/xdoc/util/ScmUtilTest.java @@ -0,0 +1,71 @@ +package org.apache.maven.xdoc.util; + +/* ==================================================================== + * Copyright 2006 The Apache Software Foundation. + * + * Licensed 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. + * ==================================================================== + */ + +import junit.framework.TestCase; + +/** + * ScmUtil Test class. + * + * @author Lukas Theussl + */ +public class ScmUtilTest extends TestCase +{ + private final ScmUtil scmUtil = new ScmUtil(); + private final String cvs1 = + "scm:cvs|pserver|username@localhost|C:/repositories|module_name"; + private final String cvs2 = + "scm:cvs:ext:username@cvs.apache.org:/cvs/root:module"; + private final String svn = "scm:svn:http://svn.apache.org/svn/root/module"; + private final String invalid = ""; + + public void testSCMConnectionSeparator() + { + assertEquals( scmUtil.getSCMConnectionSeparator( cvs1 ), "|" ); + assertEquals( scmUtil.getSCMConnectionSeparator( cvs2 ), ":" ); + assertEquals( scmUtil.getSCMConnectionSeparator( svn ), ":" ); + } + + public void testScmType() + { + assertEquals( scmUtil.getScmType( cvs1 ), "cvs" ); + assertEquals( scmUtil.getScmType( cvs2 ), "cvs" ); + assertEquals( scmUtil.getScmType( svn ), "svn" ); + assertNull( scmUtil.getScmType( invalid ) ); + } + + public void testCvsModule() + { + assertEquals( scmUtil.getCvsModule( cvs1 ), "module_name" ); + assertEquals( scmUtil.getCvsModule( cvs2 ), "module" ); + assertNull( scmUtil.getCvsModule( invalid ) ); + } + + public void testCvsConnection() + { + assertEquals( scmUtil.getCvsConnection( cvs1, "" ), + "scm:cvs|pserver|username|@localhost|C:/repositories|module_name" ); + assertEquals( scmUtil.getCvsConnection( cvs1, "john_doe" ), + "scm:cvs|pserver|john_doe@localhost|C:/repositories|module_name" ); + assertEquals( scmUtil.getCvsConnection( cvs2, "" ), + "scm:cvs:ext:username:@cvs.apache.org:/cvs/root:module" ); + assertEquals( scmUtil.getCvsConnection( cvs2, "john_doe" ), + "scm:cvs:ext:john_doe@cvs.apache.org:/cvs/root:module" ); + assertEquals( scmUtil.getCvsConnection( svn, "" ), "" ); + } +}