Alfresco the open platform for social content management launches the Alfresco Community 4, the most significant release of the platform to date. Alfresco open source 4 highlights, a wealth of new user features and UI enhancements that enable faster user adoption, along with improved tools to allow developers to create social and cloud-scale, content-rich applications. They also separated their content indexing processes from content management and replaced this functionality with their own indexing solution. Alfresco Community 4 significantly increases overall system performance.

Alfresco 4 also includes functions to publish content and status updates to social sites, such as YouTube, Facebook, LinkedIn, Twitter, Flickr and SlideShare which will be a welcome addition to users as the use of public social media rises. Other new features for cloud-scale performance, open platform for social channel publishing and user experience include:

High-performance Indexing: The New Alfresco Index Server that is based on Apache Solr extensively improves the performance by separating indexing from content processes.

Integrated workflow: It includes the automation of content-focused business processes with Activiti, which is the leading open source Java-based BPMN 2.0 business process server.

Enhanced clustering: This feature is being introduced to increase the reliability and scalability, including added support for clustered CIFS.

Simpler Process: Social content publishing, part of an enterprise content workflow, simplifies to much an extent the problem of multi-channel publishing. It also control publishing with existing review and approve workflows along with built-in content security.

Fewer Tools leads to lesser errors: This feature offers embedded social publishing into an organization’s core content and collaboration tool, which eliminates the need for social-specific tools and error-prone “copy-and-paste” to external tools.

Drag and Drop Simplicity: Drag and drop streamlines the movement of files around on HTML5 enabled browsers.

Additional support for audio, video, Adobe Creative Suite & Apple iWork documents: The support delivers inline preview and metadata extraction for more file types.

Social Features: The new added social features on Alfresco 4 enables to ‘Follow’ influential content creators as well as ‘liking’ the favorite content.

Cloud Collaboration: This includes Google Docs integration to collaborate in real time.

Mobile Support: The mobile support offers new, free iOS apps available from iTunes, along with continued support for WebDAV and CMIS standards for new mobile use cases.

Extensibility: For developers and partners, Alfresco web interface is now much easier to extend and customize.

Alfresco Community edition 4 is available for download from Alfresco’s website.

Context: Upload a file(filename.txt/tif/gif , certificate etc..) in java using selenium, tried with the attachfile Selenium api method [selenium.attachFile(fieldLocator, fileLocator)] but it is not uploading the file.

Solution: We would like to share our experience on the selenium file upload.

First we tried to upload the file using the selenium attachFile api.

void attachFile(java.lang.String fieldLocator, java.lang.String fileLocator)

where,

fieldLocator - an element locator

fileLocator - a URL pointing to the specified file

But it did not work. As we know that selenium is an automated test cases and it should run either on local machine or remote machine. Due to security restriction in the browser, JavaScript cannot fill in a path in the respective file input field by default. That’s might be the root cause of file not uploading.

After extensive search on net, got partial hint to use “type” instead of “attachFile”.

The syntax is as follows: void type(java.lang.String locator, java.lang.String value)

We unsuccessfully tried to put various appropriate file path values. Finally, we got the success when we implemented the value as file.toURI.toURL().toString().

where toURI provides the absolute path and toURL construct a URL from the URI followed by make it as string type.

Example is as follows :

// Create a file object

