Name:                httpunit
Version:             1.7
Release:             2
Epoch:               0
URL:                 http://httpunit.sourceforge.net/
Summary:             Automated web site testing toolkit
License:             MIT and ASL 2.0
Source0:             http://netix.dl.sourceforge.net/project/httpunit/httpunit/%{version}/httpunit-%{version}.zip
Source1:             https://repo1.maven.org/maven2/httpunit/httpunit/1.7/httpunit-1.7.pom
Source2:             https://www.oracle.com/webfolder/technetwork/jsc/j2ee/dtds/web-app_2_2.dtd
Source3:             https://www.oracle.com/webfolder/technetwork/jsc/dtd/web-app_2_3.dtd
Source4:             https://www.oracle.com/webfolder/technetwork/jsc/xml/ns/j2ee/web-app_2_4.xsd
Source5:             http://www.apache.org/licenses/LICENSE-2.0.txt
Patch1:              httpunit-rhino-1.7.7.patch
Patch2:              httpunit-servlettest.patch
Patch3:              httpunit-servlet31.patch
Patch4:              junit4.patch
BuildRequires:       jpackage-utils >= 0:1.6 ant >= 0:1.6 nekohtml jtidy junit >= 0:3.8
BuildRequires:       glassfish-servlet-api <= 3.1.0 javamail >= 0:1.3 rhino java-devel >= 1:1.6.0
BuildRequires:       javapackages-local
Requires:            junit >= 0:3.8 glassfish-servlet-api <= 3.1.0 nekohtml rhino
BuildArch:           noarch
Obsoletes:           httpunit-demo < %{epoch}:%{version}
%description
HttpUnit emulates the relevant portions of browser behavior, including form
submission, JavaScript, basic http authentication, cookies and automatic page
redirection, and allows Java test code to examine returned pages either as
text, an XML DOM, or containers of forms, tables, and links.
A companion framework, ServletUnit is included in the package.

%package        javadoc
Summary:        Javadoc for %{name}

%description    javadoc
Javadoc for %{name}

%package        doc
Summary:        Documentation for %{name}
Requires:       %{name}-javadoc

%description    doc
Documentation for %{name}

%prep
%autosetup -p1
find . -name "*.jar" -delete
rm -f META-INF/{web-app_2.2.dtd,web-app_2.3.dtd,web-app_2.4.xsd}
sed -i -e 's|destdir|encoding="iso-8859-1" destdir|g' build.xml
sed -i -e 's|setCharEncoding( org.w3c.tidy.Configuration.UTF8 )|setInputEncoding("UTF-8")|g' src/com/meterware/httpunit/parsing/JTidyHTMLParser.java
find . -name "*.jar" -exec rm -f {} \;
rm -rf doc/api
ln -s \
  %{_javadir}/junit.jar \
  %{_javadir}/jtidy.jar \
  %{_javadir}/nekohtml.jar \
  %{_javadir}/glassfish-servlet-api.jar \
  %{_javadir}/js.jar \
  %{_javadir}/xerces-j2.jar \
  jars
cp %{SOURCE1} pom.xml
cp %{SOURCE2} META-INF/
cp %{SOURCE3} META-INF/
cp %{SOURCE4} META-INF/
cp %{SOURCE5} LICENSE-ASL

%build
export CLASSPATH=$(build-classpath javamail)
export ANT_OPTS="-Dfile.encoding=iso-8859-1"
ant -Dbuild.compiler=modern -Dbuild.sysclasspath=last \
  jar javadocs test servlettest

%install
%mvn_file : httpunit
%mvn_artifact pom.xml lib/httpunit.jar
%mvn_install -J doc/api/
rm -rf doc/api
pushd doc
ln -sf %{_javadocdir}/httpunit api
popd

%files -f .mfiles
%doc LICENSE-ASL

%files javadoc -f .mfiles-javadoc
%doc LICENSE-ASL

%files doc
%doc doc/*

%changelog
* Fri Sep 16 2022 caodongxia <caodongxia@h-partners.com> - 0:1.7-2
- Add glassfish-servlet-api version limit

* Sat Aug 22 2020 huanghaitao <huanghaitao8@huawei.com> - 0:1.7-1
- package init
