Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 841159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:44:49+00:00 2026-05-15T05:44:49+00:00

main method: public static void main(String[] args) throws Exception { if (args.length != EXPECTED_NUMBER_OF_ARGUMENTS)

  • 0

main method:

 public static void main(String[] args) throws Exception
{
    if (args.length != EXPECTED_NUMBER_OF_ARGUMENTS)
    {
        System.err.println("Usage - java XFRCompiler ConfigXML PackageXML XFR");
    }

    String configXML = args[0];
    String packageXML = args[1];
    String xfr = args[2];

    AutoConfigCompiler compiler = new AutoConfigCompiler();
    compiler.setConfigDocument(loadDocument(configXML));
    compiler.setPackageInfoDoc(loadDocument(packageXML));
    // compiler.setVisiblityDoc(loadDocument("VisibilityFilter.xml"));
    compiler.compileModel(xfr);     

}

private static Document loadDocument(String fileName) throws Exception
{
    TXDOMParser parser = (TXDOMParser) ParserFactory.makeParser(TXDOMParser.class.getName());
    InputSource source = new InputSource(new FileInputStream(fileName));
    parser.parse(source);
    return parser.getDocument();  

}

testcase:

@Test
public void testCompileModel() throws Exception
{
  // construct parameters
  URL configFile =   Thread.currentThread().getContextClassLoader().getResource("Ford_2008_Mustang_Config.xml");
  URL packageFile = Thread.currentThread().getContextClassLoader().getResource("Ford_2008_Mustang_Package.xml");
  File tmpFile = new File("Ford_2008_Mustang_tmp.xfr");
  if(!tmpFile.exists()) {
     tmpFile.createNewFile();
  }

  String[] args = new     String[]{configFile.getPath(),packageFile.getPath(),tmpFile.getPath()};

  try {
    // test main method
    XFRCompiler.main(args);
  } catch (Exception e) {
    assertTrue(true);
  }
  try {
    // test args length is less than 3
    XFRCompiler.main(new String[]{"",""});
  } catch (Exception e) {  
    //ignore
  }
  tmpFile.delete(); 
}

Coverage outputs displayed as the lines from String configXML = args[0]; in main method
are not covered.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:44:50+00:00Added an answer on May 15, 2026 at 5:44 am
    • assertTrue(true); is a pointless no-op
    • Remove the try/catch around the call to XFRCompiler.main(args);, since all it does is swallow excpetions and make debugging harder; most likely you will then see an exception that tells you where the problem is.
    • There should be a call to fail() after the call to XFRCompiler.main(new String[]{"",""}); since you expect it to throw an exception
    • Put the two calls in separate test methods.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider a main method: public static void main(String[] args) throws Exception { System.out.println(property=' +
My main method: public static void main(String[] args) { Scanner input = new Scanner(System.in);
public static void main(String[] args) throws Exception { RSAKeyPairGenerator rsaKeyPairGen = new RSAKeyPairGenerator(); AsymmetricCipherKeyPair
public static void main(String[] args) { // TODO Auto-generated method stub BufferedReader br1 =
I have the following code: public class Tests { public static void main(String[] args)
My Java class contains the following methods: public static void main(String[] argv) //start the
I have new problem. My code: .method public static void Main() cil managed {
Consider the following code, public class StartUp { public StartUp(String[] test){} public static void
I am using jdk 1.6 My main method : exmp3<String , Integer> exmp3 =
I want to invoke the main method which is static. I got the object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.