File file = new File(”");

// Get the absolute path of application

String pathOfApplication = file.getAbsolutePath();

// Get absolute path of the file

String absolutePathOfFile = pathOfApplication + File.separatorChar + directoryName + File.separatorChar + uploadFileName;

// Where directoryName is the directory which resides in the path of application, which contains the file to be uploaded (uploadFileName)

// Create a new file having reference of absolute path

File absFile = new File(absolutePathOfFile);

// Selenium command

selenium.type(”fieldLocator “, absFile.toURI().toURL().toString());

There may be other solutions but the above implemented solution works fine for us.

How to add search in Liferay theme
Posted on September 09, 2011

Steps to add search in theme:

1. Open file [LIFRAY_SDK]/themes/{theme-name}/docroot/_diffs/templates/portal_normal.vm

2. Add $theme.search() at your desired location.

3. Build and deploy the theme.

4. A search text box will appear where the code was placed

Steps to customize the search:

In case you need to customize the search functionality to search only specific content types, follow the steps below.

1. Open file [LIFERAY_HOME]/tomcat-6.0.26/webapps/ROOT/WEB-INF/classes/portal-ext.properties

2. Add following lines:

com.liferay.portlet.blogs.util.BlogsOpenSearchImpl=true

com.liferay.portlet.bookmarks.util.BookmarksOpenSearchImpl=true

com.liferay.portlet.calendar.util.CalendarOpenSearchImpl=true

com.liferay.portlet.directory.util.DirectoryOpenSearchImpl=true

com.liferay.portlet.documentlibrary.util.DLOpenSearchImpl=true

com.liferay.portlet.imagegallery.util.IGOpenSearchImpl=true

com.liferay.portlet.journal.util.JournalOpenSearchImpl=true

com.liferay.portlet.messageboards.util.MBOpenSearchImpl=true

com.liferay.portlet.wiki.util.WikiOpenSearchImpl=true

3. Change values to “false” for those you do not want to include in search result.

For example, to search only “Web Content”, leave “com.liferay.portlet.journal.util.JournalOpenSearchImpl” to “true” and make other values to false.

Enjoy the customized search in Liferay :)

Introduction:

Windows Communication Foundation (WCF) is a communication frame work for building service-oriented applications. With WCF, data can be sent from one service endpoint to other. The data sent can be a single character or word sent as XML or a stream of binary data.

Creating and Consuming a Sample WCF Service:
There are three main steps involved in creating and using the WCF services.

  • To create a wcf Service.(Creating)
  • Bind an address to the service and host the Service. (Hosting)
  • Use the Service.(Consuming)

Step 1: Create a wcf service

In WCF, all the services are exposed as contracts. A contract is a neutral and standard way of describing what the service does. Mainly there are four types of contracts:

  • Service Contract
    This contract describes all the available operations that a client can perform on the service.
  • Data Contract
    This contract defines which data types that are passed to and from the service.
  • Fault Contract
    This contract describes about the error raised by the services and how the service propagates errors to its clients.
  • Message Contracts
    This contract provides the direct control over the SOAP message structure. This is useful in inter-operability cases and also when there is an existing message format you have to comply with.

Step 2: Binding and Hosting
Each service has its own end points. Clients communicate with this end point only. End points describe three things:

  • Address
  • Binding type
  • Contract Name (defined in STEP 1)

Every service should be associated with a unique address. Address mainly contain the following two key factors:

  • Transport protocol that is used to communicate between the client proxy and service.
  • Location of the service.
    Location of the service describe the targeted machine path (where service is hosted) and an optional port name.

Hosting:
Every service must be hosted in a host process. Hosting can be done by using:

  • IIS
  • Windows Activation Service (WAS)
  • Self hosting

IIS Hosting
IIS hosting is the same as hosting the traditional web service hosting. It can be done by creating a virtual directory and supplying a .svc file.

Hosting with Windows Activation Service (WAS)
WAS is part of IIS 7.0. It comes with VISTA OS. The hosting with Windows Activation Service is same as hosting with IIS. The only difference between these two is that IIS supports for HTTP bindings only. Whereas WAS supports for all transport schemas.

Self Hosting
In this technique the developer is responsible for providing and managing the life cycle of host process. In this the host service must be running before the client call the service. To host this service we use the .NET class ServiceHost. We have to create an instance of ServiceHost. Constructors of this class take two parameters: service type, base address. (Base address can be empty set.)

Add the Service End points to the host:
We will use the AddServiceEndpoint() method to add an end point to the host. The end point contains three things: type of service, type of binding and service Name. So, AddServiceEndpoint() method accepts these three required parameters.

Consuming by creating the channel factory:
We can consume this service by creating the channel factory manually. While creating the channel, we will have to provide the same binding type and end point address where the service is hosted.

Best Practices to create a wcf service:

General Guidelines

  • The services should be very much secure.
  • Services should be accessed by concurrent clients.
  • The services should be robust and reliable.
  • The services should be responsive and disciplined.

