javax.mail.NoSuchProviderException:imap and javax.mail.NoSuchProviderException:pop3 - jakarta-mail

I create an Android email reader app using JavaMail, before obfuscation, it works fine. However obfuscation messes up the app and throws the errors "javax.mail.NoSuchProviderException:imap and javax.mail.NoSuchProviderException:pop3"
The proguard cfg file content is:
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontskipnonpubliclibraryclassmembers
-verbose
-libraryjars "C:\Program Files\Java\jre7\lib\rt.jar"
-dontshrink
-dontoptimize
-dontpreverify
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
-dontwarn android.support.**
-dontwarn android.support.v4.**
-dontwarn javax.activation.**
-dontwarn java.awt.**
-dontwarn java.beans.Beans
-dontwarn javax.security.**
-keeppackagenames javax.mail.**
-keeppackagenames javax.activation.**
-keeppackagenames com.sun.mail.**
-keeppackagenames myjava.**
-keeppackagenames org.apache.harmony.**
-keeppackagenames mailcap.**
-keeppackagenames mimetypes.**
-keep class javamail.** {*;}
-keep class javax.mail.** {*;}
-keep class javax.activation.** {*;}
-keep class com.sun.mail.imap.** {*;}
-keep class com.sun.mail.pop3.** {*;}
-keep class com.sun.mail.dsn.** {*;}
-keep class com.sun.mail.handlers.** {*;}
-keep class com.sun.mail.smtp.** {*;}
-keep class com.sun.mail.util.** {*;}
-keep class mailcap.** {*;}
-keep class mimetypes.** {*;}
-keep class myjava.awt.datatransfer.** {*;}
-keep class org.apache.harmony.awt.** {*;}
-keep class org.apache.harmony.misc.** {*;}
-keep class android.support.v4.** { *; }
-keep class android.support.v4.app.** { *; }
-keep class com.sun.activation.registries.** { *; }
-keep interface android.support.v4.app.** { *; }
-keep public class * extends android.support.v4.**
-keep public class * extends android.app.Fragment
Please advise what went wrong, thanks!

Related

BaseTest class doesn't initialize the Webdriver instance

