ANT actual articles (2)

zhaozj2021-02-16  48

ANT actual articles (2)

Servers: Huang Kai

E_mail: hk_sz@163.com

Forehead

Since the company is now undergoing the unit test case, the evacuation understands Ant and Junit technology. The following is the collection of the director of the people (considering the summary of my idea, maybe not fully express the original author I think, I will listen out all the articles of the article or books in the reference. Everyone has time to see the original text).

If you don't understand the ANT part of the parameters, please refer to the "Ant Theory" series or Ant comes with documents.

I would like to thank our colleagues, Wang Wanpeng, providing DemoEJB instances for this document, prompting this document to be completed in advance. At the same time, I would also like to thank Guewei Dragon colleagues who have helped me, because my English is not high, and many disregarded places have helped him. I would like to express my heartfelt gratitude in this special! ! !

table of Contents

First, ANT use example

1.1 Copt Task via ANT submitted the recently updated file (according to the system time) file in the current directory to the specified directory

1.2 Develop Java programs with ANT

1.3 ANT combined with JUnit for software automatic test

1.4 ANT development and deployment web applications

1.5 ANT Packaging (JAR) application

1.6 ANT development EJB application

reference

1.5 ANT Packaging (JAR) application

1> Premise:

The directory structure used in this example is as follows:

D: / agn

SRC Java Source File Directory

Meta-INF configuration file directory

2> Create a Virtualage.java and MyVirtualage.java files in the src directory.

The content of Virtualage.java is as follows:

Public Final Class VirtuaLage

{

Public Static Int YeaSold (INT i)

{

Return i 1;

}

}

Myvirtualage.java is as follows:

Public class myvirtualage

{

Public static void main (string [] args)

{

INT myage = 10;

System.out.println ("My Age IS" Myage);

System.out.println ("My Virtual Age IS" Virtualage.YeaSold (myage));

}

}

3> Create build.properties and build.xml files in the AGE directory.

The building contents of the build.properties are as follows:

SRC = SRC

Classes = classes

JAR = jar

Manifest = META-INF

Author.name = KAY

The building contents of the build.xml are as follows:

< Javac destdir = "$ {class}">

4> Run the Ant Runjar in the AGE directory (you can also try to run the Ant Run, the result is the same).

1.6 ANT development EJB application

1> The directory structure used in this example is as follows:

D: / demoejb

SRC Java Source File Directory

Conf configuration file directory

2> Create ConvertRejb.java, ConverterHome.java, ConverterHome.java, ConverterHome.java, ConverterHome.java, ConverterHome.java, ConverterHome.java, CONVERTERHOME.JAVA.

The contents of the ConvertRejb.java file are as follows:

Import java.rmi.remoteexception;

Import javax.ejb.sessionbean;

Import javax.ejb.sessionContext;

Import java.math. *;

Public class converterejb imports sessionbean {

BigDecimal Yenrate = New BigDecimal ("121.6000");

BigDecimal EURORATE = New BigDecimal ("0.0077");

Public BigDecimal Dollartoyen (BigDecimal DOLLARS) {

BigDecimal Result = DOLLARS.MULTIPLY (YENRATE);

Return Result.setscale (2, BigDecimal.Round_UP);

}

Public BigDecimal Yentoeuro (BigDecimal Yen) {

BigDecimal result = yen.multiply (eurorate); Return Result.setscale (2, BigDecimal.Round_UP);

}

Public convertEREJB () {}

Public void ejbcreate () {}

Public void ejbremove () {}

Public void ejbactivate () {}

Public void ejbpassiVate () {}

Public void setsessionContext (sessioncontext sc) {}

}

The contents of the ConverterHome.java file are as follows:

Import javax.ejb.ejbhome;

Import java.io.serializable;

Import java.rmi.remoteexception;

Import javax.ejb.createException;

Import javax.ejb.ejbhome;

Public interface converTerhome Extends ejbhome {

Converter Create () throws RemoteException, CreateException;

}

The content of the Converter.java file is as follows:

Import javax.ejb.ejbobject;

Import java.rmi.remoteexception;

Import java.math. *;

Public Interface Converter Extends EJBOBJECT {

Public BigDecimal Dollartoyen (BigDecimal Dollars) throws RemoteException;

Public BigDecimal YENTOEURO (BigDecimal Yen) Throws RemoteException;

}

The CLIENT.JAVA file content is as follows:

Import java.rmi.remoteexception;

Import java.util.collection;

Import java.util.hashtable;

Import java.util.properties;

Import java.util.vector;

Import java.util.iterator;

Import javax.ejb.createException;

Import javax.ejb.duplicateKeyException;

Import javax.ejb.finderexception;

Import javax.ejb.ObjectNotFoundException;

Import javax.ejb.removeexception;

Import javax.naming.context;

Import javax.naming.initialcontext;

Import javax.naming.namingexception;

Import javax.rmi.portableremoteObject;

Import java.math.bigdecimal;

Public class client {

Private static context getinitialcontext () throws namingexception {

Try {

Properties h = new profment ();

H.PUT (Context.Initial_Context_Factory, "WebLogic.jndi.wlinitialContextFactory";

H.PUT (Context.Provider_URL, "T3: // localhost: 7001"); Return New InitialContext (h);

} catch (namingexception ne) {

Throw ne;

}

}

Public static void main (String [] args) {

Try {

Context initial = getinitialcontext ();

Object objref = initial.lookup ("EJB / Session / Converter");

ConverterHome Home = (ConverterHome) PortableRemoteObject.narrow (Objref, ConverterHome.Class);

Converter currencyconverter = home.create ();

BigDecimal param = New BigDecimal ("100.00");

BigDecimal amount = currencyconverter.dollartoyen (param);

System.out.println (Amount);

Amount = currencyconverter.yentoeuro (param);

System.out.println (Amount);

System.exit (0);

} catch (exception ex) {

System.err.Println ("Caught An Unexpected Exception!");

EX.PrintStackTrace ();

}

}

}

3> Create build.properties and build.xml files in the DemoEJB directory.

The building contents of the build.properties are as follows:

SRC = SRC

CONF = Conf

Classes = classes

Manifest = classes / meta-inf

JAR = jar

WebLogic.lib = C: / bea / WebLogic700 / Server / LIB

Author.name = KAY

Username = training

User.password = training

ejb.name = demoejb

WebLogic.Deploy.dir = c: / bea / user_projects / mydomain / myserver / upload

The building contents of the build.xml are as follows:

< Fileset Dir = "$ {class}" /> delete delete the jar archive file's location from web application

4> Start WebLogic Server, then run the Ant Deploy deployment in the AGE directory, then run the Ant Run to view the results.

reference

Ant use

Author: Unknown

Original site: http://php.igt.com.tw/Unit_116.htm Using Ant Development Java Programs

Author: cinc

Original site: http://www.douzhe.com/bbsjh/14/434.html

Automatically build test backup and release to project web with ANT implementation project

Author: beyondii

Or site: http://www.9cbs.net/develop/read_article.asp? Id = 20443

http://www.9cbs.net/develop/read_article.asp?id=20444

http://www.9cbs.net/develop/read_article.asp?id=20445

http://www.9cbs.net/develop/read_article.asp?id=20446

Let compilation and test process automation

Author: Erik Hatcher

Or site: http://www-900.ibm.com/developerWorks/cn/java/j-junitmail/

"J2EE application development (WebLogic JBuilder"

Publishing House: Electronic Industry Press

"THE BESTBOOK Advanced Programmer Java2"

Author: Zhang Hongbin

Publisher: unknown

转载请注明原文地址:https://www.9cbs.com/read-28142.html

New Post(0)