Essentials:

  • The service code should not be places in any hosting EXE. Instead it should be placed in a class library.
  • The provided constructors should not be parameterized.
  • The namespaces provided to the contracts should be meaningful.
  • Self hosting should be preferred over IIS hosting for intranet applications.
  • WAS hosting should be preferred over Self hosting on Windows Vista and Windows Server 2008.
  • All the end-points should be named in the config file.
  • The proxy should be cleaned up while using a tool such as Visual Studio 2008.
  • The proxy should be factored to a separate class library, if two or more clients are using the same contract.
  • The proxy should always be closed or disposed.

Service Contracts:

  • ServiceContractAttribute should always be applied on an interface, not on a class.
  • The service contract name should always be prefixed by I.
  • Property-like operations should always be avoided.
  • Contracts having only one member should also be avoided.
  • Three to five members should be tried to have in a service contract.
  • Do not have more than twenty members per service contract.

Data Contracts:

  • DataContract attribute should always be applied on Data Contracts.
  • DataMemberAttribute should be used on properties or read-only public members only.
  • Explicit XML serialization should be avoided.
  • All the members coming from the same level in the class hierarchy should be assigned the same value when using the Order property.
  • Delegates and events should not be marked as data members.
  • ADO.net DataSet and DataTables should not be accepted or returned from operations.
  • A neutral representation such as an array should be returned instead.
  • Data Contract should be shared across projects wherever possible.

Operations And Calls:

  • One way calls should not be treated as asynchronous or concurrent calls.
  • Exceptions should always be expected out of a one way operation.
  • Reliability should be enabled even on one way calls. Use of ordered delivery is optional.
  • One way operations should be avoided on a sessionful contract or it should be used as a terminating operation.
  • Callback Contract on the service side should be named after the service contract suffixed by Callback.
  • Regular callbacks and events should not be mixed on the same callback contract.
  • Event operations should be designed with return type as void and no out parameters.

Transactions:

  • One way calls should not be treated as asynchronous or concurrent calls.
  • Exceptions should always be expected out of a one way operation.
  • Reliability should be enabled even on one way calls. Use of ordered delivery is optional.
  • One way operations should be avoided on a sessionful contract or it should be used as a terminating operation.
  • Callback Contract on the service side should be named after the service contract suffixed by Callback.
  • Regular callbacks and events should not be mixed on the same callback contract.
  • Event operations should be designed with return type as void and no out parameters.

Security:

  • IDesign’s security framework should be used and manual configuration should be avoided for security purposes.
  • PrincipalPermissionAttribute should never be applied directly on service class.
  • Work requiring authorization at service constructor should be avoided.
  • Role based security should not be relied upon in the client’s callback operations.
  • Transport security should be used for Intranet clients and Message security should be used for Internet clients.
  • Clients should be allowed to negotiate the service certification.

Some of the guidelines listed above can safely be ignored when applying special circumstances. But make sure you fully understand about serialization, deserialization, and schema mechanisms involved before you deviate from the guidelines.

Further Reading:

http://msdn.microsoft.com/en-us/netframework/aa663324

http://msdn.microsoft.com/en-us/library/ms731082.aspx

http://wcftutorial.net/

http://en.wikipedia.org/wiki/Service-oriented_architecture

http://msdn.microsoft.com/en-us/library/aa480021.aspx

http://www.service-architecture.com/

http://www.webopedia.com/TERM/S/Service_Oriented_Architecture.html

http://www.javaworld.com/javaworld/jw-06-2005/jw-0613-soa.html

http://www.youtube.com/watch?v=sbd_1G8Kqjs

http://www.soapatterns.org/

http://www.cio.com/topic/3016/Service_Oriented_Architecture_SOA

http://looselycoupled.com/glossary/SOA

Selenium is a free open source software testing framework which provides tools to author, record, edit and play tests for automating user-interface tests for web applications. These tests can be run on most of the modern browsers and operation systems like Windows, Linux, and Macintosh. These test scripts can be written in a number of most common programming languages including C#, Java, Groovy, Perl, PHP, Python and Ruby.

PHPUnit is a unit testing framework for testing PHP applications. Selenium tests can be written using PHP language and integrated with PHPUnit framework for screen shot captures and easy reporting.

Following are steps to automate web browser testing using Selenium and PHPUnit.