I have gone through similar type Q&As, but couldn't figure out the issue in my code.
This is my BaseTest class
`
package com.supportiveTests;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import io.cucumber.java.After;
import io.cucumber.java.Before;
public class BaseTests {
public static WebDriver driver;
#Before
public void setUpDriver() {
System.setProperty("webdriver.chrome.driver", "src/main/resources/Drivers/chromedriver.exe");
driver = new ChromeDriver();
}
#After
public void quitDriver() {
this.driver.quit();
System.out.println("done AfterTest");
}
}
`
This is my stepDefinition class (LoginPageSteps)
`
package com.stepDefinitions;
import com.pageObjects.LoginPage;
import com.supportiveTests.BaseTests;
import io.cucumber.java.en.Given;
import io.cucumber.java.en.Then;
import io.cucumber.java.en.When;
import org.testng.annotations.Test;
#Test
public class LoginPageSteps extends BaseTests {
LoginPage obj_login;
#Given("User is on Google Home page")
public void user_is_on_google_home_page() {
BaseTests.driver.navigate().to("https://www.google.com/");
}
#Given("User is navigated to SwagLabs Login page")
public void user_is_navigated_to_swag_labs_login_page() {
BaseTests.driver.navigate().to("https://www.saucedemo.com/");
}
#When("^User enters valid (.*) and (.*)$")
public void user_enters_valid_standard_user_and_secret_sauce(String username, String password) {
obj_login = new LoginPage(driver);
obj_login.enterUserName(username);
obj_login.enterPassword(password);
}
#When("clicks on LOGIN button")
public void clicks_on_login_button() {
obj_login.clickOnLogin();
}
#Then("User is navigated to SwagLAbs Home page")
public void user_is_navigated_to_swag_l_abs_home_page() throws InterruptedException {
BaseTests.driver.getCurrentUrl().contains("https://www.saucedemo.com/inventory.html");
Thread.sleep(2000);
BaseTests.driver.quit();
}
}
`
This is my TestRunner class
`
package com.supportiveTests;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
import org.junit.runner.RunWith;
#RunWith(Cucumber.class)
#CucumberOptions(features = "src/test/Features",
glue = {"com/stepDefinitions"},
monochrome = true,
plugin = {
"pretty", "html:target/HTMLReports/report.html",
"json:target/JSONReports/report.json",
"junit:target/JUnitReports/report.xml"
}
)
public class TestRunner {
}
`
This is my pageObject class (LoginPage)
`
package com.pageObjects;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
public class LoginPage {
WebDriver driver;
public LoginPage(WebDriver driver) {
this.driver = driver;
}
By txt_username = By.xpath("//input[#id='user-name']");
By txt_password = By.xpath("//input[#id='password']");
By btn_login = By.xpath("//input[#id='login-button']");
public void enterUserName(String username){
driver.findElement(txt_username).sendKeys(username);
}
public void enterPassword(String password){
driver.findElement(txt_password).sendKeys(password);
}
public void clickOnLogin(){
driver.findElement(btn_login).click();
}
}
When the above TestRunner class is executed, I get this error
java.lang.NullPointerException: Cannot invoke "org.openqa.selenium.WebDriver.navigate()" because "com.supportiveTests.BaseTests.driver" is null
at com.stepDefinitions.LoginPageSteps.user_is_on_google_home_page(LoginPageSteps.java:16)
I went through the similar Q&As, where the solutions for driver initialization were provided, but couldn't figure out the issue. I am at basic level of Selenium testing framework, so appreciate any guidance on fixing this.

The springAOP of pointcut using #annotation is not effective when applied to IbatisDAO

Annotation:
#Retention(RetentionPolicy.RUNTIME)
#Target(ElementType.METHOD)
public #interface IbatisAnno {}
Aspect:
#Component
#Aspect
public class IbatisAsepct {
//not works
#Pointcut("#annotation(xxx.IbatisAnno)")
public void m(){}
//works
#Pointcut("execution(* xxx.xxDAO.*(..))")
public void m2(){}
#Before("m()")
public void testM(){
System.out.println("Before Method...............");
}
#Before("m2()")
public void testM2(){
System.out.println("Before Method2...............");
}
}
Target class:
#EnableAspectJAutoProxy()
public class IbatisOfferFeedDAO extends SqlMapClientDaoSupport implements OfferFeedDAO{
#IbatisAnno
public void xxx(){
this.getSqlMapClientTemplate().insert();
}
}
Aspect does not take effect when using #Pointcut("#annotation(xxx.IbatisAnno)"), but it works when using #Pointcut("execution(* xxx.xxDAO.*(..))").

Android Proguard rules for TUNE sdk

What are the proguard rules for TUNE tracking SDK? Their website mentions you should add 2 lines but they are missing: https://developers.tune.com/sdk/android-quick-start/#proguard
-keep public class com.tune.** { public *; }
-keep public class com.google.android.gms.ads.identifier.** { *; }
-keep public class com.google.android.gms.gcm.** { *; }
-keep public class com.google.android.gms.common.** { *; }
-keepclassmembers class ** {
public void onEvent(**);
}

Spring Boot with AngularJS

I have a Spring Boot project using Jersey as my REST service and using AngularJS for my front end development. While I run it without using any controller and go to index.html (which is in resource/static/index.html) it works fine. When I add a controller it renders gives the string "index.html" as an output. Spring Boot Configuration:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
#SpringBootApplication
#ComponentScan(basePackages = {"com.cst.interfaces","com.cst.configuration","com.cst.application","com.cst.application.implmentation"})
#EnableAutoConfiguration
public class ApplicationConfiguration {
public static void main(String args[]) throws Exception{
SpringApplication.run(ApplicationConfiguration.class, args);
}
public ServletRegistrationBean jerseyServlet(){
ServletRegistrationBean register = new ServletRegistrationBean(new ServletContainer(),"/*");
register.addInitParameter(ServletProperties.JAXRS_APPLICATION_CLASS, JerseyInitalize.class.getName());
return register;
}
}
JerseyConfiguration:
import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.stereotype.Component;
#Component
public class JerseyInitalize extends ResourceConfig{
public JerseyInitalize(){
super();
this.packages("com.cst.interfaces");
}
}
Controller Class:
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import org.springframework.web.bind.annotation.RestController;
#RestController
#Path("/home")
public class HomeResource {
#GET
#Produces("application/json")
public String getString(){
return "index.html";
}
}
This is because you annotated your controller with #RestController, which is a shorthand for #Controller with #ResponseBody. The latter annotation instructs the controller to render the output as-is directly into the response.
Use #Controller for controllers that are not RESTful instead.

MEF problem with import

I have problem with import shell-view-model to view-model class, I use MEF.
Shell-view-model :
namespace Spirit.ViewModels
{
using Caliburn.Micro;
using System.ComponentModel.Composition;
public interface IShellViewModel
{
void ShowLogOnView();
void ShowMessengerView();
}
[Export(typeof(IShellViewModel))]
public class ShellViewModel : Conductor<IScreen>, IShellViewModel
{
public ShellViewModel()
{
ShowLogOnView();
}
public void ShowLogOnView()
{
ActivateItem(new LogOnViewModel());
}
public void ShowMessengerView()
{
ActivateItem(new LogOnViewModel());
}
}
}
I need this class import in view-model class:
[Export]
public class LogOnViewModel : Screen, IDataErrorInfo
{
[Import]
private IShellViewModel _shellViewModel;
public void LogOn(string nick, string password)
{
IMessengerViewModel vm = IoC.Get<MessengerViewModel>();
_shellViewModel.ShowMessengerView();
}
}
Problem is after initialize is variable _shellViewModel null.
My bootstraper look like this:
public class MefBootStrapper : Bootstrapper<IShellViewModel>
{
}
MY SOLUTION:
I create interface assembly and refer this assembly in external service dll and also in wpf app.
In bootstraper I load this assembly with reflection:
var catalog =
new AggregateCatalog(
AssemblySource.Instance.Select(x => new AssemblyCatalog(x)).OfType<ComposablePartCatalog>());
catalog.Catalogs.Add(
new AssemblyCatalog(string.Format(
CultureInfo.InvariantCulture, "{0}{1}", System.IO.Directory.GetCurrentDirectory(), #"\Pokec_Toolkit.dll")));
_container = new CompositionContainer(catalog);
Than I create conductor class:
public interface IShellViewModel
{
void ShowLogOnView();
void ShowMessengerView();
}
[Export(typeof(IShellViewModel))]
public class ShellViewModel : Conductor<IScreen>, IShellViewModel
{
public ShellViewModel()
{
ShowLogOnView();
}
public void ShowLogOnView()
{
ActivateItem(IoC.Get<LogOnViewModel>());
}
public void ShowMessengerView()
{
ActivateItem(IoC.Get<MessengerViewModel>());
}
}
And in view-model I have this:
[Export]
public class LogOnViewModel : Screen, IDataErrorInfo, ILogOnViewModel
{
[Import]
private IShellViewModel _shellViewModel;
[Import]
private IPokecConnection _pokecConn;
//this method is bind on event click of button
public void LogOn(string nick, string password)
{
//SHOW NEW WIEW
_shellViewModel.ShowMessengerView();
}
}

Resources