Marcelo Ruiz

Greenhorn
+ Follow
since Dec 19, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Marcelo Ruiz

I am working on a java project that MUST use rmic (so automatic stub generation provided by java 1.5+ is NOT an option).
As part of the developing process, I created several JUnit tests, and used the rmic ant task to create the stubs and skeletons as a post-compile task.
The problem I am facing is that rmic does not create stubs and skeletons for test classes. Is there any way I can achieve that?
I am posting a link with a tiny Netbeans project with classes with no body that shows my problem. I created an ant task call 'clean-and-compile-all' that does trigger the rmic ant task, but it is not working as I expect: it just creates the stubs and skeletons for the source directory, nothing for the classes implementing Remote that are in the test one.
I don't want to clutter my source code with test classes.
I will really appreciate if any of you can tell me what I am doing wrong here.

link: Netbeans project
11 years ago
Hi ranchers!
I am running Netbeans 7.2 in Ubuntu 12.04 AMD64 and I am unit testing a GUI with Jemmy.
I would like to know if there is a way to run those tests in a virtual X server, in the same way Jenkins runs its tests (through Xvfb).
Theoretically this should be possible, but I can't find a way to make it work. Any ideas on how to do this?
Thanks!
12 years ago
Hi All,

I wanted you to know that the hard-coded fonts and cursor in the web page makes someone who has a dark theme installed (in my case in Ubuntu 9.10 with Firefox as a browser) impossible to read what is typing while posting a message.
Although it is not a crucial thing (I can write the whole message in a text editor and then copy and paste it into the selected place), it makes using the website use a little harder than it should be.
I guess you might be a way to solve this problem because I don't have it with other web pages.
I am attaching an image for you to see the effect.
Thanks!

Marcelo.
14 years ago
Hi Paul,

Thanks for your answer.
Unfortunately the users of the application are allowed to move the JTable's Columns around, and it will be awkward to have them moving the unit column and the the value one...
The worst part of this problem is that I feel this is something very common and it should have a simple solution... I am just unable to find it...
Do you think of another approach that might work?
Thanks!
14 years ago
Hi Paul,

Unfortunately the examples weren't printed as I expected, so I will post them again as code (each will be in a different column):



