What is the correct ProGuard definition for latest mp4parser/isoparser library? - android-proguard

I've been struggling with that here and there -
What is the proguard definitions you need to add to your project proguard configuration file to allow the mp4parser library to work?

Tested with mp4parser version 1.1.7:
-keep class * implements com.coremedia.iso.boxes.Box { *; }
-dontwarn com.coremedia.iso.boxes.**
-dontwarn com.googlecode.mp4parser.authoring.tracks.mjpeg.**
-dontwarn com.googlecode.mp4parser.authoring.tracks.ttml.**
Enjoy

mp4parser 1.1.22
-keep class com.coremedia.iso.** {*;}
-keep class com.googlecode.mp4parser.** {*;}
-keep class com.mp4parser.** {*;}
-dontwarn com.coremedia.**
-dontwarn com.googlecode.mp4parser.**

Related

Unitils EasyMock and JUnit #Rule from JUnit 4.10 to 4.11

I have the Problem that when I use the #RuleAnnotation from JUnit for my TemporaryFolder and want to use Mocks from unitils.easymock at the same time I get an IlleagalStateException in JUnit 4.11, whereas in JUnit 4.10 it still works.
So the following test runs under JUnit 4.10 and throws the IllegalStateException in 4.11:
import java.io.File;
import java.io.IOException;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import org.unitils.UnitilsJUnit4;
public class MyTest extends UnitilsJUnit4 {
#Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
#Test
public void testSomething() throws IOException {
File newFile = temporaryFolder.newFile();
}
}
Even if I use the Annotation for the Mocking capability instead of extends UnitilsJUnit4 it doesn't work in JUnit 4.11:
#RunWith(UnitilsJUnit4TestClassRunner.class)
public class MyTest {
...
}
The error message when testing this code is:
java.lang.IllegalStateException: the temporary folder has not yet been created
Something new I just additionally found out: In JUnit 4.10 I can also enforce the same error when passing a String in the newFile() call:
File newFile = temporaryFolder.newFile("");
My question:
What is the proper way to make TemporaryFolders or #Rules in general work together with unitils.easymock.annotation.Mocks in JUnit 4.11?
Or is Mocking with the easymock #Mock annotation and #Rules at the same time simply not possible?
Versions:
easymock 3.4
unitils 3.4.3

Issues with Mirah

