9 Mart 2016 Çarşamba

AWS S3 Maven Repository


In my project, I decided to use Amazon S3 as a maven repository. I will try to explain some hints to do that..


  • First you should create a "devops" group who has S3 full access and create a "devops" user within "devops" group. You can use "devops" user in build server and put more restrictions in future.  

  • Create Bucket. I faced many problems with region Franfurt so I recommend you to use Ireland region while creating bucket.

  • After creation of the user , apply the steps and use devops access key and secret.

I hope it will be useful for you..

2 Mart 2016 Çarşamba

JSON Validation over WSDL


Github : https://github.com/rernas35/JsonValidationOverWSDL

In our team,  we need a json validator for REST services. We have done some investigation and found out that mostly Swagger and WADL  is used for this purpose.

Our infrastructure is not adequate for Swagger or WADL that's why we have implemented a json validation library that use WSDL definitions for schema.

If you have services that is exposed in both SOAP and REST but you don't have swagger or wadl support, you can use this validation library,

Sample wsdl is a simple web service that is composed of login, logout, search and buy operations.

Output of validation library is JSON-Schema.Spec is here.

Json-Schema :

 
   "$schema":"http://json-schema.org/draft-04/schema#",
   "type":"object",
   "additionalProperties":false,
   "definitions": 
      "PurchaseStatusType_CT": 
         "type":"object",
         "additionalProperties":false,
         "id":"http://www.example.org/sample//PurchaseStatusType_CT",
         "properties": 
            "id": 
               "type":"string",
               "id":"http://www.example.org/sample//id"
            },
            "stockStatus": 
               "type":"string",
               "id":"http://www.example.org/sample//stockStatus"
            },
            "expectedDelivery": 
               "type":"string",
               "id":"http://www.example.org/sample//expectedDelivery"
            }
         },
         "required": 
            "id",
            "stockStatus",
            "expectedDelivery"
         ]
      },
      "ItemType_CT": 
         "type":"object",
         "additionalProperties":false,
         "id":"http://www.example.org/sample//ItemType_CT",
         "properties": 
            "id": 
               "type":"string",
               "id":"http://www.example.org/sample//id"
            },
            "description": 
               "type":"string",
               "id":"http://www.example.org/sample//description"
            },
            "price": 
               "type":"string",
               "id":"http://www.example.org/sample//price"
            }
         },
         "required": 
            "id",
            "description",
            "price"
         ]
      },
      "searchResponseembedded": 
         "type":"object",
         "additionalProperties":false,
         "id":"http://www.example.org/sample//searchResponseembedded",
         "properties": 
            "item": 
               "$ref":"#/definitions/ItemType_CT"
            }
         },
         "required": 
            "item"
         ]
      },
      "buyResponseembedded": 
         "type":"object",
         "additionalProperties":false,
         "id":"http://www.example.org/sample//buyResponseembedded",
         "properties": 
            "purchasestatus": 
               "$ref":"#/definitions/PurchaseStatusType_CT"
            }
         },
         "required": 
            "purchasestatus"
         ]
      }
   },
   "properties": 
      "username": 
         "type":"string",
         "id":"wsdl.namespace/username"
      },
      "password": 
         "type":"string",
         "id":"wsdl.namespace/password"
      },
      "sessionid": 
         "type":"string",
         "id":"wsdl.namespace/sessionid"
      },
      "sessioninfo": 
         "type":"string",
         "id":"wsdl.namespace/sessioninfo"
      },
      "searchstring": 
         "type":"string",
         "id":"wsdl.namespace/searchstring"
      },
      "searchResponse": 
         "$ref":"#/definitions/searchResponseembedded"
      },
      "buystring": 
         "type":"string",
         "id":"wsdl.namespace/buystring"
      },
      "buyResponse": 
         "$ref":"#/definitions/buyResponseembedded"
      }
   }
}

Test Class : 


package com.ingbank.esb.json.model;


import junit.framework.TestCase;


import org.everit.json.schema.Schema;

import org.everit.json.schema.ValidationException;
import org.json.JSONObject;

import com.devside.esb.json.model.JSONSchemaGenerator;

import com.devside.esb.json.model.TypeSchema;

public class SampleServiceTest extends TestCase {


Schema schema;

protected void setUp(){
schema = JSONSchemaGenerator.generate(TypeSchema.class.getClassLoader().getResource("sample-service.wsdl").getPath());
}

public void testEchoSuccess(){
schema.validate(new JSONObject("{\"username\":\"user01\",\"password\":\"pass01\"}"));
}

public void testEchoAdditionalField(){
try {
schema.validate(new JSONObject("{\"username\":\"user01\",\"password\":\"pass01\",\"falan\":\"filan\"}"));
assertTrue(false);
} catch (Exception e) {
assertTrue(e instanceof ValidationException);
}


}




}