02.egovframe development environment workshop i

21
Page l 1 eGovFrame Lab Workbook Development Environment eGovFrame Center 2012

Upload: chuong-nguyen

Post on 19-May-2015

485 views

Category:

Documents


3 download

DESCRIPTION

eGovFrame - Framework for e-government Development Environment - Practice

TRANSCRIPT

Page 1: 02.egovFrame  Development Environment workshop I

1Page l 1

eGovFrame Lab WorkbookDevelopment Environment

eGovFrame Center

2012

Page 2: 02.egovFrame  Development Environment workshop I

2Page l 2

Development Environment

1. Development Environment Setup

Composition of the Lab environment

Configuration of the Lab environment

2. Development Environment Practice

[LAB1] Create and run Sample Project

[LAB2] Hello World Test

[LAB3] Code Generation

Page 3: 02.egovFrame  Development Environment workshop I

3Page l 3

The lab consists of the following environments

Install

- Unzip eGovFrame-2.0zip under C:\ drive

Installed Software

- JDK5.0 (1.5.0_22) & JDK6.0 (1.6.0_29)

- Eclipse JEE Helios SR2

- Apache Tomcat 6.0.35 & 7.0.23

- Maven 2.2.1/Maven 3.0.3

Directory Information

Directory Description

bin • Executable file directory

- jdk1.5.0 / jdk1.6.0 • JDK5.0(1.5.0_22), JDK6.0(1.6.0_29)

- apache-tomcat-6.0.35

- apache-tomcat-7.0.23• Apache Tomcat 6 & 7

- apache-maven-2.2.1 • Maven (MAVEN_HOME)

- eclipse• Eclipse JEE Helios SR2 (3.6.2)

• Include implementation tools plug-ins

maven/repository • Maven Local Repository

workspace • Eclipse project workspace

Composition of the Lab environment Development Environment

Page 4: 02.egovFrame  Development Environment workshop I

4Page l 4

Configuration

Check plug-in configuration through Window Preference menu in Eclipse.

Check basic encoding (UTF-8) – General > Workspace

Development Environment

Page 5: 02.egovFrame  Development Environment workshop I

5Page l 5

Check Maven(m2eclipse) configuration– Maven > User Settings

Development Environment

Check plug-in configuration through Window Preference menu in Eclipse.

Configuration

Page 6: 02.egovFrame  Development Environment workshop I

6Page l 6

Check installed JRE – Java > Installed JREs

Check plug-in configuration through Window Preference menu in Eclipse.

Development EnvironmentConfiguration

Page 7: 02.egovFrame  Development Environment workshop I

7Page l 7

Check Apache Tomcat Server configuration – Server > Runtime Environments

Development Environment

Check plug-in configuration through Window Preference menu in Eclipse.

Configuration

C:/eGovFrame-2.0/bin/apache-tomcat-6.0.35

Page 8: 02.egovFrame  Development Environment workshop I

8Page l 8

1. Development Environment Setup

Composition of the Lab environment

Configuration of the Lab environment

2. Development Environment Practice

[LAB1] Create and run Sample Project

[LAB2] Hello World Test

[LAB3] Code Generation

Development Environment

Page 9: 02.egovFrame  Development Environment workshop I

9Page l 9

