Author: adietish
Date: 2010-11-30 05:49:23 -0500 (Tue, 30 Nov 2010)
New Revision: 27022
Added:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentTest.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageIntegrationTest.java
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/FocusPointTest.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsTestsFocusPoint.java
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageTestSuite.java
Log:
renamed JBossToolsXXX classes (to see better what's beeing tested)
Copied:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentTest.java
(from rev 25861,
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsEclipseEnvironmentTest.java)
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentTest.java
(rev 0)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentTest.java 2010-11-30
10:49:23 UTC (rev 27022)
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * 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.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.eclipse.core.runtime.IBundleGroupProvider;
+import org.jboss.tools.usage.googleanalytics.eclipse.AbstractEclipseEnvironment;
+import org.jboss.tools.usage.internal.reporting.JBossToolsComponents;
+import org.jboss.tools.usage.test.fakes.BundleGroupProviderFake;
+import org.jboss.tools.usage.test.fakes.ReportingEclipseEnvironmentFake;
+import org.junit.Test;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class EclipseEnvironmentTest {
+
+ @Test
+ public void keywordReportsJbossComponents() {
+ AbstractEclipseEnvironment eclipseEnvironment = new ReportingEclipseEnvironmentFake()
{
+
+ @Override
+ protected IBundleGroupProvider[] getBundleGroupProviders() {
+ return new IBundleGroupProvider[] {
+ new BundleGroupProviderFake(
+ "org.jboss.tools.gwt.feature",
+ "org.jboss.tools.seam.feature",
+ "org.jboss.tools.smooks.feature")
+ };
+ }
+ };
+
+ String keyword = eclipseEnvironment.getKeyword();
+
+ Matcher matcher = Pattern.compile("(([A-Z]+)-){3}").matcher(keyword);
+ assertTrue(matcher.matches());
+ assertTrue(keyword.indexOf(JBossToolsComponents.JBossToolsFeatureIdentifiers.GWT.name())
>= 0);
+ assertTrue(keyword.indexOf(JBossToolsComponents.JBossToolsFeatureIdentifiers.SEAM.name())
>= 0);
+ assertTrue(keyword.indexOf(JBossToolsComponents.JBossToolsFeatureIdentifiers.SMOOKS.name())
>= 0);
+ }
+
+ @Test
+ public void keywordIsEmptyIfNoJBossFeaturesFound() {
+ AbstractEclipseEnvironment eclipseEnvironment = new ReportingEclipseEnvironmentFake()
{
+
+ @Override
+ protected IBundleGroupProvider[] getBundleGroupProviders() {
+ return new IBundleGroupProvider[] {
+ new BundleGroupProviderFake(
+ "org.jboss.tools.gwt",
+ "org.eclipse.emf.cdo")
+ };
+ }
+ };
+
+ String keyword = eclipseEnvironment.getKeyword();
+ assertTrue(keyword != null && keyword.length() == 0);
+ }
+
+
+}
Property changes on:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/EclipseEnvironmentTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/FocusPointTest.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/FocusPointTest.java 2010-11-30
10:30:54 UTC (rev 27021)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/FocusPointTest.java 2010-11-30
10:49:23 UTC (rev 27022)
@@ -15,6 +15,7 @@
import org.jboss.tools.usage.tracker.IFocusPoint;
import org.jboss.tools.usage.tracker.internal.FocusPoint;
+import org.jboss.tools.usage.tracker.internal.SuffixFocusPoint;
import org.jboss.tools.usage.util.HttpEncodingUtils;
import org.junit.Test;
@@ -30,6 +31,11 @@
private static final String URI_SEPARATOR_ENCODED =
HttpEncodingUtils.checkedEncodeUtf8(FocusPoint.URI_SEPARATOR);
private static final String TITLE_SEPARATOR_ENCODED =
HttpEncodingUtils.checkedEncodeUtf8(FocusPoint.TITLE_SEPARATOR);
+
+ private static final String JBOSS_TOOLS_VERSION = "42.0.42";
+
+ private static final String CHILD = "child";
+
@Test
public void testGetContentURI_Simple() throws Exception {
@@ -62,4 +68,35 @@
assertNotNull(contentTitle);
assertEquals(ROOT + TITLE_SEPARATOR_ENCODED + CHILD1, contentTitle);
}
+
+ @Test
+ public void appendsJBossToolsVersionToTheEnd() throws Exception {
+ IFocusPoint focusPoint = new FocusPointFake(ROOT)
+ .setChild(new FocusPoint(CHILD)
+ .setChild(new FocusPoint(CHILD)));
+ String contentURI = focusPoint.getURI();
+
+ assertNotNull(contentURI);
+ assertEquals( URI_SEPARATOR_ENCODED
+ + ROOT
+ + URI_SEPARATOR_ENCODED
+ + CHILD + URI_SEPARATOR_ENCODED
+ + CHILD + URI_SEPARATOR_ENCODED
+ + JBOSS_TOOLS_VERSION, contentURI);
+
+ String title = focusPoint.getTitle();
+ assertNotNull(title);
+ assertEquals(ROOT
+ + TITLE_SEPARATOR_ENCODED
+ + CHILD + TITLE_SEPARATOR_ENCODED
+ + CHILD + TITLE_SEPARATOR_ENCODED
+ + JBOSS_TOOLS_VERSION, title);
+ }
+
+ private static class FocusPointFake extends SuffixFocusPoint {
+
+ public FocusPointFake(String name) {
+ super(name, JBOSS_TOOLS_VERSION);
+ }
+ }
}
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsTestsFocusPoint.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsTestsFocusPoint.java 2010-11-30
10:30:54 UTC (rev 27021)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsTestsFocusPoint.java 2010-11-30
10:49:23 UTC (rev 27022)
@@ -29,6 +29,4 @@
public static String getJBossToolsVersion() {
return JBossToolsUsageActivator.getDefault().getBundle().getVersion().toString();
}
-
-
}
Copied:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageIntegrationTest.java
(from rev 27018,
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/JBossToolsUsageIntegrationTest.java)
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageIntegrationTest.java
(rev 0)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageIntegrationTest.java 2010-11-30
10:49:23 UTC (rev 27022)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Red Hat, Inc.
+ * 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.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.jboss.tools.usage.googleanalytics.GoogleAnalyticsUrlStrategy;
+import org.jboss.tools.usage.googleanalytics.IGoogleAnalyticsParameters;
+import org.jboss.tools.usage.http.HttpGetRequest;
+import org.jboss.tools.usage.http.IHttpGetRequest;
+import org.jboss.tools.usage.test.fakes.ReportingEclipseEnvironmentFake;
+import org.jboss.tools.usage.test.fakes.RepportingEclipseEnvironmentFakeSingleton;
+import org.jboss.tools.usage.tracker.IFocusPoint;
+import org.jboss.tools.usage.tracker.IURLBuildingStrategy;
+import org.jboss.tools.usage.tracker.internal.UsagePluginLogger;
+import org.junit.Test;
+
+/**
+ * @author Andre Dietisheim
+ */
+public class UsageIntegrationTest {
+
+ @Test
+ public void sameUserIdOnSametEclipseInstance() throws Exception {
+ UrlRevealingTracker tracker =
getTracker(RepportingEclipseEnvironmentFakeSingleton.INSTANCE);
+ IFocusPoint focusPoint =
createFocusPoint("testSameUserIdOnSametEclipseInstance" +
System.currentTimeMillis());
+ tracker.trackSynchronously(focusPoint);
+ String userId = getUserId(tracker.getTrackingUrl());
+ assertTrue(userId != null);
+
+ tracker = getTracker(RepportingEclipseEnvironmentFakeSingleton.INSTANCE);
+ tracker.trackSynchronously(focusPoint);
+ String newUserId = getUserId(tracker.getTrackingUrl());
+
+ assertTrue(newUserId != null);
+ assertEquals(userId, newUserId);
+ }
+
+ @Test
+ public void differentUserIdOnDifferentEclipseInstance() throws Exception {
+ String focusPointName = "testDifferentUserIdOnDifferentEclipseInstance"
+ + System.currentTimeMillis();
+ UrlRevealingTracker tracker = getTracker(new ReportingEclipseEnvironmentFake());
+ tracker.trackSynchronously(createFocusPoint(focusPointName));
+ String userId = getUserId(tracker.getTrackingUrl());
+ assertTrue(userId != null);
+
+ tracker = getTracker(new ReportingEclipseEnvironmentFake());
+ IFocusPoint focusPoint = createFocusPoint(focusPointName);
+ tracker.trackSynchronously(focusPoint);
+ String newUserId = getUserId(tracker.getTrackingUrl());
+
+ assertTrue(newUserId != null);
+ assertTrue(!userId.equals(newUserId));
+ }
+
+ @Test
+ public void visitCountIncreases() throws Exception {
+ IGoogleAnalyticsParameters eclipseEnvironment = new ReportingEclipseEnvironmentFake();
+ assertEquals(1, eclipseEnvironment.getVisitCount());
+ UrlRevealingTracker tracker = getTracker(eclipseEnvironment);
+ tracker.trackSynchronously(createFocusPoint("testVisitCount"));
+ assertEquals(2, eclipseEnvironment.getVisitCount());
+ tracker.trackSynchronously(createFocusPoint("testVisitCount"));
+ assertEquals(3, eclipseEnvironment.getVisitCount());
+ }
+
+ @Test
+ public void urlEndsWithJBossToolsVersion() {
+ IGoogleAnalyticsParameters eclipseEnvironment = new ReportingEclipseEnvironmentFake();
+ UrlRevealingTracker tracker = getTracker(eclipseEnvironment);
+ tracker.trackSynchronously(createFocusPoint("testJBossToolsVersion"));
+ assertEquals(2, eclipseEnvironment.getVisitCount());
+ tracker.trackSynchronously(createFocusPoint("testVisitCount"));
+ assertEquals(3, eclipseEnvironment.getVisitCount());
+ }
+
+ private String getUserId(String trackingUrl) {
+ Pattern pattern = Pattern.compile(".+" +
IGoogleAnalyticsParameters.PARAM_COOKIES_UNIQUE_VISITOR_ID
+ + "%3D([0-9]+\\.[0-9]+)\\..+");
+ Matcher matcher = pattern.matcher(trackingUrl);
+ if (matcher.matches()) {
+ return matcher.group(1);
+ } else {
+ return null;
+ }
+ }
+
+ private UrlRevealingTracker getTracker(IGoogleAnalyticsParameters environment) {
+ UsagePluginLogger logger = new
UsagePluginLogger(JBossToolsUsageTestActivator.getDefault());
+ IURLBuildingStrategy urlStrategy = new GoogleAnalyticsUrlStrategy(environment);
+ IHttpGetRequest httpGetRequest = new HttpGetRequest(environment.getUserAgent(),
logger);
+ return new UrlRevealingTracker(urlStrategy, httpGetRequest, logger);
+ }
+
+ private IFocusPoint createFocusPoint(String childFocusPoint) {
+ return new JBossToolsTestsFocusPoint(childFocusPoint);
+ }
+}
Property changes on:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageIntegrationTest.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified:
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageTestSuite.java
===================================================================
---
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageTestSuite.java 2010-11-30
10:30:54 UTC (rev 27021)
+++
trunk/usage/tests/org.jboss.tools.usage.test/src/org/jboss/tools/usage/test/UsageTestSuite.java 2010-11-30
10:49:23 UTC (rev 27022)
@@ -19,15 +19,14 @@
@RunWith(Suite.class)
@Suite.SuiteClasses({
FocusPointTest.class,
- JBossToolsFocusPointTest.class,
GoogleAnalyticsUrlStrategyTest.class,
EclipseUserAgentTest.class,
LinuxSystemTest.class,
- JBossToolsEclipseEnvironmentTest.class,
+ EclipseEnvironmentTest.class,
JBossToolsComponentsTest.class,
HttpRemotePropertiesTest.class,
GlobalUsageSettingsTest.class,
UsageBrandingTest.class,
- JBossToolsUsageIntegrationTest.class })
+ UsageIntegrationTest.class })
public class UsageTestSuite {
}
\ No newline at end of file