2012-01-26 73 views
5

我一直試圖讓這個工作整個下午,不能。我想驗證我的應用程序已啓動並從我的ant腳本運行。看起來下面的任務應該完成這項工作,但事實並非如此。我已經嘗試了各種排列方式,仔細閱讀了ant文檔,但從http發現失敗的文檔非常少。任何人都可以幫忙有沒有其他人得到http與螞蟻工作好嗎?Ant http沒有失敗目標

<?xml version="1.0" encoding="UTF-8"?> 
<project name="hermes" default="test-app-running" xmlns:epam="epam://epam.com" xmlns:catalina="antlib://catalina.apache.org" xmlns:artifact="antlib:org.apache.maven.artifact.ant"> 
    <target name="test-app-running" >  
     <waitfor maxwait="10" maxwaitunit="second"> 
      <http url="http://localhost:8080/" /> 
     </waitfor> 
     <fail message="App did not come up. Check your log files, fix and try again. Good Luck :-).">  
      <condition> 
       <http url="http://localhost:8080/" /> 
      </condition> 
     </fail> 
    </target> 
</project> 
+0

<目標名稱= 「測試應用程式內運行」> \t \t \t \t \t \t \t \t \t \t \t <失敗消息=」 應用程序沒上來。檢查你的日誌文件,修復和重試。祝您好運:-)「> \t \t \t \t \t \t \t \t \t \t \t \t \t \t \t –

+1

究竟是不是工作?你可以給一些輸出,錯誤等? – oers

+0

我希望能夠從http條件中獲得結果,並且如果它的結果​​爲否定,就會失敗。螞蟻文檔說:「....服務器錯誤,未經授權,未找到等被檢測到」。這裏的麻煩是他們如何被發現?當我運行這個目標時,我得到的全部是.... test-app-running: BUILD SUCCESSFUL。即使URL不存在,它也會報告成功。 –

回答

4

該病症需要<not />。我只是測試它,它的工作原理。

<fail message="App did not come up. Check your log files, fix and try again. Good Luck :-).">  
    <condition> 
     <not> 
     <http url="http://localhost:8080/" /> 
     </not> 
    </condition> 
</fail> 

如果服務器啓動,則不會失敗。

+0

它整理出來。非常感謝你花時間陪伴。我非常感謝你在這裏給我的幫助。 –