Creating junit test cases using the reflection API

In order to use the reflection API to get information about a *.java file's class name and methods, I need to compile the *.java file first, and then get info through the *.class file. Am I right?
Eclipse, the Java IDE, can create junit test cases for java files the user selects right after the *.java files have been created, and even before the *.java files have been compiled by the user. I guess Eclipse internally compiles the java files before creating JUnit test cases for them. Does anyone know about it? Thanks.

Let me explain my problem in more details.
Given any java source tree, my program is supposed to create junit test cases for each class using java reflection. My approach is to scan through the source tree to keep the list of classes available, then compile all the java files in the given source tree, then do Class.forName() to load them to get their methods... Obviously I don't know what classes I will have at compilation time. I create a temp_classes directory as the output directory for the given source tree java files, and I add temp_classes to my classpath when I strart up my own program. However, that won't work..
D:\eclipse\workspace\cmpe271_hw4\classes>java -classpath ..\classes;..\temp_classes Test
javac -classpath .\temp_classes; -d .\temp_classes @temp_classes\javalist.txt
java.lang.ClassNotFoundException: Factory
java.lang.ClassNotFoundException: InvalidDateFormatException
java.lang.ClassNotFoundException: MyUtility
java.lang.ClassNotFoundException: Storage

Similar Messages

  • Better not to use the Reflection API?

    A few companies are creating a framework for the company I work for. They use very often the Reflection API which seems strange and even "dirty programming" to me.
    The side effects are in my eyes is that if refactoring is done within Eclipse, everything is refactored except the strings which are used to dynamically build the method name which is then invoked. I hope you know what I mean. Besides, if a UML, audit or metrics tool is used, such tools don't understand that the Reflection API is used. They don't follow the reflection trail.
    So my question to you is whether the Reflection API should be avoided like GOTO or if it should be used? If it should be avoided, what would be the best alternative to the Reflection API?

    Sounds more like a failing of Eclipse than of your partner companies. Reflection is part of Java. Whether an IDE should be capable of refactoring "runtime" code at compile time is another matter, however..
    In most cases reflection can be avoided. Yet, as with all design decisions, you've got to balance purity with simplicity. Reflection can actually be simpler/clearer than the mess you might get in trying to avoid it. It's not evil, it's just misunderstood.
    In the wrong hands it's a nightmare but used judiciously it's another useful tool.
    As for alternatives, there's really not enough information to say - if it's simply being used to install a Factory at runtime, for example, then there's not much of an alternative unless you know all the Factories that will be used and hardcode them in. If reflection's just being used to invoke a method then it could indeed be replaced unless the method is also determined at runtime. Etc...
    Sometimes extracting a common interface will resolve these problems but not always - it's horses for courses.
    Hope this helps.

  • Running a JUnit test case using Ant in Eclipse

    If I have a "JUnit", how can I run it using "Ant" in Eclipse?
    Thanks.

    Right-click on the ant build script and select "Run as ant build". But why bother? Eclipse has its own JUnit runners

  • How to create a campaign based on a template using the REST API

    Hi CodeIt-ers,
    I'm using the REST API to create campaigns in Eloqua 10, all works well except for 1 thing: I can't seem to create a campaign based on an existing Campaign template.
    Based on the documentation on REST API - Accessing Campaigns I've tried using "sourceTemplateId" (code snippet below) but that did not do the trick.
    Does that functionality simply not work or am I missing something?
    Thanks!
    Ferry
    $campaign_data = new Campaign(); 
    $campaign_data->sourceTemplateId='442';
    $campaign_data->folderId='1137';
    $campaign_data->currentStatus='draft';

    Hi Richard,
    Unfortunately no. I reached out to support, they informed me "sourceTemplateId" could not be used to create new campaigns based on a template, instead they advised to use the "Elements " property as shown in this example: Eloqua REST API - Create a Campaign with a Segment and Email
    Thanks
    Ferry

  • How do I create a user, in my context in OID using the Java API

    How do I create a user, with subschema, in my context in OID using the JAVA API
    I need to be able to create new users in my OID, I was doing it in our old iPlant Directory, but I don't seem to see the same methods in the Oracle LDAP API. I figured out how to get and modify the attributes of a user, but I can't seem to figure out how to add a new one.

    Try this code , modify it accordingly
    ------- cut here -------
    import oracle.ldap.util.*;
    import oracle.ldap.util.jndi.*;
    import javax.naming.NamingException;
    import javax.naming.directory.*;
    import java.io.*;
    import java.util.*;
    public class NewUser
    final static String ldapServerName = "yourLdapServer";
    final static String ldapServerPort = "4032";
    final static String rootdn = "cn=orcladmin";
    final static String rootpass = "welcome1";
    public static void main(String argv[]) throws NamingException
    // Create the connection to the ldap server
    InitialDirContext ctx = ConnectionUtil.getDefaultDirCtx(ldapServerName,
    ldapServerPort,
    rootdn,
    rootpass);
    // Create the subscriber object using the default subscriber
    Subscriber mysub = null;
    String [] mystr = null;
    try {
    RootOracleContext roc = new RootOracleContext(ctx);
    mysub = roc.getSubscriber(ctx, Util.IDTYPE_DN, "o=dec", mystr);
    catch (UtilException e) {
    e.printStackTrace();
    // Create ModPropertySet with user information
    ModPropertySet mps = new ModPropertySet();
    mps.addProperty(LDIF.ATTRIBUTE_CHANGE_TYPE_ADD,"cn", "Steve.Harvey");
    mps.addProperty(LDIF.ATTRIBUTE_CHANGE_TYPE_ADD,"sn", "Harvey");
    mps.addProperty(LDIF.ATTRIBUTE_CHANGE_TYPE_ADD,"uid", "SHarvey");
    mps.addProperty(LDIF.ATTRIBUTE_CHANGE_TYPE_ADD,"givenname", "Steve");
    mps.addProperty(LDIF.ATTRIBUTE_CHANGE_TYPE_ADD,"mail", "[email protected]");
    mps.addProperty(LDIF.ATTRIBUTE_CHANGE_TYPE_ADD,"userpassword", "welcome1");
    // Create the user
    User newUser = null;
    try {
    newUser = mysub.createUser(ctx, mps, true);
    System.out.println("New User DN: " + newUser.getDN(ctx));
    catch (UtilException e) {
    e.printStacktrace();
    ------- end cut --------
    Enjoy.
    Suhail

  • Help/Example needed for creating JMSQueues/JMSTopics using the MBean API

    I am trying to create JMSQueues programmatically using the MBean API. When
    I use MBeanHome.createAdminMBean(), a queue appears in the root of the
    config file. This is progress, but the queue is in the wrong place! I need
    the queues to be part of my JMS server's "destinations" as seen on the
    console.
    So now I am trying to use createConfigurationMBean() instead, but I can't
    figure out what the "parent" parameter should be- no documentation! My
    first guess was that the parent might be the JMSServer, but that doesn't
    work.
    Anyone have example code to insert JMSQueues and JMSTopics into a specific
    JMS server's destinations?
    Here is the code I tried... All goes well until the final
    createConfigurationMBean call, where it throws a MBeanCreationException:
    // Get the MBeanHome bean
    Object obj = jndiContext.lookup("weblogic.management.adminhome");
    MBeanHome mbeanhome = (MBeanHome) javax.rmi.PortableRemoteObject.narrow
    (obj, MBeanHome.class);
    // Get the server MBean
    JMSServerMBean jmsServerMB =
    (JMSServerMBean)mbeanhome.getMBean("examplesJMSServer",
    JMSServerMBean.class);
    // Create the new Queue
    JMSQueueMBean jmsQMB = (JMSQueueMBean)mbeanhome.createConfigurationMBean
    ("weblogic.examples.jms.fooQueue", "JMSQueue", jmsServerMB);

    Ok, I still don't see how I can do it differently with the admin tool. If
    you want to see the commands I'm using, I can post them, but the basic one
    is shown below in the previous message. We're trying to set up a script so
    that developers can just run it and properly configure WebLogic with the
    right components.
    Thanks,
    Michelle
    "Michelle Baxter" <[email protected]> wrote in message
    news:[email protected]...
    I am using the weblogic.Admin tool, not doing this in code. I will attempt
    to translate your advice when I get time again.
    My commands look like this:
    java weblogic.Admin -url 127.0.0.1:7001 -username system -passwordweblogic
    CREATE -mbean "mydomain:Type=JMSQueue,Name=MyJMSQueue"
    I create this, I create the JMSServer MBean, then do and INVOKE (insteadof
    CREATE) and call the addDestination method, adding the JMS Queue MBeanthat
    I created previously, using the same naming scheme as in the above CREATE.
    "Viresh Garg" <[email protected]> wrote in message
    news:[email protected]...
    Daron Cole wrote:
    You can use createConfigurationMBean with JMSQueueConfig but in the
    end
    I used
    the code below to create a topic.The code that you posted is the right way to create queus/topics. alwayscreate admin mbeans to admin
    server and let admin server internally create config Mbeans on the
    managed
    server as per the
    location/targets that you set in admin Mbeans.
    Queue's are the same, just replace the word
    Topic with Queue and it should work. It should show up in the console
    app.
    MBeanHome home = (MBeanHome)ctx.lookup(MBeanHome.JNDI_NAME+".myserver");
    ServerMBean myserver =(ServerMBean)home.getMBean("myserver",ServerMBean.class);
    String topicName = "MyNewTopic";
    JMSServerMBean jmsServerMB =(JMSServerMBean)home.getMBean("JMSServer","JMSServer","mydomain");
    JMSTopicMBean jmsTopicMB =(JMSTopicMBean)home.createAdminMBean(topicName,"JMSTopic","mydomain");
    jmsTopicMB.setJNDIName(topicName);
    jmsServerMB.addDestination(jmsTopicMB);
    Viresh Garg
    Principal Developer Relations Engineer
    BEA Systems
    "Michelle Baxter" <[email protected]> wrote:
    There is no JMSQueueConfigMBean. What do you mean?
    "Daron Cole" <[email protected]> wrote in message
    news:[email protected]...
    Try JMSQueueConfig instead of JMSQueue.
    "Michelle Baxter" <[email protected]> wrote:
    Me too! I'm trying to use the weblogic.Admin class to set up
    queues
    and
    topics and the JMS server. The same results in the config file:
    the
    queues
    and topic were set up at the root, the JMS server was added, but
    no
    destinations, even though I invoked the addDestination method withthe
    created MBean queues and topic as arguments. No exceptions, just
    no
    destinations on the JMS server resulted. What's the right order ofexecution
    for this stuff??
    Thanks,
    Michelle
    "Jude DeMeis" <[email protected]> wrote in message
    news:[email protected]...
    I am trying to create JMSQueues programmatically using the MBean
    API.
    When
    I use MBeanHome.createAdminMBean(), a queue appears in the root
    of
    the
    config file. This is progress, but the queue is in the wrong
    place!
    I
    need
    the queues to be part of my JMS server's "destinations" as seen
    on
    the
    console.
    So now I am trying to use createConfigurationMBean() instead,
    but
    I
    can't
    figure out what the "parent" parameter should be- no
    documentation!
    My
    first guess was that the parent might be the JMSServer, but that
    doesn't
    work.
    Anyone have example code to insert JMSQueues and JMSTopics intoa
    specific
    JMS server's destinations?
    Here is the code I tried... All goes well until the final
    createConfigurationMBean call, where it throws aMBeanCreationException:
    // Get the MBeanHome bean
    Object obj =
    jndiContext.lookup("weblogic.management.adminhome");
    MBeanHome mbeanhome = (MBeanHome)javax.rmi.PortableRemoteObject.narrow
    (obj, MBeanHome.class);
    // Get the server MBean
    JMSServerMBean jmsServerMB =
    (JMSServerMBean)mbeanhome.getMBean("examplesJMSServer",
    JMSServerMBean.class);
    // Create the new Queue
    JMSQueueMBean jmsQMB =(JMSQueueMBean)mbeanhome.createConfigurationMBean
    ("weblogic.examples.jms.fooQueue", "JMSQueue", jmsServerMB);

  • 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

  • Is the reflection API thread safe?

    The obvious answer would appear to be yes, however, I have not been able to find any supporting documentation.
    I need to call the newInstance(Object[] initArgs) method on the same instance of the Constructor class from multiple threads.

    Hi,
    without knowing the reflection API too well, my guess would be, you are ok. If several threads are
    just creating new instances and you are not modifying anything used in their constructors, no problem.
    However, if you have a thread changing some class variables that are used in turn by the constructors to
    initialize the instances, you are in trouble.
    In such a case, try to encapsulate read&write access to these variables in synchronized
    methods (setter/getter).
    Good luck!
    Pete

  • How to create a simple app using the MVC approach?

    Hello gurus i'm trying to learn the SAPUI5 and i'm trying to create a simple app using the MVC i created the app and trying to add a lable to the view but there is nothing appear when i run it the code for the HTML page
    <!DOCTYPE HTML>
    <html>
      <head>
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta http-equiv='Content-Type' content='text/html;charset=UTF-8'/>
      <script src="https://sapui5.hana.ondemand.com/resources/sap-ui-core.js"
      id="sap-ui-bootstrap"
      data-sap-ui-libs="sap.m"
      data-sap-ui-theme="sap_bluecrystal">
      </script>
      <!-- only load the mobile lib "sap.m" and the "sap_mvi" theme -->
      <script>
      sap.ui.localResources("mytestapp");
      var view = sap.ui.view({id:"idshell1", viewName:"mytestapp.shell", type:sap.ui.core.mvc.ViewType.JS});
      view.placeAt("content");
      </script>
      </head>
      <body class="sapUiBody" role="application">
      <div id="content"></div>
      </body>
    </html>
    the code for the view
    sap.ui.jsview("mytestapp.shell", {
      /** Specifies the Controller belonging to this View.
      * In the case that it is not implemented, or that "null" is returned, this View does not have a Controller.
      * @memberOf mytestapp.shell
      getControllerName : function() {
      return "mytestapp.shell";
      /** Is initially called once after the Controller has been instantiated. It is the place where the UI is constructed.
      * Since the Controller is given to this method, its event handlers can be attached right away.
      * @memberOf mytestapp.shell
      createContent : function(oController) {
      var oLabel = new sap.ui.commons.Label("l1");
      oLabel.setText("Test label");
      oLabel.placeAt("content");
    i dont know what is wrong or if i should use a container to display my controls
    any help will be appreciated
    thanks in advance

    Hi,
    Instead of   oLabel.placeAt("content"); use return oLabel;
    so it will as below,
    createContent : function(oController) {
      var oLabel = new sap.ui.commons.Label("l1");
      oLabel.setText("Test label");
      return oLable;
    Regards,
    Chandra

  • Create Unit Test Vectors From The Unit Test Configuration Window

    I have recently been using more test vectors in the unit test framework.
    The principle works well but if you are in a unit test and decide you need a test vector you must:
    Close the unit test configuration
    Create a test vector
    Set up your vector (entering values and data types, which is much easier if you could see the actual unit test case)
    Close the vector configuration window
    Open the unit test configuration
    Assign the new vector file to the unit test
    Now you can assign vectors to test inputs
    This seems convoluted and forces unnecessary context switchs.
    I propose that at a minimum, you should be able to create a new vector file and launch it's configuration without leaving the unit test configuration window. I suspect that the whole process could be streamlined even further though.
    James Mc
    ========
    CLA and cRIO Fanatic
    wiresmithtech.com/blog

    Oops supposed to be ideas exchange, sorry!
    James Mc
    ========
    CLA and cRIO Fanatic
    wiresmithtech.com/blog

  • Using the Preferences API

    I've never used this API before, so excuse my ignorance. I have a web application that I have been using a properties file to store base app info, such as the backend database, the url for the ldap, etc. This has been working fine, but after reading about the Preferences API, I thought that this might be the better place to store this info. However, I'm having permission problems that I haven't been able to figure out.
    I've got a development copy of everything on a single computer (using Windows XP), Sun One App Server, and Oracle.
    I created a small test class to see if I could load preferences from an xml file. Here's the class
    package portal.common;
    import java.util.*;
    import java.util.prefs.*;
    import java.io.*;
    import java.lang.*;
    public class PortalPreferences{
         Preferences sysPreferencesRoot;
         public void prefs() throws SecurityException{
    sysPreferencesRoot = Preferences.systemRoot();
         public void uploadPrefs(String file) throws IOException, InvalidPreferencesFormatException{
         FileInputStream fis = new FileInputStream(file);
         RuntimePermission rpermiss = new RuntimePermission("preferences.*");
         Preferences.importPreferences(fis);
         public Preferences getPrefs(){
         return sysPreferencesRoot;
    I then used a jsp to instantiate the class and call the uploadPrefs method. The class instantiates without error, but when I try to load the xml file I get the following error:
    access denied (java.lang.RuntimePermission preferences)
    I've never done anything with the security manager before so I'm not sure how to get around this. I tried creating a RuntimePermission object above, but that didn't work.
    If anyone has any ideas, I'd much appreciate it.

    No, actually I've got the Sun One App server loaded on a desktop I built that I'm using as a test box - its not a server. The Sun server is running fine, as is Oracle. The only problem I'm having is figuring out how to use the Preferences API. Maybe this API isn't the right thing to be using, that's why I'm asking for advice as well as how to get around the security issue that I'm having. My goal is to have application level information that can be stored somewhere other than in a database - this is because one of the pieces of app info is the database that's being used. This app will work with any backend. Currently, this info is stored in a properties file inside the WEB-INF directory. This works fine as is. However, my issue with that is that in order to load the properties file, I've got to have a real drive path. This again isn't that much of an issue except when trying to access from a class that doesn't have the servlet context, however, I am looking for an alternative solution to the properties file. The Preferences seemed like a good solution.

  • How to dispatch the result from test cases to the function that loads

    Hi ,
         I am currently working on writing a test case and i ant to execute the test case and the result of the test cases needs to be returned to function that loads the swf file using loader.
    Below is the structure
    1) Project A
             Has a action script file that has a loader which inturn loads the swf file.
    public function testRunner():void {
                loader = new Loader();
                loaderDispatcher = loader.contentLoaderInfo;         
                sharedEvents = loaderDispatcher.sharedEvents;
                parentURL = loaderDispatcher.loaderURL;
                parentDomain = URLUtil.getServerNameWithPort(parentURL);
                parentScheme = URLUtil.getProtocol(parentURL);
                load("http://localhost:8000/abc.swf");
        var callback:Function = addAsync(onMessage, 30000, {}, handleTimeout);
        sharedEvents.addEventListener("message", callback);
        /*Listener added to receive message event*/
        sharedEvents.addEventListener(MessageEvent.MESSAGE, onMessageEvent);
            private function load(location:String):void {
                // create SWF loader
                loaderDispatcher.addEventListener(Event.OPEN, onOpenEvent);
                loaderDispatcher.addEventListener(Event.INIT, onINIT);
                loaderDispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, onStatus);
                loaderDispatcher.addEventListener(Event.COMPLETE, onComplete);
                loaderDispatcher.addEventListener(IOErrorEvent.IO_ERROR, onError);
                loaderDispatcher.addEventListener(Event.UNLOAD, onUnload);
                loaderDispatcher.addEventListener(Event.CLOSE, onClose);
                var request:URLRequest = new URLRequest(location);
        //request.idleTimeout = 8000;
        try{
    loader.load(request);
    _subMovie.addChild(loader);
           catch (error:Error)
                     trace("Unable to load URL: " + error);
                // listen for DISPATCH events
                sharedEvents = loader.contentLoaderInfo.sharedEvents;
        sharedEvents.addEventListener(DISPATCH_EVENT_TYPE, handleDispatch);
    2) Project B
          Project B has the test cases written and teh swf file for this project is abc.swf.
    test.mxml
    public function go():void {
    var core:FlexUnitCore = new FlexUnitCore();
    core.addListener(new TestCaseListener());
    core.run(ABCTest);
    var messageEvent:MessageEvent = new MessageEvent("message","action test","action testing");
    //loaderInfo.sharedEvents.dispatchEvent(messageEvent);
    When I load abc.swf file this inturn call the mxml file which runs the testcases by using the FlexUnitCore .
    What I am looking for is dispatching the result that is available in TestcaseListener to the call of loader ie; in Project A
    public class TestCaseListener extends RunListener  {
    public override function testRunFinished(result:Result):void {
    trace("testRunFinished invoked 1 ::");
    trace("failureCount::"+result.failureCount);
    trace("failures::"+result.failures);
    trace("successful::"+result.successful);
    Is there any way in which i can dispatch the result from testcaselistener to the call where this swf file is loaded .

    Hello Sue,
    I just tried to export to excel with the esdev extension and got java.lang.NumberFormatException. I found the workaround at Re: Windows Multi-language env, - how do I set English for application lang?
    open the file sqldeveloper\jdev\bin\sqldeveloper.conf and add the following two lines:
    AddVMOption -Duser.language=en
    AddVMOption -Duser.country=USyet now my date formats in excel are 'american-style' instead of german. For example 01-DEC-01 so excel does not recognize it as date and therefore I can not simply change the format.
    When export to excel will be native to 1.1 perhaps someone can have a look at this 'feature'
    Regards
    Marcus

  • How can I create a new User with the Java API like OIDDAS do?

    Hello,
    I'm currently working on an BPEL based process. And i need to create an OCS user. So far I can create an user in the OID. But I cant find any documentation about given this user an email account,calendar and content function etc.
    Did anybody know if there are some OIDDAS Webservices? Or did anybody know how to do this using the Java APIs?

    You are asking about a Database User I hope.
    You can look into the Oracle 8i Documentation and find various privillages listed.
    In particular, you may find:
    Chapter 27 Privileges, Roles, and Security Policies
    an intresting chapter.
    You may want to do this with the various tools included with 8i - including the
    Oracle DBA Studio - expand the Security node and you can create USERS and ROLES.
    Or use SQL*Plus. To create a
    user / password named John / Smith, you would login to SQL*Plus as System/manager (or other) and type in:
    Create user John identified by Smith;
    Grant CONNECT to John;
    Grant SELECT ANY TABLE to John;
    commit;
    There is much more you can do
    depending on your needs.
    Please read the documentation.
    -John
    null

  • How to count number of lines inside methods() using the Doclet API

    Wrote a custom doclet using the [Doclet API|http://java.sun.com/j2se/1.3/docs/tooldocs/javadoc/doclet/index.html ] .
    The purpose for the doclet is to load Java source files and create stubs (which are identical Java source files but do not contain any method implementation details).
    Instead, the method implementation details need to be replaced with blank lines...
    public class MyDoclet {
         private static String TAB = "\t";
         public static boolean start(RootDoc root) {
              ClassDoc[] classes = root.classes();
              // Parse through class or interface
              for (ClassDoc clazz : classes) {
                   Type superClass = clazz.superclassType();     
                   // Print Methods
                   MethodDoc[] methods = clazz.methods();
                   for (MethodDoc method : methods) {
                        Parameter[] parameters = method.parameters();
                        println();
                        if (!method.isPrivate()) {
                             print(TAB + method.modifiers() + " "
                                                    + method.returnType().simpleTypeName() + " " + method.name());
                             print("(");
                             for (int i=0; i < parameters.length; i++) {
                                  Parameter parameter = (Parameter) parameters;
                                  print(parameter.type().simpleTypeName() + " " + parameter.name());
                                  if (i != parameters.length - 1) {
                                       print(", ");
                             print(")");
                             println(" {");
                             println("\n");
                             println(TAB + "}");
              return true;
    As one can see, I am just creating the method and placing the opening and closing curly braces (along with a new \n line escape sequence, in between).
    Am not really that familiar with the Doclet API...
    Question(s):
    (1) What is the best way to figure out how many lines of code are inside each method and then use a for loop to insert the exact same number of blank lines inside the methods?
    (2) Is there a way to do it using the com.sun.javadoc.SourcePosition.line() method?
    Would really appreciate it if someone could help me because this is an important requirement (hence the 10 Duke Stars).
    Happy coding to all,
    Mike                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    This is not possible using the Doclet API, because JavaDoc does not store any information regarding implementation detail. Although MethodDoc#position will give you the line where the method is declared, there is no way to determine where the method body starts and ends.
    If you need that much information, maybe you would be better of using a tool such as Eclipse's Abstract Syntax Tree parser. AST will provide you with line numbers for each code expression, hence it is relatively easy to compute the first and last line in a method body.

  • Getting error while writing JUnit test case for RestFul Services

    Hi All,
    I have written Restful services in Netbean 6.8.
    It's running well...no issues.
    {color:#0000ff}While writing JUnit test cases for them, I am getting following error:
    {color}{color:#993300}Testcase: testGetAuthenticated(com.ct.services.LoginServicesTest): Caused an ERROR
    Implementing class{color}
    java.lang.IncompatibleClassChangeError: Implementing class
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:616)
    at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
    at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
    at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:303)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:316)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:160)
    at org.eclipse.persistence.jpa.PersistenceProvider.createEntityManagerFactory(PersistenceProvider.java:65)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:52)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:34)
    at com.ct.services.LoginServices.getAuthenticated(LoginServices.java:205)
    at com.ct.services.LoginServicesTest.testGetAuthenticated(LoginServicesTest.java:84)
    Test com.ct.services.LoginServicesTest FAILED
    F:\NetbeanProjectsWorkspace\DemoProject\nbproject\build-impl.xml:972: Some tests failed; see details above.
    BUILD FAILED (total time: 11 seconds)
    {color:#0000ff}Strange thing is that when I am commenting below lines and its related calls:
    {color}
    {color:#ff0000}EntityManagerFactory mEmf = Persistence.createEntityManagerFactory("AnyName");
    EntityManager mEm = mEmf.createEntityManager();
    {color}
    {color:#0000ff}from my code, JUnit test cases are working fine.
    {color}Anybody having any idea about this ?
    Thanks
    Avi
    Edited by: Avi007 on Aug 28, 2010 5:17 AM

    Hi All,
    [http://stackoverflow.com/questions/2778295/test-driven-development-problem]
    Please refer the above link for the solution
    Thanks
    Avi
    Edited by: Avi007 on Aug 30, 2010 12:33 AM

Maybe you are looking for

  • How can I use counters to read the difference between two expernal pulse signals?

    I generated a pulse signal and sent it to a sensor which in turn gives me a pulse signal back. I need to read the time from which the sent the signal goes high to the time that the signal is returned. How can I read this? the diagram is attached Atta

  • Can't Add Movies to iTunes Library

    I have terabytes of home movies that I have imported from the camera into iMovie.  It dawned on me that I would like to watch these in my living room via my Apple TV III.  However, I'm having trouble adding these .mov files to my iTunes library. I ad

  • Remote Extractor and Real Time Infocube for SEM BCS

    Hi Experts, I have somes doubts about the integration between SEM and BW. There is a cycle that have the next processes: 1.- begin in R/3 with the movements in FI, CO and/or general ledgers 2.- Activate the extractors standards for replicate/extract

  • Samples play over one another

    I've got some audio samples loaded in EXS24--dialogue from movies to be specific. Previously, I had it set up so that I could trigger sample A via my midi keyboard and even if, for example, that sample was 10 seconds long, if I immediately hit anothe

  • Script to list paragraph styles

    Does anyone know of a script that will list all the settings for the paragraph styles in an InDesign file?