At first I thought of using a DefaultTableCellRenderer to return a formatted String of the original value (for example the result of String.format("$/hr %1$d") but that does not solve the alignment problem. I don't know any way to specify this kind of compound-justified alignment with a format String...
I was also thinking of having a custom TableCellRenderer that will return a JPanel with two labels: the first (left oriented) for the unit, and the second (right oriented) for the value. But I feel that is somehow overkilling for cell renderer.
I can't think of another solution and I feel that I missing something that will make my life easier (just with that, of course! )
Do you have any suggestions?
Thanks,

Marcelo
14 years ago
Hi all,

I would like to know if anyone could suggest me an easy way to achieve this:

I need a JTable to show a custom number in one its columns, and I need to ad a prefix to the number (the unit) that needs to be shown left aligned in the cell, and the number needs to be shown right aligned in the same cell. Examples:

"$ 100.00"
"$/hr 99.00"
"m3/s 444"

I know I need to use a custom cell renderer, but I'm having trouble deciding the most efficient way of implementing it. Any suggestions?

Thanks!
14 years ago
Hi Roel,

Thanks for your answer.
My question is related to the SCJD. I have Andrew's book and he uses logging in the example program.
I was wondering if, after deciding using logging, I would get into trouble for not following (possibly existent) logging best practices. I am surprised nothing of that is published somewhere (especially after considering the detail of Sun's code conventions).
I guess I'll stick to option #1 unless someone else points me to another direction!
Again, thanks for your answer.

Marcelo.
Hi All!

I have a question related to the proper use of logging. Maybe somebody will clarify the situation for me.

Please consider the following scenario, where three classes (each of them produce logging) are involved to allow an user to (lets say) send an e-mail. Suppose all of them have a method called "void sendMail", but the method in Class C is where the functionality is implemented: class A delegates to class B which in turn delegates to class C.

Now, lets suppose I want to add logging to my program. My question problem is deciding "What and where to log".
The following are the options I considered (along with the reasoning for each one):

Class A -------------> Class B -------------> Class C (sends the e-mail)


Option #1
---------
Class A:
entering
exiting

Class B:
entering
exiting

Class C:
entering
info (mail sent)
exiting

Reasoning: the important action happens in Class C, so log the info message just there.


Option #2
---------
Class A:
entering
info (mail sent)
exiting

Class B:
entering
info (mail sent)
exiting

Class C:
entering
info (mail sent)
exiting

Reasoning: someone reading the log of Class A should know the action happened, and that person does not care how many chained low level calls were made.


Option #3
---------
Class A:
entering
info (mail sent)
exiting

Class B:
entering
fine (mail sent)
exiting

Class C:
entering
finer (mail sent)
exiting

Reasoning: the info log should be logged at the highest level class, and the lower level classes should log "less important" messages in case tracking all the calls is necessary.


Option #4
---------
Class A:
entering
info (mail sent)
exiting

Class B:
entering
exiting

Class C:
entering
exiting

Reasoning: the info log should be logged at the highest level class, and the lower level classes are just helper classes that should not produce any log except (except for entering/exiting/arguments/returning).


I guess the same could be ask for an exceptions being thrown. So I am basically trying to get a best practice advice (I guess there should be a best practice guideline for logging somewhere... or maybe there is a book or an article about this? :S I could only find on-line logging tutorials that teach how to use the API and the reasoning for using the different logging Levels, but no explanation about how to solve this problem).
I would appreciate to hear which option (they might be more I just didn't think about, so please feel free to add them) would you choose and why.


Thank you all!

Marcelo
@Johnny

Thanks for your comments, but it is not related to the problem I had.

@Dennis

Thanks... Yeah, it is weird that is the default setting in a fresh installation. After researching more is not just a Java RMI-related problem.
Also, I think there is a problem with when Java stops the RMI Registry. I think at least they should add a: "isRunning()" method or something like that to Registry, so one can figure out if a new call to create() is needed instead of getRegistry(). This last one can return a new reference to a registry that is not initialized, and the exception you get does not help much to determine the origin of the problem.

Marcelo.
Hello Ranchers!

Roberto is right about the rmic task, but be aware that rmic ant task does a pretty lame job with processing JUnit test clases, specially inner classes. This will really annoy you if you use TDD (I try to do it most of the time) and want to have complete test cases for the client/server portion... otherwise it will create the stubs and skeletons for help you with no problem.

Ciao for now!

Marcelo.
Hello Ranchers!

I am getting frustrated with Java RMI running on Linux (I use Ubuntu 9.04). Maybe some of you faced the same problem I do now and found a solution for this, and I will really appreciate your help with this.

I get a RemoteException each time I try to bind a stub with the RMI Registry.

I do rmic the code before executing it and as far as I know I don't need to be worried about setting up a policy file or a SecurityManager for this (I have Andrew's and Terry's SCJD book and I probably read the RMI chapter 1000 times to try to find out a lead to my problem with no luck).

## My /etc/hosts file content:


## My /etc/hosts.allow file content:


## The (trimmed and simplyfied) relevant part of my code follows:



## stub information:

DataServerImpl_Stub[UnicastRef [liveRef: [endpoint:[lobo-laptop:47839](local),objID:[-31110a77:12407db5840:-7fff, -6460063892832792796]]]]

## registry information:

RegistryImpl_Stub[UnicastRef [liveRef: [endpoint:[127.0.1.1:1099](remote),objID:[0:0:0, 0]]]]

## Exception information:




It looks weird to me that the Registry implementation was bound to 127.0.1.1, and also that its ObjID is [0:0:0, 0].
It also seems that hava is not able to create sockets, but Ubuntu's log mechanism has no information about it.

Any ideas on how to solve this (besides using Windows, of course)?
Thanks a lot!

Marcelo
Hi Roberto,

Thanks again for your answer. I am designing my solution with the concept of layer isolation in mind.
I am wondering if any native English speaker could explain me why the second solution should be the one to implement. I really want to understand if I am misinterpretating the specification, or if is a lack of common sense, or whatever.
Could I fail the certification by implementing the first solution? I am concern with the initial software checks...
Thanks again Roberto for all your help,

Marcelo.
Oi Roberto! Muito Obrigado!

I already programmed the database assuming the mapping starting at 0. But I was wondering if the first approach adjusts better to the specifications (which will give me the extra benefit of using the first element of the array for versioning).

I was wondering about that because re-reading the specification (Bodgitt & Scarper) I realized that in the Server section it requires the data access class to be called Data.java, and I previously assumed that was the class for accessing the database locally, not the one the server should return to its clients (if I am understanding that well)... The point is that, after noticing that, I tried to find unclear points in the specification, and the mapping issue was one of them.

Thanks for you help!

Marcelo.
Hello Ranchers!

I have a kind-of-silly question regarding mapping the database record with the String Array that the required interface requests.

My problem is from the understanding of how mapping works, and maybe because English is not my first language.

This is from my specifications:

* (1) From the read method: "...Returns an array where each element is a record value..."

* (2) From the find method: "...Field n in the database file is described by criteria[n]..."

* (3) From the update method: "...The new value for field n appears in data[n]..."

The confusion I have is that (at least in my mother tongue) we start counting at 1. So if the database has 6 fields (like in B&S) field 1 (the first one) will be "name", and so on...

So, according to (3) the mapping should be:

Data[0] -> No mapping defined (it could be used for versioning)
Data[1] -> Db Field 1: "name"
Data[2] -> Db Field 2: "location"
Data[3] -> Db Field 3: "specialties"
Data[4] -> Db Field 4: "size"
Data[5] -> Db Field 5: "rate"
Data[6] -> Db Field 6: "owner"

The result of this approach is that my Data[] length will always be equal to the number of fields in the database PLUS ONE.

So far, all the postings that I read in this forum use this mapping:

Data[0] -> Db Field 1: "name"
Data[1] -> Db Field 2: "location"
Data[2] -> Db Field 3: "specialties"
Data[3] -> Db Field 4: "size"
Data[4] -> Db Field 5: "rate"
Data[5] -> Db Field 6: "owner

The result of this approach is that my Data[] length will always be equal to the number of fields in the database.

I would like to hear/read your thoughts about this.
Cheers,

Marcelo.
Hi Fernando and Roel!

Thanks for your answers... I was feeling a little confused about the topic...

Marcelo