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.

Similar Messages

  • Use JUnit test EJB bean class

    I'm using Junit test EJB 3.0 session bean class by initialize :
    SessionBeanClass sbc = new SessionBeanClass()
    so the object I got is just a normal object, it's not remote or local interface.
    however, when I start JUnit within Jdeveloper, looks like the embed OC4J start.
    this behivor is strange to me, I thought I 'm not calling EJB in this case,why the OC4J start?
    this is different than running JUnit outside of JDeveloper?

    Yes, this is the way JDev works -- JDeveloper notices that this class happens to be a Session bean, and when you 'run' it, it assumes you want to 'run' it in the embedded OC4J server -- though clearly it is not what you want in this case.
    One way you can override this behavior is by creating a wrapper (POJO) class to be your JUnit test class, and have that class instantiate your Session bean.

  • Exception while running a test file as JUNIT test case

    Hi,
    I am trying to build a code using Eclipse to generate an "ear" file that can be used for deployment. The ear file is generated successfully but the build is not successful as the following exception is thrown while debugging a junit test case:
    javax.naming.CommunicationException: tdk.dk:389 [Root exception is java.net.SocketTimeoutException: connect timed out]
         at com.sun.jndi.ldap.Connection.<init>(Connection.java:197)
         at com.sun.jndi.ldap.LdapClient.<init>(LdapClient.java:118)
         at com.sun.jndi.ldap.LdapClient.getInstance(LdapClient.java:1580)
         at com.sun.jndi.ldap.LdapCtx.connect(LdapCtx.java:2616)
         at com.sun.jndi.ldap.LdapCtx.<init>(LdapCtx.java:287)
         at com.sun.jndi.ldap.LdapCtxFactory.getUsingURL(LdapCtxFactory.java:175)
         at com.sun.jndi.ldap.LdapCtxFactory.getUsingURLs(LdapCtxFactory.java:193)
         at com.sun.jndi.ldap.LdapCtxFactory.getLdapCtxInstance(LdapCtxFactory.java:136)
         at com.sun.jndi.ldap.LdapCtxFactory.getInitialContext(LdapCtxFactory.java:66)
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
         at java.lang.reflect.Method.invoke(Method.java:597)
         at junit.framework.TestCase.runTest(TestCase.java:154)
         at junit.framework.TestCase.runBare(TestCase.java:127)
         at junit.framework.TestResult$1.protect(TestResult.java:106)
         at junit.framework.TestResult.runProtected(TestResult.java:124)
         at junit.framework.TestResult.run(TestResult.java:109)
         at junit.framework.TestCase.run(TestCase.java:118)
         at junit.framework.TestSuite.runTest(TestSuite.java:208)
         at junit.framework.TestSuite.run(TestSuite.java:203)
         at org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
         at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
         at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
    Kindly suggest a solution.
    P.S. : All test cases are running fine except for one test case, whose error details are given.

    No it is not. The Oracle JDeveloper and ADF forum is for development questions around development with Oracle JDeveloper and ADF.
    If you use Eclipse through OEPE, you could post the question here
    Enterprise Pack for Eclipse
    If you don't use OEPE but Eclipse, then this forum may be a great source of help: http://stackoverflow.com/
    Frank

  • Newbie question: how to compile servlet using tomcat?? Thank you

    How to set classpath? How to compile servlet.java?

    jsp is also converted into a servlet .java nd then into a class file
    this is index.jsp
    <%@ page contentType="text/html;charset=windows-1252"%>
    <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
        <title>untitled</title>
      </head>
      <body>
      </body>
    </html>this is _index.java
    /*@lineinfo:filename=/index.jsp*/
      /*@lineinfo:generated-code*/
    import oracle.jsp.runtime.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import javax.servlet.jsp.*;
    public class _index extends com.orionserver.http.OrionHttpJspPage {
      public final String _globalsClassName = null;
      // ** Begin Declarations
      // ** End Declarations
      public void _jspService(HttpServletRequest request, HttpServletResponse response) throws java.io.IOException, ServletException {
        response.setContentType( "text/html;charset=windows-1252");
        /* set up the intrinsic variables using the pageContext goober:
        ** session = HttpSession
        ** application = ServletContext
        ** out = JspWriter
        ** page = this
        ** config = ServletConfig
        ** all session/app beans declared in globals.jsa
        PageContext pageContext = JspFactory.getDefaultFactory().getPageContext( this, request, response, null, true, JspWriter.DEFAULT_BUFFER, true);
        // Note: this is not emitted if the session directive == false
        HttpSession session = pageContext.getSession();
        if (pageContext.getAttribute(OracleJspRuntime.JSP_REQUEST_REDIRECTED, PageContext.REQUEST_SCOPE) != null) {
          pageContext.setAttribute(OracleJspRuntime.JSP_PAGE_DONTNOTIFY, "true", PageContext.PAGE_SCOPE);
          JspFactory.getDefaultFactory().releasePageContext(pageContext);
          return;
        int __jsp_tag_starteval;
        ServletContext application = pageContext.getServletContext();
        JspWriter out = pageContext.getOut();
        _index page = this;
        ServletConfig config = pageContext.getServletConfig();
        try {
          // global beans
          // end global beans
          out.write(__oracle_jsp_text[0]);
        catch( Throwable e) {
          try {
            if (out != null) out.clear();
          catch( Exception clearException) {
          pageContext.handlePageException( e);
        finally {
          OracleJspRuntime.extraHandlePCFinally(pageContext,false);
          JspFactory.getDefaultFactory().releasePageContext(pageContext);
      private static final char __oracle_jsp_text[][]=new char[1][];
      static {
        try {
        __oracle_jsp_text[0] =
        "\n<html>\n  <head>\n    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">\n    <title>untitled</title>\n  </head>\n  <body>\n  </body>\n</html>\n".toCharArray();
        catch (Throwable th) {
          System.err.println(th);
    }as you can see.. my IDE converts it into a java class so it can be conpiled to a class file.. by the way i use Oracle Jdeveloper 10g for this pupose of showing you what is happening to your jsp

  • Create test scripts using e-Tester without using visual scripts

    I'm new researching on e-Test suite.
    I have the following question. Is there any possibility to create test scripts to run automatic tests without using the visual scripts created by e-Tester?
    Today, we are using Selenium to make Web based tests and this tool is included in a custom framework developed in Java. So, we don't use record and play. Directly we create code using objects, methods and attributes provided by Selenium api.

    You can create a dummy java agent script that can that call your module. The java agent script can then be automated to run in e-Load.
    1) e-tester menu ->options->New Scripts (global) -> Advanced -> Java Agent: Check on "Create Java Agent Script.." and the other 2 check boxes.
    2) menu -> File -> New Script
    3) Do Nothing. No navigations, ect...
    4) menu -> File -> Save Script i.e. "empty"
    5) Download and install Eclipse IDE (other IDEs should work but you need to create your own project)
    6) Eclipse -> Menu -> File -> Import -> General -> Existing Project into workspace: Select the root directory that contains the etester generated Java Agent script prefixed with the underscore "_" i.e c:\ETS\etest\Default!\_empty
    7) Once imported I suggest you call your module from within scriptCallback.class EndScript(RunState, ScriptResult);
    7b) When you get better at this you can return errors by changing the ScriptResult() object and view stats from the RunState() object.
    8) You will have to modify the Eclipse Project to be dependent on your jars if you want to debug in eclipse. Secondly there are 2 batch files. These two batch files create the *.JWG file which is just a renamed .JAR file.
    9) You MUST modify the batch files to create the new Empty.JWG including your *.JAR files.
    10) I recommend compiling in eclispe and only running the makefileNocompile.bat (after you add the *.jar inclusion). Ignore the makefile.bat unless you also change the javac.exe execution line to include all the correct classpaths.
    11) Once you are happy with running in Eclipse you should be able to execute in eload. I recommend you test the procedures steps 5 through 10 before adding your own module and code.

  • Testing servlet using Web2Go

    I am trying to test several servlets by registering the servelts to the Web Object Managers. After registering the servlets, I still cannot run the servlets. I can only run one at a time using "http://localhost:7070/servlets/servlet".
    Likewise, I named my servlets differently, eg. test01, test02, test03, etc. However, I cannot called it usnig the "http://localhost:7070/servlets/test01" as I thought it should after I register the servlets to the Web Object Manager.
    Is there anyway to look at the mapping of the Web2Go properties file? Where is it located? Is there a special setup to make the Web Object Manager to work properly?
    Any help will be greatful.

    The web object manger manipulates a file called wtgapp.xml. Webtogo looks for it jdev's lib directory (ie C:\jdev\lib). Unfortunately in jdev 3.1, the web object manager looks for it in the directory above (ie c:\jdev). You can get around the problem by copying it into the lib directory after you finish registration in the web object manager

  • NIST conformance tests using JUnit

    I haven't seen anyone from Oracle on the [email protected] mailing list, so I'm posting this here just to let you guys know.
    I've been working on recasting the NIST DOM test suite for Java to use JUnit and posted an initial release last night.
    The tests can easily be run against the beta XDK's parser (or any other JAXP compliant parser), but there were a substantial number test errors and failures. Some of these may be due to test problems, but I'd guess most of them are legitimate. However, I do not have time or the motivation to investigate them.
    It does seem that you take the position that the XML declaration is treated as a processing instruction (like MSXML does) which will cause 3 tests to fail, but you can adjust the tests to accept this using
    -Dnet.sourceforge.xmlconf.domunit.acceptXMLDeclPI=true
    I've made the source for my JUnit-hosted deriviatives of the NIST test suite available at http://xmlconf.sourceforge.net. You can either download the combined source and binary
    zip file from http://sourceforge.net/project/showfiles.php?group_id=8114&release_id=31676
    or you can access the source through the CVS (http://sourceforge.net/cvs/?group_id=8114)
    The tests run using JUnit 3.5 and can test JAXP 1.0 or JAXP 1.1 compliant DOM parsers.
    Xerces-J 1.3.1 does not report any test failures, crimson.jar and the other parser tested
    had a moderate amount of test failures, but no investigation has been performed to
    determine if those failures were problems with the tests or actual non-conformances
    with the spec.
    A JBuilder 4 .jpx project and an Ant 1.2 build.xml file are provided.
    ------- readme.txt from domunit 0.0.1 ---------
    domunit 0.0.1
    domunit currently contains equivalents of the NIST DOM 1 test written for
    the JUnit test framework (http://www.junit.org) and JAXP 1.1 or 1.0 compatible parsers.
    The tests were written to allow easy migration to JavaScript using JSUnit
    (http://www.jsunit.net) and CPPUnit (http://www.xprogramming.org/software)
    To run the full set of tests, place domunit.jar, junit.jar and one of the following
    combinations of jars in the same directory or on the class path.
    xerces.jar
    xml4j.jar
    jaxp.jar and parser.jar (from Sun's JAXP 1.0 Reference Implementation)
    jaxp.jar and crimson.jar (from Sun's JAXP 1.1 Reference Implementation)
    and run:
    java -jar domunit.jar
    To test Oracle's XML Processor, place jaxp.jar from the JAXP 1.0 (not 1.1) Reference Implementation
    and xmlparserv2.jar in the domunit.jar directory and run:
    java -Djavax.xml.parsers.DocumentBuilderFactory=oracle.xml.jaxp.JXDocumentBuilderFactory
    -jar domunit.jar
    The following options can adjust the tests:
    -Dnet.sourceforge.xmlconf.domunit.isExpandEntityReferences=true
    -Dnet.sourceforge.xmlconf.domunit.isCoalescing=true
    -Dnet.sourceforge.xmlconf.domunit.acceptXMLDeclPI=true
    To build the project, use either the JBuilder 4 .jpx file or
    the Ant 1.2 build.xml file.
    Curt Arnold http://xmlconf.sourceforge.net
    [email protected]
    18 April 2001
    domunit - DOM testing on the xUnit frameworks
    Copyright (C) 2001, Curt Arnold
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    null

    I haven't seen anyone from Oracle on the [email protected] mailing list, so I'm posting this here just to let you guys know.
    I've been working on recasting the NIST DOM test suite for Java to use JUnit and posted an initial release last night.
    The tests can easily be run against the beta XDK's parser (or any other JAXP compliant parser), but there were a substantial number test errors and failures. Some of these may be due to test problems, but I'd guess most of them are legitimate. However, I do not have time or the motivation to investigate them.
    It does seem that you take the position that the XML declaration is treated as a processing instruction (like MSXML does) which will cause 3 tests to fail, but you can adjust the tests to accept this using
    -Dnet.sourceforge.xmlconf.domunit.acceptXMLDeclPI=true
    I've made the source for my JUnit-hosted deriviatives of the NIST test suite available at http://xmlconf.sourceforge.net. You can either download the combined source and binary
    zip file from http://sourceforge.net/project/showfiles.php?group_id=8114&release_id=31676
    or you can access the source through the CVS (http://sourceforge.net/cvs/?group_id=8114)
    The tests run using JUnit 3.5 and can test JAXP 1.0 or JAXP 1.1 compliant DOM parsers.
    Xerces-J 1.3.1 does not report any test failures, crimson.jar and the other parser tested
    had a moderate amount of test failures, but no investigation has been performed to
    determine if those failures were problems with the tests or actual non-conformances
    with the spec.
    A JBuilder 4 .jpx project and an Ant 1.2 build.xml file are provided.
    ------- readme.txt from domunit 0.0.1 ---------
    domunit 0.0.1
    domunit currently contains equivalents of the NIST DOM 1 test written for
    the JUnit test framework (http://www.junit.org) and JAXP 1.1 or 1.0 compatible parsers.
    The tests were written to allow easy migration to JavaScript using JSUnit
    (http://www.jsunit.net) and CPPUnit (http://www.xprogramming.org/software)
    To run the full set of tests, place domunit.jar, junit.jar and one of the following
    combinations of jars in the same directory or on the class path.
    xerces.jar
    xml4j.jar
    jaxp.jar and parser.jar (from Sun's JAXP 1.0 Reference Implementation)
    jaxp.jar and crimson.jar (from Sun's JAXP 1.1 Reference Implementation)
    and run:
    java -jar domunit.jar
    To test Oracle's XML Processor, place jaxp.jar from the JAXP 1.0 (not 1.1) Reference Implementation
    and xmlparserv2.jar in the domunit.jar directory and run:
    java -Djavax.xml.parsers.DocumentBuilderFactory=oracle.xml.jaxp.JXDocumentBuilderFactory
    -jar domunit.jar
    The following options can adjust the tests:
    -Dnet.sourceforge.xmlconf.domunit.isExpandEntityReferences=true
    -Dnet.sourceforge.xmlconf.domunit.isCoalescing=true
    -Dnet.sourceforge.xmlconf.domunit.acceptXMLDeclPI=true
    To build the project, use either the JBuilder 4 .jpx file or
    the Ant 1.2 build.xml file.
    Curt Arnold http://xmlconf.sourceforge.net
    [email protected]
    18 April 2001
    domunit - DOM testing on the xUnit frameworks
    Copyright (C) 2001, Curt Arnold
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
    null

  • Junit Testing  in java

    Hi,
    I want to test a method in java using JUnit but this method neither return any value nor raises any exception. How do i test it using JUnit?
    Thanks in advance

    To perform any test you need to
    - perform an operation.
    - determine if the operation was sucessful.
    The meaning of successful is very broad. It can be as simple as; does it compile or does it run without a RuntimeException/Error. (these are not givens in every case) Or more complex such as; does it perform correctly in a multi-threaded, networked environment.
    You need to decide what you are testing and how to determine its success. This can mean refectoring you code to determine if it was successful. For example some code is written to display errors to the console. This is hard to test for and it can be simpler to change your code so this is optional and the error can be determined by the caller.
    IMHO, you want to minimise output to the screen. It is not an automated test if it relies on the user seeing an error message (or even reading the output)
    If you really don't have an option on what a successful test mean. Just start with the simplest case. i.e. does it compile and run without error. With unit tests it is often better to have this test than none at all.

  • Junit test runner error in jDeveloper 11.1.1.6.0

    Hi,
    I am having problem with the running of test project in jdeveloper. I created the test project using Application Test Framework from the Model project. Model project has the AM and PVOs used for BI VOs. The test project is created with all the selected view objects (PVOs). The following issues are noticed in the test project
    1) The VO tests and VO JtestCase.xml are created with wrong names. For example the Model project has VO name like PortfolioPVO, but the test VO was created like PortfolioVOTest.java and xml as PortfolioVOTest.xml. I renamed all these test project files accordingly to suit my model project pvo's.
    2) When I run the test project in jDeveloper, I am getting the following errors
    >> java.lang.AssertionError: AM should not be null.
    oracle.apps.financials.commonTest.util.XMLTestDataHelper.setConnectivityDetails(XMLTestDataHelper.java:171)
    oracle.apps.common.applicationsTestFramework.service.AtfAbstractAMProviderTest.setUpAtfAbstractAMProviderTest(AtfAbstractAMProviderTest.java:85)
    >> oracle.jbo.JboException: JBO-29000: Unexpected exception caught: oracle.jbo.ConfigException, msg=JBO-33001: Configuration file /common/bc4j.xcfg is not found in the classpath
    oracle.jbo.common.ampool.PoolMgr.findPool(PoolMgr.java:529)
    oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1508)
    oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1485)
    oracle.apps.financials.commonTest.util.TestAMFixture.setUp(TestAMFixture.java:158)
    oracle.apps.common.applicationsTestFramework.service.AtfAbstractAMProviderTest.setUpAtfAbstractAMProviderTest(AtfAbstractAMProviderTest.java:68)
    >>Caused by: oracle.mds.exception.MDSExceptionList: MDS-01329: unable to load element "persistence-config"
    MDS-01370: MetadataStore configuration for metadata-store-usage "WebCenterFileMetadataStore" is invalid.
    MDS-00503: The metadata path "../../mds" does not contain any valid directories.
    at oracle.mds.config.PConfig.loadFromBean(PConfig.java:954)
    ... 58 more
    Nov 8, 2012 4:41:42 PM oracle.adf.share.config.ADFContextMDSConfigHelperImpl createMDSSession
    INFO:
    oracle.adf.share.ADFShareException: MDSConfigurationException encountered in parseADFConfiguration
    at oracle.adf.share.config.ADFMDSConfig.parseADFConfiguration(ADFMDSConfig.java:182)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at oracle.adf.share.config.ADFConfigImpl.getResultFromComponent(ADFConfigImpl.java:522)
    at oracle.adf.share.config.ADFConfigImpl.getConfigObject(ADFConfigImpl.java:593)
    at oracle.adf.share.config.ADFConfigImpl.getConfigObject(ADFConfigImpl.java:571)
    at oracle.adf.share.config.ADFConfigImpl.getMDSInstance(ADFConfigImpl.java:636)
    at oracle.adf.share.config.ADFConfigImpl.getMDSInstance(ADFConfigImpl.java:631)
    at oracle.adf.share.config.ADFContextMDSConfigHelperImpl.createMDSSession(ADFContextMDSConfigHelperImpl.java:52)
    Any help is greatly appreciated ? Are these any config /jazn issue ? I followed this link for creating the test project for BI VOs.
    http://globaldc.oracle.com/perl/twiki/view/FusionSharedTools/AtfBiPVOTesting
    thanks,
    --om                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I have added all the libraries relevant to BPEL in my classpath. Also I have installed all the extensions.
    Another point to note is I dont get any error when I use BPEL 2.0 while creating a BPEL project.
    I get this error only if I use BPEL 1.1 as my standards.
    Thanks for trying to help me out.

  • How to call serlvet using ftp protocal

    Hai,
    How to call servlet using ftp protocal . if any one having please send that program . because generic servlet will receive any protocal request .

    The basics are to have your Server listen to port 21.
    You would then have to parse the request information to determine what is being asked for and generate an appropriate response.

  • Servlet Testing (using JUnit??)

    Hi there,
    I have a web application using many different servlets and now i would like to test the methods in these servlets.
    How can i do this using Junit? Is it possible or is there an alternative way of testing?
    Rahul

    junit testing is working perfectly when i am testing
    core java applications.But it gives
    unsupportedClassversion when i am trying to run
    junit on servlets.Maybe your servlet engine does not use the same JRE as the one you use to run your classical java app. e.g. Tomcat on Windows selects its JRE at install time, so if you installed another JRE afterwards...

  • 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 run test cases in a jar file using junit?

    Hi,
    I want to run test cases in a jar file using junit and the jar file is not in the class path. I wrote the following code, but it does not work.
    import java.net.URL;
    import java.net.URLClassLoader;
    import junit.framework.TestResult;
    import junit.textui.TestRunner;
    public class MyTestRunner {
         public static void main(String[] args) throws Exception{
              URL url = new URL("file:///d:/case.jar");
              URLClassLoader loader = new URLClassLoader(new URL[]{url});
              loader.loadClass("TestCase1");
              TestRunner runner = new TestRunner();
              TestResult result = runner.start(new String[]{"TestCase1"});
              System.out.println(result.toString());
    }Any ideas?
    Thanks a lot.

    Wouldn't it just be easier to put it on the classpath? You're trying to, anyway, with a URLClassLoader, albeit in an entirely unnecessarily complicated way

  • Exceptions trying to run Junit test thro Jdev. Test uses Application module

    Hi,
    my junit test works through the OraTst frame work. But I want to debug the code and If I try to run the same test through Jdev I am running into a following exception. Can somebody tell me how to fix this issue.
    I am a consumer of the Application module, I have not created it. I am using it by referencing it through the jar file provided by the owner.
    oracle.jbo.DMLException: JBO-27200: JNDI failure. Unable to lookup Data Source at context jdbc/EMReposDS
    at oracle.jbo.server.DBTransactionImpl.lookupDataSource(DBTransactionImpl.java:1414)
    at oracle.jbo.server.DBTransactionImpl2.connectToDataSource(DBTransactionImpl2.java:309)
    at oracle.jbo.common.ampool.DefaultConnectionStrategy.connect(DefaultConnectionStrategy.java:203)
    at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolConnect(ApplicationPoolMessageHandler.java:553)
    at oracle.jbo.server.ApplicationPoolMessageHandler.doPoolMessage(ApplicationPoolMessageHandler.java:409)
    at oracle.jbo.server.ApplicationModuleImpl.doPoolMessage(ApplicationModuleImpl.java:8534)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.sendPoolMessage(ApplicationPoolImpl.java:4392)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.prepareApplicationModule(ApplicationPoolImpl.java:2388)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.prepareResource(ApplicationPoolImpl.java:3621)
    at oracle.jbo.pool.ResourcePool.useResource(ResourcePool.java:344)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.doCheckout(ApplicationPoolImpl.java:2200)
    at oracle.jbo.common.ampool.ApplicationPoolImpl.useApplicationModule(ApplicationPoolImpl.java:3088)
    at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:460)
    at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:431)
    at oracle.jbo.common.ampool.SessionCookieImpl.useApplicationModule(SessionCookieImpl.java:426)
    at oracle.jbo.client.Configuration.getApplicationModule(Configuration.java:1494)
    at oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1399)
    at oracle.jbo.client.Configuration.createRootApplicationModule(Configuration.java:1370)
    -Sidd

    Sidd,
    No idea what OraTst is, but based upon the name of your data source, I'd guess you are an Oracle employee using an internal framework. I understand that there are some internal Oracle forums that you can use.
    John

  • Using TimesTen for JUnit tests

    I want to switch from using HSQL (in memory) to TimesTen in my Unit tests. Is there a simple setup for TimesTen when used for this purpose?
    For example, for HSQL, all I have to do is include the hsql.jar as a dependency in my project, then include the following line in my JUnit test:
    DataSource dataSource = new DriverManagerDataSource("org.hsqldb.jdbcDriver",
    "jdbc:hsqldb:target/test-classes/com/project/path/test/schema", user, pw);
    schema is a reference to the schema.script that includes the DDL for all the tables that I need to create in memory.
    Can anyone help me out? Thanks.

    From what little I know about it TimesTen is not an in-memory database, it is a caching architecture. Therefore I would expect the set-up to be different - the TimesTen stuff should be set up once ever[], like the schema of a regular database, rather than everytime you run your unit tests.
    I think you need to sit down with the TimesTen documentation and figure out how you are going to use the product. If you are just looking for a quick DB to use in unit tests I think you may well want to keep using HSQL.
    Cheers, APC

Maybe you are looking for

  • Issue with Adobe Flash Professional CS5.5 Security Update 11.5.2

    As part of my Adobe Design Premium CS5.5 suite, I have Flash CS5.5 version 11.5.1.349. It sorely needs updating per the security announcement page. Also Kaspersky IS keeps telling me it needs to be updated as a security vulnerability. I've tried ever

  • Webdispatcher use of existing certificate

    Hi guys, we are still runnig iis with reverseproxy (old portal EP6) on a gatewayserver in the dmz. Now we want to use the same server for webdispatcher on a different port (parallel for NW04s Portal). For http it works fine. But we want to run (termi

  • Airport card needed?

    i'm moving in with friends who have wi-fi and i need to know if i need an airport card for my powerbook g4 in order to pick up the signal. does this labtop already come equipped with airport card and is it compatible with wi-fi that isnt an airport b

  • Rendering VS Previews?

    I have noticed when I do my RT previews the task managers shows both CPU cores working but when I render to a file for CD-ROM use only one of the cores is working. I have Premiere Pro 1.0. Is it any different in PP CS3?

  • Lost all events

    Hi all, Purchased a new My Book for Mac.  Tech at store told me to select command A and drag to external drive. Worked great, right up to the point where all pics (55000) were placed into a single event. This somehow transferred over to my internal h