Delegate class to access non-public methods during testing?

In the following video, towards the end, someone asked that FlexUnit assumes functions and methods are to be public when tested.
http://tv.adobe.com/watch/max-2008-develop/testing-your-flex-applications-by-michael-labri ola/
The speaker replied (@ 52:25),  to use Delegate classes, which are linked in when being tested. 
Can someone show me an example of this?  Thanks.

Mike, thanks for the reply!
As I am new to unit testing, things are still solidifying.  I do understand that Unit Testing, “tests the smallest functional unit of code”, which are methods and functions.  However, I incorrectly assumed that *every* method needed to be tested *directly*.   Hence, I thought all methods would have to be public.  So that would have blown encapsulation out of the water.  Now I understand from your reply, that private methods get tested indirectly from public methods.  And that seems more ideal.
Thanks again.

Similar Messages

  • Error while accessing a public method of applet from javascript.

    Hi,
    I am getting "Object doesn't support this property or method" error
    when accessing a public method of applet from javascript in IE 6 using
    document.applets[0].myMethod();
    The same is working in IE 7.
    Thanks in advance.
    Regards,
    Phanikanth

    I don't know why it happens, but this works for me in both versions:
    <applet ..... name="MyApplet">
    </applet>and in javascript use
    document.MyApplet.myMethod()

  • Identifying non-public methods

    Is there any way for an object to idenify its own non-public methods (getMethods() returns only those methods that are declared public)?

    getDeclaredMethods() - I believe this might do what you want. It throws a SecurityException, but I'm not sure exactly under what circumstances! Oh, and it doesn't return methods defined on any superclasses.

  • Question about access non-public class from other package.

    Hi, everyone!
    Suppose class A and class B are in the same java file of package pkg1
    -- A.java. So, A is a public class and B is a non-public class.
    If I want to access class B from another class class C and class
    C is in package pkg2. When compiling, an error occurs indicating
    that class B is not visible to class C.
    So, If I defined serveral classes in one java file and I want to
    access every class from other package. How should I do?
    (I think in one java file, there should be only one public class and
    only the public class can be accessed from other package.)
    Thanks in advance,
    George

    So, If I defined serveral classes in one java file and
    I want to
    access every class from other package. How should I
    do? As you already seem to know, there is at most one public class allowed per source file (at least, with javac and most popular compilers). So if you want more than one public class, you will need to use more than one file...

  • Accessing a public method from javascript in an applet!!!

    Hi!!
    I'm have an applet (named say applet.class) in an html page that has a public method like this....
    public void doShowFrame()
              Frame frame = new frame();
         frame.setVisible (true);
    What I want to do is to call that method with javascript, I've tried to do it like this...
    function show(){
    applet.doShowFrame();
    But when i press the button that launch the java scipt the browser says
    'applet' is unidentified...
    What's wrong, what can I do??

    http://www.google.com/search?q=applet+javascript+communication&sourceid=opera&num=0&ie=utf-8&oe=utf-8
    how hard was that? seriously.

  • Limiting access to public methods

    Hi!
    I'm just curious if there's a way to do this.
    You see, I have a package that is supposed to read an xml file, and through public methods give out data from that file.
    Now, in order to do this, I implement a SAXHandler. But the SAXHandler needs to have public methods like startElement, etc.
    Now let's say I'm one of those anally retentive information-hiding people. I really wouldn't want those public methods to be available to ust anyone who uses my class. And I can't make them protected, because the interface says they can't be, and anyway - there's no simple way to put the SAXParser in my package
    While this example is specific, the problem seems a general one.
    What do you do when: an interface calls for public methods, but you don't want just anyone to get to those public methods. (the only one you want to allow is the one that made you implement the interface in the first place).
    Any hints? Thanks!
    /Z

    thanks for the hint's everyone! Your thoughts were along the lines of my own. Hiding the implementing class inside another class is probably my best bet.
    I doubt I'll do it though - I guess I'm just not that anal... yet...;-)
    I guess what I was thinking was that maybe there was some way around the necessity of wrapping the implementor, because that just seems ugly in a lot of cases and Java been so good at getting rid of ugly since Tiger IMHO.

  • How can I hide non visible layers during test movie ?

    Flash CS5
    I have a layer I am using for construction purposes, it shows though in test movie. If I go to publish settings and untick include hidden layers on the flash tab, when I test movie, my cars don’t appear along the guide lines at all and just pop into view as movie ends.
    How does one hide turned off visibility layers during test movie without affecting hidden guide lines ?
    Envirographics

    If I have a layer that is only acting as a guide for laying things out or whatever, what I do is right click that layer's name and select "Guide" from the menu that appears.  It will not appear in when I use Test Movie

  • Non-public methods in interface ??

    Is this possible? Or must all methods (signatures) in an interface be public?
    And would that mean that I cannot change the visibility modifier in implementing classes as this restricts the visibility by inheritance, which I believe is prohibited...
    Thanks for any answer,
    AC

    Everything in an interface must be public. However, the interface itself doesn't have to be.
    Yes that means that all implementing classes must have public implementing methods.
    However, proxies, adapters and decorators will get you out of serious design problems if you bump into any.
    Hope this helps.

  • Fuba or Class to access the variants of a test data container in ABAP

    Hi there,
    I think, that I might remember, that there was once a piece of code (Function call or static class method) that allowed one to access the variants in a testdata container within ABAP.
    Anybody ever heard of this before?
    Thank you & cheers,
    Gregor

    You can use class "cl_apl_ecatt_tdc_api" for reading test data.

  • Non-abstract methods in a Abstract class

    Abstract Class can contain Non-abstract methods.
    and Abstract Classes are not instantiable as well
    So,
    What is the purpose of Non-abstract methods in a Abstract class.
    since we can't create objects and use it
    so these non-abstract methods are only available to subclasses.
    (if the subclass is not marked as abstract)
    is that the advantage that has.(availability in subclass)
    ??

    For example, the AbstractCollection class (in
    java.util) provides an implementation for many of the
    methods defined in the Collection interface.
    Subclasses only have to implement a few more methods
    to fulfill the Collection contract. Subclasses may
    also choose to override the AbstractCollection
    functionality if - for example - they know how to
    provide an optimized implementation based on
    characteristics of the actual subclass.Another example is the abstract class MouseAdapter that implements MouseListener, MouseWheelListener, MouseMotionListener, and that you can use instead of these interfaces when you want to react to one or two types of events only.
    Quoting the javadocs: "If you implement the MouseListener, MouseMotionListener interface, you have to define all of the methods in it. This abstract class defines null methods for them all, so you can only have to define methods for events you care about."

  • Non-static method/object cannot be referenced from a static context...?????

    What does this mean. I know about static, but I don't understand why I get this so many times.
    I try to do something pretty normal and this is what I get a lot of times. I mean: the main() method should be static right? Then what good is the main() method if you cannot let it do stuff for you like this:
    public class Test extends JFrame
        public Test
            setSize( 100, 100 );
            show();
    public static main( String args[] )
        Test window = new Test();
        draw();
    public void draw()
        blablabla whatever I want to do, a lot of times I can't.....
    }Why is this, what is the reason for Java to forbid this and what can I do about it?

    Your draw() method, since it isn't defined as static is considered by Java to be part of your Test object; hence, it can only be invoked in the context of an existing instance of your object. In other words, any Java program that wanted to use your draw() method would have to create an instance of your Test class using something likemyTest = new Test()Your main method, however, is something different. Since you want to execute your class as a program, the Java run-time environment needs to have standard starting point. This starting point is the main method. The problem is that the main method must be static, because the run-time environment cannot be expected to know beforehand the correct way to create an instance of your class so that non-static methods can be invoked. The drawback is that your main method can only directly access methods that are defined as static.
    There are two possible solutions to this problem, and which of the two you want to use depends on the object-oriented nature of your program.
    On the one hand, if your draw() method is closely tied to the object itself, if the draw() method is actually drawing your object or a part of it, it should be left as an instance method, and you should simpy use the instance of the object you created in your main method:public static main( String args[] )
        Test window = new Test();
        // maybe some code to generate something to draw???
        window.draw();
    }This is what I think you are trying to do.
    On the other hand, if your draw() method was some kind of universal method that didn't depend in any way on the current configuration of your instance, you could simply define draw() as static at which point your main method (or a method in an external class) could invoke it directly, without a corresponding instance. But if you did that, the draw() method itself would only be able to access static variables and methods.
    Doug

  • Why only public methods in interfaces?

    Howdy all,
    I'm wondering if someone can shed some light on why Java doesn't allow interfaces to declare non-public methods.
    Ideally, I'd like to do something like this:
    public Interface Foo {
      protected void setFooProperty(int);
      public int getFooProperty();
    public Interface Goo {
      protected void makeGooey(boolean);
      public boolean isGooey();
    public class A implements Foo
    public class B implements Goo
    public class C implements Foo, GooI don't see any technical reason why interfaces must be restricted to declaring public methods only, but it seems too arbitrary to have been done without reason. Any ideas?

    I don't think that is a good idea to put non-public methods in public interfaces. But I beleive that's a good idea to have protected (or friendly) interfaces to be used only in package scope. It could help a lot some projets defining a second level of data exposure of an object so that developers of that package could have more information that others users from outside the package have that are interesting to develop better algorithm that work with that data. In this way, we can defien thre levels of that access: The lower is the package user, that can see the minimum that's possible, above him we have the package developer that don't work directly with the data, but needs some deep access to it to do cool stuff, and finally we have the guy that is doing the object that deals directly with the data (and encapsulate it).
    In this way we can decouple a little the data from the algorithms that work on it, put between them an interface that standarize the access to the data in an intermediate level.
    Hope you are able to understand what I wrote (my english isn't so good!).
    RGB

  • Why Java doesn't allow to reduce the accessibility of a method du

    Why Java compiler does not allow to reduce the accessibility of a method during inheritance?
    ( Eg; If the base class has a public method and if that method is overridden in child class but
    with defuault access, it gives compile error)
    Supposed answer:
    Because in the runtime, it cannot check the access modifier.
    Suppose A is the base class. It has a method fun() as public.
    B is the derived class of A.
    Suppose in some other class (say C) there is a method myFun() which takes A as parameter and
    calls the fun() method of A. So that method can take B
    also as parameter (As it is derived from A).
    So if the fun() method's accessibility is reduced in B, whether "that can
    be called in C or not" is not known. that is why compiler does not
    allow the reduce the accessibility of a method during inheritance.
    Member variables do not have this problem as they can be checked at
    compile time.
    Is this explanation correct?

    You can give private access, sort of... you could fake it, if the goal is to prevent someone from doing what the method does. Of course, they could (as long as A isn't abstract) create their own A and do whatever they want.
    class A {
       public void doThis() {
    class B extends A {
       public void doThis() {
          // explicitly do nothing
    }But I think generally, this shouldn't be a problem. I'm not sure if it's something that is common for creating an API to subclass another class to hide the superclass's methods. Usually you are adding functionality to a subclass that is for more specific things then the superclass supports. I mention creating an API because if it's just for some application class, then you are writing it, so use or not use the methods as you want. It's APIs for library type classes that other people would use, and if you are extending the library, and really need people not to call methods for some reason, document it. Maybe a good place for an assertion?

  • Access to a method located in view object from JSP page?

    Hi,
    How can i access a public method which is loacted in view
    object "viewobjectImpl.java" from JSP page.

    Juan,
    Either via Data tags or/and Java embedded code.(<%...%>).
    This method, suppose to execute a stored procedure.
    Thanks

  • Error accessing constnt public attribute of a class in an overwrite method.

    Hi Gurus,
    I am facing an error while accessing a constant public attribute while using it in the overwrite-exit of a methods.
    The constant which is declared as public in the attribute section of the class is not available in the overwrite-exit of the method.
    Please suggest me how to access the public attributes in the overwtire exits of the methods.
    Thanks.

    Hi Ramneek,
    Let me explain you the entire scenario:
    Actually we are trying to ehance the SAP standard class : CL_FITV_POWL_FEEDER_TRIPS in ECC 6.0 EHP 5 .
    We tried to create and overwrite-exit of the method "IF_POWL_FEEDER~GET_ACTIONS".
    Overwrite-exit of a method is just like a method which will be called instead of the standard method : IF_POWL_FEEDER~GET_ACTIONS.
    But the problem which we are facing here is that the Attributes which are defined in the class CL_FITV_POWL_FEEDER_TRIPS,  are getting accessed from the overwrite-exit method.
    Becuase of this we are not able to implement our custom logic.

Maybe you are looking for

  • Changing the Column names / alias

    Hi, I have an oracle query and it works fine. select q.sname, SUM( decode(p.nprofile1,10,1,0)) as "0 - 5", SUM( decode(p.nprofile1,9,1,0)) as "6 - 10", SUM( decode(p.nprofile1,8,1,0)) as "11 - 15", SUM( decode(p.nprofile1,7,1,0)) as "16 - 19", SUM( d

  • Currency and exhange rates data distribution to flat file

    Hi All I have a situation like i am sending the all  BI data to flat files but my problem is how can i send the currency exhange rates(TABLE:TCURR) data to flat files, is it possible using open hub desination or any other methods available please sug

  • PDF to Text format

    Hi All, Scenario: PDF to Text format I have to create an interface in which the sender file is in PDF format which has to pass to the recvr system  in text format thru PI. Kindly guie me the adapters to be used at sender side and also tell me if ther

  • Address Book Automatic Fill as you type

    A ver versions of the Mac OS X ago, I remember that when I typed a name, address, zip code, etc. into a field in a new contact within Address Book it would automatically begin to pre-populate the field based on data already within Address Book. In ot

  • BAdI/method for limiting Delivery type list for webshop

    Hello everyone, I need your help: I have requirement is to limit some Deliver types when ordering in the b2b webshop (webshop only not others).  I'm searching for a BAdI (I don't want to hardcode in order.jsp) and debuging/looking into CRM_ISA_BASKET