How to Test "NoSuchFieldException" Using if {} else{}?

I have a line of code in a loop:
Field column = DownloadChildClassColumns.class.getDeclaredField(id);The above code throws "NoSuchFieldException" for certain "id"s in the "getDeclaredField" method. If it happens, I have to get the Field from another class:
Field column = DownloadParentClassColumns.class.getDeclaredField(id);How do I test using if {...} else {...}. That is, if a certain Field is unavailable in one class, then get that Field in another class?
Thank you for your guidance.

JavaLaptop wrote:
I might not get the idea. Sorry, my head is as hard as a stone sometimes.
If I use the "getDeclaredField( id )", I still can get the "NoSuchFieldException".
My problem is "how" to test out if certain Field is not in one class then I go to another class to get it.Do the second test in the catch clause dependant on the first e.g.
Field field = null;
try  {
    field = class1.getField("fieldName");
  } catch(NoSuchFieldException ex) {
     try {
       field.class2.getField("fieldName");
      } catch(NoSuchFieldException ex2) {
         log.error("No such field as fieldName");
         throw new IllegalStateException("fileName not found in either class");
   }

Similar Messages

  • How to test servlet using Junit test????

    Hello everybody
    Does anybody know how to test an servlet class using Junit without using Cactus test . Is it possible to test a servlet using Junit without cactus test.Plz tell me the process how to test a servlet using Junit test .
    Regards
    srikant

    1) Do yoiu mean how to "run" your servlet code with sample parameter? This call manual testing with a sample run of you code. You need a web server(eg Tomcat), create a webapp with your servlet then deploy it there in order to run it.
    2) httpunit and junit are framework to write test case code that can be automated and repeatable. Plz read their doc.
    3) Your sample code me a very wrong way to retrieve and convert servlet parameters.
    Get a java toturial and servlet tutorial book and read it over the weekend. You need to get at least the basic.

  • How to test workflow using eCATT?

    Hi,
    Is there any method to test workflow using eCATT?
    SS

    Hi. What have you done so far, and what are your conclusions based on what you have examined and found out? I wouldn't want to tell you things you already know.
    <b>Spending 10 minutes more asking the question initially can save you a day in solving the problem.</b> See the <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/communityguidelines">Community Guidelines</a> for information about how you should ask a question (the section called Forum Rules of Engagement) to increase the likelihood of getting the best answers - that in turn will solve your problem sooner. Spending 10 minutes more asking the question initially can save you a day in solving the problem.

  • How to test sound using echo call on my Samsung Pr...

    I have a Skype account and am trying to see if the audio works on my Samsung Galaxy Pro 8.4 tablet which is running Android 4.4.2.  How do I make an echo test call on this device?

    I found some refrance it,works.But another thing is every code i found is applied on button.But,I cant use this code b.coz I have n number of buttons,it will again create problem.Can u suggest me anything more?
    I want something like it will attch sound through folder path (link).And 1 button should abale to play more than 10 sounds with diffrent click.
    Thanks.

  • How to test movie using flashplayer11.1 in Flash CS 5.5

    sorry about my terrible English
    I downloaded the flashplayer 11.1 (playerglobal.swc,flashplayerDebugger.exe and etc ),and created  a molehill project seccessfully. when I used Ctrl+Shift+Enter to debug my swf,everything is ok,Flash CS 5.5 opened flashplayer 11.1,but when I used Ctrl+Enter to test swf, a runtime error happen "can`t find flash.display::stage3D", I found that Flash CS5.5 opened an another flashplayer(not flashplayer11.1), maybe is flashplayer 10? I have replaced Adobe\Adobe Flash CS5.5\Players\Release\FlashPlayer.exe and Adobe\Adobe Flash CS5.5\Players\Debug\FlashPlayerDebugger.exe to flashplayer 11.1,why when I used "Ctrl+Enter",Flash CS5.5 opened flashplayer 10? only when I used "Ctrl+Shift+Enter",Flash CS5.5 opened flashplayer11.1?
    Ctrl+Enter
    a runtime Error
    Ctrl+Shift+Enter
    ok

    Note well, that if you upgrade the playerglobal.swc, FlashPlayer.exe and FlashPlayerDebug.exe For Flash CS6 (and 5 I believe) it does NOT change the player that Flash uses to "test" with (i.e. CTRL+Enter).  The debug Player will be updated though (i.e. CTRL+Shift+Enter). 
    I updated to FP 11.9 but CTRL+Enter still uses 11.4 as is revealed by tracing "Capabilities.version".
    - CTRL+Enter         -> 11.4
    - CTRL+Shift+Enter   -> 11.9
    - double click SWF   -> 11.9
    - in Firefox browser -> 11.9
    As long as I use the Debug player  (i.e. CTRL+Shift+Enter) or choose Publish from the file menu the code is OK both in the stand alone Player when you double click a SWF, and in a browser. 
    I have heard it said that default Test FlashPlayer is hidden inside authplay.dll.

  • How to test a generated report in my application by using web test written with Visual Studio 2012 Ultimate

    Hello,
    My application generates report in different formats, such as: Adobe, Excel, XML, CSV and HTML
    I have a webtest that makes all preparations, then generates a report. 
    In my application I have an option either to save the new generated report or open it.
    When I try to open the new report, the web test doesn't see it and therefore not allows me to test it.
    Please refer me to knowledge base or let me know how to resolve this type of issues.
    Thanks.
    qatm

    Hi qatm,
    Thank you for posting in MSDN forum.
    Since this web performance test is used to verify the Http request/respond work correctly in VS, and the browser session is then displayed as a list of URLs in the Web Performance Test Editor.
    However, as you said that you want to test a generated report in my application by using web performance test in VS2012 Ultimate. If the report is not as the Http format, so I think that it is not possible to test a generated report by using web performance
    test.
    Thanks for your understanding.
    Best Regards,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • When I try to buy or update an app on my ipad, a window comes up asking me for a password using SOMEONE ELSE'S apple ID which prevents me from buying the app. How can I get my ipad toprompt for a password using my own apple ID, like it does w/ itunes

    When I try to buy or update apps, myipad asks me for a password using SOMEONE ELSE'S apple ID, which prevents me from buying/updating apps. But when I am buying songs on itunes, the ipad asks me for my password using MY OWN apple ID and everything works fine. HOW DO I GET MY IPAD TO REQUEST MY PASSWORD USING MY OWN apple ID WHEN I AM BUYING OR UPDATING APPS?

    The apps you are trying to update were purchased with (and therfore permanently linked to) someone elses Apple ID. If you do not know the password then you need to delete the app and redownload/purchase it with your Apple ID.

  • How to test SOAP request using XML SPY

    Hi,
    1. I am new to WebServices concept, I have downloaded the wsdl file and now I need to test the SOAP requests using XML Spy. However, when I try to test the SOAP request generated by XML Spy I receive an error "Internal Error: Session is not available. Aborting" , How do I go ahead to generate the session, Is there a way I can provide the Username and password in the XML Spy to generate something like session.
    2. The second problem that I am facing is when I import the WSDL in XML Spy and generate the SOAP request, for all the fields xml tags gets populated with "aaaaaaaaaaaa" kind of data through out. Am i doing something wrong ? Is there some step while creating a SOAP request that I am missing becasue of which the gibbrish data is being populated as default ?
    Please Help !
    Thanks .

    I got my SOAP Requests tested using SOAP UI .. However I am still looking for ways to test it using XML SPY.
    In the SOAP UI Tool just do right click and select Add WS Security Token ..
    Thanks :)

  • How to test the SAP modules like SD and MM By using Quality Center and QTP

    Hi Experts,
    How to test the SAP modules like SD and MM By using Quality Center and QTP. Can you please provide the documentation regarding this.
    Regards,
    Skumar.

    Hi Sampath,
    First install QTP and SAP Addin with in QTP.
    2nd use QC to develop the test plan and then convert that test plan design to Test Scripts (QTP vesrion using settings)
    3rd record the R/3 GUI screen of SAP for SD, MM like Create order or Create PR.
    Once recording is done QTP will create a script in VB
    SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access  -  User").SAPGuiOKCode("OKCode").Set "/nVA01"
    SAPGuiSession("Session").SAPGuiWindow("SAP Easy Access  -  User").SendKey ENTER
    you can always add a parameter and other customization according to your requirement.
    Let me know if you need more information regarding this.
    Good Luck!

  • How to test the JSP pages and sevlets using JUnit. ?

    How to test the JSP pages using JUnit. How to configure what are all the steps to execute the JUnit test cases.

    Hi xiepei,
    since you are using modbus, a simple error checking is implicit in the protocol and is the comparison between returned checksum and the calculated one on the received message: checksum errors, if any, are an effect of communications errors (you should have at least 2 bits changed and on particular patterns to have the checksum be calculated correctly!). You won't be able to calculate BER on them, but you can calculate PER (Packet Error Rate).
    Another flag for communication errors, on the other direction, is to intercept error messages from the device: if it fully implements modbus protocol, it should return some warning in case of error (I seem to remember that in some cases it returns the reveived message with some error bits added: please check in modbus documentation).
    Proud to use LW/CVI from 3.1 on.
    My contributions to the Developer Zone Community
    If I have helped you, why not giving me a kudos?

  • How to test using VA03(How to customize it?)

    Hi all,
    I am working on VA03. And i got a test case using VA03. But i don't know why the VA03 konw which program and form that i made will be used.
    (How to cumtomize VA03??)
    Can you help me?
    Best regard.

    va03 is sales order display.
    when u create sales order.
    second time u will see display mode or change mode.

  • HT201365 How would i use someone else's iPhone to find my iPhone? what App to I need to run to search for my iPhone

    How would i use someone else's iPhone to find my iPhone? what App to I need to run to search for my iPhone

    Settings>general>resets>erase all content and settings.
    That will put it back to its out of the box state. Set it up with your own apple Id.

  • How can change my code without using if else in procedure

    Hai ,
    I have wrote code like this
    if RPTFORMNTH='M' then
    SELECT coalesce(SUM(IN_RWEEKS),0),
    INTO C2_COL1
    FROM HS_CASEDTA_DTLS_TB
    WHERE UPPER(VR_HAUNM) like NVL(case when HAUNM='0' then null else UPPER(HAUNM) END , UPPER(VR_HAUNM))||'%'
    AND IN_ULBOBJID=ULBOBJID AND CH_FLAG!='D'
    AND VR_RPTFORMNTH=VR_RPTFORMNTH
    AND IN_YEAR=IN_YEAR;
    ELSE
    SELECT
    coalesce(SUM(IN_RWEEKS),0),
    INTO C2_COL1
    FROM HS_CASEDTA_DTLS_TB
    WHERE UPPER(VR_HAUNM) like NVL(case when HAUNM='0' then null else UPPER(HAUNM) END , UPPER(VR_HAUNM))||'%'
    AND IN_ULBOBJID=ULBOBJID AND CH_FLAG!='D'
    AND
    TO_DATE(('01/'||VR_RPTFORMNTH||'/'||IN_YEAR),'DD/MM/YYYY')
    BETWEEN to_date('04/' || to_char(RPTYEAR-1),'MM/YY')
    AND add_months(to_date(RPTFORMNTH || to_char(RPTYEAR),'MonYYYY'),1)-1;
    END IF;
    My query is without using if else and replicate data in if and else how can i modify code.Observe that only where condition i want changes that's why i used if else without that how can i modify where clause with that two conditions.Please give me guidance.
    Regards ,
    rajendar.

    hi,
    I think you want your condition to change inside the where clause so you could have only one select statement. If that is so try this:
    SELECT coalesce(SUM(IN_RWEEKS),0),
    INTO   C2_COL1
    FROM   HS_CASEDTA_DTLS_TB
    WHERE  1 = CASE WHEN RPTFORMNTH='M' THEN
                    CASE WHEN UPPER(VR_HAUNM) like NVL(case when HAUNM='0' then null else UPPER(HAUNM) END , UPPER(VR_HAUNM))||'%'
                              AND IN_ULBOBJID=ULBOBJID AND CH_FLAG!='D'
                              AND VR_RPTFORMNTH=VR_RPTFORMNTH
                              AND IN_YEAR=IN_YEAR
                   THEN 1
                         ELSE 0
                    END
               ELSE --  RPTFORMNTH !='M'
                    CASE WHEN UPPER(VR_HAUNM) like NVL(case when HAUNM='0' then null else UPPER(HAUNM) END , UPPER(VR_HAUNM))||'%'
                              AND IN_ULBOBJID=ULBOBJID AND CH_FLAG!='D'
                              AND TO_DATE(('01/'||VR_RPTFORMNTH||'/'||IN_YEAR),'DD/MM/YYYY')
                              BETWEEN to_date('04/' || to_char(RPTYEAR-1),'MM/YY')
                              AND add_months(to_date(RPTFORMNTH || to_char(RPTYEAR),'MonYYYY'),1)-1
                         THEN 1
                         ELSE 0
                    END
               ENDMessage was edited by:
    Bobbydj
    hi Are, after belatedly reading Rob's post, I think his post is better. I was only looking at your highlighted code, but he took the most common conditions inside the where clause.

  • How to test webdynpro applications using ecatt

    Hi All,
    Can anyone give me detail explanation of what is ecatt and how it can be used for webdynpro applications.
    Thanks in advance,
    Aleem.

    Hi Aleem,
       The Extended computer Aided Test  tool is known as eCATT. Enable businesses  to record and play back applications as automated test scripts.
      The Primary aim is the automatic Testing of SAP business processes. Each test generates a detailed log that documents the test process and result.
    I have written a wiki page for webdynpro abap testing using ecatt .
    <a href="https://wiki.sdn.sap.com/wiki/x/K8Q">ecatt on webdynproabap</a>
    Regards
    Sathish

  • HT1414 I have lost one app last used months ago, Regularly Synced with I tunes. How to find without upsetting everything else ?

    I have lost one app last used months ago, Regularly Synced with I tunes. How to find without upsetting everything else ?

    Thanks, but I hoped to retrieve Saved information saved in the lost app rather than start afresh with a new download from apple
    The app was for aniverseries, birthdays  and service reminders  etc which I had already entered.
    I have Synced and backed up on my MacBook regularly, but other than a complete restore of my system, I do not know how to find and cherry pick individual apps, or even if it is possible to do such a thing.
    After all this time I am not even sure of the original name of the lost app.
    this sounds  a bit fable !  (and the spell check on this is not good either, not very good suggestions !)

