Wednesday, May 23, 2018

Using Storefront Test Automation IBM WCS

Storefront Test Automation Engine
Using Storefront Test Automation Engine of WCS v7 FEP6
The Storefront Test Automation Engine (STAE) facilitates the process of writing, maintaining, and running test scripts to test the store functionally
Below are the components of STAE
Test Suite
Test Suites are built based on JUnit and are used to select the test case that must be run.
Test
A Test performs a few tasks from different page objects to test a storefront flow. Since all tests are built using JUnit version 4, all methods must match the following criteria to be identified as a test:
·         Be annotated with @test annotation
·         Be public
·         Have no arguments
Methods that are annotated with @Before are called before each test case. They are used to prepare the data that is required by the test.
Methods that are annotated with @After are called after each test case. They are used to release resources after a test is complete or complete a cleanup.
Store Page Objects
Store page objects are Java classes that act as a high-level abstraction of the web page. They include relevant tasks and the element identifiers found on the web page that is used         by the tasks. Example: AuroraFrontPage class is a SPO
Web test engine
This layer offers functionality to the tests to interact with a web browser. We have option to use HTMLUnit or test via browsers like Firefox, IE and chrome using the Selenium server
Setting up and running tests
Installing the Storefront Test Automation Assets
We need to download the WC_V7.0_-_FEP6STSTORECOMPASSETSMPEN.zip file from IBM Partnerworld site. Once downloaded, extract the zip to a temp folder.




Step 1: Open IBM Installation Manager



Step 2: Add the downloaded test asset store repository using File->Repositories link and click Install. You will be provided with the below page.Select the Companion Asset for FEP 6 and click NEXT



Step 3: Accept the License Agreement and click Next



Step 4: Provide path and click next



Step 5: Select all options and click Next



Step 6: Click Install



Step 7: Verify if the installation is a success and click Finish



Step 8: After installation, go to the installation directory and unzip all zip files available there
Setting up the Storefront Test Automation Engine
Pre-requisites
We need to download the below items to setup the STAE
JUnit
Latest JUnit version can be downloaded from
http://sourceforge.net/projects/junit/files/junit/
Selenium Server
Latest version can be downloaded from
http://docs.seleniumhq.org/download/
HttpClient, HttpCore and HttpMime
Latest version can be downloaded from http://hc.apache.org/downloads.cgi and http://mvnrepository.com/artifact/org.apache.httpcomponents/httpmime
Some test scripts require setup steps that access WebSphere Commerce Accelerator or IBM Management Center for WebSphere Commerce. To do so, the Storefront Test Automation Engine makes HTTP calls to the WebSphere Commerce back-end tooling using HttpClient.

Google Guice

Latest version can be downloaded from http://code.google.com/p/google-guice/downloads/list
To use Chrome as a test browser, we must install separate ChromeDrive for use with Selenium. Get the latest from http://code.google.com/p/selenium/wiki/ChromeDriver
After downloading all the above required files, extract them to their respective temp folder. We need the JARs to setup the test project later
Setting up STAE:
        -      In RAD select File > Import.
        -      In the Import window, select General > Existing Projects into Workspace; then click Next.
        -      Select archive file option and then click Browse.
        -      Browse to the location where we installed Storefront assets and then select the zip file StorefrontTestAssetsWteFEP6.zip for Web testing or select MobileTestAssetsFEP6.zip for Mobile testing.
        -      Select the all projects shown and then click Finish.
Example: Wte, WCHTTPClient, WCWebTestEngine, and Aurora-Tests-Wte, Mobile-Wte
The Storefront Test Automation Engine projects are now in RAD. Since the library dependencies are not installed yet, the Problems view displays multiple compilation errors. We will resolve these errors in the next step.
Install the dependencies of the STAE
a.    In both the WCHTTPClient, Aurora-Tests-Wte, WCWebTestEngine and Wte projects, create the lib directory at the root of the project.
b.    Copy all of the JAR files related to HttpClient, HttpCore, HttpMime to the lib directory of the WCHTTPClient project.
c.    Add the above JAR files to the project build path.
d.    Browse to the directory on the file system that contains the extracted JUnit files. Copy thejunit-(version_number).jar file to the lib directory of the Wte project.
e.    Copy the following files to the lib directory of the Wte project:
      selenium-server-(version_number).jar