Fire up Selenium IDE in Firefox browser:
(NOTE: you must have the Selenium IDE add-on installed to proceed)

  • Open the Selenium IDE from the tools tab in Firefox. Now surf on any website, click on any button on website. Then on the Selenium IDE window, press the circular red button to stop the web page recording. Click on the File menu -> Export Test Case As -> PHP - PHPUnit.
  • Now you can export actions performed on that web page into a compatible PHP code. You can use this code in PHPUnit to replay them which I will show you how to do them as we proceed further.

Installing PHPUnit
To install PHPUnit you need to use the PEAR installer. The PEAR channel (pear.phpunit.de) is used to distribute PHPUnit so make sure that it is registered with your local PEAR environment:

  • pear channel-discover pear.phpunit.de
  • After the channel is registered install PHPUnit: pear install phpunit/PHPUnit

Selenium RC installation
Selenium RC is a Java based command line server that starts browser and runs commands you pass from your tests.

  • Install the Java runtime environment from here.
  • Download Selenium RC from here.
  • Once the Selenium jar file has been extracted, launch the Selenium server with this command
  • java -jar selenium-server.jar
    This will start the server on port 4444.
  • Make sure you keep this server running till you finish testing so that the server is able to accept test commands from your PHP script.

Climax: Using PHPUnit
It is time to test our PHP script that we had exported earlier using Selenium IDE. Launch your command prompt in windows & run this command:

phpunit filename.php
where filename.php is the name of your PHP file

This will start the test. Each test command from your file will be sent to the Selenium server, which does the job of launching the appropriate browser (in our case, Mozilla Firefox), open web page and perform the same recorded actions which you performed and close the browser after the test completes.

You can also add your conditional codes in the PHP script file to add more flexibility say, to catch certain exceptions.

Things to remember for future

Also, keep in mind that the PHP file which the Selenium IDE has may contain certain HTML codes which may not work when you are executing your script. For example, you clicked on a button, Selenium recorded it, converted the action into the PHP code before exporting it to a PHP file. Now when you are running the script in PHPUnit, you may or may not encounter the error that the HTML element was not found.

In that case, you will have to manually write the correct code so your script is able to find that button in the web page when you execute it again.

Regression Test Emails using Selenium
Posted on August 26, 2011

Emails are an integral part of any system and thus becomes an important functionality to be regression tested. Testing emails has been difficult because of it being non real time in nature. Sometimes emails take 5-10 minutes to get into the mailbox and thus create problems.

Because of this automated regression testing emails using Selenium is not fool proof either. One of the ways to approach it is that we check the inbox for mail until a time limit of say 10 minutes and based on that complete your test case. In normal scenario mails should reach inbox within 10 minutes. Companies running their own exchange server can actually manage this more predictably..

Here is what can be followed as a concept to regression test emails:-

Let’s assume system sends an email during registration for confirming user’s email address. For testing purpose we would consider that email is being sent to your company’s email-id that is available on web.

  • After sending mail wait for 1 minute.
  • Launch company’s web based email viewer (something like a webmail) using Selenium
  • Login into the system using Selenium
  • Click on new messages and parse the mail
  • Verify if it is the right email using Selenium
  • If not then keep on trying until all the new emails are verified.
  • If you did not receive the mail then make the thread to sleep for another 1 minute and retry.

You can put this in a loop to verify email for another 5-10 minutes and if email is not received then fail the test case.

Web Application Automation: Why open source Selenium can be a good choice?

In Agile development practice, code is evolved on daily basis with dispersed teams across globe. Maintaining quality of the product is a major concern. To maintain quality of the product continuous regression tests need to be executed to ensure predictive behavior of the product with each release. Generally companies are maintaining a set of manual test cases and run them with each product releases. With each product release new features are added and hence these test scripts are updated with new test cases and hence they becomes huge. Time of execute these huge test scripts with each product release would put adherence to the release timelines which would significantly impact time of market of the product. Hence a need arises to automate these repetitive test cycles to reduce this time and increase time to market. A good open source tool Selenium will help in automating this repetitive task. Following are advantages of using selenium over other available tools in the market.

  • Low cost open source tool: Selenium is offered as free open source test automation framework and tools to automate testing of web application developed in any language. Other commonly used open source tools are Watir , Sahi etc.
  • Language choice: Selenium client libraries can be imported into popular language IDE’s like Eclipse, Net beans, Visual Studio.Net etc.
  • Multiple Test Framework Support: Selenium supports multiple testing frameworks like JUnit, TestNG, PHPUnit etc
  • Cross Platform Browser Testing: Testing scripts can be developed once and executed on many browsers to testing.
  • Integration with Testing Ecosystem: Selenium can be easily integrate with many different suite of tools like Hudson, QMetry , selenium Grid , saucelabs etc
  • AJAX Support: Selenium offers strong support for AJAX technologies.
  • Expandable for Enhancement: Selenium can be enhanced for other complex testing like load testing, production monitoring etc.
  • Perform Comprehensive Testing : Selenium can be used for UI, functional, regression and UAT testing.
  • Strong Community: There is a good quality documents and web community available for Selenium.
  • Test Driven Development (TDD): This framework is used by developers in the Agile and extreme programming (XP) community.