[[LAB1] Generate Sample Project

Learn the functionality of the tools as creating and running the sample project, based on the eGovFrame

implementation tools.

[Step 1-1] Select eGovFramework>start>New Web Project menu in Eclipse

Select eGovFramework

Web Project

Development Environment

Page 10: 02.egovFrame  Development Environment workshop I

10Page l 10

[Step 1-2] Input below data to project creation wizard in Eclipse and click „Next‟ button.

Check „Generate Example‟ element, then click „Finish‟ button. Create a project.

Element Input Data Remarks

Project name lab101

Target Runtime Apache Tomcat 6.0

Dynamic Web Module Version

2.5 Automatic input

Group Id egovlab

Artifact Id lab101 Automatic input

Version 1.0.0 Automatic input

Example Code Generation

[LAB1] Generate Sample Project Development Environment

Page 11: 02.egovFrame  Development Environment workshop I

11Page l 11

[Step 1-3] Select the project and run „Maven > Update Project Configuration‟. It reflects the Maven

configuration.

Reflect Maven

configuration setting

[LAB1] Generate Sample Project Development Environment

Page 12: 02.egovFrame  Development Environment workshop I

12Page l 12

[Step 1-4] Run each phase in Maven lifecycle as running the project build. Select and run „Run As >

Maven package‟ menu. Then check the build description on the console and build output which is war file

under the „target‟ directory.

Reflect Maven configuration

Generate war file

[[LAB1] Generate Sample Project Development Environment

Page 13: 02.egovFrame  Development Environment workshop I

13Page l 13

[Step 1-5] Run HSQL DB for project execution.

Input and run „runHsqlDB.cmd‟ command which is under „DATABASE/db‟ directory in the project.

[LAB1] Generate Sample Project Development Environment

1

2

3

Page 14: 02.egovFrame  Development Environment workshop I

14Page l 14

[Step 1-6] Select a project and run „Run As > Run on Server‟ menu. Run a project.

Check features of the executed project. (Sample application URL : http://localhost:8080/lab101/)

[LAB1] Generate Sample Project Development Environment

Page 15: 02.egovFrame  Development Environment workshop I

15Page l 15

[LAB2] Hello World Test

As creating TestCasebased on Maven project, learn test tool functions

[Step 2-1] Check LAB2 Maven basic project structure, create HelloWorldServiceTest with a Spring Test

function

[ Maven based Project

Structure]

package egovframework.guide.helloworld;

import static org.junit.Assert.assertEquals;

import javax.annotation.Resource;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.test.context.ContextConfiguration;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

@RunWith(SpringJUnit4ClassRunner.class)

@ContextConfiguration(locations={"/context-helloworld.xml"})

public class HelloWorldServiceTest {

private HelloWorldService helloworld;

@Resource(name="helloworld")

public void setHelloWorld(HelloWorldService hello) {

this.helloworld = hello;

}

@Test

public void SayHello() {

assertEquals( "Hello egov framework!!!", helloworld.sayHello() );

}

}

[ Hello World TestCase]

Development Environment

Page 16: 02.egovFrame  Development Environment workshop I

16Page l 16

[LAB2] Hello World Test

[Step 2-2] Run TestCase

- Run test: : Select HelloWorldServiceTest class -> Run As -> JUnit Test

[Step 2-3] Check a test result

Development Environment

Page 17: 02.egovFrame  Development Environment workshop I

17Page l 17

[LAB3] Code Generation

As creating CRUD project based on Template, learn a Code Generation function.

[Step 3-1] Open lab103 project, connect to SampleDB HSQLDB in the Data Source Explorer.

[Step 3-2] As using “Show View” function from main menu, run eGovFramework > eGocFrame

Templates View.

Development Environment

Page 18: 02.egovFrame  Development Environment workshop I

18Page l 18

[LAB3] Code Generation

[Step 3-3] Select lab103 project, double click “eGovFrame Templates > CRUD > CRUD Program“ in the

eGovFrame Template view.

[Step 3-4] Select PUBLIC > SAMPLE table and click “NEXT” button.

Development Environment

Page 19: 02.egovFrame  Development Environment workshop I

19Page l 19

[LAB3] Code Generation

[Step 3-5] . Input directory information for automatically generation source code, and then click “Finish”

button.

Development Environment

Kildong, Hong

2012.10.10

Page 20: 02.egovFrame  Development Environment workshop I

20Page l 20

[LAB3] Code Generation

[Step 3-6] Open sql-map-config.xml file from egovframework.sqlmap.rte package in the

src/main/resource, add created Sample_SQL.xml file.

Development Environment

Page 21: 02.egovFrame  Development Environment workshop I

21Page l 21

[LAB3] Code Generation

[Step 3-7] Run the created project. Click lab103 > Run As > Run on Server

[Step 3-8] Check created project functions on the web browser.

Development Environment