summaryrefslogtreecommitdiff
path: root/db-4.8.30/test/scr016/makenewtest.sh
blob: 70c280318f3b8f81f3d602ee90a0bcd1ab9eaa85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117

# A script that helps create an empty test shell
# application.
# The only parameter is the name of the class.
# The output file will be in the src/com/sleepycat/db/test
# directory.


case $1 in
*Test)
;;
*)
  echo "New test case names must end in Test."
  exit 1;;
esac

outdir="src/com/sleepycat/db/test"
if [ ! -d $outdir ]
then
  echo "Could not find test source directory. Ensure the script is being run from the right place."
  exit 1
fi

outname="$outdir/$1.java"

if [ -f $outname ]
then
  echo "A test with that file name exists."
  echo -n "Are you sure you want to overwrite the file (yes/no)? "
  read got_ok
  if [ $got_ok != "yes" ]
  then
    exit 1
  else
    echo "" > $outname
  fi
fi

nameupper=`echo $1 | tr -t [:lower:] [:upper:]`
namelower=`echo $1 | tr -t [:upper:] [:lower:]`

echo "/*-" >> $outname
echo " * See the file LICENSE for redistribution information." >> $outname
echo " * " >> $outname
echo " * Copyright (c) 2002-2009 Oracle.  All rights reserved." >> $outname
echo " *" >> $outname
echo " */" >> $outname
echo "" >> $outname

echo "" >> $outname

echo "package com.sleepycat.db.test;" >> $outname
echo "" >> $outname
echo "import org.junit.After;" >> $outname
echo "import org.junit.AfterClass;" >> $outname
echo "import org.junit.Before;" >> $outname
echo "import org.junit.BeforeClass;" >> $outname
echo "import org.junit.Test;" >> $outname
echo "import static org.junit.Assert.assertEquals;" >> $outname
echo "import static org.junit.Assert.fail;" >> $outname
echo "" >> $outname
echo "import com.sleepycat.db.*;" >> $outname
echo "" >> $outname

# some other likely ones :)
echo "import java.io.File;" >> $outname
echo "import java.io.FileNotFoundException;" >> $outname
echo "import java.io.IOException;" >> $outname

echo "" >> $outname
echo "import com.sleepycat.db.test.TestUtils;" >> $outname

echo "public class $1 {" >> $outname

echo "    public static final String ${nameupper}_DBNAME = \"${namelower}.db\";" >> $outname

echo "    @BeforeClass public static void ClassInit() {" >> $outname
echo "        TestUtils.loadConfig(null);" >> $outname
echo -n "        TestUtils.check_file_removed(TestUtils." >> $outname
echo "getDBFileName(${nameupper}_DBNAME), true, true);" >> $outname
echo -n "        TestUtils.removeall(true, true, TestUtils." >> $outname
echo "BASETEST_DBDIR, TestUtils.getDBFileName(${nameupper}_DBNAME));" >> $outname
echo "    }" >> $outname

echo "" >> $outname
echo "    @AfterClass public static void ClassShutdown() {" >> $outname
echo -n "        TestUtils.check_file_removed(TestUtils." >> $outname
echo "getDBFileName(${nameupper}_DBNAME), true, true);" >> $outname
echo -n "        TestUtils.removeall(true, true, TestUtils." >> $outname
echo "BASETEST_DBDIR, TestUtils.getDBFileName(${nameupper}_DBNAME));" >> $outname
echo "    }" >> $outname

echo "" >> $outname
echo "    @Before public void PerTestInit()" >> $outname
echo "        throws Exception {" >> $outname
echo "    }" >> $outname

echo "" >> $outname
echo "    @After public void PerTestShutdown()" >> $outname
echo "        throws Exception {" >> $outname
echo "    }" >> $outname

echo "    /*" >> $outname
echo "     * Test case implementations." >> $outname
echo "     * To disable a test mark it with @Ignore" >> $outname
echo "     * To set a timeout(ms) notate like: @Test(timeout=1000)" >> $outname
echo "     * To indicate an expected exception notate like: $Test(expected=Exception)" >> $outname
echo "     */" >> $outname

echo "" >> $outname
echo "    @Test public void test1()" >> $outname
echo "        throws DatabaseException, FileNotFoundException" >> $outname
echo "    {" >> $outname
echo "    }" >> $outname

echo "}" >> $outname