Migrate, Modernize and Build Java Web Apps on Azure: This live workshop will cover methods to enhance Java application development workflow.
Modern Digital Website Security: Prepare to face any form of malicious web activity and enable your sites to optimally serve your customers.
|Accredited Investor| Enterprise Coach| Sr. TechLead|
New York, US
Joined Mar 2016
About
Arun Pandey is a technologist, Enterprise coach and Accredited Investor by profession. He has been very hands-on with many of the technologies, including Java, Python, Blockchain, AI, and Machine learning. Arun holds a master's degree in software technology and several other credentials from top institutions, for e.g. Harvard University, ICAgile, Scrum Alliance, etc... FB - https://www.facebook.com/arunpandeyusa/
Stats
Reputation: | 2344 |
Pageviews: | 2.3M |
Articles: | 42 |
Comments: | 25 |
Articles
Comments
Oct 03, 2023 · Arun Pandey
Sure, Milan. I'll take a look.
Aug 12, 2023 · Arun Pandey
I totally agree, and getting this kind of leader in our career and life is a blessing!
Aug 12, 2023 · Arun Pandey
very well said :)
Mar 12, 2018 · Arun Pandey
well said Kris!
May 21, 2017 · Arun Pandey
Thanks Sun. This is compatible with Java9.
Use this code-
public void writeToFileWithLock(String data) {
fc = randomAccessFile.getChannel();
ByteBuffer buffer = null;
try (FileLock fileLock = fc.tryLock()) {
if (null != fileLock) {
buffer = ByteBuffer.wrap(data.getBytes());
buffer.put(data.toString().getBytes());
buffer.flip();
while (buffer.hasRemaining())
fc.write(buffer);
}
} catch (OverlappingFileLockException | IOException ex) {
LOG.error("Exception occured while trying to get a lock on File... " + ex.getMessage());
}finally{
fc.close();
randomAccessFile.close();
}
}
Apr 12, 2017 · Arun Pandey
Right Peter :)
Apr 12, 2017 · Arun Pandey
Please read the last few lines carefully, hope it will clear your assumption.
"so any resource as a final or effectively final variable can be placed in try-with-resource blocks and would be eligible for automatic resource management."
This is a sample usecase to depict that how java9 ARM improvements can be put in action.
Mar 15, 2017 · Arun Pandey
Thanks Gaurav
Mar 10, 2017 · Arun Pandey
Thank you Anand
Dec 30, 2016 · Arun Pandey
Thank you Jirka. Actually ForkJoin Pool has come up with a common Pool concept in Java 8. you can refer - http://openjdk.java.net/projects/jdk8/features
" core/libs
103 Parallel Array Sorting Add additional utility methods to
java.util.Arrays
that use the JSR 166 Fork/Join parallelism common pool to provide sorting of arrays in parallel."
Dec 16, 2016 · Arun Pandey
Hi Arturo, both are matured tool, and you are right that most of the organizations are using Cucumber. JBehave is purely Java based framework while Cucumber is Ruby based.
Nov 17, 2016 · Arun Pandey
Thanks for your suggestion
Nov 08, 2016 · Arun Pandey
Yes Marc, and many of the organizations still use Java 1.5 and Ant like tool :)
Oct 16, 2016 · Arun Pandey
Hi Charles,
It could be used as below ----
@RunWith(JUnitFactoryRunner.class)
public class TextFileInputDataTest {
/** Here's where to set up test case inputs, and their expected result will be
* read from a text-file, and will be populated as an map
* (Map<TestInputData, ExpectedResultData>) and need to compare values with
* their corresponding expected result fetched from map.
* This basically reads the text input file and prepare the List<RuntimeTestCase>.
* and provides this List as an input to RuntimeTestCase
* @return
*/
@JUnitTestFactory
public static Collection<?> tests() {
Map<TestInputData, ExpectedResultData> testInputAndResultMap = getTestInputAndResultMap();
Iterator<TestInputData> testInputAndResultMapItr = testInputAndResultMap.keySet().iterator();
ArrayList<RuntimeTestCase> tests = new ArrayList<RuntimeTestCase>(testInputAndResultMap.size());
while(testInputAndResultMapItr.hasNext()){
TestInputData testInput = testInputAndResultMapItr.next();
ExpectedResultData expectedResultData = testInputAndResultMap.get(testInput);
tests.add(new RuntimeTestCase(testInput, expectedResultData));
}
return tests;
}
private static Map<TestInputData, ExpectedResultData> getTestInputAndResultMap(){
Map<TestInputData, ExpectedResultData> testInputAndResultMap = new HashMap<TestInputData,
ExpectedResultData>();
TestInputData testInputData1 = new TestInputData();
ExpectedResultData expectedResultData1 = new ExpectedResultData();
testInputData1.setName("test-1");
expectedResultData1.setName("test-1");
testInputAndResultMap.put(testInputData1, expectedResultData1);
TestInputData testInputData2 = new TestInputData();
ExpectedResultData expectedResultData2 = new ExpectedResultData();
testInputData2.setName("test-2");
expectedResultData2.setName("test-2");
testInputAndResultMap.put(testInputData2, expectedResultData2);
return testInputAndResultMap;
}
}
The same way file can be used. In above example it will create 2 test cases. Hope it will clear your doubt. Thanks :)
Oct 01, 2016 · Arun Pandey
Thanks Alex
Sep 30, 2016 · Arun Pandey
Thanks San
Sep 30, 2016 · Arun Pandey
Agreed Ivan
Sep 30, 2016 · Arun Pandey
Thanks Johannes
Sep 30, 2016 · Arun Pandey
Thank you Run
Sep 10, 2016 · Arun Pandey
Thanks Akhil
Sep 10, 2016 · Arun Pandey
Thanks Franks :)
Sep 09, 2016 · Arun Pandey
Thanks Bhavin
Sep 09, 2016 · Arun Pandey
Thanks Shaomin. To answer you - It will not fail with ConcurrentModificationException. While one thread will operate to read the data on same entry another thread would be eligible to write, so get can overlap with put.
Sep 07, 2016 · Arun Pandey
Thnaks Minborg for suggestion,
Aug 30, 2016 · Arun Pandey
Agreed Jimmy :)