Skip to content

Commit

Permalink
GEODE-837: update tests from JUnit3 to JUnit4
Browse files Browse the repository at this point in the history
* convert JUnit3 tests to use JUnit4 syntax and classes
* remove unused junit3 classes
* rename misnamed tests
* fixup and organize imports
* remove empty or worthless javadocs
* remove deadcode
* update from junit.framework.Assert to org.junit.Assert
* fix exception eating
* add usage of junit Assume
* remove some empty constructors
* increase getRepeatTimeoutMs to 2 minutes
* use getDiskDirs() and getUniqueName() for disk dirs in some tests
* move some setup code from ctor to setup
* change scope of some methods and vars to private
* add TODOs for further cleanup work
* remove some unecessary type casts
* annotate disabled tests with @ignore and @test
* change assertEquals with floats to call three arg version
* add some missing categories
  • Loading branch information
kirklund committed Jun 9, 2016
1 parent 7fb8a39 commit b914df2
Show file tree
Hide file tree
Showing 739 changed files with 25,109 additions and 20,140 deletions.
41 changes: 41 additions & 0 deletions convert_one_dunit_to_junit4.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/perl -w -i -p
# 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.

use strict;

my $filename = $ARGV;
$filename =~ s/.*\/(.*).java/$1/;

#Change constructor to a no arg constructor
s/(public.*$filename)\(String name\)/$1()/;
s/super\(name\)/super()/;

#Add @Test annotation
s/^[^\/]*public void test/ \@Test\n public void test/;

#Extend the correct junit 4 class
s/extends CacheTestCase/extends JUnit4CacheTestCase/;
s/extends DistributedTestCase/extends JUnit4DistributedTestCase/;

#Add the DistributedTest category
s/(^public class $filename)/\@Category(DistributedTest.class)\n$1/;

#Change calls to new MyTest("string") to use the no arg constructor
s/new $filename\(\".*?\"\)/new $filename\(\)/;

#Add imports
s/^(package com.gemstone.*)/$1\n\nimport org.junit.experimental.categories.Category;\nimport org.junit.Test;\n\nimport static org.junit.Assert.*;\n\nimport com.gemstone.gemfire.test.dunit.cache.internal.JUnit4CacheTestCase;\nimport com.gemstone.gemfire.test.dunit.internal.JUnit4DistributedTestCase;\nimport com.gemstone.gemfire.test.junit.categories.DistributedTest;/

Loading

0 comments on commit b914df2

Please sign in to comment.