Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
baquerd
Jul 2, 2007

by FactsAreUseless

Good Will Hrunting posted:

Why the hell does your client care about unit test results????

The client has the best, most impressive, double plus good process requiring quality audits of suppliers to ensure they are following the process. See ASPICE.

Adbot
ADBOT LOVES YOU

smackfu
Jun 7, 2004

Surefire has an impressive lack of output options.

Ariong
Jun 25, 2012

Get bashed, platonist!

Okay here's something. When I run this code:

Java code:
System.out.println(new File(".").getAbsolutePath());
I get this output.

Java code:
C:\Users\Bill Murray\Documents\NetBeansProjects\slotMachineFXML
That's not right, is it? Shouldn't src be in there somewhere?

FAT32 SHAMER
Aug 16, 2012



Good Will Hrunting posted:

Why the hell does your client care about unit test results????

We're using UiAutomation to automate some android stuff that they normally spend months doing by hand

This is the automotive industry and everyone is way behind the times lol

CPColin
Sep 9, 2003

Big ol' smile.

Ariong posted:

Okay here's something. When I run this code:

Java code:
System.out.println(new File(".").getAbsolutePath());
I get this output.

Java code:
C:\Users\Bill Murray\Documents\NetBeansProjects\slotMachineFXML
That's not right, is it? Shouldn't src be in there somewhere?

Only if you're in the src directory when you're running your code. Looks like NetBeans is running your code from the project root.

Volguus
Mar 3, 2009

Ariong posted:

Okay here's something. When I run this code:

Java code:
System.out.println(new File(".").getAbsolutePath());
I get this output.

Java code:
C:\Users\Bill Murray\Documents\NetBeansProjects\slotMachineFXML
That's not right, is it? Shouldn't src be in there somewhere?

That is perfectly ok. What that line tells you is the current directory (working directory) of the application. However, that has nothing to do with your Image problems. According to the documentation when you invoke Image(string) it expects an URL ( I don't understand why it isn't an actual URL class, but whatever, it probably has to do with FXML).

