Question

Is it possible to do JUnit on a command line?

Asked by: kayvey

I have a set of classes and an associated set of test classes that Is successfully running on my laptop with eclipse.  

Now I need to run these on a single core processor, which I must access through ssh on a terminal command line.  Is there a javac option or a package to include or something to make this work on the command line?

Note: LockFreeList.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
kayve@netlab1 ~/HW4/src $ javac -Xlint *.java
LockFreeList.java:51: warning: [unchecked] unchecked call to AtomicMarkableReference(V,boolean) as a member of the raw type java.util.concurrent.atomic.AtomicMarkableReference
        node.next = new AtomicMarkableReference(curr, false);
                    ^
LockFreeList.java:51: warning: [unchecked] unchecked conversion
found   : java.util.concurrent.atomic.AtomicMarkableReference
required: java.util.concurrent.atomic.AtomicMarkableReference<lists.LockFreeList<T>.Node>
        node.next = new AtomicMarkableReference(curr, false);
                    ^
2 warnings
kayve@netlab1 ~/HW4/src $ cd ../test
kayve@netlab1 ~/HW4/test $ ls
CoarseListTest.java  FineListTest.java  LazyListTest.java  LockFreeListTest.java  OptimisticListTest.java
kayve@netlab1 ~/HW4/test $ javac -Xlint *.java
CoarseListTest.java:9: package junit.framework does not exist
import junit.framework.*;
^
CoarseListTest.java:14: cannot find symbol
symbol: class TestCase
public class CoarseListTest extends TestCase {
                                    ^
CoarseListTest.java:19: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
  CoarseList<Integer> instance;
  ^
CoarseListTest.java:27: cannot find symbol
symbol  : class Test
location: class lists.CoarseListTest
  public static Test suite() {
                ^
FineListTest.java:9: package junit.framework does not exist
import junit.framework.*;
^
FineListTest.java:14: cannot find symbol
symbol: class TestCase
public class FineListTest extends TestCase {
                                  ^
FineListTest.java:19: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
  FineList<Integer> instance;
  ^
FineListTest.java:27: cannot find symbol
symbol  : class Test
location: class lists.FineListTest
  public static Test suite() {
                ^
LazyListTest.java:9: package junit.framework does not exist
import junit.framework.*;
^
LazyListTest.java:14: cannot find symbol
symbol: class TestCase
public class LazyListTest extends TestCase {
                                  ^
LazyListTest.java:19: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
  LazyList<Integer> instance;
  ^
LazyListTest.java:27: cannot find symbol
symbol  : class Test
location: class lists.LazyListTest
  public static Test suite() {
                ^
LockFreeListTest.java:9: package junit.framework does not exist
import junit.framework.*;
^
LockFreeListTest.java:14: cannot find symbol
symbol: class TestCase
public class LockFreeListTest extends TestCase {
                                      ^
LockFreeListTest.java:19: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
  LockFreeList<Integer> instance;
  ^
LockFreeListTest.java:27: cannot find symbol
symbol  : class Test
location: class lists.LockFreeListTest
  public static Test suite() {
                ^
OptimisticListTest.java:9: package junit.framework does not exist
import junit.framework.*;
^
OptimisticListTest.java:14: cannot find symbol
symbol: class TestCase
public class OptimisticListTest extends TestCase {
                                        ^
OptimisticListTest.java:19: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
  OptimisticList<Integer> instance;
  ^
OptimisticListTest.java:27: cannot find symbol
symbol  : class Test
location: class lists.OptimisticListTest
  public static Test suite() {
                ^
CoarseListTest.java:24: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
    instance = new CoarseList<Integer>();
                   ^
CoarseListTest.java:28: cannot find symbol
symbol  : class TestSuite
location: class lists.CoarseListTest
    TestSuite suite = new TestSuite(CoarseListTest.class);
    ^
CoarseListTest.java:28: cannot find symbol
symbol  : class TestSuite
location: class lists.CoarseListTest
    TestSuite suite = new TestSuite(CoarseListTest.class);
                          ^
CoarseListTest.java:44: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.CoarseListTest
        fail("bad contains: " + i );
        ^
CoarseListTest.java:49: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.CoarseListTest
        fail("bad remove: " + i );
        ^
CoarseListTest.java:70: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.CoarseListTest
        fail("bad contains: " + i );
        ^
CoarseListTest.java:75: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.CoarseListTest
        fail("bad remove: " + i );
        ^
CoarseListTest.java:91: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.CoarseListTest
        fail("bad contains: " + i );
        ^
CoarseListTest.java:145: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.CoarseListTest.RemoveThread
          fail("RemoveThread: duplicate remove: " + (value + i));
          ^
FineListTest.java:24: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
    instance = new FineList<Integer>();
                   ^
FineListTest.java:28: cannot find symbol
symbol  : class TestSuite
location: class lists.FineListTest
    TestSuite suite = new TestSuite(FineListTest.class);
    ^
FineListTest.java:28: cannot find symbol
symbol  : class TestSuite
location: class lists.FineListTest
    TestSuite suite = new TestSuite(FineListTest.class);
                          ^
FineListTest.java:44: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.FineListTest
        fail("bad contains: " + i );
        ^
FineListTest.java:49: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.FineListTest
        fail("bad remove: " + i );
        ^
FineListTest.java:70: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.FineListTest
        fail("bad contains: " + i );
        ^
FineListTest.java:75: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.FineListTest
        fail("bad remove: " + i );
        ^
FineListTest.java:91: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.FineListTest
        fail("bad contains: " + i );
        ^
FineListTest.java:145: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.FineListTest.RemoveThread
          fail("RemoveThread: duplicate remove: " + (value + i));
          ^
LazyListTest.java:24: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
    instance = new LazyList();
                   ^
LazyListTest.java:28: cannot find symbol
symbol  : class TestSuite
location: class lists.LazyListTest
    TestSuite suite = new TestSuite(LazyListTest.class);
    ^
LazyListTest.java:28: cannot find symbol
symbol  : class TestSuite
location: class lists.LazyListTest
    TestSuite suite = new TestSuite(LazyListTest.class);
                          ^
LazyListTest.java:44: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LazyListTest
        fail("bad contains: " + i );
        ^
LazyListTest.java:49: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LazyListTest
        fail("bad remove: " + i );
        ^
LazyListTest.java:69: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LazyListTest
        fail("bad contains: " + i );
        ^
LazyListTest.java:74: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LazyListTest
        fail("bad remove: " + i );
        ^
LazyListTest.java:89: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LazyListTest
        fail("bad contains: " + i );
        ^
LazyListTest.java:142: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LazyListTest.RemoveThread
          fail("RemoveThread: duplicate remove");
          ^
LockFreeListTest.java:24: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
    instance = new LockFreeList<Integer>();
                   ^
LockFreeListTest.java:28: cannot find symbol
symbol  : class TestSuite
location: class lists.LockFreeListTest
    TestSuite suite = new TestSuite(LockFreeListTest.class);
    ^
LockFreeListTest.java:28: cannot find symbol
symbol  : class TestSuite
location: class lists.LockFreeListTest
    TestSuite suite = new TestSuite(LockFreeListTest.class);
                          ^
LockFreeListTest.java:44: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LockFreeListTest
        fail("bad contains: " + i );
        ^
LockFreeListTest.java:49: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LockFreeListTest
        fail("bad remove: " + i );
        ^
LockFreeListTest.java:70: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LockFreeListTest
        fail("bad contains: " + i );
        ^
LockFreeListTest.java:75: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LockFreeListTest
        fail("bad remove: " + i );
        ^
LockFreeListTest.java:91: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LockFreeListTest
        fail("bad contains: " + i );
        ^
LockFreeListTest.java:145: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.LockFreeListTest.RemoveThread
          fail("RemoveThread: duplicate remove: " + (value + i));
          ^
OptimisticListTest.java:24: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
    instance = new OptimisticList<Integer>();
                   ^
OptimisticListTest.java:28: cannot find symbol
symbol  : class TestSuite
location: class lists.OptimisticListTest
    TestSuite suite = new TestSuite(OptimisticListTest.class);
    ^
OptimisticListTest.java:28: cannot find symbol
symbol  : class TestSuite
location: class lists.OptimisticListTest
    TestSuite suite = new TestSuite(OptimisticListTest.class);
                          ^
OptimisticListTest.java:44: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.OptimisticListTest
        fail("bad contains: " + i );
        ^
OptimisticListTest.java:49: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.OptimisticListTest
        fail("bad remove: " + i );
        ^
OptimisticListTest.java:70: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.OptimisticListTest
        fail("bad contains: " + i );
        ^
OptimisticListTest.java:75: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.OptimisticListTest
        fail("bad remove: " + i );
        ^
OptimisticListTest.java:91: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.OptimisticListTest
        fail("bad contains: " + i );
        ^
OptimisticListTest.java:145: cannot find symbol
symbol  : method fail(java.lang.String)
location: class lists.OptimisticListTest.RemoveThread
          fail("RemoveThread: duplicate remove: " + (value + i));
          ^
65 errors
kayve@netlab1 ~/HW4/test $ pwd
/home/kayve/HW4/test
kayve@netlab1 ~/HW4/test $ 
                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-11-04 at 10:59:30ID24872011
Topics

Java Programming Language

,

Ubuntu

,

Gentoo Linux

Participating Experts
1
Points
500
Comments
33

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Javac  *
    Hi guys I am new to Java, there are many samples on the web sites Something bothering me is that .. Why some of the samples i got to compile as below ? javac *.java (using asterisk instead of the actual program name.java) Thanks blur
  2. JUnit installation
    I've been searching all over trying to understand why I can't get JUnit to work to no avail. Here's what I've done, exactly as the instructions say: >>>>How do I install JUnit? >>>>First, download the latest version of JUnit, referred to below as ju...
  3. configure: error: javac not found
    Hi, Please kindly assist what could have been missing, installing tomcat as daemon on fedora core 3. #cd /bin #tar xvfz jsvc.tar.gz #cd jsvc-src #chmod +711 ./configure # ./configure --with-java=/usr/java/jdk1.5.0_04/bin/ <---error sad to say, a error message ...
  4. Javac
    What happened to javac in the sdk 1.5 build 6? I used to command line build java files with javac X.java. What should I use instead?

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: kayveyPosted on 2009-11-04 at 11:00:16ID: 25742628

this is my laptop:

sftp> quit
kayve@kayve-laptop:~/workspace/HW4/test/lists$ uname -a
Linux kayve-laptop 2.6.28-16-generic #55-Ubuntu SMP Tue Oct 20 19:48:24 UTC 2009 i686 GNU/Linux
kayve@kayve-laptop:~/workspace/HW4/test/lists$


this is the single core machine:

/home/kayve/HW4/test
kayve@netlab1 ~/HW4/test $ uname -a
Linux netlab1 2.6.25-gentoo-r7 #1 SMP Thu Aug 28 11:55:42 PDT 2008 i686 Intel(R) Celeron(R) CPU 2.60GHz GenuineIntel GNU/Linux
kayve@netlab1 ~/HW4/test $

 

by: objectsPosted on 2009-11-04 at 12:31:59ID: 25743585

you need to include junit jar in your classpath

javac -Xlint -classpath junit.jar:. *.java

 

by: kayveyPosted on 2009-11-04 at 13:23:51ID: 25744096

oh oh.  does this mean some sysadmin work needs to be done?

kayve@netlab1 ~/HW4 $ cd test
kayve@netlab1 ~/HW4/test $ javac -Xlint -classpath junit.jar:. *.java
warning: [path] bad path element "junit.jar": no such file or directory
CoarseListTest.java:9: package junit.framework does not exist
import junit.framework.*;

 

by: objectsPosted on 2009-11-04 at 13:28:25ID: 25744140

> kayve@netlab1 ~/HW4/test $ javac -Xlint -classpath junit.jar:. *.java

you'll need to change that to include the actual path to your junit jar (I don't know where you keep it)

 

by: kayveyPosted on 2009-11-04 at 13:33:38ID: 25744180

umm.. I changed the "/"'s to "."'s ?

kayve@netlab1 ~/HW4/test $ find / -name junit 2> /dev/null
/usr/portage/dev-java/junit

 

by: kayveyPosted on 2009-11-04 at 13:34:18ID: 25744186

changed = will change

 

by: objectsPosted on 2009-11-04 at 13:38:28ID: 25744232

eg. if the path to junit jar is /usr/portage/dev-java/junit/junit.jar

then you would use:


javac -Xlint -classpath /usr/portage/dev-java/junit/junit.jar:. *.java

 

by: kayveyPosted on 2009-11-04 at 13:41:12ID: 25744255

There's no jar.. what about these other things?

kayve@netlab1 ~/HW4/test $ ls /usr/portage/dev-java/junit
ChangeLog  files                  junit-3.8.2-r1.ebuild  metadata.xml
Manifest   junit-3.8.1-r3.ebuild  junit-4.4-r1.ebuild
kayve@netlab1 ~/HW4/test $ ls /usr/portage/dev-java/junit/files
junit-3.8.2-build.xml
kayve@netlab1 ~/HW4/test $

 

by: objectsPosted on 2009-11-04 at 13:53:07ID: 25744362

you need the junit jar to be able to compile (and run) your tests
you can download it from http://www.junit.org/

 

by: kayveyPosted on 2009-11-04 at 14:07:02ID: 25744513

Do I need root access on the machine?

 

by: kayveyPosted on 2009-11-04 at 14:07:18ID: 25744515

..because I don't have it {:}

 

by: kayveyPosted on 2009-11-04 at 14:08:29ID: 25744528

The most recent one?.. I was using 3.8.1 on my other platform

 

by: objectsPosted on 2009-11-04 at 14:12:20ID: 25744571

> The most recent one?.. I was using 3.8.1 on my other platform

the version you use is up to you. best to be consistent

 

by: kayveyPosted on 2009-11-04 at 14:19:07ID: 25744638

darn

kayve@netlab1 ~/HW4/test $ ls
CoarseListTest.java  LazyListTest.java      OptimisticListTest.java
FineListTest.java    LockFreeListTest.java
kayve@netlab1 ~/HW4/test $ ls ..
junit-4.7.jar  src  test
kayve@netlab1 ~/HW4/test $ javac -Xlint -classpath ../junit-4.7.jar:. *.java
CoarseListTest.java:19: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
  CoarseList<Integer> instance;
  ^
FineListTest.java:19: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
  FineList<Integer> instance;
  ^
LazyListTest.java:19: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
  LazyList<Integer> instance;
  ^
LockFreeListTest.java:19: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
  LockFreeList<Integer> instance;
  ^
OptimisticListTest.java:19: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
  OptimisticList<Integer> instance;
  ^
CoarseListTest.java:24: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
    instance = new CoarseList<Integer>();
                   ^
FineListTest.java:24: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
    instance = new FineList<Integer>();
                   ^
LazyListTest.java:24: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
    instance = new LazyList();
                   ^
LockFreeListTest.java:24: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
    instance = new LockFreeList<Integer>();
                   ^
OptimisticListTest.java:24: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
    instance = new OptimisticList<Integer>();
                   ^
10 errors
kayve@netlab1 ~/HW4/test $ mv ../junit-4.7.jar .
kayve@netlab1 ~/HW4/test $ javac -Xlint -classpath junit-4.7.jar:. *.java
CoarseListTest.java:19: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
  CoarseList<Integer> instance;
  ^
FineListTest.java:19: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
  FineList<Integer> instance;
  ^
LazyListTest.java:19: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
  LazyList<Integer> instance;
  ^
LockFreeListTest.java:19: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
  LockFreeList<Integer> instance;
  ^
OptimisticListTest.java:19: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
  OptimisticList<Integer> instance;
  ^
CoarseListTest.java:24: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
    instance = new CoarseList<Integer>();
                   ^
FineListTest.java:24: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
    instance = new FineList<Integer>();
                   ^
LazyListTest.java:24: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
    instance = new LazyList();
                   ^
LockFreeListTest.java:24: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
    instance = new LockFreeList<Integer>();
                   ^
OptimisticListTest.java:24: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
    instance = new OptimisticList<Integer>();
                   ^
10 errors
kayve@netlab1 ~/HW4/test $ javac -Xlint -classpath ./junit-4.7.jar:. *.java
CoarseListTest.java:19: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
  CoarseList<Integer> instance;
  ^
FineListTest.java:19: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
  FineList<Integer> instance;
  ^
LazyListTest.java:19: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
  LazyList<Integer> instance;
  ^
LockFreeListTest.java:19: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
  LockFreeList<Integer> instance;
  ^
OptimisticListTest.java:19: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
  OptimisticList<Integer> instance;
  ^
CoarseListTest.java:24: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
    instance = new CoarseList<Integer>();
                   ^
FineListTest.java:24: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
    instance = new FineList<Integer>();
                   ^
LazyListTest.java:24: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
    instance = new LazyList();
                   ^
LockFreeListTest.java:24: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
    instance = new LockFreeList<Integer>();
                   ^
OptimisticListTest.java:24: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
    instance = new OptimisticList<Integer>();
                   ^
10 errors
kayve@netlab1 ~/HW4/test $ 
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:

Select allOpen in new window

 

by: objectsPosted on 2009-11-04 at 15:33:54ID: 25745340

you need to tell it where all your classes are, try

javac -Xlint -classpath ../junit-4.7.jar:../src:. *.java

 

by: kayveyPosted on 2009-11-04 at 17:49:49ID: 25746079

This is confusing

1 warning
kayve@netlab1 ~/HW4/test $ ls
CoarseListTest.java  LazyListTest.java      OptimisticListTest.java
FineListTest.java    LockFreeListTest.java
kayve@netlab1 ~/HW4/test $ ls ..
junit-4.7.jar  src  test
kayve@netlab1 ~/HW4/test $ ls ../src
CoarseList$Node.class  LazyList$Node.class        LockFreeList.java
CoarseList.class       LazyList.class             OptimisticList$Entry.class
CoarseList.java        LazyList.java              OptimisticList.class
FineList$Node.class    LockFreeList$Node.class    OptimisticList.java
FineList.class         LockFreeList$Window.class
FineList.java          LockFreeList.class
kayve@netlab1 ~/HW4/test $ javac -Xlint -classpath ../junit-4.7.jar:.../src:. *.java
warning: [path] bad path element ".../src": no such file or directory
CoarseListTest.java:19: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
  CoarseList<Integer> instance;
  ^
FineListTest.java:19: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
  FineList<Integer> instance;
  ^
LazyListTest.java:19: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
  LazyList<Integer> instance;
  ^
LockFreeListTest.java:19: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
  LockFreeList<Integer> instance;
  ^
OptimisticListTest.java:19: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
  OptimisticList<Integer> instance;
  ^
CoarseListTest.java:24: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
    instance = new CoarseList<Integer>();
                   ^
FineListTest.java:24: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
    instance = new FineList<Integer>();
                   ^
LazyListTest.java:24: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
    instance = new LazyList();
                   ^
LockFreeListTest.java:24: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
    instance = new LockFreeList<Integer>();
                   ^
OptimisticListTest.java:24: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
    instance = new OptimisticList<Integer>();
                   ^
10 errors
1 warning
kayve@netlab1 ~/HW4/test $ 
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:

Select allOpen in new window

 

by: kayveyPosted on 2009-11-04 at 17:50:51ID: 25746087

there was a typo

kayve@netlab1 ~/HW4/test $ javac -Xlint -classpath ../junit-4.7.jar:../src:. *.java
CoarseListTest.java:19: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
  CoarseList<Integer> instance;
  ^
FineListTest.java:19: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
  FineList<Integer> instance;
  ^
LazyListTest.java:19: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
  LazyList<Integer> instance;
  ^
LockFreeListTest.java:19: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
  LockFreeList<Integer> instance;
  ^
OptimisticListTest.java:19: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
  OptimisticList<Integer> instance;
  ^
CoarseListTest.java:24: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
    instance = new CoarseList<Integer>();
                   ^
FineListTest.java:24: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
    instance = new FineList<Integer>();
                   ^
LazyListTest.java:24: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
    instance = new LazyList();
                   ^
LockFreeListTest.java:24: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
    instance = new LockFreeList<Integer>();
                   ^
OptimisticListTest.java:24: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
    instance = new OptimisticList<Integer>();
                   ^
10 errors
kayve@netlab1 ~/HW4/test $ 
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:

Select allOpen in new window

 

by: objectsPosted on 2009-11-04 at 17:54:42ID: 25746103

you need to tell it where the missing classes are, eg. CoarseList, FineList etc.

 

by: kayveyPosted on 2009-11-04 at 17:57:43ID: 25746118

they are in ../src  I thought I showed the listing.

 

by: kayveyPosted on 2009-11-04 at 17:59:46ID: 25746128

                  ^
LockFreeListTest.java:24: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
    instance = new LockFreeList<Integer>();
                   ^
OptimisticListTest.java:24: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
    instance = new OptimisticList<Integer>();
                   ^
10 errors
kayve@netlab1 ~/HW4/test $ grep LockFreeList ../src/*
Binary file ../src/LockFreeList$Node.class matches
Binary file ../src/LockFreeList$Window.class matches
Binary file ../src/LockFreeList.class matches
../src/LockFreeList.java: * LockFreeList.java
../src/LockFreeList.java:public class LockFreeList<T> {
../src/LockFreeList.java:  public LockFreeList() {
kayve@netlab1 ~/HW4/test $

 

by: objectsPosted on 2009-11-04 at 18:04:01ID: 25746146

are your classes in packages? if you need to ensure the classes are in directory structure that matches your package

 

by: kayveyPosted on 2009-11-04 at 18:08:45ID: 25746173

umm.. maybe here is one of the files:

 * CoarseList.java
package lists;
import java.util.concurrent.locks.Lock;
/**
 * List using coarse-grained synchronization.
 * @param T Item type.
 * @author Maurice Herlihy
 */
public class CoarseList<T> {

at least the top.  How do I do that?

 

by: objectsPosted on 2009-11-04 at 18:32:54ID: 25746271

> package lists;

it is in package so it needs to be in directory src/lists

 

by: kayveyPosted on 2009-11-04 at 18:34:40ID: 25746278

umm.. move all the files?

*@&#@ these crazy path issues!

 

by: kayveyPosted on 2009-11-04 at 18:36:20ID: 25746283

*&@#

use -help for a list of possible options
kayve@netlab1 ~/HW4/src $ popd
~/HW4/test
kayve@netlab1 ~/HW4/test $ javac -Xlint -classpath ../junit-4.7.jar:../src/lists:. *.java
CoarseListTest.java:19: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
  CoarseList<Integer> instance;
  ^
FineListTest.java:19: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
  FineList<Integer> instance;
  ^
LazyListTest.java:19: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
  LazyList<Integer> instance;
  ^
LockFreeListTest.java:19: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
  LockFreeList<Integer> instance;
  ^
OptimisticListTest.java:19: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
  OptimisticList<Integer> instance;
  ^
CoarseListTest.java:24: cannot find symbol
symbol  : class CoarseList
location: class lists.CoarseListTest
    instance = new CoarseList<Integer>();
                   ^
FineListTest.java:24: cannot find symbol
symbol  : class FineList
location: class lists.FineListTest
    instance = new FineList<Integer>();
                   ^
LazyListTest.java:24: cannot find symbol
symbol  : class LazyList
location: class lists.LazyListTest
    instance = new LazyList();
                   ^
LockFreeListTest.java:24: cannot find symbol
symbol  : class LockFreeList
location: class lists.LockFreeListTest
    instance = new LockFreeList<Integer>();
                   ^
OptimisticListTest.java:24: cannot find symbol
symbol  : class OptimisticList
location: class lists.OptimisticListTest
    instance = new OptimisticList<Integer>();
                   ^
10 errors
kayve@netlab1 ~/HW4/test $ ls
CoarseListTest.java  LazyListTest.java      OptimisticListTest.java
FineListTest.java    LockFreeListTest.java
kayve@netlab1 ~/HW4/test $ ls ../src
lists
kayve@netlab1 ~/HW4/test $ ls ../src/lists
CoarseList$Node.class  FineList.class       LazyList.java              LockFreeList.java
CoarseList.class       FineList.java        LockFreeList$Node.class    OptimisticList$Entry.class
CoarseList.java        LazyList$Node.class  LockFreeList$Window.class  OptimisticList.class
FineList$Node.class    LazyList.class       LockFreeList.class         OptimisticList.java
kayve@netlab1 ~/HW4/test $ 
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:

Select allOpen in new window

 

by: objectsPosted on 2009-11-04 at 18:39:34ID: 25746298

> javac -Xlint -classpath ../junit-4.7.jar:../src/lists:. *.java

you didn't need to change the javac command

 

by: kayveyPosted on 2009-11-04 at 18:43:34ID: 25746314

OKAY it compiled but now I am confused on how to run it I guess

kayve@netlab1 ~/HW4/test $ javac -Xlint -classpath ../junit-4.7.jar:../src:. *.java
LazyListTest.java:24: warning: [unchecked] unchecked conversion
found   : lists.LazyList
required: lists.LazyList<java.lang.Integer>
    instance = new LazyList();
               ^
1 warning
kayve@netlab1 ~/HW4/test $ ls
CoarseListTest$AddThread.class     LazyListTest.class
CoarseListTest$RemoveThread.class  LazyListTest.java
CoarseListTest.class               LockFreeListTest$AddThread.class
CoarseListTest.java                LockFreeListTest$RemoveThread.class
FineListTest$AddThread.class       LockFreeListTest.class
FineListTest$RemoveThread.class    LockFreeListTest.java
FineListTest.class                 OptimisticListTest$AddThread.class
FineListTest.java                  OptimisticListTest$RemoveThread.class
LazyListTest$AddThread.class       OptimisticListTest.class
LazyListTest$RemoveThread.class    OptimisticListTest.java
kayve@netlab1 ~/HW4/test $ java LazyListTest
Exception in thread "main" java.lang.NoClassDefFoundError: LazyListTest (wrong name: lists/LazyListTest)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	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:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
kayve@netlab1 ~/HW4/test $ ls
CoarseListTest$AddThread.class     LazyListTest.class
CoarseListTest$RemoveThread.class  LazyListTest.java
CoarseListTest.class               LockFreeListTest$AddThread.class
CoarseListTest.java                LockFreeListTest$RemoveThread.class
FineListTest$AddThread.class       LockFreeListTest.class
FineListTest$RemoveThread.class    LockFreeListTest.java
FineListTest.class                 OptimisticListTest$AddThread.class
FineListTest.java                  OptimisticListTest$RemoveThread.class
LazyListTest$AddThread.class       OptimisticListTest.class
LazyListTest$RemoveThread.class    OptimisticListTest.java
kayve@netlab1 ~/HW4/test $ mkdir lists
kayve@netlab1 ~/HW4/test $ mv * lists
mv: cannot move `lists' to a subdirectory of itself, `lists/lists'
kayve@netlab1 ~/HW4/test $ cd lists/
kayve@netlab1 ~/HW4/test/lists $ java LazyListTest
Exception in thread "main" java.lang.NoClassDefFoundError: LazyListTest (wrong name: lists/LazyListTest)
	at java.lang.ClassLoader.defineClass1(Native Method)
	at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
	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:306)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
kayve@netlab1 ~/HW4/test/lists $ 
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:

Select allOpen in new window

 

by: objectsPosted on 2009-11-04 at 18:50:14ID: 25746344

> kayve@netlab1 ~/HW4/test $ java LazyListTest
> Exception in thread "main" java.lang.NoClassDefFoundError: LazyListTest (wrong name: lists/LazyListTest)

looks like your test class is also in a package, so you need to specify the full name to run it (and include the classpath)

java -classpath ../junit-4.7.jar:../src:. lists.LazyListTest

 

by: kayveyPosted on 2009-11-04 at 18:59:27ID: 25746392

Maybe I have to run it as JUint?  oh.  we are doing that?

kayve@netlab1 ~/HW4/test $ java -classpath ../junit-4.7.jar:../src:. lists.LazyListTest
Exception in thread "main" java.lang.NoSuchMethodError: main
kayve@netlab1 ~/HW4/test $


package lists; 
import junit.framework.*; 
/**
 * @author Maurice Herlihy
 */
public class LazyListTest extends TestCase {
  
  private final static int THREADS = 8;
  private final static int TEST_SIZE = 512;
  private final static int PER_THREAD = TEST_SIZE / THREADS;
  LazyList<Integer> instance;
  Thread[] thread = new Thread[THREADS];
  
  public LazyListTest(String testName) {
    super(testName);
    instance = new LazyList();
  }
  
  public static Test suite() {
    TestSuite suite = new TestSuite(LazyListTest.class);
    
    return suite;
  }
  
  /**
   * Sequential calls.
   */
  public void testSequential() {
    System.out.println("sequential add, contains, and remove");
    
    for (int i = 0; i < TEST_SIZE; i++) {
      instance.add(i);
    }
    for (int i = 0; i < TEST_SIZE; i++) {
      if (!instance.contains(i)) {
        fail("bad contains: " + i );
      }
    }
    for (int i = 0; i < TEST_SIZE; i++) {
      if (!instance.remove(i)) {
        fail("bad remove: " + i );
      }
    }
  }
  /**
   * Parallel add, sequential removes
   */
  public void testParallelAdd()  throws Exception {
    System.out.println("parallel add");
    for (int i = 0; i < THREADS; i++) {
      thread[i] = new AddThread(i * PER_THREAD);
    }
    for (int i = 0; i < THREADS; i ++) {
      thread[i].start();
    }
    for (int i = 0; i < THREADS; i ++) {
      thread[i].join();
    }
    for (int i = 0; i < TEST_SIZE; i++) {
      if (!instance.contains(i)) {
        fail("bad contains: " + i );
      }
    }
    for (int i = 0; i < TEST_SIZE; i++) {
      if (!instance.remove(i)) {
        fail("bad remove: " + i );
      }
    }
  } 
  /**
   * Sequential adds, parallel removes
   */
  public void testParallelRemove()  throws Exception {
    System.out.println("parallel remove");
    for (int i = 0; i < TEST_SIZE; i++) {
      instance.add(i);
    }
    for (int i = 0; i < TEST_SIZE; i++) {
      if (!instance.contains(i)) {
        fail("bad contains: " + i );
      }
    }
    for (int i = 0; i < THREADS; i++) {
      thread[i] = new RemoveThread(i * PER_THREAD);
    }
    for (int i = 0; i < THREADS; i ++) {
      thread[i].start();
    }
    for (int i = 0; i < THREADS; i ++) {
      thread[i].join();
    }
  }
  
  /**
   * Parallel adds, removes
   */
  public void testParallelBoth()  throws Exception {
    System.out.println("parallel both");
    Thread[] myThreads = new Thread[2 * THREADS];
    for (int i = 0; i < THREADS; i++) {
      myThreads[i] = new AddThread(i * PER_THREAD);
      myThreads[i + THREADS] = new RemoveThread(i * PER_THREAD);
    }
    for (int i = 0; i < 2 * THREADS; i ++) {
      myThreads[i].start();
    }
    for (int i = 0; i < 2 * THREADS; i ++) {
      myThreads[i].join();
    }
  }
  class AddThread extends Thread {
    int value;
    AddThread(int i) {
      value = i;
    }
    public void run() {
      for (int i = 0; i < PER_THREAD; i++) {
        if (value + i == 128) {
          int z =0;
        }
        instance.add(value + i);
      }
    }
  }
  class RemoveThread extends Thread {
    int value;
    RemoveThread(int i) {
      value = i;
    }
    public void run() {
      for (int i = 0; i < PER_THREAD; i++) {
        if (!instance.remove(value + i)) {
          fail("RemoveThread: duplicate remove");
        }
      }
    }
  }
  
}
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:

Select allOpen in new window

 

by: objectsPosted on 2009-11-04 at 19:07:59ID: 25746430

if you don't have a main you need to use TestRunner

http://clarkware.com/articles/JUnitPrimer.html#run

 

by: kayveyPosted on 2009-11-04 at 19:14:11ID: 25746462

So I have to do this step first?

Step 3: Write a Test Suite

Next, we'll write a test suite that includes several test cases. The test suite will allow us to run all of its test cases in one fell swoop.

To write a test suite, follow these steps:

   1.

      Write a Java class that defines a static suite() factory method that creates a TestSuite containing all the tests.
   2.

      Optionally define a main() method that runs the TestSuite in batch mode.

The following is an example test suite:

import junit.framework.Test;
import junit.framework.TestSuite;

public class EcommerceTestSuite {
 
    public static Test suite() {

        TestSuite suite = new TestSuite();
 
        //
        // The ShoppingCartTest we created above.
        //
        suite.addTestSuite(ShoppingCartTest.class);

        //
        // Another example test suite of tests.
        //
        suite.addTest(CreditCardTestSuite.suite());

        //
        // Add more tests here
        //

        return suite;
    }

    /**
     * Runs the test suite using the textual runner.
     */
    public static void main(String[] args) {
        junit.textui.TestRunner.run(suite());
    }
}

 

by: objectsPosted on 2009-11-04 at 23:23:46ID: 25747361

yes thats the standard way if you want to run it from command line

 

by: kayveyPosted on 2009-11-05 at 16:54:30ID: 25755801

OK.. I am done with this project. I am going to give you points now. Thanks a lot.. you did get me past from compiler errors.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...