Recent Notes
Displaying keyword search results 21 - 30
Created by Fang on November 10, 2011 09:26:12
Last update: November 10, 2011 09:26:12
Syntax highlighted XML schema for JSF 2.0 Application Configuration Resource File ( faces-config.xml ). Almost 3000 lines!
<?xml version="1.0" encoding="UTF-8"?>
<xsd:sch...
Created by Fang on September 07, 2009 20:44:15
Last update: November 03, 2011 14:43:19
Step 1: Repackage a web app as EAR A Java EE application is a multimodule Maven project. At the very least you'll need to package a WAR and an EAR. To get started, I'll simply re-package the simple webapp as an EAR. Create a directory named javaee-app Copy the webapp from here to javaee-app . Rename struts1app to webapp . Create pom.xml under javaee-app :
<project> <modelVersion>4.0.0</modelVersion>... Create a directory named ear under javaee-app . Create pom.xml under ear : <project> <modelVersion>4.0.0</modelVersion>... Modify pom.xml in the webapp directory so that it looks like this: <project> <modelVersion>4.0.0</modelVersion> ... Build with " mvn package " in the javaee-app directory. You can see that ear-1.0.ear is successfully generated in javaee-app/ear/target . Maven successfully resolves dependencies between the sub-projects....
Created by Fang on October 30, 2011 19:19:33
Last update: October 30, 2011 19:21:11
I've seen both
<context-param>
<param-name>javax.faces.PRO...
and
<context-param>
<param-name>facelets.DEVE...
in web.xml .
But I cannot find any documentation of facelets.DEVELOPMENT in the JSF 2 spec. I cannot find any code referencing facelets.DEVELOPMENT in mojarra-2.1.3-FCS (the reference JSF implementation) either. So my guess is facelets.DEVELOPMENT is a thing of the past .
About javax.faces.PROJECT_STAGE , this is what's documented in the JSF 2 spec:
javax.faces.PROJECT_STAGE - A human readable string describing where this particular JSF application is in the software development lifecycle.
Valid values are “ Development ”, “ UnitTest ”, “ SystemTest ”, or “ Production ”, corresponding to the enum constants of the class javax.faces.application.ProjectStage .
It is also possible to set this value via JNDI. See the javadocs for Application.getProjectStage() .
Created by freyo on September 29, 2011 16:01:31
Last update: September 29, 2011 16:09:37
With standalone broadcast receiver
AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifes...
Java code:
package com.android.networkreceiver;
import...
Register listener inside Activity programmatically
AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifes...
Java code:
package com.android.networklistener;
import...
Register/unregister broadcast receiver in onResume / onPause works because the connectivity change broadcast is sticky . I intentionally used two registerReceiver calls in onResume to demonstrate this - onReceive will be called once for each registration.
Created by magnum on September 27, 2011 21:51:05
Last update: September 28, 2011 18:02:49
Client socket usually does not call bind . But I've seen code that does and it was puzzling to me what bind does to a client socket. Therefore, this little test program. It retrieves a web url and displays info about the socket. You can optionally give a bind host name/ip and port and see what it does.
Here are my test results:
$ ./client www.google.com
Local addr: 172.16.0....
This is the code:
#include <stdio.h>
#include <stdlib.h>
#incl...
Created by freyo on May 13, 2011 15:45:29
Last update: September 20, 2011 08:08:12
This is an Android app that dumps any binarized xml file as plain text - to the sdcard on the device or emulator.
build.xml :
<?xml version="1.0" encoding="UTF-8"?>
<project...
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<man...
res/layout/main.xml
<?xml version="1.0" encoding="utf-8"?>
<Lin...
res/values/strings.xml :
<?xml version="1.0" encoding="utf-8"?>
<res...
src/com/android/xmltool/DumpXml.java
package com.android.xmltool;
import java.ut...
Screenshot
Pre-built APK can be downloaded from: http://code.google.com/p/android-binxml-dump/
Created by magnum on September 11, 2011 21:31:45
Last update: September 11, 2011 21:32:00
The warning message was emitted by the gcc compiler with the " -Wdeclaration-after-statement " switch:
$ gcc -Wdeclaration-after-statement hello.c
for the following code:
#include <stdio.h>
int main(int argc, char* arg...
There were no warnings without the " -Wdeclaration-after-statement " switch. GCC manual says:
-Wdeclaration-after-statement (C and Objective-C only)
Warn when a declaration is found after a statement in a block. This construct, known from C++, was introduced with ISO C99 and is by default allowed in GCC. It is not supported by ISO C90 and was not supported by GCC versions before GCC 3.0.
Created by freyo on September 09, 2011 11:43:36
Last update: September 09, 2011 11:45:45
When you run automated Android tests with Eclipse or from the command line, you get text output, which isn't good for reporting purposes. If you run a large set of test cases with automated build, the text report isn't very helpful. Fortunately, Android CTS generates test reports in XML with accompanying XSL to make it look nice in a browser. To run your own tests with Android CTS: Download Android CTS Make a new directory MyRepository under android-cts , alongside the existing repository directory. Copy host_config.xml from repository to MyRepository Create directory plans under MyRepository , add a test plan ( MyTests.xml ):
<?xml version="1.0" encoding="UTF-8"?> <TestPla... Create directory testcases under MyRepository . Copy TestDeviceSetup.apk from repository/testcases to MyRepository/testcases Under MyRepository/testcases , create a test...
Created by freyo on September 08, 2011 07:45:35
Last update: September 08, 2011 13:22:13
Activity test:
AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifes...
Test code:
package com.example.android.test;
import co...
Notes: Methods setUp and tearDown are called repetitively for each test method. If you override them, you must call the corresponding super methods for the tests to work.
Self-instrumentation test (the target package is the test package itself):
AndroidManifest.xml :
<?xml version="1.0" encoding="utf-8"?>
<manifes...
Test code:
package com.android.test;
import android.ut...
Created by freyo on September 07, 2011 16:46:14
Last update: September 07, 2011 19:23:00
The Android unit test framework is based on JUnit 3 , not JUnit 4. Test cases have to extend junit.framework.TestCase or a subclass (such as android.test.InstrumentationTestCase ). Tests are identified by public methods whose name starts with test , not methods annotated with @Test (as in JUnit 4). An Android test suite is packaged as an APK, just like the application being tested. To create a test package, first you need to identify the application package it is testing. Google suggests to put the test package source in a directory named tests/ alongside the src/ directory of the main application. At runtime, Android instrumentation loads both the test package and the application under test into the same process. Therefore, the tests can invoke methods on...