2015년 3월 27일 금요일

아파치에서 403 오류 나올때.

이것저것 했는데 403이 계속 나오면..


chcon -R --reference=/var/www /www/webroot

2015년 3월 24일 화요일

spring junit testcase 작성

maven에 아래 추가.


   org.springframework
   spring-test
   4.0.5.RELEASE
   test
  


test java코드 MemberServiceTest.java

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration( {
  "classpath:servlet-context.xml",
  "classpath:config/context-datasource.xml"
}
)
public class MemberServiceTest {

    @Autowired
    MemberService memberService;


    @Test
    public void testSr2002() throws Exception {
        RequestData req = new RequestData(null, new DbMap());
        ResponseData res = new ResponseData(new DbMap());

        memberService.sr2002(req, res);
    }

}



이때 디비를 jndi-lookup 를 이용하는 경우를 위해 test/resources/config/context-datasource.xml 을 넣어서 아래와 같이 기존 id를 덮었다.

test/resources/config/context-datasource.xml 파일





    





2015년 3월 10일 화요일

spring-rabbitmq 연동

설치는 그냥 rpm 으로 설치

# 서버 시작.
sbin/rabbitmq-server start

# 서버 중지
sbin/rabbitmqctl stop




--- spring-rabbit 연동 pom.xml


  org.springframework.amqp
  spring-rabbit
  1.4.1.RELEASE




context-rabbitmq.xml














    





MqService.java

@Service
public class MqService implements MessageListener {
    private static final Logger logger = LoggerFactory.getLogger(MqService.class);
    private static final String TASK_QUEUE_NAME = "simple_queue";

    @Autowired
    private RabbitTemplate rabbitTemplate;

    public void send(String message) throws IOException {
        rabbitTemplate.convertAndSend(TASK_QUEUE_NAME, message);

        logger.info("send message={}", message);
    }

    @Override
    public void onMessage(Message message) {
        String msg = null;
        try {
            msg = new String(message.getBody(), "UTF-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }

        logger.info("recv message=" + msg );
    }
}

2015년 3월 4일 수요일

git 관련 명령어 모음

// svn to git 마이그레이션
$ git svn clone --stdlayout --no-metadata -A users.txt svn://example.com/repository/projectname
$ cd projectname

// 아래 users.txt 만드는건데 perl 이 없어서 그런지.. 안되네요... ㅠ
//$ svn log ^/ --xml | grep -P "^<author" | sort -u | \ perl -pe 's/<author>(.*?)<\/author>/$1 = /' > users.txt

// ignore file처리
$ git svn show-ignore -i trunk > .gitignore

// remote git 지정
$ git remote add origin git@git.example.com:group/projectname.git

// tags 처리
$ git for-each-ref refs/remotes/tags | cut -d / -f 4- | grep -v @ | while read tagname; do git tag "$tagname" "tags/$tagname"; git branch -r -d "tags/$tagname"; done

// branches 처리
$ git for-each-ref refs/remotes | cut -d / -f 3- | grep -v @ | while read branchname; do git branch "$branchname" "refs/remotes/$branchname"; git branch -r -d "$branchname"; done

// push한다.
$ git push origin --all
$ git push origin --tags

// revert local commit
git reset —hard remotes/origin/HEAD


-----------

// backup
$ sudo gitlab-rake gitlab:backup:create

// restore (가장 최근꺼 복원)
$ sudo gitlab-rake gitlab:backup:restore

// restore OPTION (아래 지정한 타임스탬프로 복원시켜준다는건가.. 안해봄..)
BACKUP=timestamp_of_backup (required if more than one backup exists)