top-image

OLDER ARTICLES

Often, developers forgotten the transactional behaviour of proxies Spring:
– by default, the transaction is rollbacked only in the case of runtime, unchecked exceptions (an instance or subclass of RuntimeException) and for Errors;
– the transaction is not rollbacked if a checked exception is thrown from a transactional method.

A good practice is to create 2 types of checked exceptions extending Exception:
– one for the rollback needs for example “BusinessMessageException extends Exception”,
– an other for the no-rollback needs for example “BusinessMessageExcWithoutRollback extends BusinessMessageException”,

and modify the transaction parameters of classes with

"@Transactional(readOnly = true, rollbackFor=BusinessMessageException.class)"

and depending on needs, the parameters of each transactional method with:

"@Transactional(readOnly = false, propagation = Propagation.REQUIRED, noRollbackFor=BusinessMessageExcWithoutRollback.class)"

After several information’s requests concerning the Spring certification, I have decided to write these some words about the SFC certification (Spring Framework Core) in order to share my resources and mock exams.

First, I have received during october 2008, the first training “Spring Framework Core” (4 days) at Luxembourg by the company Spring Source (Creators of the Spring framework). At the end of training, a voucher had been offered to allow the examination. Then, I took the exam SFC 2.5 during june 2011. This exam was about the version 2.5 of Spring, it had 50 multiple choice questions (one only possible answer per question), 88 minutes allotted for this exam. It is success when more than 75% of correct answers, and a provisional certificate of achievement is printed and delivered. The final certificate is received by email and/or post a few weeks later.

Concerning the registration and scheduling of exams, the candidates must register and schedule by:

  • Visiting the Pearsonvue website or Calling the Pearson VUE Call Center.
  • Spring exam should be scheduled at least one full business day in advance.
  • Candidates who need to cancel or reschedule their appointment must do so within 24 hours of their exam appointment.

For my preparation, I have studied Spring with:

For the mock exams, you could use the following resources which some are free and others by paying some euros:

To conclude this post, I propose you a ZIP bonus: a ZIP file certif_spring_mock_exam.zip containing the several mock exams with the corrections.

Best regards,

Hello,

Today, I propose a very simple fake SMTP server designed for unit and system testing applications that send email messages. The class is a ServerSocket (Runnable) which responds to the standard SMTP commands but does not deliver messages to the user. The messages are printed in the full SMTP server log containing all the information exchanged between the SMTP server & the clients.

This ServerSocket could be executed in standalone in a Runnable or in a WEB project via a ContextServletListener configured in the web.xml:

	public static void main(String[] args) {
		try {
			FakeSMTPServer srv = new FakeSMTPServer();
			while (true) {
				Thread.sleep(10000);
			} // end-while
		} catch (Exception e) {
			e.printStackTrace();
		} // end-try
	}

The classes in attachment need the junit-4.1.jar, mail-1.3.2.jar and spring-2.5.5.jar to be used.
FakeSMTPServer.zip

Note: There is other products like SMTP4DEV usable directly without installation.
smtp4dev.zip

For the needs of a project, I have had the opportunity to use the Apache Commons Compress libary in order to archive and compress files in ZIP, TAR, GZIP.

Here, a brief presentation of this library from Apache:
Apache Commons Compress software defines an API for working with compression and archive formats. These include: bzip2, gzip, pack200 and ar, cpio, jar, tar, zip, dump. This is a Java API for working with tar, zip, gz, jar, cpio and bzip2 files. The code has origins in other Apache projects like Excalibur, Ant, Commons-IO and jRPM.
The compress component is split into compressors and archivers. While compressors (un)compress streams that usually store a single entry, archivers deal with archives that contain structured content represented by ArchiveEntry instances which in turn usually correspond to single files or directories. Currently the bzip2 and gzip formats are supported as compressors where gzip support is provided by the java.util.zip package of the Java class library. The ar, cpio, tar and zip formats are supported as archivers where the zip implementation provides capabilities that go beyond the features found in java.util.zip. The compress component provides abstract base classes for compressors and archivers together with factories that can be used to choose implementations by algorithm name.
In the case of input streams the factories can also be used to guess the format and provide the matching implementation.

A note concerning the differences between GZIP and ZIP:
+ GZIP files (the Gnu format) are not archives and compress only one file. GZIP is essentially a one file subset of the Zip format.
+ GZIP compresses only one file and does not have a header. ZIP contains header information about what files are contained in the file.
+ ZIP is an archive file format, popularized on PCs, that contains multiple compressed files.

In the attachments files, you could find a project using commons-compress-1.0.jar with the classes:
CompressArchiveUtil: tool allowing the manipulations of tar or tar.gz documents;
ZipUtil: Utility to Zip and Unzip nested directories recursively

The outputs/files are created in test_compress1\bin\jUnitResources folder.

test_compress1.zip

Source: Apache Commons Compress

Page 52 of 54:« First« 49 50 51 52 53 54 »
bottom-img
Copyright ® 2012 Huseyin Ozveren. No reproduction, even partial, can be used from this site and all its contents including text, documents, images, etc.. without the express permission of the author.