f.     Browse to the directory on the file system that contains the extracted Google Guice files. Copy the following files to the lib directory of the Wte project:
      Guice-(version_number).jar.
g.    Add the JARS to project build path

h.    In the Aurora-Tests-Wte project, browse to src\com\ibm\commerce, delete the url directory, and then refresh the project in RAD.
i.      Right-click the Aurora-Tests-Wte project and click Build Path > Configure Build Path. In the Projects directory remove any projects that are marked as missing.
j.     In the WCWebTestEngine lib folder add guice-(verison_number).jar and guice-assitedinject-(verison)number).jar.
k.    Add the same to the project build path
Running Tests

In the config.properties file present in Aurora-Tests-Wte project, change the following properties to reflect our environment:
# The host name of their server you are testing.
HOSTNAME=localhost
# The path part of the URL of the store to open (exluding the host).
STOREURL=/webapp/wcs/stores/servlet/en/aurora
# The browser type.
# Possible values: FIREFOX, INTERNET_EXPLORER
BROWSER_TYPE=FIREFOX
#Path to where screenshots are stored for failed test cases
SCREENSHOTPATH=c:/screenshots/
#Site administrator userid and password
ADMIN_USER_NAME=wcsadmin
ADMIN_PASSWORD=wcsadm1n
#URL of the esite store
ESITE_URL=/webapp/wcs/stores/servlet/StoreView?storeId=11001

 Use one of the following scenarios to run your tests:

Option
Description
Run the entire test bucket
a.    In the Java perspective of your Eclipse-based environment, locate the Package Explorer view and navigate to the tests directory.
b.    Locate the AllTests.java class.
c.    Right-click the AllTests.java class; then select Run As > JUnit Test.
Run a test scenario
d.    In your Eclipse-based environment, open the Package Explorer view and navigate to the tests scenario directory.
e.    Right-click the test script that you want to run; then select Run As > JUnit Test.
Run a single test case
Note: Since many test cases require data created by the FSTOREB2C_00.java test case, it is recommended that you run this test case first to populate the required test data.
f.     In your Eclipse-based environment, open the Package Explorer view and navigate to the tests scenario directory.
g.    Locate the test scenario that contains the test case you want to run; double-click the test scenario to open it.
h.    Locate the single test case that you want to run. There is one Java method for each test case.
i.      Right-click the Java method name for the test case; then select Run As > JUnit Test.



Future Work:

We can use Selemiun Grid which is part of Selenium 2 to run tests on multiple machines using multiple browsers to speed up the test case execution time or is we want to test multiple browsers simultaneously.

More info at:



http://docs.seleniumhq.org/docs/07_selenium_grid.jsp


Wednesday, May 16, 2018

Resolve ORA-011033: ORACLE initialization or shutdown in progress

Two way to resolve:

go to cmd prompt :



1.  Run below query

sqlplus system/Oracle_1@pdborcl as sysdba;
alter database open;

If it not work

2. Run below query..



> sqlplus /nolog

SQL> connect / as sysdba

Connected.

SQL> shutdown abort

ORACLE Instance shut down.

SQL> startup nomount

ORACLE Instance started

SQL> alter database mount;

SQL> alter database open;
Which still gave the error:

ORA-00600: internal error code, arguments: [kcratr1_lostwrt]
I then found the advice to do the following:

SQL> startup mount

ORACLE Instance started

SQL> recover database 

Media recovery complete

SQL> alter database open;

Database altered

Monday, April 16, 2018

Solr Search Customization by introducing a new facet in Websphere Commerce

schema.xml 

This file defines the schema fields and data type of the fields.This file also defines the SOLR field settings. Searchable,sortable SOLR fields are defined here.