Maybe you are looking for

  • How to sync two iphone agendas with one mac ?

    Dear all, This is my first question here, and I looked it up, but so far I didn't find a satisfactory answer I own a MacBook Pro and iPhone, that I keep for private stuff. Recently my employer provided me with a new iPhone for work. Both therefore ha

  • Illustrator CS6 64-bit dvaui.dll and msvcr100.dll crashing problem, any solution?

    First things first, trying to find a tech support Email address or phone number has been infuriating.  The "3-step support wizard" which results in "go to the forums" is also infuriating and insulting. I have a Windows 7 64-bit PC running CS6 64-bit

  • DOCTYPE and window scrolling break mouse capture positioning in IE6/IE8

    If I specify the DOCTYPE header in my html page the following bug is observed: If you scroll the browser window down using the scroll wheel or the scroll bar and click on the map, the position is recorded with a vertical offset of the amount in which

  • Security update 2014-002 1.0

    Security Update 2014-002 1.0 appears in the list of updates for installation.  I have tried to install 4 times now.  The update appears in the installed list 4 times but has not cleared from the ready for installation area.  Is this a problem? How ca

  • Suppliment pricing condition

    What is the use of Condition Suppliment? In our scenario There are two condition type for gross Price in one pricing procedure ZRM000 P000 and P001 For P001 condition type pricing procedure is maintain supplement pricing procedure (zm0001) that is no