You can find more information about Selenium and download it from below link
http://seleniumhq.org/

When you want to include custom JavaScript and CSS file in pages (Velocity Templates) specific to your custom plug-in module, please follow these steps:

1. Place the js/css file into desired directory (let it - includes/effects/js/ )

2. Place the following entry into atlassian-plugin.xml

<web-resource key=”resources” name=”resources” >

<resource type=”download” name=”report.js” location=”includes/effects/js/report.js” />

<resource type=”download” name=”report.css” location=”includes/effects/css/report.css” />

————

<context>custum-resources</context>

</web-resource>

3. Add the following line in template file where you want to include above JS/CSS (Velocity template)

$webResourceManager.requireResourcesForContext(”custum-resources”)

Are you not able to enhance a product easily because the design is not allowing you to do?

Are you not able to integrate new interfaces/services?

Are you not able to connect to multiple databases?

Above are some typical problems that come during maintenance of existing applications to incorporate new business requirement. These are also some common requirements while defining scalable framework for new application and products so that future changes can be incorporated with minimal design changes. To address above concerns there are industry proven pattern available which is named as “Inversion of Control (IoC)” or “Dependency Injection Pattern (DI)” by Martin Fowler or  “Unity Application Block” in Enterprise Library 4.1 by Microsoft.

The purpose of this pattern is to reduce coupling between software components and build loosely coupled applications. It provides a way to handle dependencies between objects. Traditional approach was to hard-code objects and their dependencies. For instances application can hard-code single/multiple database driver which would enable it to connect to a particular database but what if business requirement changes to connect to different family of database. This would require changes to existing code to connect to new database which can introduce more defects into code and above all there will be two pieces of code which need to be modified for any changes in the way application interacts with database.

This pattern offers a solution to this problem, Instead of hard-coding the dependencies, a component/object just lists the necessary services in configuration files (In our case database drivers and Unity Framework or DI framework will provide (create, initialize and setup) these services (database drivers) to objects or software components at runtime. These services can be changed or modified later based on business requirements which makes code scalable and maintainable in future.

Benefits of above pattern is to reduce common code to create, initialize and setup dependencies or objects, this is handled automatically by pattern framework using configuration files. Configuration files also provides flexibility to incorporate alternate implementations or a given service/component or object. This is also useful during unit testing as it is easy to inject fake implementations of a service (If actual services are paid or inaccessible from development environment) into objects being tested by changing configuration files.

References:-

http://martinfowler.com/articles/injection.html

http://msdn.microsoft.com/en-us/library/ff648512.aspx

HTML 5
Posted on August 22, 2011

HTML 5 is a response when web applications are most popular in the market using HTML and XML features. People want to access applications anywhere or from any system which is driving market to look closely at browser side enhancements.

HTML 5 is having many syntactical features. These include the <video>, <audio> , <header> , <canvas> and much more elements. These features enable developers to represent multimedia and graphics content in a much more sophisticated way. No flashes, images and urls to reduce the performance of a web application.

HTML 5 features include:

1. Storage Events
2. Dataset (data-* attributes)
3. Drag/ Drop
4. GeoLocation
5. Offline Detection
6. Offline Application using Manifest
7. Storage
8. Web SQL Database Storage

HTML 5 together with JQuery enrich the developers to make the application extremely animated and rich which was taking lots of effort with classic application.

Happy Programming with HTML 5 ! :)