Go to the below folder
<WCDE>\search\solr\home\MC_<master_catalog_id>\en_US\CatalogEntry\conf.

Open the file schema.xml in a text editor.

Search for the string “Catentry's basic attributes”. This will bring you to the section of the file where the index fields are defined.

The first block of index fields represent data from the CATENTRY table. Since the field1 value is also stored in the CATENTRY table, you need to add the new index field here.

 At the bottom of the CATENTRY fields add the line:

<!--    Catentry's basic attributes: map to table CATENTRY   -->
<field name="catentry_id" type="string" indexed="true" stored="true" required="true" multiValued="false"/>
<field name="member_id" type="long" indexed="true" stored="true" multiValued="false"/>
<field name="mfName" type="wc_text" indexed="true" stored="true"  multiValued="false"/>
<field name="buyable" type="int" indexed="true" stored="true" multiValued="false"/>
<field name="field1" type="long" indexed="true" stored="true" multiValued="false"/>

Next we  will update the queries that are used to populate the Solr index from the WebSphere Commerce database tables. Each query needs to retrieve the data stored in field1 of the CATENTRY table.

wc-data-config.xml 

This file contains queries for getting data from preprocess tables (regular WC tables if necessary)to populate the search index. The query results are mapped to SOLR fields in this file. Open the file wc-data-config.xml.

(<WCDE>\search\solr\home\MC_<master_catalog_id>\en_US\CatalogEntry\conf)

The wc-data-config.xml file loads catalog entry data in three separate parts. Product data is loaded first. This is followed by bundle data and finally all other catalog entry types. For each of the three sections there is a query for populating the full index and another query for delta updates. For each section (product, bundle and other), you need to update the two queries and then add a new field element to assign the data from the WebSphere Commerce database to the field1 field in the Solr index. All together there are nine updates you need to make to this file.

Update the product queries and assignment.

1) Search for the string buyable from the top of the file. This is another column in the CATENTRY table that is already included in the query.
2) The first place you find the string is in the main product query. Add CATENTRY.FIELD1 to the SELECT statement immediately following CATENTRY.BUYABLE. Your updated query should look like the screen capture below.

query="SELECT CATENTRY.CATENTRY_ID,CATENTRY.MEMBER_ID,CATENTRY.CATENTTYPE_ID,CATENTRY.PARTNUMBER,CATENTRY.MFPARTNUMBER,CATENTRY.MFNAME, CATENTRY.BUYABLE,CATENTRY.FIELD1,STORECENT.STOREENT_ID

Search for buyable again. The second place you find the string is the delta index query. Make the same update to this query as you did to the previous one.

deltaImportQuery="SELECT CATENTRY.CATENTRY_ID,CATENTRY.MEMBER_ID,CATENTRY.CATENTTYPE_ID,CATENTRY.PARTNUMBER,CATENTRY.MFPARTNUMBER,CATENTRY.MFNAME, CATENTRY.BUYABLE,CATENTRY.FIELD1,STORECENT.STOREENT_ID,

Search for buyable once more. This brings you to the section where the data retrieved from the WebSphere Commerce database is assigned to the Solr index fields. Add an element under buyable to map the FIELD1 database column to the field1 index field. Your updated file should look like the screen capture below.

<field column="CATENTRY_ID" name="catentry_id" />
<field column="MEMBER_ID" name="member_id" />
<field column="PARTNUMBER" name="partNumber" />
<field column="MFNAME" name="mfName" />
<field column="BUYABLE" name="buyable" />
<field column="FIELD1" name="field1" />
                                                                                                                                                                 
Do the steps done for products for  bundles  if required

Make field1 a product facet by making entries in SRCHATTR, SRCHATTRPROP tables

Update the SRCHATTR table. Each row in this table represents the logical name of a catalog attribute that is defined in the search schema.

Enter the SQL below to add field1 to the table. You can use any available primary key, the value 101 is used here as an example. The value of ‘0’ for INDEXSCOPE indicates that this is a site-wide field.

