|
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.
|
# ? Apr 26, 2017 23:50 |
|
|
# ? Jun 1, 2024 17:48 |
|
Surefire has an impressive lack of output options.
|
# ? Apr 26, 2017 23:58 |
|
Okay here's something. When I run this code:Java code:
Java code:
|
# ? Apr 27, 2017 02:04 |
|
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
|
# ? Apr 27, 2017 02:16 |
|
Ariong posted:Okay here's something. When I run this code: 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.
|
# ? Apr 27, 2017 02:23 |
|
Ariong posted:Okay here's something. When I run this code: 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:
Now, you have a few options to create an image from the file:
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:
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:
|
# ? Apr 27, 2017 03:08 |
|
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.
|
# ? Apr 27, 2017 03:08 |
|
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.
|
# ? Apr 27, 2017 20:23 |
|
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.
|
# ? Apr 27, 2017 20:35 |
|
Ariong posted:I appreciate you taking the time to explain all this. However, I could use a bit of clarification. How can this 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:
So, how will MyClass from the com.mycompany package access a file Apple.png from the com.mycompany.Fruit package? 2 ways: code:
Volguus fucked around with this message at 21:47 on Apr 27, 2017 |
# ? Apr 27, 2017 21:42 |
|
Oh, I get it! Thanks so much, very big help.
|
# ? Apr 27, 2017 22:08 |
|
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?
|
# ? Apr 28, 2017 05:53 |
|
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 |
# ? Apr 28, 2017 07:05 |
|
funny Star Wars parody posted:We're using UiAutomation to automate some android stuff that they normally spend months doing by hand 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
|
# ? Apr 28, 2017 08:29 |
|
TheresaJayne posted:and they didnt insist on writing it in MISRA C Does Misra stand for Miserable?!?
|
# ? Apr 28, 2017 08:32 |
|
How is that not something they write a custom compiler for rather than enforce at the human level?
|
# ? Apr 28, 2017 08:35 |
|
Zaphod42 posted:Does Misra stand for Miserable?!? https://www.misra.org.uk/ the Motor Industry Software Reliability Association
|
# ? Apr 28, 2017 08:35 |
|
TheresaJayne posted:https://www.misra.org.uk/ So just a happy co-incedence then Like most point of sale systems being abbreviated POS.
|
# ? Apr 28, 2017 08:38 |
|
Haha it hasn't been updated since 1994.
|
# ? Apr 28, 2017 08:38 |
|
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.
|
# ? Apr 28, 2017 08:47 |
|
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.
|
# ? Apr 28, 2017 23:30 |
|
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
|
# ? Apr 29, 2017 00:51 |
|
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() ?
|
# ? Apr 29, 2017 19:40 |
|
If I have the "Use fx:root construct" unchecked in scene builder, why would I be getting this exception?code:
|
# ? May 1, 2017 02:43 |
|
Carbon dioxide posted:Okay, a question from me this time. 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.
|
# ? May 1, 2017 04:11 |
|
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.
|
# ? May 4, 2017 19:20 |
|
Zaphod42 posted: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.
|
# ? May 4, 2017 19:32 |
|
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.
|
# ? May 10, 2017 01:44 |
|
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
|
# ? May 10, 2017 03:09 |
|
FateFree posted:Ok going out on a limb here with this one but I'm looking for some more architecture advice. 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 |
# ? May 10, 2017 06:37 |
|
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?
|
# ? May 11, 2017 18:17 |
|
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
|
# ? May 11, 2017 20:15 |
|
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:
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:
venutolo fucked around with this message at 01:36 on May 12, 2017 |
# ? May 12, 2017 01:06 |
|
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.
|
# ? May 12, 2017 01:24 |
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/
|
|
# ? May 12, 2017 01:30 |
|
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 |
# ? May 12, 2017 01:32 |
|
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.
|
# ? May 12, 2017 01:35 |
|
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.
|
# ? May 12, 2017 18:09 |
|
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/ .
|
# ? May 12, 2017 18:14 |
|
|
# ? Jun 1, 2024 17:48 |
|
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.
|
# ? May 12, 2017 18:18 |