FELIX-4060 : Update to latest http whiteboard api : ServletContextDTO.contextName has been removed
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1662128 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/http/api/src/main/java/org/osgi/service/http/runtime/dto/ServletContextDTO.java b/http/api/src/main/java/org/osgi/service/http/runtime/dto/ServletContextDTO.java
index 668a57a..9be72ae 100644
--- a/http/api/src/main/java/org/osgi/service/http/runtime/dto/ServletContextDTO.java
+++ b/http/api/src/main/java/org/osgi/service/http/runtime/dto/ServletContextDTO.java
@@ -1,6 +1,6 @@
/*
* Copyright (c) OSGi Alliance (2012, 2014). All Rights Reserved.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
@@ -17,6 +17,7 @@
package org.osgi.service.http.runtime.dto;
import java.util.Map;
+
import org.osgi.dto.DTO;
/**
@@ -24,31 +25,22 @@
* resources, servlet Filters, and listeners associated with that servlet
* context. The Servlet Context is usually backed by a
* {@link org.osgi.service.http.context.ServletContextHelper} service.
- *
+ *
* @NotThreadSafe
* @author $Id$
*/
public class ServletContextDTO extends DTO {
/**
* The name of the servlet context.
- *
+ *
* The name of the corresponding
* {@link org.osgi.service.http.context.ServletContextHelper}.
*/
public String name;
/**
- * The context name of the servlet context.
- *
- * <p>
- * This is the value returned by the
- * {@code ServletContext.getServletContextName()} method.
- */
- public String contextName;
-
- /**
* The servlet context path.
- *
+ *
* This is the value returned by the {@code ServletContext.getContextPath()}
* method.
*/
@@ -64,7 +56,7 @@
/**
* The servlet context attributes.
- *
+ *
* <p>
* The value type must be a numerical type, {@code Boolean}, {@code String},
* {@code DTO} or an array of any of the former. Therefore this method will
@@ -88,7 +80,7 @@
/**
* Returns the representations of the {@code Servlet} services associated
* with this context.
- *
+ *
* The representations of the {@code Servlet} services associated with this
* context. The returned array may be empty if this context is currently not
* associated with any {@code Servlet} services.
@@ -98,7 +90,7 @@
/**
* Returns the representations of the resource services associated with this
* context.
- *
+ *
* The representations of the resource services associated with this
* context. The returned array may be empty if this context is currently not
* associated with any resource services.
@@ -108,7 +100,7 @@
/**
* Returns the representations of the servlet {@code Filter} services
* associated with this context.
- *
+ *
* The representations of the servlet {@code Filter} services associated
* with this context. The returned array may be empty if this context is
* currently not associated with any servlet {@code Filter} services.
@@ -118,7 +110,7 @@
/**
* Returns the representations of the error page {@code Servlet} services
* associated with this context.
- *
+ *
* The representations of the error page {@code Servlet} services associated
* with this context. The returned array may be empty if this context is
* currently not associated with any error pages.
@@ -128,7 +120,7 @@
/**
* Returns the representations of the listener services associated with this
* context.
- *
+ *
* The representations of the listener services associated with this
* context. The returned array may be empty if this context is currently not
* associated with any listener services.
diff --git a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletContextDTOBuilder.java b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletContextDTOBuilder.java
index 5ee0fa1..83b76c2 100644
--- a/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletContextDTOBuilder.java
+++ b/http/base/src/main/java/org/apache/felix/http/base/internal/runtime/dto/ServletContextDTOBuilder.java
@@ -79,13 +79,12 @@
ServletContextDTO contextDTO = new ServletContextDTO();
contextDTO.attributes = getAttributes(context);
- contextDTO.contextName = context.getServletContextName();
contextDTO.contextPath = context.getContextPath();
contextDTO.errorPageDTOs = errorPageDTOs;
contextDTO.filterDTOs = filterDTOs;
contextDTO.initParams = getInitParameters(context);
contextDTO.listenerDTOs = listenerDTOs;
- contextDTO.name = contextId >= 0 ? contextInfo.getName() : null;
+ contextDTO.name = context.getServletContextName();
contextDTO.resourceDTOs = resourceDTOs;
contextDTO.servletDTOs = servletDTOs;
contextDTO.serviceId = contextId;
diff --git a/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilderTest.java b/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilderTest.java
index 31b3cab..5db1315 100644
--- a/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilderTest.java
+++ b/http/base/src/test/java/org/apache/felix/http/base/internal/runtime/dto/RuntimeDTOBuilderTest.java
@@ -34,7 +34,6 @@
import static org.apache.felix.http.base.internal.runtime.WhiteboardServiceHelper.createTestServletWithServiceId;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -59,9 +58,9 @@
import org.apache.felix.http.base.internal.context.ExtServletContext;
import org.apache.felix.http.base.internal.handler.FilterHandler;
import org.apache.felix.http.base.internal.handler.ServletHandler;
+import org.apache.felix.http.base.internal.runtime.FilterInfo;
import org.apache.felix.http.base.internal.runtime.HandlerRuntime;
import org.apache.felix.http.base.internal.runtime.HandlerRuntime.ErrorPage;
-import org.apache.felix.http.base.internal.runtime.FilterInfo;
import org.apache.felix.http.base.internal.runtime.RegistryRuntime;
import org.apache.felix.http.base.internal.runtime.ServletContextHelperInfo;
import org.apache.felix.http.base.internal.runtime.ServletInfo;
@@ -233,12 +232,10 @@
for (ServletContextDTO servletContextDTO : runtimeDTO.servletContextDTOs)
{
- String contextName = servletContextDTO.contextName;
+ String contextName = servletContextDTO.name;
assertTrue(CONTEXT_NAMES.contains(contextName));
if (contextName.equals("0"))
{
- assertNull(contextName,
- servletContextDTO.name);
assertTrue(contextName,
servletContextDTO.serviceId < 0);
assertEquals(contextName,
@@ -252,9 +249,6 @@
}
else
{
- assertEquals(contextName,
- contextName, servletContextDTO.name);
-
int expectedId = CONTEXT_NAMES.indexOf(contextName) + 1;
assertEquals(contextName,
expectedId, servletContextDTO.serviceId);