paul a carron

Ranch Hand
+ Follow
since Nov 19, 2016
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
16
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by paul a carron



I have this code for date entry in a Thymeleaf template:

 
   

The date format should be DD/MM/YYYY but currently if something like  D/M/YYYY is entered no validation catches this and it causes an error in  a downstream application. I'd like to add some functionality where a  leading zero is added if the length of D or M are 1.

An example of what I'm trying to do but done with JSP and JavaScript are as follows:

 
Think maybe I could do something along the lines of but not quite this:

2 years ago
I'm trying to familiarise myself with JUnit/Mockito and am using the below method to attempt some unit tests:



I wish to test that the fileNotFoundException is thrown if status.isDirectory == true.

I believe I must invoke the getObj() method and for I must ensure the value is true. I think this is done with I'm not sure how to invoke the method and make sure this takes place.

So far I've got this JUnit but it doesn't seem to be correct as its returning the below error:



java.lang.AssertionError: Expected test to throw an instance of java.io.FileNotFoundException at org.junit.Assert.fail(Assert.java:88) at org.junit.rules.ExpectedException.failDueToMissingException(ExpectedException.java:263) at org.junit.rules.ExpectedException.access$200(ExpectedException.java:106) at org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:245) at org.powermock.modules.junit4.internal.impl.PowerMockJUnit47RunnerDelegateImpl$PowerMockJUnit47MethodRunner.executeTest(PowerMockJUnit47RunnerDelegateImpl.java:91) at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$PowerMockJUnit44MethodRunner.runBeforesThenTestThenAfters(PowerMockJUnit44RunnerDelegateImpl.java:282) at org.junit.internal.runners.MethodRoadie.runTest(MethodRoadie.java:87) at org.junit.internal.runners.MethodRoadie.run(MethodRoadie.java:50) at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.invokeTestMethod(PowerMockJUnit44RunnerDelegateImpl.java:207) at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.runMethods(PowerMockJUnit44RunnerDelegateImpl.java:146) at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl$1.run(PowerMockJUnit44RunnerDelegateImpl.java:120) at org.junit.internal.runners.ClassRoadie.runUnprotected(ClassRoadie.java:34) at org.junit.internal.runners.ClassRoadie.runProtected(ClassRoadie.java:44) at org.powermock.modules.junit4.internal.impl.PowerMockJUnit44RunnerDelegateImpl.run(PowerMockJUnit44RunnerDelegateImpl.java:122) at org.powermock.modules.junit4.common.internal.impl.JUnit4TestSuiteChunkerImpl.run(JUnit4TestSuiteChunkerImpl.java:106) at org.powermock.modules.junit4.common.internal.impl.AbstractCommonPowerMockRunner.run(AbstractCommonPowerMockRunner.java:53) at org.powermock.modules.junit4.PowerMockRunner.run(PowerMockRunner.java:59) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)



Can anybody advise what I'm doing wrong?
6 years ago
I have a JUnit test which causes the below exception:



I suspect the offending line of code is in a thread but I'm not yet sure.

Is this likely to be the issue?
6 years ago
Hi,

I have this piece of code in my Java program:



I also have a code check xml which checks the format of my Java code. The xml contains the following check which prevents me fromm using the this keyword:


Is there any way I can edit my program to work without using this?
6 years ago
Thanks guys.

Richie, I agree. It seems somewhat dated or restrictive. Unfortunately that's only one aspect of the template. There's quite a few things in it that I'm not so keen on.
6 years ago
Actually I think I have it. The first letter should be s followed by an upper case letter followed by any combination of numbers and letters.

6 years ago
I'm developing in Eclipse and have a code format file which contains the following:



This prevents me from using the following static variable:



I believe it's forcing me to name the variable in a cretain way vut don't know what structure it should take. Initially I thought it should beginwith an upper case letter followed by any combination of letters and numbers but this didn't work. I'n not sure what ^s means.

Can anybody please advise?
6 years ago
I finally got this figured out.

First off I needed to have a / at the beginning of my canonicalURI:



Secondly, the awsHeader I created was case sensitive. It needs to be a lower case "host":


Now that I've made those changes I can access the end point.
6 years ago
Hi,

I've created the below AWS v43 Authorization:



When my code is executed I get the following 403 message:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Error><Code>AccessDenied</Code><Message>Access Denied</Message><Resource>/<my bucket>/config/ignore-keys</Resource><RequestId>d302a469-f79f-4c97-85f7-165dcd87b233</RequestId><httpStatusCode>403</httpStatusCode></Error>



This message doesn't tell me very much but I can pass the url with the same credentials in Postman and the GET works. Is there anything I can do to resolvce this ro atleast investigate a little further?

I have noticed that the signature my Java application generates is different from the one generated by Postman. Could this be the issue. Or an I passing something incorrect to cause the different signature to be generated?

Cheers
Paul
6 years ago
Hi,

I've been writing a Rest service using Jackson to extract the name and sizeFromStorage inside the response value.

I created the below classes in an attempt to do this:



The output I get from this is:
[[{vaults=[{id=20, name=Apple, description=, sizeFromStorage=95957225298, storagePools=[{storagePool={id=1, name=storage-pool1, sizeFromStorage=5043, estimateUsableTotalLogicalSizeFromStorage=95957225298, generations=[{generation={sequence=0}}]}}]}, {id=20, name=Apple, description=, sizeFromStorage=95957225298, storagePools=[{storagePool={id=1, name=storage-pool1, sizeFromStorage=5043, estimateUsableTotalLogicalSizeFromStorage=95957225298, generations=[{generation={sequence=0}}]}}]}]]

However, what I want to do is the name and sizeFromStorage values. So far I've managed to strip out the first three values. Unfortunately I'm now stuck as I'm not very familiar with Rest services or reading JSON. Is there any way I can delve further into the JSON to get what I need or have I approached this in the wrong way?

Cheerrs
Paul
Never mind. I was pointing to the wrong folder location.
6 years ago
I'm trying to read Json from a file(json.json). It's in my projcet in a folder called JsonRead. I've used the following code to read it but am getting nothing.



The returns [].

Am I referencing it incorrectly?
6 years ago
Hi,

I took the example tutorial from https://inducesmile.com/android/android-camera2-api-example-tutorial/ and have been working at making my own changes to it in an effort to familiarise myself with Android development.

The first thing I di  was to change the file name of the image I created from "pic.jpg" to "PIN_<yyyyMMdd>_<HHmmss>.jpg". I then changed the directory images get saved to to DCIM/Camera/AndroidCameraApi/.

My issue now is that the images get saved in the correct folder but are not visible in the gallery app unless I restart my phone.

Here's what I've done:


I had read somewhere online that I need the sendBroadcast to force a reindex of the AndroidCameraApi folder but it doesn't seem to be working. Perhaps I've done something wrong in here.

Do I need to put something into the manifest relating to ACTION_MEDIA_SCANNER_SCAN_FILE or have I made a mistake with some other aspect of it?

Thanks
Paul
7 years ago
Ah thanks. I had a few silly mistakes that I didn't spot when I was looking at it earlier.

In CircularQueue I changed


for


In IQDemo I also changed


for


All working as expected now.
7 years ago