I am using the Mirah library in Codename One mainly as an object mapper between Json and Java classes.
I am running into the issue where Mirah is trying to map classes that were not declared in the .mirah class. For example my .mirah class has a data mapper for Product
data_mapper Product:ProductMapper
But the error is complaining about IUser interface and not the Product class! For a starter, I don't understand why Mirah would complain about a class that is not declared as a datamapper. Am I missing something ? Please keep in mind in my current code, Product has only primitive data type variables and absolutely no reference to the IUser interface or the User implementing class.
nbproject\mirah-build-cn1.xml:152:
java.lang.RuntimeException: Could not find stub for interface IUser
at ca.weblite.asm.JavaExtendedStubCompiler$2.visitClass(JavaExtendedStubCompiler.java:694)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:720)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:91)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:99)
at com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:120)
at ca.weblite.asm.JavaExtendedStubCompiler$2.visitCompilationUnit(JavaExtendedStubCompiler.java:275)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:550)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:91)
at ca.weblite.asm.JavaExtendedStubCompiler.compile(JavaExtendedStubCompiler.java:797)
at ca.weblite.asm.JavaExtendedStubCompiler.compileFile(JavaExtendedStubCompiler.java:174)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:211)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:214)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:214)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:214)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:214)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:193)
at ca.weblite.asm.WLMirahCompiler.compile(WLMirahCompiler.java:208)
at ca.weblite.mirah.ant.MirahcTask.execute(MirahcTask.java:158)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor68.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:286)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:555)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
BUILD FAILED (total time: 10 seconds)
I would also like to mention that I highly suspect that cleaning the project may not be cleaning all Mirah generated classes. Since I was unable to build my application at all due to the error above, I tried deleting the ".mirah" class from my project, then tried cleaning and rebuilding but I still received the same error from that point on.
The only way I was able to get the project to compile again is to start a brand new project and move my source file there leaving the .mirah class out.
I appreciate any insights!
More details Updates below
Hi Steve. Thank you very much for your feedback! I spent some time trying to track down the issue. I think the issue has to do somehow with Generics. As far as I know, generic types are substituted at compile time so I am guessing Codename One would support generics just fine. Also my code compiled well before attempting to go the Mirah route. I really think Mirah is a brilliant idea.
Here's few steps to recreate the issue. I started a CN1 Hello world project and created the following classes
1)IHouse
import java.util.List;
public interface IHouse<W extends IWindow> {
public int getHouseColor();
public void setHouseColor(int color);
public List<W> getWindows();
public void setWindows(List<W> windows);
}
2)IWindow
public interface IWindow {
public int getWindowColor();
public void setWindowColor(int newColor);
public String getShape();
}
3) RoundWindow
public class RoundWindow implements IWindow {
private int windowColor;
private String shape;
public RoundWindow() {
String shape = "ROUND";
}
#Override
public int getWindowColor() {
return windowColor;
}
#Override
public void setWindowColor(int newColor) {
windowColor = newColor;
}
#Override
public String getShape() {
return shape;
}
}
4) SquareWindow
public class SquareWindow implements IWindow {
private int windowColor;
private String shape;
public SquareWindow() {
String shape = "SQUARE";
}
#Override
public int getWindowColor() {
return windowColor;
}
#Override
public void setWindowColor(int newColor) {
windowColor = newColor;
}
#Override
public String getShape() {
return shape;
}
}
5) House
public class House implements IHouse<RoundWindow> {
private int houseColor;
List<RoundWindow> windows;
#Override
public int getHouseColor() {
return houseColor;
}
#Override
public void setHouseColor(int color) {
houseColor = color;
}
#Override
public List<RoundWindow> getWindows() {
return windows;
}
#Override
public void setWindows(List<RoundWindow> windows) {
this.windows = windows;
}
}
To Recap , I have a IHouse interface supporting any type of window that implements IWindow. Then the House class that implements the IHouse interface can strictly specify which Window it supports / works with.
This code compiles well in CN1 before adding the Mirah plugin. Though I receive an identical error to what I had explained before when I add Mirah.
the following error occurred while executing this line:
C:\Users\location\NetBeansProjects\Test\nbproject\mirah-build.xml:51:
java.lang.RuntimeException: Could not find stub for interface IHouse
at ca.weblite.asm.JavaExtendedStubCompiler$2.visitClass(JavaExtendedStubCompiler.java:694)
at com.sun.tools.javac.tree.JCTree$JCClassDecl.accept(JCTree.java:720)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:91)
at com.sun.source.util.TreeScanner.scanAndReduce(TreeScanner.java:99)
at com.sun.source.util.TreeScanner.visitCompilationUnit(TreeScanner.java:120)
at ca.weblite.asm.JavaExtendedStubCompiler$2.visitCompilationUnit(JavaExtendedStubCompiler.java:275)
at com.sun.tools.javac.tree.JCTree$JCCompilationUnit.accept(JCTree.java:550)
at com.sun.source.util.TreePathScanner.scan(TreePathScanner.java:68)
at com.sun.source.util.TreeScanner.scan(TreeScanner.java:91)
at ca.weblite.asm.JavaExtendedStubCompiler.compile(JavaExtendedStubCompiler.java:797)
at ca.weblite.asm.JavaExtendedStubCompiler.compileFile(JavaExtendedStubCompiler.java:174)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:211)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:214)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:214)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:214)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:214)
at ca.weblite.asm.JavaExtendedStubCompiler.compileDirectory(JavaExtendedStubCompiler.java:193)
at ca.weblite.asm.WLMirahCompiler.compile(WLMirahCompiler.java:208)
at ca.weblite.mirah.ant.MirahcTask.execute(MirahcTask.java:158)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor323.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor323.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.MacroInstance.execute(MacroInstance.java:396)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor323.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:435)
at org.apache.tools.ant.Target.performTasks(Target.java:456)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1393)
at org.apache.tools.ant.Project.executeTarget(Project.java:1364)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1248)
at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:286)
at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:555)
at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
BUILD FAILED (total time: 9 seconds)
Few Observation, if I remove the House class, the code builds well (showing "build successful" at the end) but I see the following warnings. I believe these are due to an attempt to pre-compile a generic interface where we don't know yet the exact type for w (until runtime). This could be the root cause for the issue.
Failed to get signature for method
public List<W> getWindows();
Failed to get signature for method
public void setWindows(List<W> windows);
Finally, changing my model design and getting rid of the Generics altogether gets my code to compile again without any Mirah complaint. In my real project, I would like to keep my current design (with generics) for many reasons.
Would it be possible to also use the Mirah Json to Java conversion tool along with generics?
Thank you in advance for your time!
The Mirah netbeans plugin allows for two-way mirah-java dependencies in project. To accomplish this, it first compiles "stubs" of the java sources in the project so that they can be referenced from Mirah during the mirah compile step. After mirah is finished compiling to .classes, it then does the "real" java compilation step which references the compiled mirah files. This is why it is referencing the IUser class.. that is the "pre-compile" step that is choking on it.
The error indicates that it can't find the IUser class while pre-compiling the java stubs. I'd have to see the project to know why.

DebugKit.ToolbarComponent could not be found

I followed the instruction in the README.md file in the directory DebugKit. But when I add this line I am getting this error above but when i comment out the line in the AppController then everything is ok and i'm getting "DebugKit plugin is present"
<?php
App::uses('Controller', 'Controller');
class AppController extends Controller {
public $components = array('DebugKit.Toolbar');
}
does anyone know how can i smooth this error out?
I have ubuntu 14.10 CakePHP 2.5
Make sure you have
\DebugKit
\Controller
\Component
\ToolbarComponent.php
In case you don't have this directory (which was the case for me)
then
cd Plugin/DebugKit
sudo mkdir Controller
sudo mkdir Component
sudo gedit ToolbarComponent.php
And then the text editor will pop up and just put the code below
<?php
class ToolbarComponent extends Component {
}

