Skip to content

Instantly share code, notes, and snippets.

Yogesh Upadhyay yupadhyay

Block or report user

Report or block yupadhyay

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View WordCount.java
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;
View CustomPDFRendererServlet.java
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 Feb 21, 2017
Find google URL Relevency for an end point and save it in excel sheet
View GoogleRelevency.py
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 = '*****'
View AEMServletTest.java
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 Dec 9, 2016
adding jacoco test coverage to LinkedIn
View jacocoaempom.xml
<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 Dec 9, 2016
Dependencies for AEM Tests
View aemtestpom.xml
<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 Dec 8, 2016
Class showing, how to activate a service with properties
View MyServiceImplTest.java
//Method 1, By using Inject Mock
@RunWith(PowerMockRunner.class)
@PrepareForTest(MyServiceImpl.class)
public class MyServiceImplTest {
@InjectMocks
MyServiceImpl _myService;
@Before
View LiCommonRequestUtilsTest.java
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;
View CommonStringUtilTest.java
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;
View GetClientAdress.java
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"),
You can’t perform that action at this time.