JBoss Tools SVN: r25352 - trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-09-30 14:05:43 -0400 (Thu, 30 Sep 2010)
New Revision: 25352
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java
Log:
[JBIDE-7208] documentation added
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java 2010-09-30 17:59:58 UTC (rev 25351)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java 2010-09-30 18:05:43 UTC (rev 25352)
@@ -134,6 +134,9 @@
* @see <a
* href="http://www.analyticsexperts.com/google-analytics/information-about-the-ut...">Information
* about the utmLinker and the __utma, __utmb and __utmc cookies</a>
+ * @see <a
+ * href="http://www.martynj.com/google-analytics-cookies-tracking-multiple-domains...">cookie
+ * values and formats</a>
*/
private String getCookies() {
StringBuilder builder = new StringBuilder();
@@ -199,17 +202,19 @@
/**
* <tt>User defined Value<tt> cookie format: (domain hash).(setvar value)
- * @see <a href="http://www.martynj.com/google-analytics-cookies-tracking-multiple-domains...">__utmv, __utmb, __utmc cookies formats and more</a>
+ *
+ * @see <a
+ * href="http://www.martynj.com/google-analytics-cookies-tracking-multiple-domains...">__utmv,
+ * __utmb, __utmc cookies formats and more</a>
*/
new GoogleAnalyticsCookie(IGoogleAnalyticsParameters.PARAM_COOKIES_USERDEFINED,
getRandomNumber()
- + IGoogleAnalyticsParameters.DOT
- + googleParameters.getUserDefined())
- .appendTo(builder);
+ + IGoogleAnalyticsParameters.DOT
+ + googleParameters.getUserDefined())
+ .appendTo(builder);
builder.append(IGoogleAnalyticsParameters.SEMICOLON);
-
return HttpEncodingUtils.checkedEncodeUtf8(builder.toString());
}
13 years, 7 months
JBoss Tools SVN: r25351 - in trunk/usage: plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-09-30 13:59:58 -0400 (Thu, 30 Sep 2010)
New Revision: 25351
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsUsageRequestsTest.java
Log:
[JBIDE-7208] bug: no hits triggered! -> cookie format was wrong. Corrected and documented
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java 2010-09-30 17:20:11 UTC (rev 25350)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/GoogleAnalyticsUrlStrategy.java 2010-09-30 17:59:58 UTC (rev 25351)
@@ -193,16 +193,23 @@
IGoogleAnalyticsParameters.PIPE)
.appendTo(builder);
- new GoogleAnalyticsCookie(IGoogleAnalyticsParameters.PARAM_COOKIES_USERDEFINED,
- googleParameters.getUserDefined())
- .appendTo(builder);
-
new GoogleAnalyticsCookie(IGoogleAnalyticsParameters.PARAM_COOKIES_KEYWORD,
googleParameters.getKeyword())
.appendTo(builder);
+ /**
+ * <tt>User defined Value<tt> cookie format: (domain hash).(setvar value)
+ * @see <a href="http://www.martynj.com/google-analytics-cookies-tracking-multiple-domains...">__utmv, __utmb, __utmc cookies formats and more</a>
+ */
+ new GoogleAnalyticsCookie(IGoogleAnalyticsParameters.PARAM_COOKIES_USERDEFINED,
+ getRandomNumber()
+ + IGoogleAnalyticsParameters.DOT
+ + googleParameters.getUserDefined())
+ .appendTo(builder);
+
builder.append(IGoogleAnalyticsParameters.SEMICOLON);
+
return HttpEncodingUtils.checkedEncodeUtf8(builder.toString());
}
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java 2010-09-30 17:20:11 UTC (rev 25350)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java 2010-09-30 17:59:58 UTC (rev 25351)
@@ -21,6 +21,7 @@
/**
* @see <a href="http://linuxmafia.com/faq/Admin/release-files.html">
* an extensive list of release file locations</a>
+ *
* @see <a
* href="http://superuser.com/questions/11008/how-do-i-find-out-what-version-of-li...">
* release-file strings</a>
Modified: trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsUsageRequestsTest.java
===================================================================
--- trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsUsageRequestsTest.java 2010-09-30 17:20:11 UTC (rev 25350)
+++ trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsUsageRequestsTest.java 2010-09-30 17:59:58 UTC (rev 25351)
@@ -81,7 +81,7 @@
// assertEquals(HttpURLConnection.HTTP_OK, method.getResponseCode());
// }
//
- // @Ignore
+ // @IgnoreJBossToolsUsageRequestsTest
// @Test
// public void testUrl0_1() throws IOException {
// String userAgent =
@@ -1713,7 +1713,7 @@
+ "utmccn%3D(direct)%7C"
+ "utmcmd%3D(none)%7C"
+ "__utmv%3Distro.Fedora13"
- + "utmctr%3Dtest1%7Ctest2%7Ctest3%7Ctest4%7Ctest5%7Ctest6%7Ctest7%7Ctest8%7Ctest8%7Ctest9%7Ctest10%7Ctest11%7Ctest12%7Ctest13%7Ctest514%7Ctest14%7Ctest15%7Ctest16%7Ctest17%7Ctest18%7Ctest19%7Ctest20%7Ctest20%7Ctest21%7Ctest22%7Ctest23%7Ctest514%7Ctest24%7Ctest25%7Ctest26%7Ctest27%7Ctest28%7Ctest29%7Ctest30%7Ctest31%3B"
+ + "&utmcc=__utma%3D999.75104087789840654911285868550350.1285868546766.1285868546766.1285868546766.1%3B%2B__utmz%3D999.1285868546766.1.1.%EF%BF%BFutmcsr%3D%28direct%29%7Cutmccn%3D%28direct%29%7Cutmcmd%3D%28none%29%7C__utmv%3D1917863289.CentOS13%EF%BF%BF%3B"
+ "&gaq=1";
method.request(url);
assertEquals(HttpURLConnection.HTTP_OK, method.getResponseCode());
@@ -1752,6 +1752,29 @@
assertEquals(HttpURLConnection.HTTP_OK, method.getResponseCode());
}
+ @Test
+ public void verifyCurrentReportingRequest() throws IOException {
+ TestHttpGetMethod method = new TestHttpGetMethod(
+ "JBossToolsTest/6.0 (compatible; Konqueror/3.5; Linux 2.6.14-fc13; X11) KHTML/3.5.3 (like Gecko) (Fedora)");
+ String url = "http://www.google-analytics.com/__utm.gif?utmwv=4.7.2"
+ +"&utmn=363487156"
+ +"&utmhn=jboss.org"
+ +"&utmcs=UTF-8"
+ +"&utmsr=2880x1024"
+ +"&utmsc=24-bit"
+ +"&utmul=en-US"
+ +"&utmdt=verifyCurrentReportingRequest"
+ +"&utmfl=1.6.0_21"
+ +"&utmr=0"
+ +"&utmp=" + new JBossToolsTestsFocusPoint("verifyCurrentReportingRequest").getURI()
+ +"&utmac=UA-17645367-1"
+ +"&utmcc=__utma%3D999.32635895694074051961285867957380.1285867856601.1285867856601.1285867856601.1%3B%2B__utmz%3D999.1285867856601.1.1.%EF%BF%BFutmcsr%3D%28direct%29%7Cutmccn%3D%28direct%29%7Cutmcmd%3D%28none%29%7C__utmv%3DCentOS13%EF%BF%BF%3B"
+ +"&gaq=1";
+ method.request(url);
+ assertEquals(HttpURLConnection.HTTP_OK, method.getResponseCode());
+ }
+
+
protected class TestHttpGetMethod extends HttpGetRequest {
private HttpURLConnection urlConnection;
13 years, 7 months
JBoss Tools SVN: r25350 - trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-09-30 13:20:11 -0400 (Thu, 30 Sep 2010)
New Revision: 25350
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java
Log:
[JBIDE-7208] documentation links added
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java 2010-09-30 17:16:18 UTC (rev 25349)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java 2010-09-30 17:20:11 UTC (rev 25350)
@@ -18,6 +18,13 @@
public class LinuxSystem {
+ /**
+ * @see <a href="http://linuxmafia.com/faq/Admin/release-files.html">
+ * an extensive list of release file locations</a>
+ * @see <a
+ * href="http://superuser.com/questions/11008/how-do-i-find-out-what-version-of-li...">
+ * release-file strings</a>
+ */
public static final LinuxDistro CENTOS = new LinuxDistro("CentOS", "/etc/redhat-release");
public static final LinuxDistro DEBIAN = new LinuxDistro("Debian", "/etc/debian_version");
public static final LinuxDistro FEDORA = new LinuxDistro("Fedora", "/etc/fedora-release");
@@ -73,10 +80,6 @@
* The pattern to match the contents of the release-file -
* /etc/fedora-release etc. Attention: Ubuntu has multi-line release
* file
- *
- * @see <a
- * href="http://superuser.com/questions/11008/how-do-i-find-out-what-version-of-li...">release-file
- * strings</a>
*/
private final Pattern VERSION_REGEX = Pattern.compile("([0-9.]+)");
13 years, 7 months
JBoss Tools SVN: r25349 - in trunk/usage: tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-09-30 13:16:18 -0400 (Thu, 30 Sep 2010)
New Revision: 25349
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java
Log:
[JBIDE-7208] support for CentOS added
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java 2010-09-30 17:10:05 UTC (rev 25348)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java 2010-09-30 17:16:18 UTC (rev 25349)
@@ -18,9 +18,11 @@
public class LinuxSystem {
+ public static final LinuxDistro CENTOS = new LinuxDistro("CentOS", "/etc/redhat-release");
public static final LinuxDistro DEBIAN = new LinuxDistro("Debian", "/etc/debian_version");
public static final LinuxDistro FEDORA = new LinuxDistro("Fedora", "/etc/fedora-release");
public static final LinuxDistro GENTOO = new LinuxDistro("Gentoo", "/etc/gentoo-release");
+ public static final LinuxDistro YELLOWDOG = new LinuxDistro("YellowDog", "/etc/yellowdog-release");
public static final LinuxDistro KNOPPIX = new LinuxDistro("Knoppix", "knoppix_version");
public static final LinuxDistro MANDRAKE = new LinuxDistro("Mandrake", "/etc/mandrake-release");
public static final LinuxDistro MANDRIVA = new LinuxDistro("Mandriva", "/etc/mandriva-release");
@@ -29,41 +31,41 @@
public static final LinuxDistro SLACKWARE = new LinuxDistro("Slackware", "/etc/slackware-version");
public static final LinuxDistro SUSE = new LinuxDistro("SUSE", "/etc/SuSE-release");
public static final LinuxDistro UBUNTU = new LinuxDistro("Ubuntu", "/etc/lsb-release");
- public static final LinuxDistro YELLOWDOG = new LinuxDistro("YellowDog", "/etc/yellowdog-release");
private static final LinuxDistro[] ALL = new LinuxDistro[] {
- DEBIAN,
- FEDORA,
- GENTOO,
- KNOPPIX,
- MANDRAKE,
- MANDRIVA,
- PLD,
- REDHAT,
- SLACKWARE,
- SUSE,
- UBUNTU,
- YELLOWDOG
+ CENTOS,
+ DEBIAN,
+ FEDORA,
+ GENTOO,
+ KNOPPIX,
+ MANDRAKE,
+ MANDRIVA,
+ PLD,
+ REDHAT,
+ SLACKWARE,
+ SUSE,
+ UBUNTU,
+ YELLOWDOG
};
public static LinuxDistro getDistro() {
- for (LinuxDistro distro : ALL) {
- if (distro.currentSysIsDistro()) {
- return distro;
- }
+ for (LinuxDistro distro : ALL) {
+ if (distro.currentSysIsDistro()) {
+ return distro;
}
- return null;
-
}
+ return null;
+ }
+
public static String getDistroNameAndVersion() {
- LinuxDistro distro = getDistro();
- if (distro != null) {
- return distro.getNameAndVersion();
- } else {
- return "";
- }
+ LinuxDistro distro = getDistro();
+ if (distro != null) {
+ return distro.getNameAndVersion();
+ } else {
+ return "";
}
+ }
public static class LinuxDistro {
Modified: trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java
===================================================================
--- trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java 2010-09-30 17:10:05 UTC (rev 25348)
+++ trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java 2010-09-30 17:16:18 UTC (rev 25349)
@@ -44,5 +44,12 @@
"Gentoo Base System release 2.0.1");
assertEquals("Gentoo2.0.1", distro.getNameAndVersion());
}
+
+ @Test
+ public void canExtractCentOSVersion() {
+ LinuxDistro distro = new LinuxDistroFake(LinuxSystem.CENTOS.getName(),
+ "CentOS release 5.3 (Final)");
+ assertEquals("CentOS5.3", distro.getNameAndVersion());
+ }
}
13 years, 7 months
JBoss Tools SVN: r25348 - in trunk/usage: tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-09-30 13:10:05 -0400 (Thu, 30 Sep 2010)
New Revision: 25348
Added:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java
Removed:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/CurrentLinuxDistro.java
Modified:
trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/AbstractEclipseEnvironment.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/LinuxDistroFake.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/ReportingEclipseEnvironmentFake.java
Log:
[JBIDE-7208] refactored
Modified: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/AbstractEclipseEnvironment.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/AbstractEclipseEnvironment.java 2010-09-30 16:29:25 UTC (rev 25347)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/AbstractEclipseEnvironment.java 2010-09-30 17:10:05 UTC (rev 25348)
@@ -180,7 +180,7 @@
}
protected String getLinuxDistroNameAndVersion() {
- return CurrentLinuxDistro.getNameAndVersion();
+ return LinuxSystem.getDistroNameAndVersion();
}
}
Deleted: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/CurrentLinuxDistro.java
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/CurrentLinuxDistro.java 2010-09-30 16:29:25 UTC (rev 25347)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/CurrentLinuxDistro.java 2010-09-30 17:10:05 UTC (rev 25348)
@@ -1,127 +0,0 @@
-/*******************************************************************************
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.usage.googleanalytics.eclipse;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class CurrentLinuxDistro {
-
- public static final LinuxDistro DEBIAN = new LinuxDistro("Debian", "/etc/debian_version");
- public static final LinuxDistro FEDORA = new LinuxDistro("Fedora", "/etc/fedora-release");
- public static final LinuxDistro GENTOO = new LinuxDistro("Gentoo", "/etc/gentoo-release");
- public static final LinuxDistro KNOPPIX = new LinuxDistro("Knoppix", "knoppix_version");
- public static final LinuxDistro MANDRAKE = new LinuxDistro("Mandrake", "/etc/mandrake-release");
- public static final LinuxDistro MANDRIVA = new LinuxDistro("Mandriva", "/etc/mandriva-release");
- public static final LinuxDistro PLD = new LinuxDistro("PLD", "/etc/pld-release");
- public static final LinuxDistro REDHAT = new LinuxDistro("RedHat", "/etc/redhat-release");
- public static final LinuxDistro SLACKWARE = new LinuxDistro("Slackware", "/etc/slackware-version");
- public static final LinuxDistro SUSE = new LinuxDistro("SUSE", "/etc/SuSE-release");
- public static final LinuxDistro UBUNTU = new LinuxDistro("Ubuntu", "/etc/lsb-release");
- public static final LinuxDistro YELLOWDOG = new LinuxDistro("YellowDog", "/etc/yellowdog-release");
-
- private static final LinuxDistro[] ALL = new LinuxDistro[] {
- DEBIAN,
- FEDORA,
- GENTOO,
- KNOPPIX,
- MANDRAKE,
- MANDRIVA,
- PLD,
- REDHAT,
- SLACKWARE,
- SUSE,
- UBUNTU,
- YELLOWDOG
- };
-
- public static LinuxDistro getDistro() {
- for (LinuxDistro distro : ALL) {
- if (distro.currentSysIsDistro()) {
- return distro;
- }
- }
- return null;
-
- }
-
- public static String getNameAndVersion() {
- LinuxDistro distro = getDistro();
- if (distro != null) {
- return distro.getNameAndVersion();
- } else {
- return "";
- }
- }
-
- public static class LinuxDistro {
-
- /**
- * The pattern to match the contents of the release-file -
- * /etc/fedora-release etc. Attention: Ubuntu has multi-line release
- * file
- *
- * @see <a
- * href="http://superuser.com/questions/11008/how-do-i-find-out-what-version-of-li...">release-file
- * strings</a>
- */
- private final Pattern VERSION_REGEX = Pattern.compile("([0-9.]+)");
-
- private final String releaseFilePath;
- private String name;
-
- protected LinuxDistro(String name, String releaseFilePath) {
- this.name = name;
- this.releaseFilePath = releaseFilePath;
- }
-
- private boolean currentSysIsDistro() {
- return new File(releaseFilePath).exists();
- }
-
- public String getName() {
- return name;
- }
-
- public String getVersion() {
- try {
- String distroString = getDistroFileContent(releaseFilePath);
- Matcher matcher = VERSION_REGEX.matcher(distroString);
- if (matcher.find()) {
- return matcher.group(1);
- }
- } catch (IOException e) {
- }
- return "";
- }
-
- public String getNameAndVersion() {
- return new StringBuilder().append(getName()).append(getVersion()).toString();
- }
-
- protected String getDistroFileContent(String filePath) throws IOException {
- int charachtersToRead = 1024;
- StringBuilder builder = new StringBuilder(charachtersToRead);
- BufferedReader reader = new BufferedReader(new FileReader(filePath));
- char[] buf = new char[charachtersToRead];
- int charRead = 0;
- while ((charRead = reader.read(buf)) != -1 && builder.length() < charachtersToRead) {
- String readData = String.valueOf(buf, 0, charRead);
- builder.append(readData);
- }
- reader.close();
- return builder.toString();
- }
- }
-}
Copied: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java (from rev 25340, trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/CurrentLinuxDistro.java)
===================================================================
--- trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java (rev 0)
+++ trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java 2010-09-30 17:10:05 UTC (rev 25348)
@@ -0,0 +1,127 @@
+/*******************************************************************************
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.usage.googleanalytics.eclipse;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class LinuxSystem {
+
+ public static final LinuxDistro DEBIAN = new LinuxDistro("Debian", "/etc/debian_version");
+ public static final LinuxDistro FEDORA = new LinuxDistro("Fedora", "/etc/fedora-release");
+ public static final LinuxDistro GENTOO = new LinuxDistro("Gentoo", "/etc/gentoo-release");
+ public static final LinuxDistro KNOPPIX = new LinuxDistro("Knoppix", "knoppix_version");
+ public static final LinuxDistro MANDRAKE = new LinuxDistro("Mandrake", "/etc/mandrake-release");
+ public static final LinuxDistro MANDRIVA = new LinuxDistro("Mandriva", "/etc/mandriva-release");
+ public static final LinuxDistro PLD = new LinuxDistro("PLD", "/etc/pld-release");
+ public static final LinuxDistro REDHAT = new LinuxDistro("RedHat", "/etc/redhat-release");
+ public static final LinuxDistro SLACKWARE = new LinuxDistro("Slackware", "/etc/slackware-version");
+ public static final LinuxDistro SUSE = new LinuxDistro("SUSE", "/etc/SuSE-release");
+ public static final LinuxDistro UBUNTU = new LinuxDistro("Ubuntu", "/etc/lsb-release");
+ public static final LinuxDistro YELLOWDOG = new LinuxDistro("YellowDog", "/etc/yellowdog-release");
+
+ private static final LinuxDistro[] ALL = new LinuxDistro[] {
+ DEBIAN,
+ FEDORA,
+ GENTOO,
+ KNOPPIX,
+ MANDRAKE,
+ MANDRIVA,
+ PLD,
+ REDHAT,
+ SLACKWARE,
+ SUSE,
+ UBUNTU,
+ YELLOWDOG
+ };
+
+ public static LinuxDistro getDistro() {
+ for (LinuxDistro distro : ALL) {
+ if (distro.currentSysIsDistro()) {
+ return distro;
+ }
+ }
+ return null;
+
+ }
+
+ public static String getDistroNameAndVersion() {
+ LinuxDistro distro = getDistro();
+ if (distro != null) {
+ return distro.getNameAndVersion();
+ } else {
+ return "";
+ }
+ }
+
+ public static class LinuxDistro {
+
+ /**
+ * The pattern to match the contents of the release-file -
+ * /etc/fedora-release etc. Attention: Ubuntu has multi-line release
+ * file
+ *
+ * @see <a
+ * href="http://superuser.com/questions/11008/how-do-i-find-out-what-version-of-li...">release-file
+ * strings</a>
+ */
+ private final Pattern VERSION_REGEX = Pattern.compile("([0-9.]+)");
+
+ private final String releaseFilePath;
+ private String name;
+
+ protected LinuxDistro(String name, String releaseFilePath) {
+ this.name = name;
+ this.releaseFilePath = releaseFilePath;
+ }
+
+ private boolean currentSysIsDistro() {
+ return new File(releaseFilePath).exists();
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getVersion() {
+ try {
+ String distroString = getDistroFileContent(releaseFilePath);
+ Matcher matcher = VERSION_REGEX.matcher(distroString);
+ if (matcher.find()) {
+ return matcher.group(1);
+ }
+ } catch (IOException e) {
+ }
+ return "";
+ }
+
+ public String getNameAndVersion() {
+ return new StringBuilder().append(getName()).append(getVersion()).toString();
+ }
+
+ protected String getDistroFileContent(String filePath) throws IOException {
+ int charachtersToRead = 1024;
+ StringBuilder builder = new StringBuilder(charachtersToRead);
+ BufferedReader reader = new BufferedReader(new FileReader(filePath));
+ char[] buf = new char[charachtersToRead];
+ int charRead = 0;
+ while ((charRead = reader.read(buf)) != -1 && builder.length() < charachtersToRead) {
+ String readData = String.valueOf(buf, 0, charRead);
+ builder.append(readData);
+ }
+ reader.close();
+ return builder.toString();
+ }
+ }
+}
Property changes on: trunk/usage/plugins/org.jboss.tools.usage/src/org/jboss/tools/usage/googleanalytics/eclipse/LinuxSystem.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java
===================================================================
--- trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java 2010-09-30 16:29:25 UTC (rev 25347)
+++ trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java 2010-09-30 17:10:05 UTC (rev 25348)
@@ -11,8 +11,8 @@
import static org.junit.Assert.assertEquals;
-import org.jboss.tools.usage.googleanalytics.eclipse.CurrentLinuxDistro;
-import org.jboss.tools.usage.googleanalytics.eclipse.CurrentLinuxDistro.LinuxDistro;
+import org.jboss.tools.usage.googleanalytics.eclipse.LinuxSystem;
+import org.jboss.tools.usage.googleanalytics.eclipse.LinuxSystem.LinuxDistro;
import org.jboss.tools.usage.test.fakes.LinuxDistroFake;
import org.junit.Test;
@@ -20,27 +20,27 @@
@Test
public void canExtractFedoraVersion() {
- LinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.FEDORA.getName(), "Fedora release 13 (Goddard)");
+ LinuxDistro distro = new LinuxDistroFake(LinuxSystem.FEDORA.getName(), "Fedora release 13 (Goddard)");
assertEquals("13", distro.getVersion());
}
@Test
public void canExtractUbuntuVersion() {
- LinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.UBUNTU.getName(),
+ LinuxDistro distro = new LinuxDistroFake(LinuxSystem.UBUNTU.getName(),
"DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=9.04\nDISTRIB_CODENAME=jaunty\nDISTRIB_DESCRIPTION=\"Ubuntu 9.04\"");
assertEquals("Ubuntu9.04", distro.getNameAndVersion());
}
@Test
public void canExtractRedHatVersion() {
- LinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.REDHAT.getName(),
+ LinuxDistro distro = new LinuxDistroFake(LinuxSystem.REDHAT.getName(),
"Red Hat Enterprise Linux Workstation release 6.0 (Santiago)");
assertEquals("RedHat6.0", distro.getNameAndVersion());
}
@Test
public void canExtractGentooVersion() {
- LinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.GENTOO.getName(),
+ LinuxDistro distro = new LinuxDistroFake(LinuxSystem.GENTOO.getName(),
"Gentoo Base System release 2.0.1");
assertEquals("Gentoo2.0.1", distro.getNameAndVersion());
}
Modified: trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/LinuxDistroFake.java
===================================================================
--- trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/LinuxDistroFake.java 2010-09-30 16:29:25 UTC (rev 25347)
+++ trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/LinuxDistroFake.java 2010-09-30 17:10:05 UTC (rev 25348)
@@ -11,7 +11,7 @@
import java.io.IOException;
-import org.jboss.tools.usage.googleanalytics.eclipse.CurrentLinuxDistro.LinuxDistro;
+import org.jboss.tools.usage.googleanalytics.eclipse.LinuxSystem.LinuxDistro;
public class LinuxDistroFake extends LinuxDistro {
Modified: trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/ReportingEclipseEnvironmentFake.java
===================================================================
--- trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/ReportingEclipseEnvironmentFake.java 2010-09-30 16:29:25 UTC (rev 25347)
+++ trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/fakes/ReportingEclipseEnvironmentFake.java 2010-09-30 17:10:05 UTC (rev 25348)
@@ -11,7 +11,7 @@
package org.jboss.tools.usage.test.fakes;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.jboss.tools.usage.googleanalytics.eclipse.CurrentLinuxDistro;
+import org.jboss.tools.usage.googleanalytics.eclipse.LinuxSystem;
import org.jboss.tools.usage.googleanalytics.eclipse.IEclipseUserAgent;
import org.jboss.tools.usage.internal.reporting.JBossToolsEclipseEnvironment;
@@ -70,6 +70,6 @@
@Override
protected String getLinuxDistroNameAndVersion() {
- return new LinuxDistroFake(CurrentLinuxDistro.FEDORA.getName(), "Fedora release 13 (Goddard)").getNameAndVersion();
+ return new LinuxDistroFake(LinuxSystem.FEDORA.getName(), "Fedora release 13 (Goddard)").getNameAndVersion();
}
}
13 years, 7 months
JBoss Tools SVN: r25347 - in trunk/esb/tests/org.jboss.tools.esb.validator.test: META-INF and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-09-30 12:29:25 -0400 (Thu, 30 Sep 2010)
New Revision: 25347
Removed:
trunk/esb/tests/org.jboss.tools.esb.validator.test/esb-validator-test.jar
Modified:
trunk/esb/tests/org.jboss.tools.esb.validator.test/META-INF/MANIFEST.MF
trunk/esb/tests/org.jboss.tools.esb.validator.test/build.properties
Log:
https://jira.jboss.org/browse/JBIDE-6085 Added esb validator plug-in to tycho build.
Modified: trunk/esb/tests/org.jboss.tools.esb.validator.test/META-INF/MANIFEST.MF
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.validator.test/META-INF/MANIFEST.MF 2010-09-30 16:25:13 UTC (rev 25346)
+++ trunk/esb/tests/org.jboss.tools.esb.validator.test/META-INF/MANIFEST.MF 2010-09-30 16:29:25 UTC (rev 25347)
@@ -18,4 +18,3 @@
org.jboss.tools.common.model.ui,
org.eclipse.ltk.core.refactoring
Export-Package: org.jboss.tools.esb.validator.test
-Bundle-ClassPath: esb-validator-test.jar
Modified: trunk/esb/tests/org.jboss.tools.esb.validator.test/build.properties
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.validator.test/build.properties 2010-09-30 16:25:13 UTC (rev 25346)
+++ trunk/esb/tests/org.jboss.tools.esb.validator.test/build.properties 2010-09-30 16:29:25 UTC (rev 25347)
@@ -1,6 +1,4 @@
source.. = src/
output.esb-validator-test.jar = bin/
bin.includes = META-INF/,\
- esb-validator-test.jar,\
projects/
-source.esb-validator-test.jar = src/
Deleted: trunk/esb/tests/org.jboss.tools.esb.validator.test/esb-validator-test.jar
===================================================================
(Binary files differ)
13 years, 7 months
JBoss Tools SVN: r25346 - trunk/esb/features/org.jboss.tools.esb.test.feature.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-09-30 12:25:13 -0400 (Thu, 30 Sep 2010)
New Revision: 25346
Modified:
trunk/esb/features/org.jboss.tools.esb.test.feature/feature.xml
Log:
https://jira.jboss.org/browse/JBIDE-6085 Added esb validator plug-in to tycho build.
Modified: trunk/esb/features/org.jboss.tools.esb.test.feature/feature.xml
===================================================================
--- trunk/esb/features/org.jboss.tools.esb.test.feature/feature.xml 2010-09-30 16:23:00 UTC (rev 25345)
+++ trunk/esb/features/org.jboss.tools.esb.test.feature/feature.xml 2010-09-30 16:25:13 UTC (rev 25346)
@@ -30,4 +30,10 @@
version="0.0.0"
unpack="false"/>
+ <plugin
+ id="org.jboss.tools.esb.validator.test"
+ download-size="0"
+ install-size="0"
+ version="0.0.0"/>
+
</feature>
13 years, 7 months
JBoss Tools SVN: r25345 - in trunk/esb: tests and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-09-30 12:23:00 -0400 (Thu, 30 Sep 2010)
New Revision: 25345
Modified:
trunk/esb/plugins/pom.xml
trunk/esb/tests/pom.xml
Log:
https://jira.jboss.org/browse/JBIDE-6085 Added esb validator plug-in to tycho build.
Modified: trunk/esb/plugins/pom.xml
===================================================================
--- trunk/esb/plugins/pom.xml 2010-09-30 16:16:38 UTC (rev 25344)
+++ trunk/esb/plugins/pom.xml 2010-09-30 16:23:00 UTC (rev 25345)
@@ -11,6 +11,7 @@
<module>org.jboss.tools.esb.project.core</module>
<module>org.jboss.tools.esb.project.ui</module>
<module>org.jboss.tools.esb.ui</module>
+ <module>org.jboss.tools.esb.validator</module>
</modules>
</project>
Modified: trunk/esb/tests/pom.xml
===================================================================
--- trunk/esb/tests/pom.xml 2010-09-30 16:16:38 UTC (rev 25344)
+++ trunk/esb/tests/pom.xml 2010-09-30 16:23:00 UTC (rev 25345)
@@ -9,6 +9,7 @@
<modules>
<module>org.jboss.tools.esb.core.test</module>
<module>org.jboss.tools.esb.project.core.test</module>
+ <module>org.jboss.tools.esb.validator.test</module>
</modules>
</project>
13 years, 7 months
JBoss Tools SVN: r25344 - in trunk/esb: tests/org.jboss.tools.esb.validator.test and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2010-09-30 12:16:38 -0400 (Thu, 30 Sep 2010)
New Revision: 25344
Added:
trunk/esb/tests/org.jboss.tools.esb.validator.test/esb-validator-test.jar
Modified:
trunk/esb/plugins/org.jboss.tools.esb.validator/pom.xml
trunk/esb/tests/org.jboss.tools.esb.validator.test/pom.xml
Log:
https://jira.jboss.org/browse/JBIDE-6085 Added esb validator plug-in to tycho build.
Modified: trunk/esb/plugins/org.jboss.tools.esb.validator/pom.xml
===================================================================
--- trunk/esb/plugins/org.jboss.tools.esb.validator/pom.xml 2010-09-30 15:55:55 UTC (rev 25343)
+++ trunk/esb/plugins/org.jboss.tools.esb.validator/pom.xml 2010-09-30 16:16:38 UTC (rev 25344)
@@ -6,8 +6,8 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
+ <groupId>org.jboss.tools.esb.plugins</groupId>
<artifactId>org.jboss.tools.esb.validator</artifactId>
- <version>2.0.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-plugin</packaging>
</project>
Added: trunk/esb/tests/org.jboss.tools.esb.validator.test/esb-validator-test.jar
===================================================================
(Binary files differ)
Property changes on: trunk/esb/tests/org.jboss.tools.esb.validator.test/esb-validator-test.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/esb/tests/org.jboss.tools.esb.validator.test/pom.xml
===================================================================
--- trunk/esb/tests/org.jboss.tools.esb.validator.test/pom.xml 2010-09-30 15:55:55 UTC (rev 25343)
+++ trunk/esb/tests/org.jboss.tools.esb.validator.test/pom.xml 2010-09-30 16:16:38 UTC (rev 25344)
@@ -6,8 +6,8 @@
<artifactId>org.jboss.tools.parent.pom</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
- <groupId>org.jboss.tools</groupId>
+ <groupId>org.jboss.tools.esb.tests</groupId>
<artifactId>org.jboss.tools.esb.validator.test</artifactId>
- <version>1.0.0-SNAPSHOT</version>
+ <version>1.3.0-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>
</project>
13 years, 7 months
JBoss Tools SVN: r25343 - trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test.
by jbosstools-commits@lists.jboss.org
Author: adietish
Date: 2010-09-30 11:55:55 -0400 (Thu, 30 Sep 2010)
New Revision: 25343
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java
Log:
[JBIDE-7208] added gentoo test
Modified: trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java
===================================================================
--- trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java 2010-09-30 15:53:01 UTC (rev 25342)
+++ trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/LinuxDistroTest.java 2010-09-30 15:55:55 UTC (rev 25343)
@@ -28,13 +28,21 @@
public void canExtractUbuntuVersion() {
LinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.UBUNTU.getName(),
"DISTRIB_ID=Ubuntu\nDISTRIB_RELEASE=9.04\nDISTRIB_CODENAME=jaunty\nDISTRIB_DESCRIPTION=\"Ubuntu 9.04\"");
- assertEquals("9.04", distro.getVersion());
+ assertEquals("Ubuntu9.04", distro.getNameAndVersion());
}
@Test
- public void canExtractREDHATVersion() {
+ public void canExtractRedHatVersion() {
LinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.REDHAT.getName(),
"Red Hat Enterprise Linux Workstation release 6.0 (Santiago)");
- assertEquals("6.0", distro.getVersion());
+ assertEquals("RedHat6.0", distro.getNameAndVersion());
}
+
+ @Test
+ public void canExtractGentooVersion() {
+ LinuxDistro distro = new LinuxDistroFake(CurrentLinuxDistro.GENTOO.getName(),
+ "Gentoo Base System release 2.0.1");
+ assertEquals("Gentoo2.0.1", distro.getNameAndVersion());
+ }
}
+
13 years, 7 months