Selenium how to open a web browser to run a selenium script

I exported a script from selenium IDE 1.9.0 as Java/TestNG/RemoteControl.
I would like to run this script using TestNG within Eclipse and I want to see the script play back in Firefox browser.
I did some search online, but I could not make it work. I need some instructions and guidance on how to make the code work. Your help is greatly appreciated.
Here is my code:
import java.util.List;
import org.testng.annotations.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;
import static org.testng.Assert.*;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class search_donor_suzy_ng //extends SeleneseTestNgHelper {
#BeforeTest
public void setUp() throws Exception {
//initizlize Firefoxbrowser:
WebDriver ffoxdriver = new FirefoxDriver();
String baseUrl = "www.google.com"; //sample URL
}
#Test
public void testSearch_donor_suzy_ng() throws Exception {
// set overall speed of the test case
selenium.setSpeed("4000");
selenium.open("/?html=openid");
selenium.click("css=input[type=\"submit\"]");
selenium.waitForPageToLoad("30000");
Thread.sleep(4000);
selenium.type("id=edit-name", "jeffshu");
selenium.type("id=edit-pass", "tEgvz9xsaNjnwe4Y");
selenium.click("id=edit-submit");
selenium.waitForPageToLoad("30000");
Thread.sleep(4000);
selenium.click("id=cmp_admin");
selenium.waitForPageToLoad("30000");
selenium.click("id=quicksearch_anchor");
selenium.click("css=img[alt=\"Member\"]");
selenium.waitForPageToLoad("30000");
selenium.type("id=search_name", "suzy");
selenium.click("css=input[type=\"image\"]");
selenium.click("link=Balagia, Suzy");
selenium.waitForPageToLoad("30000");
}
#AfterTest
public void tearDown() throws Exception {
ffoxdriver.quit();
}
}
For starters, you do need to refer to the documentation # http://docs.seleniumhq.org/docs/03_webdriver.jsp
In your code, you are intializing the driver object in your beforetest method, which you are not using. Driver is Webdriver's way of launching your browser, whereas in your testmethod you are using selenium and selenium 1 commands. As a quick step, you can replace your selenium with driver (put your declaration of driver in class scope and method scope). SeleneseTestngHelper is also selenium1.
Make sure you have the necessary webdriver jars in your project.
Certain commands in webdriver are different than selenium 1 and you might see compile erros when you do the replacement. Look at the methods available with driver. and use corresponding commands eg. Use get() of webdriver instead of open(). You can refer the javadocs for this or use your ide to get to know these.

JAX-RS webservice using #Path("/") at class level fails on TomEE+ 1.5.1

This simple root resource class fails when running on TomEE+ 1.5.1, return is a 404 error "The requested resource is not available." It is packaged as a WAR with and empty web.xml file in WEB-INF.
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;
#Path("/")
#Produces({ "text/plain", "text/html", "text/xml", "application/xml", "application/json" })
public class BrokenResource {
private static final Log logger = LogFactory.getLog(BrokenResource.class);
public BrokenResource()
{
logger.info("constructed");
}
#GET
#Path("getloggedinguids")
public Response foo(#Context UriInfo uInfo)
{
return Response.ok("\n\n\nrequest URI = " + uInfo.getRequestUri()).build();
}
}
It deploys and I see these lines in the console output:
Mar 22, 2013 4:56:16 PM org.apache.openejb.server.rest.RESTService deployPojo
INFO: REST Service: http://localhost:8080/test//* -> Pojo BrokenResource
I have also tried packaging it with a web.xml that declares:
<servlet>
<servlet-name>test</servlet-name>
<display-name>Test OpenEJBRest Servlet</display-name>
<servlet-class>
org.apache.openejb.server.rest.OpenEJBRestServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>test</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
Same results as with an empty web.xml file.
I also tried changing the class level #Path annotation to #Path("*") and then I get a different response, in the console output I see the following line:
WARNING: No root resource matching request path /test/getloggedinguids has been found, Relative Path: /getloggedinguids.
Finally... if I change the #Path annotation to something like #Path("/foo") then that works exactly as expected... hitting /test/foo/getloggedinguids returns the request URI..
I've be trying all sorts of variations of servlet mapping versus class level annotations and one thing is consistent... a #Path("/") annotation at the class leve always fails.
I even grabbed an example from the "RESTful Java with JAX-RS book" that uses the #Path("/") at the class level... that also fails.
Is this a bug in the CXF implementation of the JAX-RS standard? My project requires that I use a stock TomEE+ container so I can't switch to another JAX-RS implementation :-(
Instead of adding entries into the web.xml, keep in mind TomEE has native support for JAX-RS if you use the JAX-RS or TomEE+ versions.
Add a class like this and remove your web.xml entries:
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
#ApplicationPath("/")
public class NoteTakerApplication extends Application {
#Override
public Set<Class<?>> getClasses() {
return new HashSet<Class<?>>(Arrays.asList(BrokenResource.class, RestExceptionMapper.class, OtherClassesYouMayHave.class));
}
}

Resources