insert into SRCHATTR (srchattr_id, indexscope, indextype, identifier)values (101, '0', 'CatalogEntry','_cat.Field1');

Update the SRCHATTRPROP table. This table stores information about which fields are defined as facets.

insert into SRCHATTRPROP (srchattr_id, propertyname, propertyvalue) values (101,'facet','field1');

JSP Related Changes for displaying facet in Store

Add the facet to the storefront  so that the Madisons storefront to display the facet data in the left sidebar.

Navigate to Stores>WebContent>Madisons>Snippets>ReusableObjects and open the file SearchFacetsDisplay.jspf. This JSP fragment loops through the available global facets and includes another JSP fragment to display each facet’s data. You will create the new JSP fragment for field1 in a later step.

Add a new test into the <c:choose> block to look for the field1 facet and include its display JSP fragment. You can copy one of the existing <c:when> blocks and update it to match the screen capture below.

<c:when test=”${facetField.value eq ‘field1’}”>
 <%@ include file=”../../ Field1FacetDisplay.jspf”%>
 <c:set var=”f” value=”$(f+1}”/>
</when>

Navigate to Stores > WebContent > Madisons > Snippets > Search.
Make a copy of the file  BrandFacetDisplay.jspf and call the new file Field1FacetDisplay.jspf.

Open Field1FacetDisplay.jspf. Remove   the below line starts with

<span class =left_sidebar_header”> <fmt:message key="SEARCH_FACET_MANUFACTURER" bundle="${storeText}"/></span>
Add the below line
<span class =left_sidebar_header”> Shopper points</span>

Management Center changes

1.Login into Management Center
2.Select the Madisons store.
3.Expand the master catalog and select the Coffee Tables category to display the catalog entries list.
4.Select catalog entry
5.Choose configure columns
6.Select field1,and assign some value so that it will come in facets
7.Do the same for other catalog entries

Thursday, March 29, 2018

EJB Bean and table relation in ibm wcs

Some time i want to see custome access bean belongs to which table.

You search for map.mapxmi this file have linking og table with bean.


For OOB beans refer below URL :

Cross-reference of data beans, EJB beans, and tables

Wednesday, March 21, 2018

IBM WCS Toolkit - java.lang.ClassNotFoundException: com.ibm.db2.jcc.am.SqlDataException



ISSUE:
Frist time after starting WCS V8, I hit store URL and i got below exception:
The exception seems to derive from the class: com.ibm.commerce.foundation.server.command.bod.BusinessObjectDocumentProcessor
In particular, this class makes a check about the existing masked exceptions; the list of values of the masked exceptions is contained in the following file:
 IBM\WCDE80\workspace\WC\xml\config\com.ibm.commerce.foundation\wc-component.xml
<_config:configgrouping name="BusinessObjectDocumentProcessor">
    <_config:property name="maskedExceptionClassList" value="java.sql.SQLException,com.ibm.db2.jcc.am.SqlDataException,com.ibm.commerce.foundation.server.services.dataaccess.exception.QueryServiceSystemException"/>
</_config:configgrouping>
The above code contains- in the maskedExceptionClassList property- the class com.ibm.db2.jcc.am.SqlDataException.
 However, the system is not using DB2 but Oracle, so it's pretty normal an exception is thrown and the class is not found.


