TEST-DRIVEN DEVELOPMENT


 


테스트 주도 개발


START : 2012/06/06

END : ????


후기

: 종료된 시점에 작성 예정.


Ch. 1 Multi-Currency Money 3 

Ch. 2 Degenerate Objects 11 

Ch. 3 Equality for All 15 

Ch. 4 Privacy 19 

Ch. 5 Franc-ly Speaking 23 

Ch. 6 Equality for All, Redux 27 

Ch. 7 Apples and Oranges 33 

Ch. 8 Makin' Objects 35 

Ch. 9 Times We're Livin' In 39 

Ch. 10 Interesting Times 45 

Ch. 11 The Root of All Evil 51 

Ch. 12 Addition, Finally 55 

Ch. 13 Make It 61 

Ch. 14 Change 67 

Ch. 15 Mixed Currencies 73 

Ch. 16 Abstraction, Finally 77 

Ch. 17 Money Retrospective 81 

Ch. 18 First Steps to xUnit 91 

Ch. 19 Set the Table 97 

Ch. 20 Cleaning Up After 101 

Ch. 21 Counting 105 

Ch. 22 Dealing with Failure 109 

Ch. 23 How Suite It Is 113 

Ch. 24 xUnit Retrospective 119 

Ch. 25 Test-Driven Development Patterns 123 

Ch. 26 Red Bar Patterns 133 

Ch. 27 Testing Patterns 143 

Ch. 28 Green Bar Patterns 151 

Ch. 29 xUnit Patterns 157 

Ch. 30 Design Patterns 165 

Ch. 31 Refactoring 181 

Ch. 32 Mastering TDD 193 

작업환경 : 이클립스 J2EE  & FLEX 환경 (설치 참조 : http://wonsama.tistory.com/180 )
테스트 목적 : Remote Object를 확인하기 위해 테스트를 진행.
작업진행 : Eclipse에서 환경설정 및 클래스 생성 이후 Flex에서 해당 서비스 호출 소스 작성을 실시한다.

[Eclipse]
// WEB-INF/flex/remoting-config.xml :  리모트 오브젝트 관련 환경을 설정한다.

<?xml version="1.0" encoding="UTF-8"?>
<service id="remoting-service" class="flex.messaging.services.RemotingService">

    <adapters>
        <adapter-definition id="java-object"
            class="flex.messaging.services.remoting.adapters.JavaAdapter"
            default="true" />
    </adapters>

    <default-channels>
        <channel ref="my-amf" />
    </default-channels>

    <destination id="empRO">
        <properties>
            <source>book.EmployeeManager</source>           
        </properties>
    </destination>

</service>

RO를 사용하기 위하여 추가적으로 설정한 내용임.
1: destination id - FLEX에서 호출하는 RemoteObject의 destination 를 지정한다.
2: source - 참조하는 클래스 소스를 설정한다.

[Eclipse]
// src/book/Employee.java

package book;

import java.io.Serializable;

public class Employee implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 1L;
    public String name;
    public String phone;
    public String email;
    public Employee(){

    }

    public Employee(String name, String phone, String email){
        this.name = name;
        this.phone = phone;
        this.email = email;
    }
}

[Eclipse]
// src/book/EmployeeManager.java

package book;

import org.apache.log4j.Logger;
import java.util.ArrayList;

public class EmployeeManager {
    /**
     * Logger for this class
     */
    private static final Logger logger = Logger.getLogger(EmployeeManager.class);
   
    public EmployeeManager(){

    }

   
    public Object[] getList(String deptId){

        if (logger.isDebugEnabled()) {
            logger.debug("getList(String) - start"); //$NON-NLS-1$
        }

        ArrayList<Employee> list = new ArrayList<Employee>();
        if(deptId.equals("ENG")){
            list.add(new Employee("Christina Coenreaets", "555-219-270","ccoenraets@fictitious.com" ));
            list.add(new Employee("Louis Freligh", "555-219-2270", "lfrelight@fictitious.com" ));
        }else if(deptId.equals("PM")){
            list.add(new Employee("Ronnie Hodgman", "555-219-2270", "ccoenraets@fictitious.com" ));
            list.add(new Employee("Joanne Wall", "555-219-2270", "lfrelight@fictitious.com" ));  
        }else if(deptId.equals("MKT")){
            list.add(new Employee("Maurice Smith", "555-219-2270", "ccoenraets@fictitious.com" ));
            list.add(new Employee("Mary Jones", "555-219-2270", "lfrelight@fictitious.com" ));  
        }
        Object[] returnObjectArray = list.toArray();

        if (logger.isDebugEnabled()) {
            logger.debug("getList(String) - end"); //$NON-NLS-1$
        }else{
            System.out.println("err");
        }

        return returnObjectArray;
    }
}

[FLEX]
// src/blaze.mxml

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
 <mx:Script>
  <![CDATA[
   import mx.controls.Alert;
   import mx.rpc.events.FaultEvent;
   import mx.rpc.events.ResultEvent;
  
   private function resultHandler(event:ResultEvent):void{
    dg.dataProvider = event.result;
   }
  
   private function faultHandler(event:FaultEvent):void{
    mx.controls.Alert.show(event.fault.message);
   }
  
  ]]>
 </mx:Script>
 
 <mx:RemoteObject id="emp" destination="empRO" showBusyCursor="true"  result="resultHandler(event)" fault="faultHandler(event)"/>


 <mx:Panel width="95%" height="95%" layout="absolute"
     title="RemoteObject UTF8" >
  <mx:DataGrid id="dg" width="100%" height="100%" />
  <mx:ControlBar horizontalAlign="center">
   <mx:HBox>
    <mx:Label text="Select a department :" />
    <mx:ComboBox id="dept" width="150">
     <mx:dataProvider>
      <mx:Array>
       <mx:Object label="Engineering" data="ENG" />
       <mx:Object label="Product Management" data="PM" />
       <mx:Object label="Marketing" data="MKT" />
      </mx:Array>
     </mx:dataProvider>
    </mx:ComboBox>
    <mx:Button label="Get Employee List" click="emp.getList(dept.selectedItem.data)" />
   </mx:HBox>
  </mx:ControlBar>
 
 </mx:Panel>
 
</mx:Application>


<mx:RemoteObject id="emp" destination="empRO" showBusyCursor="true"  result="resultHandler(event)" fault="faultHandler(event)"/>
=> RO를 설정한 부분
=> destination : Eclipse에 설정된 클래스를 호출하기 위한 Destination

<mx:Button label="Get Employee List" click="emp.getList(dept.selectedItem.data)" />
=> RO를 호출하는 부분
=> emp.getList :  getList 메소드를 호출한다. 처리 결과는 위에서 설정한 리스너를 통해 들어온다.

[처리 결과]


결론 및 요약 :

- [Eclipse] remoting-config.xml 설정 => 설정에 맞춰 클래스 생성 => [Flex] RO호출
- RO를 통해 처리를 JAVA로 위임한 이후 결과를 받아 처리 할 수 있음. 매우 유익한듯.





'기타 > Old' 카테고리의 다른 글

MS '윈도7 RC 버전' 공개됐다  (0) 2009.05.01
구글·네이버, 닮은꼴 서비스 경쟁 '후끈'  (0) 2009.04.30
설치하기  (0) 2009.04.29
이벤트 링크  (0) 2009.04.29
삼성電, 'AM-OLED 안드로이드폰' 6월 출시  (1) 2009.04.28

+ Recent posts