Itapaj� Takeguma

Ranch Hand
+ Follow
since Jul 21, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Itapaj� Takeguma

Hello,

Well Preuss, that is a very strong argument... I will try to expose it to the client! Thanks a lot.

But because I could not spoke to him today, I continued my way across the ClassLoaders and as Koskela asked me to expose my (awkward) work around, I dispose here a piece of the solution (it is still messy and deserves a lot of refactoring, but only if the client agrees to pay the price).

Part of the solution came from a pdf I found at google: Understanding the Java ClassLoader. The important idea taken from this document is that one can "set" a custom class loader. In my solution, I do:

java my_package.MockApplicationLoader my_package.MockClassLoader junit.textui.TestRunner MyTest

The MockApplicationLoader instatiates the MockClassLoader. It works like a bootstrap class, or the like.
The MockClassLoader loads the junit.textui.TestRunner.
And the TestRunner finally instatiates the MyTest.

MockApplicationLoader and MockClassLoader are loaded by the system class loader, while TestRunner and MyTest are loaded by MockClassLoader.

It seems to work and I could run some preliminary tests over JUnit's textui. When I run the JUnit's swingui I had some problems, I think it is possible that JUnit is overriding my class loader in some way.

It is remaning the part when I compile the mocked classes at runtime, but it isn't a big deal, I think.

Anyway, now I really agree with Preuss. It is too much work. Anyway, I think this "framework" might be valuable, because the client may have some static calls like these with no unit tests.

Thanks all,
Sory for the long text, but it was the shorter I could be,
Itapaj� Takeguma.
19 years ago
Well (Preuss)... I really can't change signature and I can't change implementation. If I asked the client (the one who is paying for the system (the sponsor), not client in the sense of the one who is using the class (the caller)), he will just say: "hey, I architectured this way. If you don't like it, I'll find one who will" (but in portuguese).

Any away, I understood the solution advocated by Friedman-Hill [thanks for your posting], but unfortunately I should be able to test the class without changing it in any way. I can do whatever I want with the unit tests, but nothing at all with the classes.

That's why I started to think about deceiving class A at a much lower level: loding a faked class... but I don't know if it is possible, given that class B is in the class path!

thanks for all of you,
Itapaj�.
19 years ago
Hello,

post Tools for testing static methods talks about the subject of unit testing static methods.

In short, one wants to unit test ClassA, but ClassA uses some ClassB's static methods.

There, it was advice to wrap those static calls using interfaces and so on..

That is a good solution and sounds like good OO and the code looks pretty much like IoC. But what if you cannot do it. What if you have to call those methods statically (just because the client wants that way, and that's that!)?

Trying to figure out how could I unit test a ClassA, I started to think that I could try to change the system class loader. Such that when a request for ClassA's bytecodes was made, I could return the real ClassA, and when a request for ClassB was made, I could return a faked ClassB (compiled at runtime, for instance).

Does anyone has a clue if it is possible? I've seen that the java command has an "-Xbootclasspath" flag, but I think I doesn't help much.

Or someone has a better idea (but please, don't tell me to say dirty words to the client)?

Thanks.
Itapaj�.

[ EJFH: Fixed link ]
[ November 14, 2005: Message edited by: Ernest Friedman-Hill ]
19 years ago
Thanks to everyone. this 'myjavaserver' seens to work, I will give a look.

thanks again.
Itapaj� S. Takeguma.
20 years ago
[Sory if it is in the wrong topic]

Does anyone know about the existance of the legend of free web hosting (supporting Servlets and perhaps some DB)?

I'd be glad to know about it.

thanks,
Itapaj� S. Takeguma.
20 years ago
it seems wrong to me your statement u're using "select .... VALUES (val1, val2...)" where you should use "selec ... VALUES (" + val1 + ", '" + val2 + "' ...)"

instead you could see preparedStatement.

You could try to put the second jsp page inside a servlet, so you could debug.

hope I could help you,
Itapaj� Takeguma.
20 years ago
JSP
If you want to pass a PARAMETER to the second jsp, you can just do:

<jsp:include page='second.jsp' >
<param name='param1' value='value1' />
</jsp:include>

if you're using <%@ include %> than you shall try to use the page variable or even a request and set an ATTRIBUTE.

Hope I could help,
Itapaj� Takeguma
20 years ago
JSP
sory if there are any posts on this topic, but I couldn't find.

I found an atomic.jar file that could manage file transactions and I was wondering if I could use an entity bean to represent a file system and, some how, tell the container to call the TransactionManager's commit or rollback (inside this atomic.jar).

thanks,
Itapaj�.
Oh, I found it. Thanks again, Monkhouse. I think the result was interesting, so I paste it here:

General Con: 100/100
Documentation: 49 /70
OOD: 30/30
GUI: 22 / 40
Locking: 80/80
Data Store: 40/40
Network Server: 40/40
Total: 361/400

What is funny is that I though documentation and GUI would be the easiest part. Perhaps my gui was not pretty enough and my english is not so good as it should be.

Well, that's it. I would like to thank you (Monkhouse), Peter Wooster and everyone else who makes this a better site every day.

Maybe I'll fill you of questions at SCBCD.

thaks again,
Itapaj� Takeguma
20 years ago
After a delay of 33 days, I saw at www.certmanager.net/sun that I am a SCJD. But I still have a last question, how do I know my score?

thanks,
Itapaj�.

SCJP, SCJD, SCWCD
20 years ago
I started thinking that it would make the interface much easier to use if the user could sort the records (by pressing twice at the table header for example), but, says the assignment,

You will not receive extra credit points for work beyond the requirements of the specification.

does anyone think it would be good to let the user sort the records?

thanks,
Itapaj�.

I will extend my DBAccess Interface.



I asked sun if I could insert a method getScheme in BBMain interface, they said I MUST not insert or remove methods of this interface.

About update the client when the data base changes (my assignemt is that of CSR of Scarper LCC...), when the user presses the book button, first I try to lock, then I read the record and update the table acordingly.

well, that's it.
Itapaj� Takeguma.
SCJD in progress....

Originally posted by Andrew Monkhouse:
Hi Itapaj�,

If you start the RMI Registry programatically from within your application then it will already know the base path structure to your classes, and you will not need to specify the codebase on the command line.

The user's options should be persisted to the properties file - you may find that challenging if the properties file is inside the jar file.

Regards, Andrew



I've never hear about start RMI regitry programatically, could u tell where I can find some reference?

One more thing, should or shouldn't I hava a properties file? If I have some default string may I simply do:
but the assignment says the user will type java -jar server and not java -jar -Djava... server !
(assignment) java -jar <path_and_filename> [<mode>]

and I think that if the property file stay inside the jar, it seens to me more clean. my readme does not have to say "unpack the java.properties file to the current directory...".

thanks guys,
Itapaj�.
hello there,
1)
To run my server aplication I must do java -Djava.rmi.codebase.... ServerFrame server

I think my self how can I creat a JAR file where the user types:
java -jar server if I have to type -Djava...??

2)
another question: if I have a java.properties file in the current directory how can I access this file when it is inside the jar file? I can only access the properties file when put a copy outside the jar file.

thanks,
Itapaj� Takeguma.