[3/21/18 12:02:57:315 IST] 000000f6 BusinessObjec W com.ibm.commerce.foundation.server.command.bod.BusinessObjectDocumentProcessor static com.ibm.db2.jcc.am.SqlDataException
                                 java.lang.ClassNotFoundException: com.ibm.db2.jcc.am.SqlDataException
 at java.lang.Class.forNameImpl(Native Method)
 at java.lang.Class.forName(Class.java:256)
 at com.ibm.commerce.foundation.server.command.bod.BusinessObjectDocumentProcessor.<clinit>(BusinessObjectDocumentProcessor.java:141)
 at java.lang.J9VMInternals.initializeImpl(Native Method)
 at java.lang.J9VMInternals.initialize(J9VMInternals.java:235)
 at com.ibm.commerce.catalog.facade.server.CatalogFacadeImpl.getCatalog(CatalogFacadeImpl.java:56)
 at com.ibm.commerce.catalog.facade.server.EJSLocalStatelessCatalog_867afe99.getCatalog(EJSLocalStatelessCatalog_867afe99.java:845)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:95)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:56)
 at java.lang.reflect.Method.invoke(Method.java:620)
 at com.ibm.commerce.foundation.internal.client.services.invocation.impl.LocalEJBInvocationBindingImpl.invoke(LocalEJBInvocationBindingImpl.java:211)
 at com.ibm.commerce.foundation.internal.client.services.invocation.InvocationService.invoke(InvocationService.java:113)
 at com.ibm.commerce.foundation.client.facade.bod.AbstractBusinessObjectDocumentFacadeClient.internalSendBusinessObjectDocument(AbstractBusinessObjectDocumentFacadeClient.java:813)
 at com.ibm.commerce.foundation.client.facade.bod.AbstractBusinessObjectDocumentFacadeClient.sendBusinessObjectDocument(AbstractBusinessObjectDocumentFacadeClient.java:529)
 at com.ibm.commerce.catalog.facade.client.AbstractCatalogFacadeClient.getCatalog(AbstractCatalogFacadeClient.java:186)
 at com.ibm.commerce.catalog.facade.client.AbstractCatalogFacadeClient.getCatalog(AbstractCatalogFacadeClient.java:371)
 at com.ibm.commerce.catalog.facade.client.AbstractCatalogFacadeClient.getCatalog(AbstractCatalogFacadeClient.java:397)
 at com.ibm.commerce.catalog.facade.server.cache.DefaultCatalogCache$MyDefaultCatalogCacheableDataAndDependencyIdGenerator.generateCacheableData(DefaultCatalogCache.java:117)
 at com.ibm.commerce.datatype.AbstractFinderResult.invokeFinder(AbstractFinderResult.java:622)
 at com.ibm.commerce.datatype.CacheableFinderResult.invokeFinder(CacheableFinderResult.java:195)
 at com.ibm.commerce.dynacache.commands.AbstractFinderResultCache.myInvokeFinder(AbstractFinderResultCache.java:1526)
 at com.ibm.commerce.dynacache.commands.AbstractFinderResultCache.invokeFinder(AbstractFinderResultCache.java:1161)
 at com.ibm.commerce.dynacache.commands.AbstractDistributedMapCache$Cache.getOrPut(AbstractDistributedMapCache.java:520)
 at com.ibm.commerce.dynacache.commands.AbstractDistributedMapCache$Cache.access$3(AbstractDistributedMapCache.java:507)
 at com.ibm.commerce.dynacache.commands.AbstractDistributedMapCache.getOrPut(AbstractDistributedMapCache.java:285)
 at com.ibm.commerce.catalog.facade.server.cache.DefaultCatalogCache.getDefaultCatalogId(DefaultCatalogCache.java:168)
 at com.ibm.commerce.catalog.facade.server.helpers.CatalogComponentHelper.getDefaultCatalogId(CatalogComponentHelper.java:6272)
 at com.ibm.commerce.seo.registry.SEOConfigurationRegistry.populateStoreUrlKeywords(SEOConfigurationRegistry.java:552)
 at com.ibm.commerce.seo.registry.SEOConfigurationRegistry.initialize(SEOConfigurationRegistry.java:306)
 at com.ibm.commerce.seo.registry.SEOConfigurationRegistry.initializeRegistry(SEOConfigurationRegistry.java:1644)
 at com.ibm.commerce.seo.registry.SEOConfigurationRegistry.singleton(SEOConfigurationRegistry.java:843)
 at com.ibm.commerce.seo.url.helpers.SEOURLMapperImpl.getStoreIdFromSEOURL(SEOURLMapperImpl.java:1636)
 at com.ibm.commerce.seo.url.helpers.SEOURLMapperImpl.processRequestURL(SEOURLMapperImpl.java:1743)
 at com.ibm.commerce.webcontroller.RuntimeServletFilter.doFilterAction(RuntimeServletFilter.java:647)
 at com.ibm.commerce.webcontroller.RuntimeServletFilter.access$0(RuntimeServletFilter.java:614)
 at com.ibm.commerce.webcontroller.RuntimeServletFilter$1.run(RuntimeServletFilter.java:458)
 at com.ibm.commerce.webcontroller.RuntimeServletFilter.doFilter(RuntimeServletFilter.java:500)
 at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:195)
 at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:91)
 at com.ibm.ws.webcontainer.filter.WebAppFilterManager.doFilter(WebAppFilterManager.java:967)
 at com.ibm.ws.webcontainer.filter.WebAppFilterManager.invokeFilters(WebAppFilterManager.java:1107)
 at com.ibm.ws.webcontainer.webapp.WebApp.handleRequest(WebApp.java:3926)
 at com.ibm.ws.webcontainer.webapp.WebGroup.handleRequest(WebGroup.java:304)
 at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1007)
 at com.ibm.ws.webcontainer.WSWebContainer.handleRequest(WSWebContainer.java:1817)
 at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:200)
 at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:463)
 at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewRequest(HttpInboundLink.java:530)
 at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.processRequest(HttpInboundLink.java:316)
 at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.ready(HttpInboundLink.java:287)
 at com.ibm.ws.ssl.channel.impl.SSLConnectionLink.determineNextChannel(SSLConnectionLink.java:1049)
 at com.ibm.ws.ssl.channel.impl.SSLConnectionLink$MyReadCompletedCallback.complete(SSLConnectionLink.java:643)
 at com.ibm.ws.ssl.channel.impl.SSLReadServiceContext$SSLReadCompletedCallback.complete(SSLReadServiceContext.java:1818)
 at com.ibm.ws.tcp.channel.impl.AioReadCompletionListener.futureCompleted(AioReadCompletionListener.java:175)
 at com.ibm.io.async.AbstractAsyncFuture.invokeCallback(AbstractAsyncFuture.java:217)
 at com.ibm.io.async.AsyncChannelFuture.fireCompletionActions(AsyncChannelFuture.java:161)
 at com.ibm.io.async.AsyncFuture.completed(AsyncFuture.java:138)
 at com.ibm.io.async.ResultHandler.complete(ResultHandler.java:204)
 at com.ibm.io.async.ResultHandler.runEventProcessingLoop(ResultHandler.java:775)
 at com.ibm.io.async.ResultHandler$2.run(ResultHandler.java:905)
 at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:1881)

 Resolution:
1) edit the file
  --> IBM\WCDE80\workspace\WC\xml\config\com.ibm.commerce.foundation\wc-component.xml
 and change the property maskedExceptionClassList with the following value:
 java.sql.SQLException,com.ibm.commerce.foundation.server.services.dataaccess.exception.QueryServiceSystemException

 After change value:

  <_config:configgrouping name="BusinessObjectDocumentProcessor">
   <_config:property name="maskedExceptionClassList" value="java.sql.SQLException,com.ibm.commerce.foundation.server.services.dataaccess.exception.QueryServiceSystemException"/>
  </_config:configgrouping>

 2) restart the test server

Monday, February 12, 2018

CreateKeyException in ibm wcs

"com.ibm.commerce.key.CreateKeyException: unexpected error - no row in keys table for XTABLE"

This issue mostly happens when in you bean class e.g. TableBeam - EjbCreate method using table name in capital and in KEYS table TABLE name is in small.

Solution : Eighter update bean with small letters as you have in keys table or Update KEYS table with table name you have in bean class.

Monday, November 13, 2017

constructing XPATH in IBM WCS



Catalog :

https://www.ibm.com/support/knowledgecenter/en/SSZLC2_7.0.0/com.ibm.commerce.services.doc/Catalog/CatalogEntry/noun.htm