Skip to content

Instantly share code, notes, and snippets.

package test;
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;
package com.wemblog.cq.core.servlet;
import com.day.cq.dam.api.Asset;
import com.day.cq.dam.commons.util.DamUtil;
import com.wemblog.utility.RunModeUtil;
import java.io.IOException;
import java.util.Dictionary;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import org.apache.commons.lang3.StringUtils;
@yupadhyay
yupadhyay / GoogleRelevency.py
Created February 21, 2017 17:36
Find google URL Relevency for an end point and save it in excel sheet
import json
import requests
import urllib2
import urllib
import datetime
from openpyxl import Workbook
from watson_developer_cloud import AlchemyLanguageV1
# Get google API key from https://developers.google.com/custom-search/json-api/v1/introduction#identify_your_application_to_google_with_api_key
google_api_key = '*****'
package com.wemblog.test;
import com.adobe.granite.xss.XSSAPI;
import com.google.gson.JsonArray;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import static org.junit.Assert.*;
import static org.mockito.Mockito.any;
@yupadhyay
yupadhyay / jacocoaempom.xml
Created December 9, 2016 20:50
adding jacoco test coverage to LinkedIn
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.2.201409121644</version>
<executions>
<!-- Prepares the property pointing to the JaCoCo runtime agent
which is passed as VM argument when Maven the Surefire plugin is executed. -->
<execution>
<id>pre-unit-test</id>
<goals>
@yupadhyay
yupadhyay / aemtestpom.xml
Created December 9, 2016 20:47
Dependencies for AEM Tests
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
@yupadhyay
yupadhyay / MyServiceImplTest.java
Created December 8, 2016 21:10
Class showing, how to activate a service with properties
//Method 1, By using Inject Mock
@RunWith(PowerMockRunner.class)
@PrepareForTest(MyServiceImpl.class)
public class MyServiceImplTest {
@InjectMocks
MyServiceImpl _myService;
@Before
package com.wemblog.util;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
package com.wemblog.foundation.utility;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
public enum IPHeaders {
CLIENT_IP_UNDERSCORE("Client_IP"),
CLIENT_IP("Client-IP"),
X_CLIENT_IP("X-Client-IP"),
X_FORWARDED_FOR("X-Forwarded-For"),
FORWARDED_FOR("Forwarded-For"),
VIA("Via"),
REMOTE_ADDR("Remote-Addr"),
X_REMOTE_ADDR("X-Remote-Addr"),
X_CLUSTER_CLIENT_IP("X-Cluster-Client-IP"),