However, that string (the URL) can be either a remote URL (http://domain/picture.jpg) or an internal URL (/package/path/to/image.jpg).
Just like with getClass().getResource(), when trying to load an internal image the only place it looks is on the classpath. The src/ folder is not on the classpath when you are running the application. The out, bin/classes, target/classes, build/classes folders are on the classpath, since those are the folders that contain the .class files. When you package your application as a jar, the contents of the jar will be in the classpath.

Going back to your earlier posted stack trace, the most important line in there is this: "Invalid URL: Invalid URL or resource not found". It simply cannot find your image. The string that you posted there is simply wrong, it doesn't point to the location of the image in the classpath. According to this line, however, the problem becomes clear:
code:
leftImage.setImage(new Image("file:///C:/Users/Bill Murray/Documents/NetBeansProjects/slotMachineFXML/src/slotmachinefxml/Fruit/Apple.png"));
The "Apple.png" resides in the slotmachinefxml/Fruit folder, under src. Which means, that in the classpath, the absolute path to this file will be: "/slotmachinefxml/Fruit/Apple.png".
Now, you have a few options to create an image from the file:

  • Image image = new Image("/slotmachinefxml/Fruit/Apple.png");//when passing a string to image, that string has to be the absolute path (in the classpath) to the file
  • Image image = new Image(getClass().getResourceAsStream("Apple.png"));//if calling getResourceAsStream() you can pass a relative path. That is, relative to the class calling it. If the class is in the slotmachinefxml.Fruit package, then this line will work
  • Image image = new Image(getClass().getResource("Apple.png").toString());//behaves just as getResourceAsStream(), but returns an URL instead of an InputStream

In general, when loading a resource (anything really) from the classpath, there are a few things you have to keep in mind. Let's assume that the class loading the resource is com.mycompany.MyClass. Let's assume (again) that the resource we're loading is located in com.myresources.Resource.txt.
com.mycompany.MyClass has a few options to load that resource:
  • getClass().getResourceAsStream("/com/myresources/Resource.txt"); // absolute path
  • getClass().getResourceAsStream("../myresources/Resource.txt"); // relative path

To load a resource (txt, jpg, or whatever file) from the current package, all you have to do is: getClass().getResourceAsStream("resource.txt");.


One more piece of advice: If you're using getResourceAsStream(), always use it in the try-with-resources block to ensure it will be closed:
code:
try(InputStream in = getClass().getResourceAsStream("file.txt)){
//do something with "in"
}
Sorry for the long post, had a few beers and it was getting tiring to see you running around the bush.

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.
Is your img folder in src? May be that all you need to do is move the folder or add /src/ to the URL.

I really hate working on bugs like this, just stabbing at the dark until you finally get it to load the right file.

Ellie Crabcakes
Feb 1, 2008

Stop emailing my boyfriend Gay Crungus

Volguus posted:

Oh yes, I remember those days. Had a lib folder for each project where i downloaded the dependencies. And then with ant build the drat thing so that an IDE was not required. Or sometimes gently caress ant and you better use an IDE. Better yet, my IDE. Even better, when the project files made by the IDE did not have relative paths, so you better match my setup to even dream of contributing.
When wanting to update a library was quite an adventure, dependencies and other cool stuff.

When joining a new project, it was a week before one could have done anything, as opposed to a simple git clone, mvn package as it is now (3 minutes or 3 hours depending on project size).

Oh yes, good old days.
Maven may have its problems, but I still have nightmares about the crap involved in doing java dev in the 90s.

Ariong
Jun 25, 2012

Get bashed, platonist!

Volguus posted:

Sorry for the long post, had a few beers and it was getting tiring to see you running around the bush.

I appreciate you taking the time to explain all this. However, I could use a bit of clarification. How can this


Volguus posted:

getClass().getResourceAsStream("/com/myresources/Resource.txt"); // absolute path

be an absolute path if it starts at com? Wouldn't it have to start at the root folder?

The two relative solutions you gave resulted in null pointer exceptions, which I assume is because the class is in the slotmachinefxml folder and not the fruit folder.

Volguus
Mar 3, 2009

Ariong posted:

I appreciate you taking the time to explain all this. However, I could use a bit of clarification. How can this


be an absolute path if it starts at com? Wouldn't it have to start at the root folder?

The two relative solutions you gave resulted in null pointer exceptions, which I assume is because the class is in the slotmachinefxml folder and not the fruit folder.

The source folder is the root. Ok, here's an example, since I saw that you're using Netbeans. Consider that I have this project:



The "Source Packages" folder is your root. That is / . Now, if you look in your project properties, you will see in the "Sources" category that it (by default) only has the "src" folder. But you can add as many folders as you want. Doesn't matter.
So, since "Source Packages" is root, how do I access resource.txt? Via "/com/mycompany/resource.txt". Does it make sense now? On the disk, that will be under "...../MyProject/src/com/mycompany/resource.txt".

However, that is the absolute path (not a bad idea to always use absolute paths, since Image class requires that). With getClass().getResourceAsStream() you can specify relative paths as well.

So, if you were to have in com.mycompany.MyClass a method that will read "resource.txt", it can look like this:

code:
private void readResource() {
 InputStream in = getClass().getResourceAsStream("resource.txt");
}
Why does that work? Because MyClass and resource.txt are in the same package. Packages in java are just simple folders. That "jar" file that you make is just a simple zip file with a META-INF/MANIFEST.MF file as well. So, when accessing a file, you just specify the path (absolute or relative) to that particular file, starting from the root (source packages).

So, how will MyClass from the com.mycompany package access a file Apple.png from the com.mycompany.Fruit package? 2 ways:

code:
private void readResource() {
 InputStream in = getClass().getResourceAsStream("/com/mycompany/Fruit/Apple.png");//absolute
//OR
InputStream in = getClass().getResourceAsStream("Fruit/Apple.png");//relative
}
In your case, based on the information provided so far, "/slotmachinefxml/Fruit/Apple.png" is the full path to your png file. This will work from either Image constructor or getClass().getResourceAsStream(). If it doesn't work (get null pointer exceptions or cannot find file or other shenanigans), check to see if you have the png file copied in the build/classes folder. Most likely is not there, which means that for some reason netbeans didn't think to copy it there. That's a netbeans setting, but unless you messed with it, it should just work.

Volguus fucked around with this message at 21:47 on Apr 27, 2017

Ariong
Jun 25, 2012

Get bashed, platonist!

Oh, I get it! Thanks so much, very big help.

Captain Cappy
Aug 7, 2008

I'm pretty much out of my element when it comes to Java and I feel like I'm missing something obvious about this. So I have a Collection of T, T has a get function that returns U, and I want to create a lightly wrapped (no new list) Collection/Iterable of U from the Collection of T using that getter. My first thought is to use stream.flatmap, but I don't want to create a new list or anything since that would be wasteful. Will Stream.flatMap(T::getU).iterator() or something similar create a new list? Are there any guarantees about this behavior? Is there something already in the standard library that will just lightly wrap the Collection of T and make it return U using the function I specify?

Carbon dioxide
Oct 9, 2012

Captain Cappy posted:

I'm pretty much out of my element when it comes to Java and I feel like I'm missing something obvious about this. So I have a Collection of T, T has a get function that returns U, and I want to create a lightly wrapped (no new list) Collection/Iterable of U from the Collection of T using that getter. My first thought is to use stream.flatmap, but I don't want to create a new list or anything since that would be wasteful. Will Stream.flatMap(T::getU).iterator() or something similar create a new list? Are there any guarantees about this behavior? Is there something already in the standard library that will just lightly wrap the Collection of T and make it return U using the function I specify?

You're using the Streaming API which is good, but it's also somewhat advanced. Of course you could use the old way of doing a foreach.

But to create a list from another using the Streaming api isn't that hard if you know the syntax.

I am not sure if with T you mean you have an actual type, or if T is the identifier for a generic (T is very commonly used for that). If T is a generic you would want to make sure there's always a class in there that has a getU() method( so define T as <T extends SomeInterfaceWithGetU> ).

Anyway, let's assume T is an actual type.

Assuming your collection is in a variable called 'collection', it would be something like this:

List<U> newList = collection.stream().map(x::getU).collect(Collectors.toList()); // No guarantees considering the type of list that's returned
newList = collection.stream().map(x::getU).collect(Collectors.toCollection(new::ArrayList)); // Always returns an ArrayList.

The reason I'm using map() instead of flatMap() is because as I understand it, U is not a Collection itself, just a simple field. flatMap() does an extra step where it checks if U is a collection, and if so, it turns the stream of collections into a stream of all the elements in all those collections. That's not needed in this case, so a map() will do.

E: Oh I read wrong, you literally said you do not want a new list. Okay. In that case, the best thing to do is just directly do your operations on the stream that results from the map() method. You can use the Stream functions to do nearly everything you'd ever want with a list/iterable. Just don't go passing a Stream around, because once you use up values in a Stream, you can't go back.

collection.stream().map(x::getU) // Use this directly

But seriously, what is the problem of making an extra list? Are you limited to 16K of RAM or something? If you need this often just make a method that returns a List<U> given a List<T> and use the above code.

Carbon dioxide fucked around with this message at 07:21 on Apr 28, 2017

TheresaJayne
Jul 1, 2011

funny Star Wars parody posted:

We're using UiAutomation to automate some android stuff that they normally spend months doing by hand

This is the automotive industry and everyone is way behind the times lol

and they didnt insist on writing it in MISRA C
seriously go check it out its used for automotive and aeronautical i did some work for the ESA (European space agency) and it is written in their form of Misra C

No for loops allowed
Malloc / dealloc not allowed
every method has to return a boolean true/false to show if the method worked or not
++ and -- not allowed
+= not allowed
** pointer to pointer not allowed
if then else not allowed
Case statements have to have a default that is an error

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

TheresaJayne posted:

and they didnt insist on writing it in MISRA C
seriously go check it out its used for automotive and aeronautical i did some work for the ESA (European space agency) and it is written in their form of Misra C

No for loops allowed
Malloc / dealloc not allowed
every method has to return a boolean true/false to show if the method worked or not
++ and -- not allowed
+= not allowed
** pointer to pointer not allowed
if then else not allowed
Case statements have to have a default that is an error

:stonk: Does Misra stand for Miserable?!?

Snak
Oct 10, 2005

I myself will carry you to the Gates of Valhalla...
You will ride eternal,
shiny and chrome.
Grimey Drawer
How is that not something they write a custom compiler for rather than enforce at the human level?

TheresaJayne
Jul 1, 2011

Zaphod42 posted:

:stonk: Does Misra stand for Miserable?!?

https://www.misra.org.uk/

the Motor Industry Software Reliability Association

Zaphod42
Sep 13, 2012

If there's anything more important than my ego around, I want it caught and shot now.

TheresaJayne posted:

https://www.misra.org.uk/

the Motor Industry Software Reliability Association

So just a happy co-incedence then :v:

Like most point of sale systems being abbreviated POS.

Snak
Oct 10, 2005

I myself will carry you to the Gates of Valhalla...
You will ride eternal,
shiny and chrome.
Grimey Drawer
Haha it hasn't been updated since 1994.

baquerd
Jul 2, 2007

by FactsAreUseless
I once had an auditor attempt to apply Misra rules to a Java cloud based REST API. Because ASPICE. We had to carefully watch our language too, we couldn't call unit tests unit tests because then every test would need to be tracked back to a product requirement.

Captain Cappy
Aug 7, 2008

Carbon dioxide posted:

But seriously, what is the problem of making an extra list? Are you limited to 16K of RAM or something? If you need this often just make a method that returns a List<U> given a List<T> and use the above code.

Thanks for the help. I figured I might have to use the stream directly but wasn't sure if there is a better way. I guess there isn't really a problem with making an extra list, it just feels very wasteful and we've had performance issues already on this project. We're basically a bunch of C++ developers that got forced to write a Java application and therefore we don't know the best practices to avoid getting nickel and dimed on performance issues. I'd rather try to do things right, the fast non-obtuse way than just go with the lazy route because it will become my problem later down the line.

baka kaba
Jul 19, 2003

PLEASE ASK ME, THE SELF-PROFESSED NO #1 PAUL CATTERMOLE FAN IN THE SOMETHING AWFUL S-CLUB 7 MEGATHREAD, TO NAME A SINGLE SONG BY HIS EXCELLENT NU-METAL SIDE PROJECT, SKUA, AND IF I CAN'T PLEASE TELL ME TO
EAT SHIT

Captain Cappy posted:

Thanks for the help. I figured I might have to use the stream directly but wasn't sure if there is a better way. I guess there isn't really a problem with making an extra list, it just feels very wasteful and we've had performance issues already on this project. We're basically a bunch of C++ developers that got forced to write a Java application and therefore we don't know the best practices to avoid getting nickel and dimed on performance issues. I'd rather try to do things right, the fast non-obtuse way than just go with the lazy route because it will become my problem later down the line.

Is this an incredibly high performance application, or is your function going to be run multiple times concurrently on a massive scale? If not, you really shouldn't worry about it. If creating a list object is an issue, you'll probably have to start profiling the rest of your code too - for example Iterator objects get created a lot, and you're explicitly creating one yourself! I had to drop a foreach loop that was doing that, and use an index lookup instead, but only because this was a 60fps rendering thread that would generate a lot of garbage

I guess if you really wanted to you could create a raw ArrayList (i.e no type), put all your Ts in it, then iterate by index and replace each with its U. Then cast the list to the U type when you want to get the things back out. I think that would work? But don't do that

Carbon dioxide
Oct 9, 2012

Okay, a question from me this time.

On the rare occassion you have to read input from console, do you prefer new Scanner(System.in) or System.console() ?

Ariong
Jun 25, 2012

Get bashed, platonist!

If I have the "Use fx:root construct" unchecked in scene builder, why would I be getting this exception?

code:
Caused by: javafx.fxml.LoadException: Root hasn't been set. Use method setRoot() before load.

Volguus
Mar 3, 2009

Carbon dioxide posted:

Okay, a question from me this time.

On the rare occassion you have to read input from console, do you prefer new Scanner(System.in) or System.console() ?

I don't believe it matters whatsoever. Use whatever gives you the features you need. The main purpose of Console was to give you a "readPassword" method though it did add some other helper methods in addition to that. If you need that nextInt, nextLong methods from Scanner, then by all means, use that.

scissorman
Feb 7, 2011
Ramrod XTreme
What's the best resource for an in-depth look of Apache Tomcat?
I looked at the available books and they seem to be seriously outdated.

HFX
Nov 29, 2004

Zaphod42 posted:

:stonk: Does Misra stand for Miserable?!?

If you ever do embedded development with tight resource / real time requirements, some of those become a lot more understandable.

FateFree
Nov 14, 2003

Ok going out on a limb here with this one but I'm looking for some more architecture advice.

I am building a java app for a client containing medical data. My client wants to expand so that we can spin up new instances of the application for other companies they work with. Unfortunately, due to hipaa regulations, they want each app to be isolated (nginx/tomcat/db). I'm using Docker to bundle my application, so in the past I just bundled up another image and deployed it. However, they also want the ability to spin up these extra containers dynamically through an admin tool.

I'm wondering how to approach this. One idea I had was to learn the Docker Engine API which I believe I could use from a java application to execute docker commands. Maybe every time they want to add a new client, I could create a new docker instance on the fly? I don't know how thats going to work with certs and everything though. Whats even more annoying is they want the admins to be able to log into any of the client applications, which means despite being isolated those client apps would need to reach the admin authentication server.

Anyway this is very early on in the planning stages. If anyone has any similar experience with a structure like this, I'd appreciate any advice, no matter what level of detail.

FAT32 SHAMER
Aug 16, 2012



Based on my own experience doing similar things in the automotive world, the Docker API sounds like a great loving idea compared to the bullshit we were doing


gently caress

Carbon dioxide
Oct 9, 2012

FateFree posted:

Ok going out on a limb here with this one but I'm looking for some more architecture advice.

I am building a java app for a client containing medical data. My client wants to expand so that we can spin up new instances of the application for other companies they work with. Unfortunately, due to hipaa regulations, they want each app to be isolated (nginx/tomcat/db). I'm using Docker to bundle my application, so in the past I just bundled up another image and deployed it. However, they also want the ability to spin up these extra containers dynamically through an admin tool.

I'm wondering how to approach this. One idea I had was to learn the Docker Engine API which I believe I could use from a java application to execute docker commands. Maybe every time they want to add a new client, I could create a new docker instance on the fly? I don't know how thats going to work with certs and everything though. Whats even more annoying is they want the admins to be able to log into any of the client applications, which means despite being isolated those client apps would need to reach the admin authentication server.

Anyway this is very early on in the planning stages. If anyone has any similar experience with a structure like this, I'd appreciate any advice, no matter what level of detail.

I have no experience with your specific setup, but perhaps I can ask around a bit.

We currently use Docker for running integration tests. We have a special gradle task (which just calls Java code) that builds all parts of our system, then brings up docker containers, one corresponding to each prod server. It uses either stored images or the just built application for that, depending on the instance. I'm not sure if this is custom code or part of the Docker API, but the servers seem to communicate on different port numbers each time. It all works out. After that, we can run integration tests by just imitating the commands a user would send to a public-facing part of the system. A different gradle task is available to shut down all containers cleanly.

We're currently looking into getting this same setup working on a test server, so we can run it as a step in our automatic deployment instead of locally.

I'm not really sure how to deal with the certs. Considering your admin authentication server, I don't know... I'm thinking that as part of the start-up process it tells the admin server it's live and confirms this with a secure token or something, and from that point on the admin server will accept requests from that docker instance. But that's just the first thing that popped into my head and might be wrong.

E: Or, if it's web-based, use some kind of SAML implementation, and let the admin server handle the hard work.

Carbon dioxide fucked around with this message at 06:46 on May 10, 2017

FateFree
Nov 14, 2003

Thanks for the suggestions guys. I had a few meetings and it turns out the isolated docker instances weren't favored because they would rather have all the user data live in one database, and client specific data in a separate database, but still have everything running under one application server. This makes things a little bit easier, I just have to figure out whether I can use Amazon's API to create a database on the fly. Then I could run a schema file to prepare it, and dynamically connect to it or others depending on where in the application they are.

I imagine there must be some customizable datasource that I can create in Spring and call up specific repository classes that have been wired to use it. Has anyone done any crazy stuff like that before?

poemdexter
Feb 18, 2005

Hooray Indie Games!

College Slice
Make drat sure you're not breaking any HIPAA poo poo throwing medical information onto the cloud. Amazon wrote up a white paper to cover AWS and HIPAA. https://d0.awsstatic.com/whitepapers/compliance/AWS_HIPAA_Compliance_Whitepaper.pdf

venutolo
Jun 4, 2003

Dinosaur Gum
A discussion about unit testing came up in a code review, and I could use some outside opinion on it. I can't seem to put together a good answer.

The unit test code reviewed looked something like this much-simplified example:

code:
public class BundleTest {

    static class Bundle {
        private final String filename;
        private final int version;

        // filename is expected to be of form: 'bundle_<version>.tar.gz'
        Bundle(String filename) {
            this.filename = filename;
            this.version = -1; // pretend the version is actually parsed from the filename
        }

        String getFilename() { return filename; }
        int getVersion() { return version; }
    }

    private final String noLeadingZeroFilename = "bundle_3.tar.gz";
    private final String withLeadingZeroFilename = "bundle_04.tar.gz";

    private Bundle noLeadingZeroBundle;
    private Bundle withLeadingZeroBundle;

    @Before
    public void testNewInstance() throws Exception {
        noLeadingZeroBundle = new Bundle(noLeadingZeroFilename);
        withLeadingZeroBundle = new Bundle(withLeadingZeroFilename);
    }

    @Test
    public void testGetVersion() throws Exception {
        Assert.assertEquals(3, noLeadingZeroBundle.getVersion());
        Assert.assertEquals(4, withLeadingZeroBundle.getVersion());
    }

    @Test
    public void testGetFileName() throws Exception {
        Assert.assertEquals(noLeadingZeroFilename, noLeadingZeroBundle.getFilename());
        Assert.assertEquals(withLeadingZeroFilename, withLeadingZeroBundle.getFilename());
    }
    
}
I commented that the name of the @Before method, testNewInstance, was deceptive and that typically those methods are named something like setup. The response was to ask what to name it if it is both setup and a test, since calling the constructor is necessarily exercising that bit of code. In this particular class under test the version is parsed from the file name in the constructor (and presumably would throw an exception if the filename passed to the constructor was bad). Another dev chimed in to say that the @Before method should not contain any code that tests anything.

What would you say here? Are setup methods that create instances of the class-under-test okay? If so, are they necessarily tests? Is there a better approach to what is being accomplished here?


Would tests like this be better? (Removing the setup method)
code:
    @Test
    public void bundleNoLeadingZeroVersionCorrect() throws Exception {
        Bundle bundle = new Bundle("bundle_3.tar.gz");
        Assert.assertEquals(3, bundle.getVersion());
    }
	
    @Test
    public void bundleWithLeadingZeroVersionCorrect() throws Exception {
        Bundle bundle = new Bundle("bundle_04.tar.gz");
        Assert.assertEquals(4, bundle.getVersion());
    }
e: replaced using the instance variables in the second example.

venutolo fucked around with this message at 01:36 on May 12, 2017

FateFree
Nov 14, 2003

I agree that the setup method should not contain any code nor should it be named test. I really don't see the value in your test for declaring those Bundles as instance variables - there is much nicer encapsulation with the last examples you gave. The Before annotations are meant to really get your test environment ready, that might mean creating and destroying a database schema or something of that nature. Just look how much nicer your last two tests read, I can see in one block of code how the bundle is being created and how its being tested. Compare that against the initial version where I have to read a setup method or look all over the test to find out whats going on.

If you have recurring code in your tests, theres nothing wrong with creating a private method that multiple tests call up to get an object ready to be tested.

fletcher
Jun 27, 2003

ken park is my favorite movie

Cybernetic Crumb
I think your latter example makes more sense, get rid of the setup methods they are not necessary here.

I also agree with FateFree, the values for the tests don't need to be instance variables.

I think @DataProvider would make more sense for this particular scenario: http://websystique.com/java/testing/testng-dataprovider-example/

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...
I strongly agree. The latter code snippet is the "right" way to do it. You should only declare member variables of your test class to exercise DRY. If the variable is used in one test, simply place if in that test.

Also, it's 100% wrong to have @Before be a test. @Before is for Before The Test. Your coworker is a horror.

Volmarias fucked around with this message at 01:34 on May 12, 2017

venutolo
Jun 4, 2003

Dinosaur Gum
Thanks for the responses. I would replace those filename instance variables. That was just from mocking up a quick example in the existing code. I've edited the code in the post.

long-ass nips Diane
Dec 13, 2010

Breathe.

I just got my first programming job out of college, and they're using Java & the Eclipse IDE. I have literally zero experience with either, since all my undergrad work was either in C++ or Python. I'm going through the Java w/ Eclipse tutorial that's linked in the first post, but does anyone have a good recommendation for where to go after that? I've got a little under a month before I start, and while there will be training at work I'd like to be at least a bit familiar with all of this stuff before I start, just so I'm not totally useless.

Volguus
Mar 3, 2009

long-rear end nips Diane posted:

I just got my first programming job out of college, and they're using Java & the Eclipse IDE. I have literally zero experience with either, since all my undergrad work was either in C++ or Python. I'm going through the Java w/ Eclipse tutorial that's linked in the first post, but does anyone have a good recommendation for where to go after that? I've got a little under a month before I start, and while there will be training at work I'd like to be at least a bit familiar with all of this stuff before I start, just so I'm not totally useless.

What exactly are they doing with Java? The field is extremely large so narrowing things a bit may help. Web applications? Micro-services? Machine Learning? Desktop? Databases (sql/nosql)? Oracle does have a java tutorial website where they tackle quite a few topics: https://docs.oracle.com/javase/tutorial/ .

Adbot
ADBOT LOVES YOU

long-ass nips Diane
Dec 13, 2010

Breathe.

Volguus posted:

What exactly are they doing with Java? The field is extremely large so narrowing things a bit may help. Web applications? Micro-services? Machine Learning? Desktop? Databases (sql/nosql)? Oracle does have a java tutorial website where they tackle quite a few topics: https://docs.oracle.com/javase/tutorial/ .

I'm updating 30 year old logistics software that's been converted from like COBOL and Power-something(I can't remember the actual name) to Java using some proprietary tool. I know it interfaces with Weblogic and Oracle DB stuff but from the conversation I had with my manager I'd be working in pure Java 99% of the time.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply